Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to make the packet forward hop by hop #480

Open
Memtwo opened this issue Mar 3, 2021 · 11 comments
Open

How to make the packet forward hop by hop #480

Memtwo opened this issue Mar 3, 2021 · 11 comments

Comments

@Memtwo
Copy link

Memtwo commented Mar 3, 2021

Hello! I am learning how to use click to forward packets.I want the packet forward hop by hop like node1 to node2, then node2 to node3.
My setup is as follows:
I have three different nodes in the order below, each running a different click configuration
Node1 (source) --> Node2(forward) --> Node3 (sink)

Three nodes' information is as follows:
Node1 ens33:192.128.32.128 00:0c:29:92:68:92 ; ens38:192.168.32.129 00:0c:29:92:68:9c
Node2 ens33:192.168.32.130 00:0c:29:57:e6:e1 ; ens38:192.168.32.131 00:0c:29:57:e6:eb
Node3 ens33:192.168.32.132 00:0c:29:db:6e:56 ; ens38:192.168.32.133 00:0c:29:db:6e:60

Node1:
Source.click

FastUDPSource(800000, -1, 60, 00:0c:29:92:68:92, 192.168.32.128, 1234,
00:0c:29:db:6e:56, 192.168.32.132, 1234)
->IPPrint("Hello")
->ToDevice(ens33);

Node2:
Forward.click

FromDevice(ens38, PROMISC true)
-> Queue
-> ToDevice(ens33);

Node3:
Sink.click

FromDevice(ens33, PROMISC true) -> c:: Counter -> Discard;
Script(wait 10, print c.rate, loop);

I can see the result on node3. I use tcpdump on node2 and can see the packet 192.168.32.128.1234 > 192.168.32.132.1234.
However, I don't know whether the packet sent to node3 from node1 hop by hop or node1 sent packets both to node2 and node3 like broadcast.
How can I make sure it is hop by hop which node1 send packet to node2, then node2 send packet to node3

@tbarbette
Copy link
Collaborator

You can add a Print on node2 to verify. Also in Node1 you target the DST mac address of Node 3 so I doubt you hop through node2 indeed. Node 2 should have an EtherRewrite element to handle mac properly (or ARPQuerier ecosystem).
If you're using userlevel mode Click, you'll want SNIFFER false parameter in your FromDevice to avoid packets being routed in the linux stack too.

@Memtwo
Copy link
Author

Memtwo commented Mar 3, 2021

You can add a Print on node2 to verify. Also in Node1 you target the DST mac address of Node 3 so I doubt you hop through node2 indeed. Node 2 should have an EtherRewrite element to handle mac properly (or ARPQuerier ecosystem).
If you're using userlevel mode Click, you'll want SNIFFER false parameter in your FromDevice to avoid packets being routed in the linux stack too.

Thanks! Do you mean I should first set DST to node2, then on node2 use EtherRewrite element and set it to node3?

@tbarbette
Copy link
Collaborator

Do you mean I should first set DST to node2, then on node2 use EtherRewrite element and set it to node3?

Well, if they're connected to a switch, how would the switch know packets should go to node 2 if you set the address of node 2? A beauty of Click imo is that the magic of networking disappears. Packets do exactly what you ask them to do :)

@ahenning
Copy link

ahenning commented Mar 3, 2021

How can I make sure it is hop by hop which node1 send packet to node2, then node2 send packet to node3

Physically connect the ethernet cables from node1 to node2 and from node2 to node3

@Memtwo
Copy link
Author

Memtwo commented Mar 3, 2021

How can I make sure it is hop by hop which node1 send packet to node2, then node2 send packet to node3

Physically connect the ethernet cables from node1 to node2 and from node2 to node3

Thanks, but I do this on VM

@Memtwo
Copy link
Author

Memtwo commented Mar 3, 2021

Sorry since I am nearly newbie to click, I really don’t know how to modify it.
May I trouble you to give me a more specific configuration example?

@xt1234567
Copy link

Sorry since I am nearly newbie to click, I really don’t know how to modify it. May I trouble you to give me a more specific configuration example?

hello, i also encountered this trouble, If you solve it, can you share your experience,thank you!

@tbarbette
Copy link
Collaborator

If it's about VM configuration to make the hop-by-hop wiring, it depends on your hypervisor, not Click.

@xt1234567
Copy link

If it's about VM configuration to make the hop-by-hop wiring, it depends on your hypervisor, not Click.

Thank you for your answer, i used EtherRewrite then it can work correctly. But I have another question,click send the packets by ToDevice(),and it seems to skip iptables rules so that i can't achieve SNAT on my hypervisor. How can I make it work?Thanks!

@tbarbette
Copy link
Collaborator

If you use Click for packet processing you have to use it for everything. Do the SNAT inside Click, not with IPTables. Or use a virtual interface in ToDevice and then add an SNAT

@xt1234567
Copy link

If you use Click for packet processing you have to use it for everything. Do the SNAT inside Click, not with IPTables. Or use a virtual interface in ToDevice and then add an SNAT

I got it. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants