How to Implement Network Carrier to Interference Ratio in ns3

To implement and investigate the Carrier-to-Interference Ratio (CIR) in ns-3, follow this step. CIR is a key for performance of metric in wireless communication which computes the ratio of power in desired carrier signal for the power of intrusive signals.

Steps to Implement Network Carrier to Interference Ratio in ns3

  1. Understand Carrier-to-Interference Ratio (CIR)

CIR is designed as:

CIR=Carrier Signal Power (Pc)Interference Power (Pi)\text{CIR} = \frac{\text{Carrier Signal Power (P}_c\text{)}}{\text{Interference Power (P}_i\text{)}}CIR=Interference Power (Pi​)Carrier Signal Power (Pc​)​

Where:

  • Carrier Signal Power (PcP_cPc​): Desired signal is the power of carrier.
  • Interference Power (PiP_iPi​): Associates the power of all intrusive signals.

CIR is used to implement the effect of intrusion in network’s performance, and it is typically stated in decibels (dB).

  1. Set Up Your Environment

Assure the tool ns-3 is installed and functional. Use the Wi-Fi, LTE, or 5G component, depending on the network setting.

  1. Create a Network Topology

Example: Wireless Network with Interference

NodeContainer nodes;

nodes.Create(3); // One transmitter, one receiver, and one interferer

MobilityHelper mobility;

mobility.SetPositionAllocator(“ns3::GridPositionAllocator”,

“MinX”, DoubleValue(0.0),

“MinY”, DoubleValue(0.0),

“DeltaX”, DoubleValue(50.0),

“DeltaY”, DoubleValue(50.0),

“GridWidth”, UintegerValue(3),

“LayoutType”, StringValue(“RowFirst”));

mobility.SetMobilityModel(“ns3::ConstantPositionMobilityModel”);

mobility.Install(nodes);

YansWifiChannelHelper channel = YansWifiChannelHelper::Default();

YansWifiPhyHelper phy = YansWifiPhyHelper::Default();

phy.SetChannel(channel.Create());

WifiHelper wifi;

wifi.SetStandard(WIFI_PHY_STANDARD_80211n);

WifiMacHelper mac;

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

 

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

  1. Set Up the Internet Stack

Install the Internet stack for IP-based communication:

InternetStackHelper stack;

stack.Install(nodes);

Ipv4AddressHelper address;

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

Ipv4InterfaceContainer interfaces = address.Assign(devices);

  1. Generate Traffic

Example: Desired Signal

Replicate the congestion among the transmitter and receiver for install applications:

UdpEchoServerHelper echoServer(9);

ApplicationContainer serverApps = echoServer.Install(nodes.Get(1)); // Receiver

serverApps.Start(Seconds(1.0));

serverApps.Stop(Seconds(10.0));

UdpEchoClientHelper echoClient(interfaces.GetAddress(1), 9);

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

echoClient.SetAttribute(“Interval”, TimeValue(Seconds(0.01))); // 10ms interval

echoClient.SetAttribute(“PacketSize”, UintegerValue(1024)); // 1KB packets

ApplicationContainer clientApps = echoClient.Install(nodes.Get(0)); // Transmitter

clientApps.Start(Seconds(2.0));

clientApps.Stop(Seconds(10.0));

Example: Interference

Install an interfering application:

UdpEchoClientHelper interfererClient(interfaces.GetAddress(1), 9);

interfererClient.SetAttribute(“MaxPackets”, UintegerValue(1000));

interfererClient.SetAttribute(“Interval”, TimeValue(Seconds(0.01))); // Same interval as desired signal

interfererClient.SetAttribute(“PacketSize”, UintegerValue(1024));

ApplicationContainer interfererApps = interfererClient.Install(nodes.Get(2)); // Interferer

interfererApps.Start(Seconds(2.0));

interfererApps.Stop(Seconds(10.0));

  1. Measure Carrier Signal Power

Monitor the carrier signal power using the PHY layer:

Ptr<WifiPhy> phy = DynamicCast<WifiNetDevice>(devices.Get(1))->GetPhy();

std::vector<double> carrierPowers;

phy->TraceConnectWithoutContext(“RxOk”, MakeCallback([&](Ptr<const Packet> packet, double rxPowerDbm) {

double powerWatts = std::pow(10, rxPowerDbm / 10) / 1000; // Convert dBm to watts

carrierPowers.push_back(powerWatts);

std::cout << “Carrier Signal Power (Watts): ” << powerWatts << std::endl;

}));

  1. Measure Interference Power

Follow the interference power using the similar PHY layer:

std::vector<double> interferencePowers;

phy->TraceConnectWithoutContext(“RxNoise”, MakeCallback([&](Ptr<const Packet> packet, double noisePowerDbm) {

double powerWatts = std::pow(10, noisePowerDbm / 10) / 1000; // Convert dBm to watts

interferencePowers.push_back(powerWatts);

std::cout << “Interference Power (Watts): ” << powerWatts << std::endl;

}));

  1. Calculate CIR

After the replication, for every action calculate the CIR:

for (size_t i = 0; i < carrierPowers.size(); ++i) {

double cir = carrierPowers[i] / (interferencePowers[i] + 1e-12); // Add small value to avoid division by zero

std::cout << “CIR: ” << 10 * std::log10(cir) << ” dB” << std::endl; // Convert CIR to dB

}

  1. Enable Tracing

ASCII and PCAP Tracing

Make complete logs of CIR measures:

AsciiTraceHelper ascii;

phy.EnableAsciiAll(ascii.CreateFileStream(“cir_analysis.tr”));

phy.EnablePcapAll(“cir_analysis”);

  1. Visualize Results
  • Transfer the CIR data for plotting in MATLAB or Excel.
  • Use to envision the network NetAnim:

AnimationInterface anim(“cir_analysis.xml”);

  1. Experiment with Parameters
  • Validate are changed the distances among nodes for execute the effect of CIR.
  • Introduce the additional interferers for improve the power of interference.
  • Testing by various congestion designs and PHY layer configurations for sample modulation schemes.
  1. Run the Simulation

It executes and studies for CIR outcomes:

Simulator::Run();

Simulator::Destroy();

Network carriers to interference ratio is to capture applicable metrics for instance received signal power and interference power and gather the data and executed by ns3 simulation. We can provide the more information regarding to CIR.