The step-by-step procedure for building a simple LAN
In this section, we are going to learn how to set up a CSM LAN using a 24-port switch/bridge in ns-3. Let’s see how to set up the LAN with the following specifications:
- The maximum number of hosts is 24
- The CSMA link speed is 1 Gbps and the propagation delay is 1 nanoseconds
- Use a 24-port switch and connect all hosts to it using CSMA links
- Test connectivity between nodes using the ns-3 ping application
- Check the LAN speed using ns-3
OnOffApplication
Let’s write the following ns-3 code snippets in pkt_simplelan.cc
to simulate the CSMA LAN.
Start by including all necessary ns-3 modules:
#include "ns3/core-module.h" #include "ns3/network-module.h" #include "ns3/bridge-module.h" #include "ns3/internet-apps-module.h" #include "ns3/csma-module.h" #include "ns3/internet-module.h" #include "ns3/applications-module.h" ...