To develop the Unicast Routing Projects has involves the NS-3. The Unicast routing is process of routing packets from single source to single destination using a devoted path. In NS-3, unicast routing can be executed using:
- Static Routing for instance Manual routes
- Dynamic Routing Protocols for sample AODV, OLSR, DSDV, DSR
- Custom Unicast Routing Procedures
Steps to Develop a Unicast Routing Project in NS3
- Install and Set Up NS3
We assure the NS3 is installed:
git clone
cd ns-3-dev
./ns3 configure –enable-examples –enable-tests
./ns3 build
- Define a Network Topology
The point-to-point connection in wired or wireless network can be used for unicast routing.
Example: Create a 6-Node Network
NodeContainer nodes;
nodes.Create(6); // Create 6 nodes
Link the nodes are using the Point-to-Point connections
PointToPointHelper p2p;
p2p.SetDeviceAttribute(“DataRate”, StringValue(“1Gbps”));
p2p.SetChannelAttribute(“Delay”, StringValue(“2ms”));
NetDeviceContainer devices01 = p2p.Install(nodes.Get(0), nodes.Get(1));
NetDeviceContainer devices12 = p2p.Install(nodes.Get(1), nodes.Get(2));
NetDeviceContainer devices13 = p2p.Install(nodes.Get(1), nodes.Get(3));
NetDeviceContainer devices34 = p2p.Install(nodes.Get(3), nodes.Get(4));
NetDeviceContainer devices35 = p2p.Install(nodes.Get(3), nodes.Get(5));
- Allocate the IP Addresses for unicast routing
InternetStackHelper stack;
stack.Install(nodes);
Ipv4AddressHelper address;
address.SetBase(“10.1.1.0”, “255.255.255.0”);
Ipv4InterfaceContainer interfaces01 = address.Assign(devices01);
address.SetBase(“10.1.2.0”, “255.255.255.0”);
Ipv4InterfaceContainer interfaces12 = address.Assign(devices12);
address.SetBase(“10.1.3.0”, “255.255.255.0”);
Ipv4InterfaceContainer interfaces13 = address.Assign(devices13);
address.SetBase(“10.1.4.0”, “255.255.255.0”);
Ipv4InterfaceContainer interfaces34 = address.Assign(devices34);
address.SetBase(“10.1.5.0”, “255.255.255.0”);
Ipv4InterfaceContainer interfaces35 = address.Assign(devices35);
- Implement Unicast Routing
There are three ways to execute the unicast routing in NS3:
(A) Static Unicast Routing (Manual)
We utilized the Ipv4StaticRouting to describe the static routes manually.
Setting a Static Routing Table
Ptr<Ipv4StaticRouting> staticRouting0 = Ipv4RoutingHelper::GetRouting<Ipv4StaticRouting>(nodes.Get(0)->GetObject<Ipv4>());
staticRouting0->AddHostRouteTo(Ipv4Address(“10.1.5.2”), Ipv4Address(“10.1.1.2”), 1);
(B) Dynamic Unicast Routing (Using Protocols)
The NS-3 has encouraged for built-in dynamic routing protocols, like as:
- DSDV (Destination-Sequenced Distance Vector)
- AODV (Ad hoc On-Demand Distance Vector)
- OLSR (Optimized Link State Routing)
- DSR (Dynamic Source Routing)
Example: Using AODV for Unicast Routing
AodvHelper aodv;
Ipv4ListRoutingHelper list;
list.Add(aodv, 100);
InternetStackHelper stack;
stack.SetRoutingHelper(list);
stack.Install(nodes);
(C) Custom Unicast Routing Algorithm
We employ the custom unicast routing procedure, encompass for Ipv4RoutingProtocol.
For build a Custom Unicast Routing Class
class CustomUnicastRouting : public Ipv4RoutingProtocol {
public:
void RoutePacket(Ptr<Packet> packet, Ipv4Address destination);
};
We apply the Unicast Routing Function
void CustomUnicastRouting::RoutePacket(Ptr<Packet> packet, Ipv4Address destination) {
if (destination == Ipv4Address(“10.1.5.2”)) {
Ptr<Ipv4StaticRouting> staticRouting = Ipv4RoutingHelper::GetRouting<Ipv4StaticRouting>(GetObject<Ipv4>());
staticRouting->AddHostRouteTo(destination, Ipv4Address(“10.1.1.2”), 1);
}
}
Implement for Custom Unicast Routing
Ptr<CustomUnicastRouting> unicastRouting = CreateObject<CustomUnicastRouting>();
nodes.Get(0)->AggregateObject(unicastRouting);
- Configure the congestion Applications
UdpEchoServerHelper echoServer(9);
ApplicationContainer serverApps = echoServer.Install(nodes.Get(5));
serverApps.Start(Seconds(1.0));
serverApps.Stop(Seconds(10.0));
UdpEchoClientHelper echoClient(Ipv4Address(“10.1.5.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));
- Permit the Tracing for Debugging
AsciiTraceHelper ascii;
p2p.EnableAsciiAll(ascii.CreateFileStream(“unicast-routing.tr”));
p2p.EnablePcapAll(“unicast-routing”);
- Implement the replication
Simulator::Run();
Simulator::Destroy();
- Analyze Results
Ensure the outcomes for envision the NetAnim:
./waf –run unicast-routing
netanim
- Extend with Advanced Features
- QoS-based Unicast Routing: Enhance the performance metrices based on latency, jitter, and bandwidth.
- Energy-efficient Unicast Routing: Improve for minimal energy usage.
- AI-based Unicast Routing: We execute the machine learning-based on route selection.
According to this procedure we have seen and aggregated the essential information regarding the example based on Unicast routing that includes the simulation process in the ns3 tool. We will also offer more information about the Unicast routing.