To develop the Route Access Protocol (RAP) projects using NS-3 contains the multiple procedures, including configure the replication surroundings, execute the protocol, and examine the performance of parameter metrics. Below is a step-by-step guide.
Steps to Develop a Route Access Protocol (RAP) Project Using NS-3
- Setup NS-3 Environment
The Previous executing the RAP, ensure that NS-3 is installed on your system.
Install NS-3
sudo apt update
sudo apt install git g++ python3 python3-pip cmake ninja-build
git clone
cd ns-3-dev
./ns3 configure –enable-examples –enable-tests
./ns3 build
- Understand Route Access Protocol (RAP)
RAP is routing protocol model for high-speed wireless networks, assuring the effective packet delivery. It frequently uses the performance of parameter metrics like as:
- Delay
- Link Quality
- Bandwidth availability
- Implementing Route Access Protocol in NS-3
NS-3 has built-in routing protocols such as AODV, DSDV, and OLSR. We can alter an previous protocol or generate a new routing agent.
Create a New Routing Protocol in NS-3
- Navigate to the Routing Directory
cd ns-3-dev/src/network/model
- Define the Protocol Header (rap-header.h)
#ifndef RAP_HEADER_H
#define RAP_HEADER_H
#include “ns3/header.h”
namespace ns3 {
class RapHeader : public Header {
public:
RapHeader();
static TypeId GetTypeId();
virtual void Serialize(Buffer::Iterator start) const;
virtual uint32_t Deserialize(Buffer::Iterator start);
virtual uint32_t GetSerializedSize() const;
virtual void Print(std::ostream &os) const;
private:
uint16_t m_source;
uint16_t m_destination;
uint32_t m_sequenceNumber;
};
} // namespace ns3
#endif
- Implement Protocol Logic (rap-routing.cc)
#include “ns3/rap-header.h”
#include “ns3/rap-routing.h”
namespace ns3 {
NS_LOG_COMPONENT_DEFINE(“RapRouting”);
TypeId RapRouting::GetTypeId() {
static TypeId tid = TypeId(“ns3::RapRouting”)
.SetParent<Ipv4RoutingProtocol>()
.SetGroupName(“Internet”)
.AddConstructor<RapRouting>();
return tid;
}
void RapRouting::DoInitialize() {
NS_LOG_INFO(“Initializing RAP Routing Protocol”);
Ipv4RoutingProtocol::DoInitialize();
}
void RapRouting::SendPacket(Ptr<Packet> packet, Ipv4Address src, Ipv4Address dst) {
RapHeader header;
packet->AddHeader(header);
NS_LOG_INFO(“Sending packet via RAP: ” << src << ” to ” << dst);
m_ipv4->Send(packet, src, dst, Ipv4Header::PROTO_RAP);
}
} // namespace ns3
- Register the Protocol (rap-routing-helper.cc)
#include “ns3/rap-routing-helper.h”
#include “ns3/rap-routing.h”
namespace ns3 {
RapRoutingHelper::RapRoutingHelper() {}
Ptr<Ipv4RoutingProtocol> RapRoutingHelper::Create() const {
return CreateObject<RapRouting>();
}
} // namespace ns3
- Create a Simulation Script
We check and validate the RAP implementation, write a replication script (rap-test.cc).
Basic NS-3 Simulation Script
#include “ns3/core-module.h”
#include “ns3/network-module.h”
#include “ns3/internet-module.h”
#include “ns3/rap-routing-helper.h”
using namespace ns3;
int main(int argc, char *argv[]) {
CommandLine cmd;
cmd.Parse(argc, argv);
NodeContainer nodes;
nodes.Create(3);
InternetStackHelper stack;
RapRoutingHelper rapRouting;
stack.SetRoutingHelper(rapRouting);
stack.Install(nodes);
Ipv4AddressHelper address;
address.SetBase(“10.1.1.0”, “255.255.255.0”);
Simulator::Run();
Simulator::Destroy();
return 0;
}
- Compile and Run the Simulation
We generate a NS-3 Code for this project
./ns3 build
Implement the replication of this method
./ns3 run “scratch/rap-test”
- Examine the performance of parameter metrices such as
We estimate the Route Access Protocol (RAP), can calculate the route access protocols:
- Throughput
- Packet delivery ratio (PDR)
- End-to-end delay
- Routing overhead
We utilize the tool NS-3’s for tracing the system:
Config::Connect(“/NodeList/*/ApplicationList/*/$ns3::PacketSink/Rx”, MakeCallback(&ReceivePacket));
As shown above, we provided the detailed complete procedures to simulate the Route Access Protocol project which were implemented and analyse the outcomes using the tool of NS3. Additional information with certain details on this Route Access Protocol will be provided in another manual.