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

Sunday, February 8, 2009

[NS2] The difference between an instproc "compute-routes" and a C++ function "computes_routes()"

Two NS2 functions and instproc has very similar name: "compute-routes{}" and "compute_routes()". The differences are shown below:

compute-routes{}
  • is an OTcl command
  • is defined in class Simulator
  • is defined in file ~ns/tcl/lib/ns-route.tcl
  • populate routing information into nodes

compute_routes()
  • is a C++ function
  • is defined in class RouteLogic
  • is defined in file ~ns/routing/route.cc
  • computes the routing information for all pairs of nodes

For more information about Nodes and Route setup, see Chapter 6 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