Network Simulation Program

Network simulation Program code.

NS-3 is a new simulator, written from scratch but not really an evolution of NS-2.

Packet: tags in ns3 program:

  • A tag is a small chunk of information
  • New tag types are defined similarly to header types
  • Any number of tags can be attached a packet
  • Structure type of Tags is:
  • Ptr <Packet>p;
  • MyTag tag;
  • p-> AddTag(tag)
  • p->PeekTag(tag)

Uses of Tags:

  • convey additional information across layers
  • Attach context information to a packet for example NetDevice attaches destination MAC address when queuing, retrieves it when dequeuing for transmission.

Sample network simulation program:
This is the simple program for how to connect two nodes with each other. Each of which has unique network interface device.
int main(int argc, char *argv[]){
NodeContainer nodes;
PointToPointHelper pointToPoint;
pointToPoint.SetDeviceAttribute(“DataRate”, StringValue(“4Mbps”));
NetDeviceContainer devices;
Devices = pointToPoint.Install (nodes);
InternetStackHelper stack;
Stack.Install (nodes);
Ipv4AddressHelper address;
Address.SetBase (“”, “”);
UdpEchoServerHelper echoServer (9);
ApplicationContainer serverApps = echoServer.Install (nodes.Get(1));
serverApps.Start (Seconds(1.0));
serverApps.Stop (seconds(11.0));
UdpEchoClientHelper echoClient (interfaces.GetAddress (1),9);
ApplicationContainer clientApps = echoClinet.Install (nodes.Get(0));
return 0;