To simulate the CCNA protocols in NS3, we can concentrate on numerous protocols are taught in CCNA (Cisco Certified Network Associate) courses, like RIP, OSPF, EIGRP, and BGP, along with simple concepts such as VLANs, Ethernet, and TCP/IP. Here we provide basic guide on how to replicate these CCNA-level protocols and concepts using NS3.
Common CCNA Protocols and Concepts to Simulate:
- RIP (Routing Information Protocol): Distance-vector routing protocol.
- OSPF (Open Shortest Path First): Link-state routing protocol.
- EIGRP (Enhanced Interior Gateway Routing Protocol): Cisco’s hybrid protocol.
- VLAN (Virtual LAN): Network segmentation concept.
- Ethernet: Basic wired communication using point-to-point links.
- TCP/IP: Application of network communication and traffic generation.
Steps to Simulate CCNA Protocols projects in NS3
- Simulating RIP in NS3:
RIP is natively supported in NS3 and can be replicated using the RipHelper class.
Example: Simulating RIP in NS3
#include “ns3/core-module.h”
#include “ns3/network-module.h”
#include “ns3/internet-module.h”
#include “ns3/rip-helper.h”
#include “ns3/point-to-point-module.h”
#include “ns3/applications-module.h”
using namespace ns3;
int main (int argc, char *argv[])
{
NodeContainer routers;
routers.Create (4);
PointToPointHelper p2p;
p2p.SetDeviceAttribute (“DataRate”, StringValue (“1Mbps”));
p2p.SetChannelAttribute (“Delay”, StringValue (“2ms”));
NetDeviceContainer devices;
for (uint32_t i = 0; i < routers.GetN() – 1; ++i)
{
devices.Add(p2p.Install (routers.Get(i), routers.Get(i+1)));
}
InternetStackHelper internet;
RipHelper ripRouting;
Ipv4ListRoutingHelper list;
list.Add (ripRouting, 0);
internet.SetRoutingHelper (list);
internet.Install (routers);
Ipv4AddressHelper ipv4;
ipv4.SetBase (“10.0.1.0”, “255.255.255.0”);
ipv4.Assign (devices);
UdpEchoServerHelper echoServer (9);
ApplicationContainer serverApps = echoServer.Install (routers.Get (3));
serverApps.Start (Seconds (1.0));
serverApps.Stop (Seconds (10.0));
UdpEchoClientHelper echoClient (Ipv4Address (“10.0.1.4”), 9);
echoClient.SetAttribute (“MaxPackets”, UintegerValue (1));
echoClient.SetAttribute (“Interval”, TimeValue (Seconds (1.0)));
echoClient.SetAttribute (“PacketSize”, UintegerValue (1024));
ApplicationContainer clientApps = echoClient.Install (routers.Get (0));
clientApps.Start (Seconds (2.0));
clientApps.Stop (Seconds (10.0));
Simulator::Run ();
Simulator::Destroy ();
return 0;
}
- Simulating OSPF in NS3:
OSPF is not natively obtainable within NS3, however we can estimate OSPF behaviour using global routing or physically describe the OSPF-like behaviour by configuring the routing tables.
Example: Simulating OSPF-like Behavior Using Static Routes:
#include “ns3/core-module.h”
#include “ns3/network-module.h”
#include “ns3/internet-module.h”
#include “ns3/point-to-point-module.h”
#include “ns3/applications-module.h”
using namespace ns3;
int main (int argc, char *argv[])
{
NodeContainer routers;
routers.Create (3);
PointToPointHelper p2p;
p2p.SetDeviceAttribute (“DataRate”, StringValue (“5Mbps”));
p2p.SetChannelAttribute (“Delay”, StringValue (“2ms”));
NetDeviceContainer devices12 = p2p.Install (routers.Get(0), routers.Get(1));
NetDeviceContainer devices23 = p2p.Install (routers.Get(1), routers.Get(2));
InternetStackHelper internet;
internet.Install (routers);
Ipv4AddressHelper ipv4;
ipv4.SetBase (“10.1.1.0”, “255.255.255.0”);
Ipv4InterfaceContainer interfaces12 = ipv4.Assign (devices12);
ipv4.SetBase (“10.1.2.0”, “255.255.255.0”);
Ipv4InterfaceContainer interfaces23 = ipv4.Assign (devices23);
Ipv4GlobalRoutingHelper::PopulateRoutingTables();
UdpEchoServerHelper echoServer (9);
ApplicationContainer serverApps = echoServer.Install (routers.Get (2));
serverApps.Start (Seconds (1.0));
serverApps.Stop (Seconds (10.0));
UdpEchoClientHelper echoClient (interfaces23.GetAddress (1), 9);
echoClient.SetAttribute (“MaxPackets”, UintegerValue (1));
echoClient.SetAttribute (“Interval”, TimeValue (Seconds (1.0)));
echoClient.SetAttribute (“PacketSize”, UintegerValue (1024));
ApplicationContainer clientApps = echoClient.Install (routers.Get (0));
clientApps.Start (Seconds (2.0));
clientApps.Stop (Seconds (10.0));
Simulator::Run ();
Simulator::Destroy ();
return 0;
}
- Simulating VLANs in NS3:
NS3 doesn’t natively support VLANs, however we can replicate the VLAN-like behaviour by segmenting traffic using various subnets and physically setting up the routes among various parts of the network.
- Simulating EIGRP in NS3:
EIGRP is not natively supported by NS3, thus we could require to manually execute the EIGRP’s behaviour, or we use an external tool such as Quagga combined with NS3-DCE to replicate an EIGRP.
- Simulating Ethernet in NS3:
We can use point-to-point links to replicate the Ethernet connections among nodes. Here’s an instance to replicate Ethernet communication among the routers.
Example: Simulating Ethernet Communication Using Point-to-Point Links
#include “ns3/core-module.h”
#include “ns3/network-module.h”
#include “ns3/internet-module.h”
#include “ns3/point-to-point-module.h”
#include “ns3/applications-module.h”
using namespace ns3;
int main (int argc, char *argv[])
{
NodeContainer nodes;
nodes.Create (2);
PointToPointHelper pointToPoint;
pointToPoint.SetDeviceAttribute (“DataRate”, StringValue (“5Mbps”));
pointToPoint.SetChannelAttribute (“Delay”, StringValue (“2ms”));
NetDeviceContainer devices = pointToPoint.Install (nodes);
InternetStackHelper stack;
stack.Install (nodes);
Ipv4AddressHelper address;
address.SetBase (“10.1.1.0”, “255.255.255.0”);
Ipv4InterfaceContainer interfaces = address.Assign (devices);
UdpEchoServerHelper echoServer (9);
ApplicationContainer serverApps = echoServer.Install (nodes.Get (1));
serverApps.Start (Seconds (1.0));
serverApps.Stop (Seconds (10.0));
UdpEchoClientHelper echoClient (interfaces.GetAddress (1), 9);
echoClient.SetAttribute (“MaxPackets”, UintegerValue (1));
echoClient.SetAttribute (“Interval”, TimeValue (Seconds (1.0)));
echoClient.SetAttribute (“PacketSize”, UintegerValue (1024));
ApplicationContainer clientApps = echoClient.Install (nodes.Get (0));
clientApps.Start (Seconds (2.0));
clientApps.Stop (Seconds (10.0));
Simulator::Run ();
Simulator::Destroy ();
return 0;
}
- Simulating TCP/IP in NS3:
NS3 natively supports TCP/IP, and we can be replicated the TCP or UDP traffic among the nodes in the network.
Example: Simulating TCP Traffic
#include “ns3/core-module.h”
#include “ns3/network-module.h”
#include “ns3/internet-module.h”
#include “ns3/point-to-point-module.h”
#include “ns3/applications-module.h”
using namespace ns3;
int main (int argc, char *argv[])
{
NodeContainer nodes;
nodes.Create (2);
PointToPointHelper p2p;
p2p.SetDeviceAttribute (“DataRate”, StringValue (“10Mbps”));
p2p.SetChannelAttribute (“Delay”, StringValue (“2ms”));
NetDeviceContainer devices = p2p.Install (nodes);
InternetStackHelper stack;
stack.Install (nodes);
Ipv4AddressHelper address;
address.SetBase (“10.1.1.0”, “255.255.255.0”);
Ipv4InterfaceContainer interfaces = address.Assign (devices);
uint16_t port = 8080;
Address serverAddress (InetSocketAddress (interfaces.GetAddress (1), port));
OnOffHelper onOffHelper (“ns3::TcpSocketFactory”, serverAddress);
onOffHelper.SetAttribute (“DataRate”, StringValue (“5Mbps”));
onOffHelper.SetAttribute (“PacketSize”, UintegerValue (1024));
ApplicationContainer clientApp = onOffHelper.Install (nodes.Get (0));
clientApp.Start (Seconds (1.0));
clientApp.Stop (Seconds (10.0));
PacketSinkHelper packetSinkHelper (“ns3::TcpSocketFactory”, serverAddress);
ApplicationContainer serverApp = packetSinkHelper.Install (nodes.Get (1));
serverApp.Start (Seconds (0.0));
serverApp.Stop (Seconds (10.0));
Simulator::Run ();
Simulator::Destroy ();
return 0;
}
How to Extend:
- EIGRP: We can use an external tools such as Quagga to replicate EIGRP through NS3-DCE.
- Advanced VLAN: We can replicate VLANs using more furthered network segmentation with switches and tagging.
- BGP for CCNA: We can combine BGP through Quagga or FRRouting for more advanced networking simulations.
In this page, we had exposed about CCNA protocols that has simulate RIP, OSPF, VLAN, EIGRP, Ethernet, replicate and extend within NS3 simulation tool. We will be provided advanced concepts and informations according to your requirements.
To simulate the CCNA protocols in NS3 all you have to do is share with us all the research details you have by mail we will reply you immediately, get valuable and best outcomes from us. We will help in comparative analysis for your projects.