How to Implement SD WAN Protocol in NS2

 

To implement Software-Defined Wide Area Network (SD-WAN) protocols in NS2 has needs to mimic the mechanisms that were utilize in SD-WANs, like centralized control, dynamic path selection, traffic management, and policy enforcement. The SD-WAN is a more recent development in networking, and NS2, being a traditional simulation tool that not directly support the SD-WAN features. Furthermore, we can generate a custom implementation that approximates the key functionalities of SD-WAN.

The given below is the procedure to execute a basic SD-WAN protocol in NS2:

Step-by-Step Implementation:

Step 1: Understand SD-WAN Key Concepts

SD-WAN use a centralized controller to handle the WAN connections among the distributed sites. The key features include:

  • Centralized Control: A central controller handles the policies, path selection, and routing.
  • Dynamic Path Selection: Traffic is enthusiastically routed based on parameters such as latency, jitter, and packet loss.
  • Traffic Management: Policies selects and route traffic based on the application, user, or other criteria.
  • Multi-Path Support: The ability to route traffic over multiple WAN links.

Step 2: Set Up NS2

Make sure NS2 is installed on the system. Since NS2 is traditional, it does not have native support for SD-WAN-specific features, so we will be executing custom agents to mimic the SD-WAN behaviour.

Step 3: Implement the SD-WAN Protocol in C++

  1. Create the SD-WAN Controller Class

The SD-WAN controller will handle the routing decisions and implement policies via the network.

#include <agent.h>

#include <packet.h>

#include <trace.h>

#include <address.h>

#include <map>

class SDWANController : public Agent {

public:

SDWANController();

void recv(Packet* p, Handler* h);

void makeRoutingDecision(Packet* p);

void enforcePolicy(Packet* p);

void selectBestPath(Packet* p);

protected:

std::map<int, int> routingTable_; // Destination -> Next Hop

std::map<int, std::string> policyTable_; // Application -> Policy

std::map<int, std::vector<int>> pathMetrics_; // Destination -> Path Metrics

};

// Constructor

SDWANController::SDWANController() : Agent(PT_UDP) {

// Initialization code here

}

// Packet reception

void SDWANController::recv(Packet* p, Handler* h) {

// Apply policy and make routing decisions

enforcePolicy(p);

selectBestPath(p);

makeRoutingDecision(p);

}

// Enforce policies based on application type, user, etc.

void SDWANController::enforcePolicy(Packet* p) {

// Example: Prioritize VoIP traffic

hdr_cmn* cmnh = hdr_cmn::access(p);

if (cmnh->ptype() == PT_VOIP) {

// Apply high-priority policy

}

}

// Select the best path based on path metrics

void SDWANController::selectBestPath(Packet* p) {

hdr_ip* iph = hdr_ip::access(p);

int dest = iph->dst();

// Implement logic to select the best path (e.g., based on latency)

}

// Make the final routing decision and forward the packet

void SDWANController::makeRoutingDecision(Packet* p) {

hdr_ip* iph = hdr_ip::access(p);

int nextHop = routingTable_[iph->dst()];

send(p, nextHop);

}

  1. Create the SD-WAN Edge Node Class

SD-WAN edge nodes will interact with the central controller to transmit the traffic based on the controller’s decisions.

class SDWANEdgeNode : public Agent {

public:

SDWANEdgeNode();

void recv(Packet* p, Handler* h);

void requestRoutingDecision(Packet* p);

protected:

SDWANController* controller_;

};

// Constructor

SDWANEdgeNode::SDWANEdgeNode() : Agent(PT_UDP), controller_(nullptr) {

// Initialization code here

}

// Packet reception

void SDWANEdgeNode::recv(Packet* p, Handler* h) {

// Send packet to the controller for a routing decision

requestRoutingDecision(p);

}

// Request routing decision from the SD-WAN controller

void SDWANEdgeNode::requestRoutingDecision(Packet* p) {

if (controller_) {

controller_->recv(p, nullptr);

} else {

// Handle the packet if no controller is available

}

}

Step 4: Integrate the SD-WAN Protocol into NS2

  1. Modify the Makefile: Add the new SDWANController and SDWANEdgeNode classes to the NS2 Makefile so that they acquire to executed with the rest of the simulator.
  2. Recompile NS2:

make clean

make

Step 5: Create a Tcl Script to Simulate the SD-WAN Network

Once the SD-WAN protocol is executed and compiled, generate a Tcl script to emulate a network using custom protocol.

Example Tcl Script:

# Create a simulator object

set ns [new Simulator]

# Define the topology

set val(chan)   Channel/WiredChannel

set val(ll)     LL

set val(ifq)    Queue/DropTail/PriQueue

set val(ifqlen) 50

set val(stop)   50.0

# Initialize the topology object

set topo [new Topography]

$topo load_flatgrid 500 500

# Create nodes representing the SD-WAN controller and edge nodes

set controller [$ns node]

set edge1 [$ns node]

set edge2 [$ns node]

# Establish links between the controller and edge nodes

$ns duplex-link $controller $edge1 10Mb 10ms DropTail

$ns duplex-link $controller $edge2 10Mb 10ms DropTail

# Attach SD-WAN controller and edge node agents

set sdwan_ctrl [new Agent/SDWANController]

set sdwan_edge1 [new Agent/SDWANEdgeNode]

set sdwan_edge2 [new Agent/SDWANEdgeNode]

$ns attach-agent $controller $sdwan_ctrl

$ns attach-agent $edge1 $sdwan_edge1

$ns attach-agent $edge2 $sdwan_edge2

# Set up traffic sources and sinks

set udp [new Agent/UDP]

set null [new Agent/Null]

$ns attach-agent $edge1 $udp

$ns attach-agent $edge2 $null

$ns connect $udp $null

# Start the simulation

$ns at 0.0 “$udp start”

$ns at $val(stop) “stop”

$ns at $val(stop) “exit 0”

proc stop {} {

global ns

$ns flush-trace

exit 0

}

# Run the simulation

$ns run

Step 6: Run the Simulation

  1. Save the Tcl script (sdwan_simulation.tcl).
  2. Open a terminal and navigate to the directory in which we saved the Tcl script.
  3. Execute the simulation using the following command:

ns sdwan_simulation.tcl

Step 7: Analyse the Results

  • Use trace files and the network animator (NAM) to evaluate the performance of SD-WAN protocol, concentrate on parameters like routing efficiency, policy enforcement, and path selection effectiveness.
  • Inspect on how well the protocol manages diverse traffic types, path conditions, and network topologies.

Additional Considerations

  • Advanced Features: Execute more advanced SD-WAN features like link failover, load balancing via multiple WAN links, and incorporation with cloud services.
  • Scalability: Evaluate the SD-WAN protocol in larger networks with more edge nodes and diverse WAN links to assess the scalability and performance.
  • Real-World Scenarios: Replicate real-world scenarios like branch office connectivity, multi-cloud routing, and application-aware routing.

In the end of the manual, we had discovered the simple implementation process on how to execute the Software-Defined Wide Area Network that manages the routes and enhance the network performance. If you need additional information regarding the Software-Defined Wide Area Network we will provide it too. For help with implementing the Routing Interface Protocol in NS2, you can contact  ns2project.com. We offer support for SD-WAN features, so please share your project details with us, and we will provide detailed guidance