NS2 Programs Code

Ns2 programs are generated in Tcl programs.


Basics of Tcl programs:

  • Initialization and termination aspects of network simulator
  • Define the network nodes, links, queues, and topology as well
  • Define the agents and their applications
  • Generation of NAM (Network Animator)
  • Tracing
  • This is the sample code for how to create a header file for multimedia application and define header class.


//multimedia header structure

Struct hdr_mm{
int ack;
int seq;
int nbytes;
double time;
int scale;

//packet header access functions

static int offset_;
inline statuc int& offset() {return offset_;}
inline static hdr_mm* access (const Packet* p) {
	returen (hdr_mm*) p access(offset_);

\\ Multimedia Header class
static class MultimediaHeaderClass : public PacketHeaderClass {
  MultimediaHeaderClass() : PacketHeaderClass(“PacketHeader/Multimedia”, sizeof(hdr_mm)) {

Journal Support for NS2 Projects: