How to Begin Implement Network Goodput in NS3

To implement the Network Goodput suggest to the rate of successful data delivery for application layer, not including the protocol overhead and retransmitted packets. In ns-3, employing the goodput has contains the compute a total of useful data successfully has received at the destination over a detailed duration.

Here’s a step-by-step guide to implement Goodput Measurement in ns-3:

Steps to Begin Implement Network Goodput in NS3

  1. Understand Goodput
  • Formula: Goodput (bps)=Total Useful Data Received (bits)Time Interval (seconds)\text{Goodput (bps)} = \frac{\text{Total Useful Data Received (bits)}}{\text{Time Interval (seconds)}}Goodput (bps)=Time Interval (seconds)Total Useful Data Received (bits)​
  • Key Points:
    • Only total application-level for payload data.
    • Implement the retransmissions, headers, and dropped packets.
  1. Set up ns-3
  • Install ns-3:

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

./waf build

  • Verify the installation:

./waf –run hello-simulator

  1. Define the Goodput Scenario
  • Select the kinds of congestion for sample UDP, TCP.
  • Describe the application-level data for calculate the goodput.
  • Track the packets are successfully received in the application layer.
  1. Set up a Basic Network

Generate a basic network topology for the goodput replication.

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(100));

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

echoClient.SetAttribute(“PacketSize”, UintegerValue(512)); // 512 bytes of payload

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. Measure Goodput
  • Assign the callback function for track packets established in the application layer.

Example: Goodput Calculation

  1. Global Variables for Goodput:

uint64_t totalBytesReceived = 0;

  1. Callback to Track Received Packets:

void PacketReceivedCallback(Ptr<const Packet> packet, const Address &address)

{

totalBytesReceived += packet->GetSize(); // Accumulate payload size in bytes

}

  1. Attach Callback to the Application:
    • Get the server socket and linked the callback.

Ptr<UdpEchoServer> server = DynamicCast<UdpEchoServer>(serverApp.Get(0));

server->TraceConnectWithoutContext(“Rx”, MakeCallback(&PacketReceivedCallback));

  1. Calculate and Log Goodput:
    • Estimate for final replication.

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

double goodput = (totalBytesReceived * 8.0) / 8.0; // Convert bytes to bits

NS_LOG_UNCOND(“Goodput: ” << goodput << ” bits per second”);

});

  1. Run the Simulation
  • Create and process for the replication:

./waf –run scratch/goodput-measurement

  • Monitor the measured a goodput for log results.
  1. Enhance the Goodput Measurement
  • It contains the further performance of metrics such as:
    • Latency or jitter.
    • Packet loss.
  • It replicates the environment by various congestion designs for instance bursty traffic, congestion.

Example: Dynamic Traffic Analysis

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

NS_LOG_UNCOND(“Current Total Bytes Received: ” << totalBytesReceived);

});

  1. Simulate Advanced Scenarios
  • Below for validate the goodput:
    • Changed the transport protocols for instance TCP vs UDP.
    • Different network conditions for sample link delays, bandwidth modification.

Example: Add TCP Traffic

BulkSendHelper bulkSend(“ns3::TcpSocketFactory”, InetSocketAddress(interfaces.GetAddress(1), port));

bulkSend.SetAttribute(“MaxBytes”, UintegerValue(0)); // Unlimited bytes

ApplicationContainer bulkApp = bulkSend.Install(nodes.Get(0));

bulkApp.Start(Seconds(3.0));

bulkApp.Stop(Seconds(10.0));

  1. Analyze Results
  • Associate the goodput with various environment:
    • Protocols.
    • Link characteristics.
    • Traffic patterns.
  1. Visualize Results
  • Distribute the goodput data to file for examine the tools like gnuplot or Python.

Example: Export Goodput to a File

std::ofstream goodputFile;

goodputFile.open(“goodput-results.txt”, std::ios::out);

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

double goodput = (totalBytesReceived * 8.0) / 8.0; // Convert bytes to bits

goodputFile << “Goodput: ” << goodput << ” bps” << std::endl;

goodputFile.close();

});

In this establishment we learned to compute the goodput in the network using the ns3 tool that needs to put on the basic network model then track the data after that simulate and calculate the goodput. A dedicated manual will be shared to handle further questions about this project.