Back
NS3 Introduction

Using NS-3 for Real Network Research

Research & methods

A lot of NS-3 tutorials teach you how to run a scenario. Far fewer teach you how to trust the numbers that come out of it. That second part is where actual research happens - and it's the part most people learn the hard way, usually by shipping a result that turns out to be wrong.

This post walks through what that looks like in practice, using a real example: a bug that made our own simulation report packet delivery ratios above 1.0 - a value that's mathematically impossible, since PDR is a fraction of packets received out of packets sent, and can never exceed 1.

What NS-3 actually is, briefly

NS-3 is an open-source, discrete-event network simulator, widely used in academic wireless and networking research. "Discrete-event" means it doesn't simulate time continuously - it jumps from event to event (a packet transmitted, a timer expiring, a channel becoming free), which is what makes it possible to simulate hours of network behaviour in seconds of real computation.

It ships with real protocol implementations, not simplified stand-ins - when you simulate 802.15.4's CSMA-CA channel access or LTE's scheduling, you're running the same logic (at the level of the standard's actual behaviour) that a real radio chip would execute. That's the whole point: the results are meant to be trustworthy enough to publish, not just illustrative.

The methodology that actually matters

1. Start with the simplest version of your scenario, and verify it against known behaviour before adding complexity.

Before running any real experiment, it's worth confirming the model behaves the way theory predicts in the easy cases. For a wireless link, that might mean: confirm packet delivery is perfect at short range with plenty of transmit power, confirm it fails completely at long range with too little power, and confirm it recovers once you compensate with more power. If those three sanity checks don't hold, nothing built on top of the model is trustworthy yet - no point running a 500-point parameter sweep on a model you haven't confirmed does the basics correctly.

2. Parameter sweeps, not single runs.

A single simulation run tells you what happens for one specific combination of settings. Real findings come from sweeping a grid - every combination of the parameters you care about (device count, distance, transmit power, whatever's relevant to your question) - and looking at the shape of the result across that grid, not any one point in isolation. This is usually the difference between "I ran NS-3 once" and an actual dataset.

3. Treat a surprising result as a bug to investigate, not a finding to report - until you've ruled out the bug.

Here's the concrete example. A full sweep of a wireless sensor network scenario - a star topology, one coordinator, several end devices, standard 802.15.4 - produced packet delivery ratios above 1.0 on a subset of runs. Not close to 1.0. Actually above it, up to 1.06 in the worst cases.

That's impossible by definition, which made it useful: an impossible number is a gift, because it can't be explained away as "an unusual but valid outcome." Something in the model or the measurement code had to be wrong.

The investigation

All the affected runs clustered at a specific kind of parameter combination - moderate distance, reduced transmit power. That's exactly the condition where a data packet is likely to arrive successfully, but the acknowledgment sent back in response is more likely to get lost on the return trip. And that pointed at the actual mechanism: 802.15.4's acknowledged-transmission (ARQ) behaviour means a sender that doesn't hear an ACK will retransmit - even if the original packet actually made it through, and the receiver just never heard the sender knew that. The receiver then sees the same message twice.

The standard has a real solution for this: every frame carries a Data Sequence Number, specifically so a receiver can recognise "I've already seen this exact frame from this sender" and silently drop the duplicate. The simulation's measurement code wasn't doing that check - it was counting every arrival as a new success, duplicates included. The fix was a few lines: deduplicate by (sender address, sequence number) before counting a packet as received. After that, PDR was correctly bounded to [0, 1] across the entire dataset.

Why this is worth dwelling on: the bug wasn't in the network model - NS-3's protocol implementation was behaving exactly like the real standard says it should. The bug was in how success was being measured. That's a very common failure mode in simulation research generally, not just NS-3: the simulated world can be behaving correctly while your instrumentation of it is wrong. An impossible number is often the only signal you get that this has happened, which is why treating one as a red flag - rather than an outlier to exclude - matters.

What the data is actually good for

Trustworthy sweep data isn't just an academic exercise - once you can stand behind the numbers, they feed directly into decisions that would otherwise require expensive hardware trials or guesswork. A few of the more common uses:

  1. Pre-deployment network planning. Before installing a real sensor network - agricultural monitoring, smart-building sensors, industrial IoT - a validated PDR-vs-distance-vs-power sweep tells you how densely to place devices and what transmit power to configure, without burying hardware in the field first to find out it doesn't reach.
  2. Protocol and algorithm comparison. Routing protocols (AODV vs. OLSR, for instance), MAC-layer variants, or scheduling algorithms can be compared under identical, repeatable conditions - something that's close to impossible to do fairly on real hardware, where you can never quite reproduce the same channel conditions twice.
  3. Capacity and scaling estimates. Sweeping device count against throughput or latency gives an evidence-based answer to "how many nodes can this network actually support before it degrades," which is exactly the kind of question a network operator or systems architect needs answered before committing to a deployment size.
  4. Evaluating new protocols before standardization. Researchers proposing changes to a standard, or entirely new protocols, use simulation data as evidence in IEEE or IETF working group discussions - results have to be reproducible and methodologically sound because they're informing decisions other people will build hardware around.
  5. Security and failure-mode analysis. Sweeps that vary attacker behaviour, jamming, or node failure rates let you characterise how a network degrades under adversarial or faulty conditions - the kind of testing that's dangerous, expensive, or simply impractical to run against a live network.
  6. Academic publication and reproducibility. Peer review expects the sweep methodology and validation steps to be documented well enough that someone else could rerun the experiment and get the same shape of result - which is the whole reason the verification habits above matter as much as they do.

The common thread: in every one of these cases, the simulated data is standing in for something that would be slow, costly, or dangerous to test directly. That's only a fair trade if the data is actually correct - which loops back to the whole point of this post.

A few practical habits worth adopting

  1. Check your results against the theory before trusting the theory against your results. If a channel model predicts a sharp distance/power threshold, confirm your data actually shows a threshold shape before using the data to make claims about anything past that.
  2. When something in a large sweep fails or looks wrong, isolate exactly which parameter region it clusters in - that's usually the fastest route to the actual mechanism, the way "moderate distance, reduced power" pointed straight at the ACK-loss explanation above.
  3. A single anomalous number is worth more debugging time than it looks like it deserves. It's tempting to write off one bad data point in a 500-point sweep as noise. Sometimes it is. Sometimes it's the one thread that unravels a real measurement bug affecting every result that shares its conditions.
  4. Document what you found wrong, not just what you fixed. The duplicate-delivery bug above is more useful written up as "here's what broke and why" than as a silent fix - both because it's genuinely interesting protocol behaviour, and because the next person who hits something similar (in NS-3 or any other simulator) will recognise the pattern faster having seen it once.

None of this replaces domain knowledge - you still need to understand the protocol you're simulating well enough to know what "correct" should look like. What this methodology buys you is the difference between a simulation that runs and a simulation whose output you can actually stand behind. For research specifically, that difference is the whole job.

Leave A Reply