how to set and get the TTL value from a packet?

200 views
Skip to first unread message

Victor

unread,
Jul 1, 2014, 6:12:37 AM7/1/14
to ns-3-...@googlegroups.com
Dear all,

Suppose I have two nodes, says node A and node B. Node A has been assigned an Ipv4address says "10.0.0.1" and node B has also got an Ipv4address as well, which is "10.0.0.2". Now, I would like to send a packet from node A to node B. Specifically, before sending the packet from node A, I would like to set an initial TTL value of this packet and whenever node B receive this packet, it will be able to get this TTL value from the packet. I have actually found some functions that are capable to do that, i.e. SetTtl and GetTtl. However, I cannot code correctly as what I expected. Just wondering is there any simple example codes in NS3 that can help? 

Thanks for the help.

Regards,
Victor

Konstantinos

unread,
Jul 1, 2014, 12:07:37 PM7/1/14
to ns-3-...@googlegroups.com
TTL is an element of Ipv4Header. In order to access it you have to be in the correct layer. 
If you study the documentation you can find this http://www.nsnam.org/docs/models/html/internet-stack.html#example-path-of-a-packet
Step 4 in the outgoing path adds the Ipv4Header (the Ipv4L3Protocol or Ipv6). This is the correct place to "SetTTL" and similarly in the incoming path Ipv4L3Protocol (or Ipv6) will remove the header.
Reply all
Reply to author
Forward
0 new messages