Friday, February 27, 2009

Packet size in NS2

In general, a packet consists of packet header and data payload. Packet header stores packet attributes (e.g., source and destination IP addresses) necessary for packet delivery, while data payload contains user information. Although this concept is typical in practice, NS2 models packets differently.

In most cases, NS2 extracts information from data payload and stores the information into packet header. This idea removes the necessity to process data payload at runtime. For example, instead of counting the number of bits in a packet, NS2 stores packet size in variable hdr_cmn::size_, and accesses this variable at runtime

Given a pointer to a Packet object p, the following statement sets the packet size to be "my_size"

hdr_cmn* hdr = hdr_cmn::access(p);
hdr->size() = my_size;

For more information about Packets, see Chapter 8 in the following book from Springer:

T. Issaraiyakul and E. Hossain, "Introduction to Network Simulator NS2", Springer 2008.
http://www.springer.com/engineering/signals/book/978-0-387-71759-3

You may also find the following website useful:
http://www.ece.ubc.ca/~teerawat/NS2.htm

1 comment:

Sohail said...

Hi,
Actually my work is related to DSR routing proto. I want to share some information (in table)with my neighbour nodes.
so how will i send a table in broadcast packet and how the neighbours will extract the data.

Thanks alot for your help

Sohail