How to get a packet sequence number using C++ in NS2


In network protocol, packet sequence number plays the role of ensuring the tracking of end to end packet delivery. Especially TCP utilizes the packet sequence number as the main parameter in end to end flow control for sending acknowledgment and retransmission. The code given below gives the command to access the sequence number attached in the header of the packet.

struct hdr_cmn *ch = HDR_CMN(p);
int sequence_number =ch->uid();