Ns3 Projects for B.E/B.Tech M.E/M.Tech PhD Scholars.  Phone-Number:9790238391   E-mail: ns3simulation@gmail.com

How to Implement DWDM Fiber in ns3

To implement Dense Wavelength Division Multiplexing (DWDM) fiber in ns3, we need to simulate an optical network in which we can transmit data over the same optical fiber with multiple wavelengths. For this process we need to configure nodes to represent the transmitters and receivers. And also simulating data transmission and  setting up the optical fiber links with DWDM capabilities by configuring the nodes.

If you encounter challenges in implementing DWDM Fiber in ns3tool after following the aforementioned steps, you may reach out to our team for further assistance.

The following step will guide on how to implement DWDM fiber in ns3.

Step-by-step guide to implement DWDM fiber network in ns3.

Step 1: Setup ns3 Environment

Ensure that ns3 is installed and properly configured.

git clone https://gitlab.com/nsnam/ns-3-dev.git

cd ns-3-dev

./waf configure

./waf build

Step 2: Create the DWDM Fiber Simulation Script

We will create a script that sets up nodes with DWDM capabilities, configures the optical fiber links, and simulates data transmission.

#include “ns3/core-module.h”

#include “ns3/network-module.h”

#include “ns3/internet-module.h”

#include “ns3/point-to-point-module.h”

#include “ns3/applications-module.h”

#include “ns3/flow-monitor-module.h”

#include “ns3/point-to-point-layout-module.h”

using namespace ns3;

NS_LOG_COMPONENT_DEFINE(“DwdmFiberExample”);

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

{

CommandLine cmd;

cmd.Parse(argc, argv);

// Create nodes

NodeContainer nodes;

nodes.Create(4); // Four nodes to represent transmitters and receivers

// Set up DWDM point-to-point links

PointToPointHelper dwdmP2P;

dwdmP2P.SetDeviceAttribute(“DataRate”, StringValue(“10Gbps”));

dwdmP2P.SetChannelAttribute(“Delay”, StringValue(“1ms”));

NetDeviceContainer devices1 = dwdmP2P.Install(nodes.Get(0), nodes.Get(1));

NetDeviceContainer devices2 = dwdmP2P.Install(nodes.Get(1), nodes.Get(2));

NetDeviceContainer devices3 = dwdmP2P.Install(nodes.Get(2), nodes.Get(3));

// Install the internet stack

InternetStackHelper stack;

stack.Install(nodes);

// Assign IP addresses

Ipv4AddressHelper address;

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

Ipv4InterfaceContainer interfaces1 = address.Assign(devices1);

address.NewNetwork();

Ipv4InterfaceContainer interfaces2 = address.Assign(devices2);

address.NewNetwork();

Ipv4InterfaceContainer interfaces3 = address.Assign(devices3);

// Install applications to generate traffic

uint16_t port = 9;

// Node 0 will send data to Node 3

OnOffHelperonoff(“ns3::UdpSocketFactory”, Address(InetSocketAddress(interfaces3.GetAddress(1), port)));

onoff.SetConstantRate(DataRate(“5Gbps”));

ApplicationContainer apps = onoff.Install(nodes.Get(0));

apps.Start(Seconds(1.0));

apps.Stop(Seconds(10.0));

// Install packet sink on Node 3 to receive packets

PacketSinkHelpersink(“ns3::UdpSocketFactory”, Address(InetSocketAddress(Ipv4Address::GetAny(), port)));

apps = sink.Install(nodes.Get(3));

apps.Start(Seconds(0.0));

apps.Stop(Seconds(10.0));

// Enable FlowMonitor to measure performance metrics

FlowMonitorHelper flowmon;

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

// Run the simulation

Simulator::Stop(Seconds(10.0));

Simulator::Run();

// Print per-flow statistics

monitor->CheckForLostPackets();

Ptr<Ipv4FlowClassifier>classifier= DynamicCast<Ipv4FlowClassifier>(flowmon.GetClassifier());

std::map<FlowId, FlowMonitor::FlowStats> stats = monitor->GetFlowStats();

for (std::map<FlowId, FlowMonitor::FlowStats>::const_iterator i = stats.begin(); i != stats.end(); ++i)

{

Ipv4FlowClassifier::FiveTuple t = classifier->FindFlow(i->first);

NS_LOG_UNCOND(“Flow ” << i->first << ” (” << t.sourceAddress << ” -> ” << t.destinationAddress << “)”);

NS_LOG_UNCOND(”  Tx Packets: ” << i->second.txPackets);

NS_LOG_UNCOND(”  Tx Bytes:   ” << i->second.txBytes);

NS_LOG_UNCOND(”  Rx Packets: ” << i->second.rxPackets);

NS_LOG_UNCOND(”  Rx Bytes:   ” << i->second.rxBytes);

NS_LOG_UNCOND(”  Lost Packets: ” << i->second.lostPackets);

NS_LOG_UNCOND(”  Throughput: ” << i->second.rxBytes * 8.0 / (i->second.timeLastRxPacket.GetSeconds() – i->second.timeFirstTxPacket.GetSeconds()) / 1024 / 1024 << ” Mbps”);

}

// Clean up

Simulator::Destroy();

return 0;

}

Step 3: Compile and Run the Simulation

  1. Compile the Simulation:

./waf configure –enable-examples

./waf build

Run the Simulation:

./waf –run scratch/dwdm-fiber-example

Step 4: Analyze Results

The simulation script sets up a DWDM fiber network with multiple nodes and simulates data transmission between them. FlowMonitor is used to collect and print out statistics about the traffic flows, such as packet loss, throughput, and delay.

Additional Considerations

To extend the functionality of your DWDM fiber network simulation, consider the following:

1. Multiple Wavelengths

Implement multiple wavelengths for each link by configuring multiple logical point-to-point connections with different delays or data rates.

2. Dynamic Wavelength Allocation

Integrate dynamic wavelength allocation mechanisms to manage bandwidth and optimize the usage of the optical spectrum.

3. Fault Tolerance

Implement fault tolerance mechanisms to handle link failures and reroute traffic to maintain communication.

4. Traffic Patterns

Simulate different types of traffic patterns, such as IoT data, VoIP, video streaming, and bulk data transfer, to study their impact on the network.

5. Quality of Service (QoS)

Implement QoS mechanisms to prioritize certain types of traffic and ensure that critical data flows receive the necessary bandwidth and low latency.

6. Performance Metrics

Collect and analyze additional metrics such as jitter, packet delay variation, and error rates to evaluate the network performance more comprehensively.

From the given steps and example we can clearly understand the implementation process of Dense Wavelength Division Multiplexing (DWDM) fiber in ns3, by configuring the nodes to represent the transmitter and receivers.