Computer Network Simulation
Types of computer network design:
There are two different types of computer networks designs are available.
- Peer-to-peer network model.
- Client/server model.
Common computer network topologies are:
- Star.
- Mesh.
- Bus.
- Ring.
Sample code for computer network simulation :
NS_LOG_INFO (“Create nodes.”);
NodeContainer nodes;
nodes.Create (2);
NS_LOG_INFO (“Create channels.”);
PointToPointHelper pointToPoint;
pointToPoint.SetDeviceAttribute (“DataRate”, StringValue (“500Kbps”));
pointToPoint.SetChannelAttribute (“Delay”, StringValue (“5ms”));
NetDeviceContainer devices;
devices = pointToPoint.Install (nodes);
InternetStackHelper internet;
internet.Install (nodes);
NS_LOG_INFO (“Assign IP Addresses.”);
Ipv4AddressHelper ipv4;
ipv4.SetBase (“10.1.1.0”, “255.255.255.0”);
Ipv4InterfaceContainer i = ipv4.Assign (devices);
NS_LOG_INFO (“Create Applications.”);
uint16_t port = 9; // well-known echo port number
BulkSendHelper source (“ns3::TcpSocketFactory”,
InetSocketAddress (i.GetAddress (1), port));
// Set the amount of data to send in bytes. Zero is unlimited.
source.SetAttribute (“MaxBytes”, UintegerValue (maxBytes));
ApplicationContainer sourceApps = source.Install (nodes.Get (0));
sourceApps.Start (Seconds (0.0));
sourceApps.Stop (Seconds (10.0));