How to Begin Implement Network Normalized MSE in NS3

To Begin the Normalized Mean Squared Error (NMSE) is frequently used to estimate the performance of network estimation procedures, associate the valued signal or parameter to its true value. Employing the NMSE in ns-3 has involves the replicate a network situation, manipulate the estimation error, and normalizing through true value’s magnitude.

Here’s how to implement NMSE in ns-3 step by step:

Steps to Begin Implement Network Normalized MSE in NS3

  1. Understand NMSE
  • Formula: NMSE=∑i=1N(xi−x^i)2∑i=1Nxi2\text{NMSE} = \frac{\sum_{i=1}^{N} (x_i – \hat{x}_i)^2}{\sum_{i=1}^{N} x_i^2}NMSE=∑i=1N​xi2​∑i=1N​(xi​−x^i​)2​
    • xix_ixi​: True value of the parameter.
    • x^i\hat{x}_ix^i​: Estimated value.
    • NNN: Number of samples.
  • Purpose: Quantifies on how close the evaluated values (x^i\hat{x}_ix^i​) are to the true values (xix_ixi​) in a normalized form.
  1. Set Up ns-3
  • Install ns-3:

./waf configure –build-profile=debug –enable-examples –enable-tests

./waf build

  • Verify the setup:

./waf –run hello-simulator

  1. Define the Estimation Scenario
  • Select for evaluate the network parameter:
    • Throughput.
    • Latency.
    • Signal strength (RSSI).
  • Generate a device for build the true and estimated values.
  1. Set up a Basic Network
  • Build a basic network topology for NMSE calculation.

Example: Basic Topology

#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”

using namespace ns3;

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

{

Time::SetResolution(Time::NS);

// Create nodes

NodeContainer nodes;

nodes.Create(2); // Client and Server

// Configure point-to-point link

PointToPointHelper p2p;

p2p.SetDeviceAttribute(“DataRate”, StringValue(“10Mbps”));

p2p.SetChannelAttribute(“Delay”, StringValue(“2ms”));

// Install devices

NetDeviceContainer devices = p2p.Install(nodes);

// Install Internet stack

InternetStackHelper stack;

stack.Install(nodes);

// Assign IP addresses

Ipv4AddressHelper address;

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

Ipv4InterfaceContainer interfaces = address.Assign(devices);

// Set up a UDP echo server on Node 1

uint16_t port = 9;

UdpEchoServerHelper echoServer(port);

ApplicationContainer serverApp = echoServer.Install(nodes.Get(1));

serverApp.Start(Seconds(1.0));

serverApp.Stop(Seconds(10.0));

// Set up a UDP echo client on Node 0

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

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

echoClient.SetAttribute(“Interval”, TimeValue(Seconds(1.0)));

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

ApplicationContainer clientApp = echoClient.Install(nodes.Get(0));

clientApp.Start(Seconds(2.0));

clientApp.Stop(Seconds(10.0));

// Run simulation

Simulator::Run();

Simulator::Destroy();

return 0;

}

  1. Collect True and Estimated Values
  • Use callbacks for track the network parameters.

Example: Collect Throughput

std::vector<double> trueValues;

std::vector<double> estimatedValues;

void MonitorThroughput(Ptr<const Packet> packet)

{

double trueValue = 1024; // Example true value (e.g., expected packet size)

double estimatedValue = packet->GetSize();

trueValues.push_back(trueValue);

estimatedValues.push_back(estimatedValue);

}

Assign the following function:

Ptr<NetDevice> device = nodes.Get(0)->GetDevice(0);

device->TraceConnectWithoutContext(“MacTx”, MakeCallback(&MonitorThroughput))

  1. Calculate NMSE
  • Executes the NMSE formula for the replication.

NMSE Calculation Function

double CalculateNMSE(const std::vector<double> &trueValues, const std::vector<double> &estimatedValues)

{

double numerator = 0.0;

double denominator = 0.0;

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

{

double error = trueValues[i] – estimatedValues[i];

numerator += error * error;

denominator += trueValues[i] * trueValues[i];

}

return (denominator > 0) ? numerator / denominator : 0.0;

}

  1. Integrate NMSE Calculation
  • At the final for the replication of program are designed.

Simulator::Schedule(Seconds(10.0), []() {

double nmse = CalculateNMSE(trueValues, estimatedValues);

NS_LOG_UNCOND(“NMSE: ” << nmse);

});

  1. Run and Test
  • Make and implement the replication:

./waf –run scratch/nmse-simulation

  • Check the logs for the NMSE outcomes.
  1. Enhance the Simulation
  • Use further complex environment by:
    • Multiple nodes.
    • Congestion designs are different.
  • Implement the NMSE for various parameters such as latency or signal strength.
  1. Analyze Results
  • Interpret the NMSE:
    • The NMSE Low specifies for accurate evaluation.
    • It increases for NMSE refers the important deviations.

The detailed guide contains the expounded manual that will support you with the computation of normalized mean squared error in the ns3 environment by accumulating data from the network and it also provides some samples. We organize the provide a further statistics about the NMSE.