To develop the Static Routing has includes the simulation of NS-3. The Static routing is manual routing approach in which routes are preconfigured and do not change terms on network environments. In NS-3, static routing can be executed using the support of Ipv4StaticRouting.
Steps to Develop a Static Routing Project in NS-3
- Install and Setup NS-3
Assure the NS-3 tool is installed:
git clone
cd ns-3-dev
./ns3 configure –enable-examples –enable-tests
./ns3 build
- Define a Network Topology
Static routing is effective for wired or infrastructure-based on networks.
Example: Create a Simple Network
NodeContainer nodes;
nodes.Create(3); // Create 3 nodes
We link the nodes for utilized the point-to-point connections
PointToPointHelper p2p;
p2p.SetDeviceAttribute(“DataRate”, StringValue(“1Gbps”));
p2p.SetChannelAttribute(“Delay”, StringValue(“2ms”));
NetDeviceContainer devicesAB = p2p.Install(nodes.Get(0), nodes.Get(1));
NetDeviceContainer devicesBC = p2p.Install(nodes.Get(1), nodes.Get(2));
- Allocate the IP Addresses
InternetStackHelper stack;
stack.Install(nodes);
Ipv4AddressHelper address;
address.SetBase(“10.1.1.0”, “255.255.255.0”);
Ipv4InterfaceContainer interfacesAB = address.Assign(devicesAB);
address.SetBase(“10.1.2.0”, “255.255.255.0”);
Ipv4InterfaceContainer interfacesBC = address.Assign(devicesBC);
- Implement Static Routing
Static routing contain for manually set-ups the routes.
Get the Static Routing Table
Ptr<Ipv4StaticRouting> staticRoutingA = Ipv4RoutingHelper::GetRouting <Ipv4StaticRouting> (nodes.Get(0)->GetObject<Ipv4> ());
Ptr<Ipv4StaticRouting> staticRoutingB = Ipv4RoutingHelper::GetRouting <Ipv4StaticRouting> (nodes.Get(1)->GetObject<Ipv4> ());
Ptr<Ipv4StaticRouting> staticRoutingC = Ipv4RoutingHelper::GetRouting <Ipv4StaticRouting> (nodes.Get(2)->GetObject<Ipv4> ());
Manually Enhance the Static Routes
staticRoutingA->AddHostRouteTo(Ipv4Address(“10.1.2.2”), Ipv4Address(“10.1.1.2”), 1);
staticRoutingB->AddHostRouteTo(Ipv4Address(“10.1.2.2”), Ipv4Address(“10.1.2.2”), 2);
staticRoutingC->AddHostRouteTo(Ipv4Address(“10.1.1.1”), Ipv4Address(“10.1.2.1”), 1);
- Setup Traffic and Applications
It validate for used the UDP/TCP congestion:
UdpEchoServerHelper echoServer(9);
ApplicationContainer serverApps = echoServer.Install(nodes.Get(2));
serverApps.Start(Seconds(1.0));
serverApps.Stop(Seconds(10.0));
UdpEchoClientHelper echoClient(Ipv4Address(“10.1.2.2”), 9);
echoClient.SetAttribute(“MaxPackets”, UintegerValue(5));
echoClient.SetAttribute(“Interval”, TimeValue(Seconds(1.0)));
echoClient.SetAttribute(“PacketSize”, UintegerValue(512));
ApplicationContainer clientApps = echoClient.Install(nodes.Get(0));
clientApps.Start(Seconds(2.0));
clientApps.Stop(Seconds(10.0));
- We assist the tracing for Debugging
AsciiTraceHelper ascii;
p2p.EnableAsciiAll(ascii.CreateFileStream(“static-routing.tr”));
p2p.EnablePcapAll(“static-routing”);
- Implement the replication
Simulator::Run();
Simulator::Destroy();
- Analyze Results
NetAnim like permit for envision the outcomes:
./waf –run static-routing
netanim
- Encompass by improved the Features
- IPv6 Static Routing
- Multiple Routes in per Node
- Firewall-based on Static Routing
- Execute for Quality of Service (QoS)
In this simulation setup, we understood the concept clearly on how to install the simulation and analyse the outcomes for static routing using ns3 simulation tool. If you have concerns or queries, they will be addressed in a separate manual.