Forwarding from one Port to the other.

145 views
Skip to first unread message

Noel Farrugia

unread,
May 7, 2017, 5:43:04 PM5/7/17
to ns-3-users
Dear All,

I am trying to create a simple forwarding mechanism as follows:

Node 0 ------- > Node 1  -------- > Node 2

What I am trying to achieve is to forward whatever Node 1 is receiving on Port 0 (i.e. coming from Node 0) to Node 1's Port 1 (going to Node 2). I have successfully created a Callback to the NetDevice receive function and I am calling the NetDevice's send function however the Sink Application is not reporting that a packet was received.

The terminal output is the following:

Per Packet Flow Splitting Simulator
At time 1.00235s on-off application sent 1470 bytes to 10.1.1.3 port 1000 total Tx 1470 bytes
A packet was received on node
1
Send successful

Previously I have achieved this task by modifying the provided bridge net device. However, I wanted to see if there was a simpler way of instead of creating a new NetDevice that it's main purpose is to store a vector of other NetDevices.

I have attached the simulation code for reference.

Do not hesitate to contact me should you require further information.

Thanks a lot for your time and attention.

Kind Regards,
Noel
ppfs.cc

Tommaso Pecorella

unread,
May 7, 2017, 6:58:27 PM5/7/17
to ns-3-users
Hi,

there's a short and a long explanation.

The short is: you didn't do it right. I guess you want the long one tho.

The long one is: the middle node is going insane.
It has two interfaces with similar IP numbers, both belonging to the same subnet. Even if you trap the packets below IP, its IP layer will still kick in (and it won't be happy).
Moreover, since you're using P2P interfaces, the middle node *knows* that you're trying to reach an impossible IP number, an will reply with a destination unreachable. After all, in a P2P link there are only 2 IP numbers.

What you have to do is:
- Remove the IP layer from the middle node - otherwise you'll always get a lot of destination unreachable ICMPs, and
- Use the right IP number - your intended destination is interfaces.GetAddress(3), not interfaces.GetAddress(2)

Oh... and you might also want to enable a two-way communication :D

T.

Noel Farrugia

unread,
May 8, 2017, 3:23:01 AM5/8/17
to ns-3-users
Hi Tommaso,

It works now! Thanks a lot! :-)

If I may take a bit more of your time, I am planning on simulating a network with x number of switches that will be running on a custom routing algorithm. The switches' routing table will be calculated before any packet transmission occurs, similar to what is being done in the IPv4 routing helper. What I am not 100% sure is whether I should implement a custom net device similar to the bridge OR use a technique similar to this example (i.e. without the creation of a net device) to forward the packets from one node to the other. Using the latter technique, I would set all the ports to call the same receive callback function and based on the Node number and Port Number I would consult the node's routing table and route accordingly.

Correct me if I'm wrong, but I don't think that there will be any performance difference using either of the two techniques I've mentioned because ns3 is an event driven single thread simulator. Therefore, my question is, given your experience with ns3, which route would you recommend I take?

Thanks a lot for your time.

Kind Regards,
Noel

Tommaso Pecorella

unread,
May 8, 2017, 11:25:59 AM5/8/17
to ns-3-users
Hi,

if you're using a custom routing (but it's really a L2 forwarding) scheme, then you can't use the bridge net device because you'll have a "flat" network in that way.
You can either use your approach, or click, or OpenFlow. All of them are more or less equivalent.
About what solution is faster... well, it depends on the lookup tables, but you shouldn't see dramatic differences.

T.

Noel Farrugia

unread,
May 8, 2017, 3:54:26 PM5/8/17
to ns-3-users
Hi,

Thanks a lot for your feed. Much appreciated.

Regards,
Noel
Reply all
Reply to author
Forward
0 new messages