How to Begin Implement an Interior Protocol in NS3
To start executing an Interior Gateway Protocol (IGP) in ns3, we can replicate the routing protocols that are intended for routing in a single autonomous system (AS). Followings are general interior protocols:
- RIP (Routing Information Protocol) – It is a distance-vector protocol.
- OSPF (Open Shortest Path First) – A link-state protocol.
- IS-IS (Intermediate System to Intermediate System) – Another link-state protocol which isn’t directly supported within ns3.
Here’s a step-by-step guide for executing RIP or OSPF that have direct support within ns3. We could prolong the ns3 or add an external library for IS-IS.
Steps to Begin Implement an Interior Protocol in NS3
- Set Up ns3 Environment
- Install ns3:
- We should download and set up ns3 on the machine.
- Make sure that the installation using ./waf –run hello-simulator.
- Enable Required Modules:
- Confirm the necessary modules such as internet, ipv4, point-to-point, and applications modules are contained for IGP simulation.
- Define Objectives for Interior Protocol Simulation
Focus on the interior protocol goals to replicate:
- RIP: Mimic a basic distance-vector routing protocol.
- OSPF: It supports to replicate a vigorous link-state routing protocol.
- Metrics: Estimate the performance parameters such as latency, convergence time, and routing overhead.
- Set Up Network Topology
- Create Nodes:
- Make a network topology that contains routers and hosts within the network.
NodeContainer routers, hosts;
routers.Create(3); // 3 routers
hosts.Create(2); // 2 hosts
- Establish Links:
- Link routers and hosts utilising PointToPointHelper.
PointToPointHelper p2p;
p2p.SetDeviceAttribute(“DataRate”, StringValue(“10Mbps”));
p2p.SetChannelAttribute(“Delay”, StringValue(“2ms”));
NetDeviceContainer routerLink1 = p2p.Install(routers.Get(0), routers.Get(1));
NetDeviceContainer routerLink2 = p2p.Install(routers.Get(1), routers.Get(2));
NetDeviceContainer hostRouter1 = p2p.Install(hosts.Get(0), routers.Get(0));
NetDeviceContainer hostRouter2 = p2p.Install(hosts.Get(1), routers.Get(2));
- Assign IP Addresses:
- Make use of Ipv4AddressHelper for allocating an unique addresses.
InternetStackHelper internet;
internet.Install(routers);
internet.Install(hosts);
Ipv4AddressHelper ipv4;
ipv4.SetBase(“10.1.1.0”, “255.255.255.0”);
Ipv4InterfaceContainer interfaces1 = ipv4.Assign(routerLink1);
ipv4.SetBase(“10.1.2.0”, “255.255.255.0”);
Ipv4InterfaceContainer interfaces2 = ipv4.Assign(routerLink2);
ipv4.SetBase(“10.1.3.0”, “255.255.255.0”);
Ipv4InterfaceContainer interfaces3 = ipv4.Assign(hostRouter1);
ipv4.SetBase(“10.1.4.0”, “255.255.255.0”);
Ipv4InterfaceContainer interfaces4 = ipv4.Assign(hostRouter2);
- Enable Routing Protocol
- RIP Implementation
- Set Up RIP on Routers:
- Allow RIP at every router nodes with RipHelper.
RipHelper rip;
Ipv4ListRoutingHelper list;
list.Add(rip, 10); // Priority 10 for RIP
internet.SetRoutingHelper(list);
- Install RIP:
- In the network, utilize RIP to every router.
internet.Install(routers);
- OSPF Implementation
- Set Up OSPF on Routers:
- We need to utilize an external or custom OSPF execution since NS3 does not have direct support for OSPF.
- On the other hand, replicate the behaviour of OSPF to leverage static routes and link-state logic.
- Install Applications
- Simulate Traffic:
- Replicate interaction with UdpEchoServerHelper and UdpEchoClientHelper.
UdpEchoServerHelper echoServer(9);
ApplicationContainer serverApps = echoServer.Install(hosts.Get(1)); // Server on host 2
serverApps.Start(Seconds(1.0));
serverApps.Stop(Seconds(10.0));
UdpEchoClientHelper echoClient(Ipv4Address(“10.1.4.1”), 9);
echoClient.SetAttribute(“MaxPackets”, UintegerValue(20));
echoClient.SetAttribute(“Interval”, TimeValue(Seconds(1.0)));
echoClient.SetAttribute(“PacketSize”, UintegerValue(1024));
ApplicationContainer clientApps = echoClient.Install(hosts.Get(0)); // Client on host 1
clientApps.Start(Seconds(2.0));
clientApps.Stop(Seconds(10.0));
- Monitor Traffic:
- Accumulate and examine the packets applying PacketSink.
PacketSinkHelper sink(“ns3::UdpSocketFactory”,
InetSocketAddress(Ipv4Address::GetAny(), 9));
ApplicationContainer sinkApps = sink.Install(hosts.Get(1));
sinkApps.Start(Seconds(1.0));
sinkApps.Stop(Seconds(10.0));
- Simulate Link Changes
- Simulate Link Failures:
- Inactivate a link and then monitor the protocol convergence.
Simulator::Schedule(Seconds(5.0), &NetDevice::SetLinkDown, routerLink1.Get(1));
- Simulate Recovery:
- After a specific duration, re-enable the connection.
Simulator::Schedule(Seconds(7.0), &NetDevice::SetLinkUp, routerLink1.Get(1));
- Enable Tracing and Logging
- Enable Ascii Tracing:
- Record all routing events with interior protocol.
AsciiTraceHelper ascii;
p2p.EnableAsciiAll(ascii.CreateFileStream(“interior-protocols.tr”));
- Enable PCAP Tracing:
- Seizure packets using Wireshark for analysis.
p2p.EnablePcapAll(“interior-protocols”);
- Use FlowMonitor:
- Examine the traffic parameters such as throughput and delay with the support of FlowMonitor.
FlowMonitorHelper flowmon;
Ptr<FlowMonitor> monitor = flowmon.InstallAll();
- Run the Simulation
- Start the Simulation:
Simulator::Run();
Simulator::Destroy();
- Export Results:
- We need to store outcomes for offline analysis.
monitor->SerializeToXmlFile(“interior-protocols-results.xml”, true, true);
- Visualize Results
- NetAnim Visualization:
- Transfer the simulation data for envisioning in NetAnim.
AnimationInterface anim(“interior-protocols.xml”);
- Analyze Metrics:
- Measure effectiveness of routing protocol in diverse simulation situations.
- Extend the Implementation
- Scaling:
- Maximize the volume of routers and then experiment the scalability.
- Topology Changes:
- Analyse the behaviour of routing in often topology modifications.
- Advanced Metrics:
- Estimate the advanced indicators such as routing overhead, convergence time, and protocol robustness.
Example Use Cases
- Data Center Networks:
- For routing in a data center, we will leverage RIP or OSPF.
- Campus Networks:
- Assess the performance of IGP within immobile or mobile environments.
- IoT Networks:
- Replicate routing with the help of RIP or same protocols for constrained networks.
These set up walk you through the overall execution, analysis, and visualization of Interior Protocol using NS3 environment. Based on your needs we will present in-depth details and advance implementation in another manual.