To simulate Software-Defined Wide Area Networks (SD-WAN) using NS2 has includes to design a network that utilizes the software-defined networking (SDN) principles to regulate and handle WAN traffic dynamically. SD-WAN frameworks decouple the control plane from the data plane, allowing the centralized control over network paths, traffic routing, and policies.
While NS2 does not directly support SDN or SD-WAN, we can simulate SD-WAN projects by prolonging the network features with the help of custom agents or scripts that implement centralized control, dynamic routing, and traffic management.
Here’s a guide to simulate SD-WAN projects using NS2:
Steps to Simulate Software Defined Wide Area Network Projects in NS2
- Install NS2
- Download and install NS2 from the official NS2 website.
- Make sure that Tcl/Tk, OTcl, and NAM (Network Animator) are installed for executing the simulations and envision the outcomes.
- Understand SD-WAN Concepts
- Control Plane: The centralized SD-WAN controller handle network policies, routing, and traffic optimization.
- Data Plane: This is responsible for forwarding packets according to the control plane’s decisions.
- Multiple WAN Links: SD-WAN usually utilizes multiple paths, like MPLS, broadband, and LTE, to enhance traffic.
- Dynamic Path Selection: SD-WAN controller’s tracks network conditions and adapt the routing of traffic dynamically.
- Define the SD-WAN Topology
In NS2, we can generate a network in which branch offices (or edge nodes) are associated to multiple WAN links. A centralized SD-WAN controller makes routing decisions enthusiastically according to network conditions, like link quality, latency, or traffic load.
Example OTcl Code for SD-WAN Topology:
# Create a simulator instance
set ns [new Simulator]
# Define the topography (for WAN and branch offices)
set topo [new Topography]
$topo load_flatgrid 2000 2000 ;# Large area to simulate a WAN
# Create branch office nodes (representing offices or edge nodes)
set branch1 [$ns node]
set branch2 [$ns node]
set branch3 [$ns node]
# Create SD-WAN controller node (centralized control)
set sdwan_controller [$ns node]
# Create core network nodes (representing multiple WAN links, e.g., MPLS, LTE)
set wan1 [$ns node]
set wan2 [$ns node]
# Set up links between branch offices and WAN links (e.g., broadband or MPLS links)
$ns duplex-link $branch1 $wan1 10Mb 50ms DropTail ;# Branch1 to WAN1 (e.g., MPLS)
$ns duplex-link $branch1 $wan2 20Mb 30ms DropTail ;# Branch1 to WAN2 (e.g., broadband)
$ns duplex-link $branch2 $wan1 10Mb 50ms DropTail ;# Branch2 to WAN1
$ns duplex-link $branch2 $wan2 20Mb 30ms DropTail ;# Branch2 to WAN2
$ns duplex-link $branch3 $wan1 10Mb 50ms DropTail ;# Branch3 to WAN1
$ns duplex-link $branch3 $wan2 20Mb 30ms DropTail ;# Branch3 to WAN2
# Set up links between WAN links and SD-WAN controller
$ns duplex-link $wan1 $sdwan_controller 100Mb 100ms DropTail
$ns duplex-link $wan2 $sdwan_controller 100Mb 80ms DropTail
In this example:
- Branch offices denotes edge nodes that essential WAN connectivity.
- WAN links simulate different kinds of connections (such as MPLS, LTE, or broadband).
- SD-WAN controller manages routing and traffic optimization by enthusiastically choosing the paths.
- Simulate the SD-WAN Controller’s Dynamic Path Selection
In an SD-WAN environment, the controller tracks the network and enthusiastically adapts the routing of traffic. We can replicate this behaviour by occasionally validating network conditions (like delay, throughput, or packet loss) and rerouting traffic consequently.
Example: Dynamic Path Selection Based on Latency
# Function to simulate SD-WAN dynamic path selection based on link delay
proc sdwan_dynamic_routing {branch_id} {
global ns
# Example: dynamically select the best path for Branch 1
if {$branch_id == 1} {
set delay_wan1 50 ;# Example delay for WAN1
set delay_wan2 30 ;# Example delay for WAN2
# Select the lower-latency WAN link for traffic routing
if {$delay_wan2 < $delay_wan1} {
puts “Branch 1: Selecting WAN2 (lower latency)”
$ns at [$ns now] “route_traffic $branch1 $wan2”
} else {
puts “Branch 1: Selecting WAN1”
$ns at [$ns now] “route_traffic $branch1 $wan1”
}
}
}
# Function to route traffic from a branch to the selected WAN link
proc route_traffic {branch wan} {
puts “Routing traffic from $branch to $wan”
# Perform routing decisions here
}
# Start dynamic routing decisions at regular intervals
$ns at 2.0 “sdwan_dynamic_routing 1”
$ns at 4.0 “sdwan_dynamic_routing 1”
In this example:
- The SD-WAN controller intermittently validates the latency of WAN links and chooses the path with the lowest latency for routing traffic.
- The sdwan_dynamic_routing function replicates the controller’s decision-making.
- Simulate Traffic Flows in SD-WAN
We can replicate different kinds of traffic flows among branch offices and a data centre or between branches. Use TCP or UDP agents to design traffic over the SD-WAN links.
Example: TCP Traffic between Branch 1 and Branch 2
# Create a TCP agent at Branch 1 (for sending data)
set tcp_branch1 [new Agent/TCP]
$ns attach-agent $branch1 $tcp_branch1
# Create a TCP sink at Branch 2 (for receiving data)
set tcp_sink_branch2 [new Agent/TCPSink]
$ns attach-agent $branch2 $tcp_sink_branch2
# Connect the TCP agents between Branch 1 and Branch 2
$ns connect $tcp_branch1 $tcp_sink_branch2
# Create an FTP application to generate traffic from Branch 1 to Branch 2
set ftp [new Application/FTP]
$ftp attach-agent $tcp_branch1
# Start the FTP traffic at time 1.0 seconds
$ns at 1.0 “$ftp start”
In this example:
- TCP traffic is created from Branch 1 to Branch 2 over the SD-WAN.
- The SD-WAN controller can enthusiastically adapt that WAN link the traffic flows through, according to network conditions.
- Run the Simulation
Save OTcl script as sdwan_simulation.tcl and executed it using the NS2 command:
ns sdwan_simulation.tcl
- Analyse the Results
NS2 creates trace files which capture all network events that contain traffic routing decisions, packet transmissions, delays, and packet losses. We can measure these files to measure parameters like:
- Throughput: Evaluate on how much data was routed successfully over the SD-WAN.
- Latency: Assess the round-trip time (RTT) of packets transmit via different WAN links.
- Packet Loss: measure on how usual the packets were dropped because of congestion or link failures.
- Path Selection: Monitor on how usual the SD-WAN controller changed the path according to network conditions.
Example: Analyse Trace Files Using Awk
awk -f analyze_trace.awk sdwan_simulation.tr
- Visualize the Simulation Using NAM
We can utilize Network Animator (NAM) to envision the traffic flows and path selection in SD-WAN network.
nam sdwan_simulation.nam
- Advanced SD-WAN Features to Simulate
We can prolong your SD-WAN simulation by adding advanced features:
- QoS Policies: Execute traffic prioritization for different kinds of traffic (such as voice, video, data) in the SD-WAN controller.
- Failure Recovery: Mimic link failures and how the SD-WAN controller reroutes traffic to backup links.
- Bandwidth Management: Replicate dynamic bandwidth allocation according to network load.
- Security: Replicate VPN tunnels or IPSec encryption among branch offices for secure communication.
- Multi-Cloud Connectivity: Prolong the simulation to contain data centres or cloud providers associated through SD-WAN.
Example Simulation Script Outline for SD-WAN
# SD-WAN Simulation Script using NS2
set ns [new Simulator]
set topo [new Topography]
$topo load_flatgrid 2000 2000 ;# Define topology area for SD-WAN
# Create branch office nodes
set branch1 [$ns node]
set branch2 [$ns node]
set branch3 [$ns node]
# Create SD-WAN controller
set sdwan_controller [$ns node]
# Create WAN links (representing multiple WAN connections)
set wan1 [$ns node] ;# WAN link 1 (e.g., MPLS)
set wan2 [$ns node] ;# WAN link 2 (e.g., broadband)
# Set up links between branches and WAN links
$ns duplex-link $branch1 $wan1 10Mb 50ms DropTail
$ns duplex-link $branch1 $wan2 20Mb 30ms DropTail
$ns duplex-link $branch2 $wan1 10Mb 50ms DropTail
$ns duplex-link $branch2 $wan2 20Mb 30ms DropTail
# Set up links between WANs and SD-WAN controller
$ns duplex-link $wan1 $sdwan_controller 100Mb 100ms DropTail
$ns duplex-link $wan2 $sdwan_controller 100Mb 80ms DropTail
# Function for SD-WAN dynamic path selection
proc sdwan_dynamic_routing {branch_id} {
global ns
set delay_wan1 50
set delay_wan2 30
if {$delay_wan2 < $delay_wan1} {
puts “Selecting WAN2 for branch $branch_id”
$ns at [$ns now] “route_traffic $branch_id $wan2”
} else {
puts “Selecting WAN1 for branch $branch_id”
$ns at [$ns now] “route_traffic $branch_id $wan1”
}
}
# Create TCP traffic between branch offices
set tcp_branch1 [new Agent/TCP]
$ns attach-agent $branch1 $tcp_branch1
set tcp_sink_branch2 [new Agent/TCPSink]
$ns attach-agent $branch2 $tcp_sink_branch2
$ns connect $tcp_branch1 $tcp_sink_branch2
# FTP traffic generation
set ftp [new Application/FTP]
$ftp attach-agent $tcp_branch1
$ns at 1.0 “$ftp start”
# End simulation after 10 seconds
$ns at 10.0 “finish”
# Run the simulation
$ns run
Key Points:
- Dynamic Routing: Execute SD-WAN’s ability to enthusiastically route traffic via multiple WAN links according to network conditions.
- Centralized Control: Utilize a centralized SD-WAN controller to handle routing and traffic optimization.
- Multiple WAN Links: replicate different kinds of WAN links such as MPLS, broadband, LTE and enthusiastically adapts traffic flow among them.
- Traffic Types: replicate numerous traffic types such as video, voice, and data to validate QoS policies and bandwidth allocation.
In the end of evaluation process, we all get a knowledge about the Software-Defined Wide Area Networks projects run in ns2 tool and also we understood the concepts and ideas on how to installing the environment and how to simulate this project in the simulation tool including sample snippets. We also provide how the Software-Defined Wide Area Networks performs in diverse scenarios.
By sharing complete information of your Software Defined Wide Area Network Projects, we ensure optimal simulation results. Seek advice from our team on SDN or SD-WAN, and maintain communication with us to achieve the best simulations and project execution tailored to your needs.