How to Start STAR Protocol Projects Using NS3

To start a STAR (Source Tree Adaptive Routing) protocol project in NS3 has structured method to execute or replicate this proactive routing protocol utilized within ad-hoc wireless networks. STAR targets to minimize overhead by sustaining the source tree for routing instead of flooding the network including control packets. We follow these steps:

Steps to Start STAR Protocol Projects in NS3

  1. Understand STAR Protocol
  • Key Features of STAR:
    • Source Tree-Based Routing: Nodes sustain source trees signifying the paths to destinations.
    • Proactive Protocol: Routes are sustained before they are required.
    • Reduced Overhead: Disparate reactive protocols, STAR protocol prevents the flooding with the support of incremental updates.
  • Advantages:
    • It is appropriate for dynamic and mobile networks.
    • This protocol minimizes the control overhead that equated to traditional link-state protocols.
  • Use Cases:
    • STAR protocol typically used in ad-hoc networks and dynamic wireless environments.
  1. Set Up NS3
  • Install NS3:
    • In nsnam.org, we download and install NS3 environment on the system.
  • Verify Installation:

./waf –run scratch/test-example

  • Modules to Enable:
    • internet: It supports for IP and routing stack.
    • wifi: For wireless interaction, we can utilized this module.
    • mobility: For dynamic movement of nodes.
    • manet-routing: Optional, it is used for base routing executions.
  1. Plan Your STAR Protocol Project
  • Objectives:
    • To replicate the STAR and then measure their performance within an ad-hoc wireless network.
    • Equate STAR with other protocols such as AODV, DSR.
    • To enhance the STAR for certain use cases like scalability, mobility.
  • Metrics to Measure:
    • We should estimate the metrics like packet delivery ratio, routing overhead, end-to-end delay, and throughput.
  • Simulation Topology:
    • To simulate star, grid, or random placement of nodes within a wireless network.
  1. Write a Basic Wireless Network Simulation
  • Mimic a wireless network as per initial point to utilize NS3.
  • Example: Wireless Network Setup

#include “ns3/core-module.h”

#include “ns3/network-module.h”

#include “ns3/internet-module.h”

#include “ns3/wifi-module.h”

#include “ns3/mobility-module.h”

#include “ns3/applications-module.h”

using namespace ns3;

int main(int argc, char *argv[]) {

uint32_t nNodes = 10; // Number of nodes

double simulationTime = 20.0;

// Create nodes

NodeContainer nodes;

nodes.Create(nNodes);

// Configure Wi-Fi

WifiHelper wifi;

wifi.SetStandard(WIFI_PHY_STANDARD_80211b);

YansWifiPhyHelper phy = YansWifiPhyHelper::Default();

YansWifiChannelHelper channel = YansWifiChannelHelper::Default();

phy.SetChannel(channel.Create());

WifiMacHelper mac;

mac.SetType(“ns3::AdhocWifiMac”);

NetDeviceContainer devices = wifi.Install(phy, mac, nodes);

// Mobility model

MobilityHelper mobility;

mobility.SetPositionAllocator(“ns3::RandomRectanglePositionAllocator”,

“X”, StringValue(“ns3::UniformRandomVariable[Min=0|Max=100]”),

“Y”, StringValue(“ns3::UniformRandomVariable[Min=0|Max=100]”));

mobility.SetMobilityModel(“ns3::RandomWaypointMobilityModel”,

“Speed”, StringValue(“ns3::UniformRandomVariable[Min=1.0|Max=3.0]”),

“Pause”, StringValue(“ns3::ConstantRandomVariable[Constant=2.0]”));

mobility.Install(nodes);

// Install Internet stack

InternetStackHelper stack;

stack.Install(nodes);

// Assign IP addresses

Ipv4AddressHelper ipv4;

ipv4.SetBase(“10.1.1.0”, “255.255.255.0”);

ipv4.Assign(devices);

// Application: UDP Echo

uint16_t port = 9;

UdpEchoServerHelper echoServer(port);

ApplicationContainer serverApps = echoServer.Install(nodes.Get(nNodes – 1));

serverApps.Start(Seconds(1.0));

serverApps.Stop(Seconds(simulationTime));

UdpEchoClientHelper echoClient(Ipv4Address(“10.1.1.10”), port);

echoClient.SetAttribute(“MaxPackets”, UintegerValue(10));

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(simulationTime));

// Enable pcap tracing

phy.EnablePcapAll(“star-protocol”);

Simulator::Run();

Simulator::Destroy();

return 0;

}

  1. Implement STAR Protocol
  • Extend NS3’s Routing Classes:
    • Create the execution on the Ipv4RoutingProtocol class.
    • Implement following crucial techniques:
  • RouteInput(): To manage the incoming packets.
  • RouteOutput(): It helps to find the next hop for outgoing packets.
  • NotifyInterfaceUp() and NotifyInterfaceDown(): According to the network changes, which is supports for modernize source trees.

Key Steps to Implement:

Source Tree Management:

  • We should sustain the source trees on each node signifying the paths to destinations.

Routing Table Updates:

  • Transmit source tree occasionally updates with neighbors.

Incremental Updates:

  • We need to transmit only modifications to the source tree minimizing overhead.

Packet Forwarding:

  • Send packets to the proper next hop utilising the source tree.
  1. Test and Debug
  • Enable Logging:

export NS_LOG=Ipv4RoutingProtocol=level_all

./waf –run scratch/star-protocol

  • Inspect Routing Behavior:
    • Analyse the routing tables:

Ptr<Ipv4> ipv4 = nodes.Get(0)->GetObject<Ipv4>();

ipv4->GetRoutingProtocol()->Print(std::cout);

  • Analyze Packets:
    • Examine routing control packets within Wireshark to utilize PCAP files.
  1. Evaluate Performance
  • Metrics to Evaluate:
    • We estimate the performance parameters such as packet delivery ratio, routing overhead, end-to-end delay, and energy consumption (for mobile networks).
  • Use FlowMonitor:
    • Incorporate the FlowMonitor for performance analysis:

FlowMonitorHelper flowMonitor;

Ptr<FlowMonitor> monitor = flowMonitor.InstallAll();

  1. Advanced Features
  • Mobility and Scalability:
    • Experiment the STAR protocol under highly dynamic or large-scale scenarios.
  • Optimizations:
    • We execute the adaptive mechanisms minimizing control overhead.
  • Comparison:
    • We need to equate the performance of STAR including other protocols such as AODV, OLSR.

From the guide we clearly learned the valuable concepts with stepwise approach to implement and simulate the STAR Protocol Projects using NS3 environment. We plan to deliver more information about this protocol if necessary.

If you are looking for more project updates you can reach us out for more help.