A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
wifi-roaming.cc File Reference

This example considers two APs and a server connected to a CSMA bridge. More...

#include "ns3/applications-module.h"
#include "ns3/bridge-module.h"
#include "ns3/core-module.h"
#include "ns3/csma-module.h"
#include "ns3/internet-module.h"
#include "ns3/mobility-module.h"
#include "ns3/network-module.h"
#include "ns3/propagation-module.h"
#include "ns3/spectrum-module.h"
#include "ns3/wifi-module.h"
#include <algorithm>
#include <fstream>
#include <iostream>
#include <map>
#include <vector>
Include dependency graph for wifi-roaming.cc:

Go to the source code of this file.

Classes

struct  anonymous_namespace{wifi-roaming.cc}::DropStats
 Packet drop statistics. More...
struct  anonymous_namespace{wifi-roaming.cc}::WifiSetupParams
 Wi-Fi setup parameters. More...

Namespaces

namespace  anonymous_namespace{wifi-roaming.cc}

Functions

std::pair< NetDeviceContainer, NetDeviceContainer > anonymous_namespace{wifi-roaming.cc}::CreateWifiDevices (const WifiSetupParams &wifiParams)
 Create Wi-Fi devices.
SpectrumWifiPhyHelper anonymous_namespace{wifi-roaming.cc}::GetPhyHelper (const std::string &channelsStr, Ptr< SpectrumChannel > channel)
 Get a SpectrumWifiPhyHelper object configured with the channel settings listed in the given input string and with the given Spectrum channel.
void anonymous_namespace{wifi-roaming.cc}::PrintThroughput (const Time &start, const Time &end, Ptr< Node > serverNode, Ptr< Node > staNode, uint64_t ulTxBytes, uint64_t dlTxBytes, uint64_t &ulRxBytes, uint64_t &dlRxBytes)
 Print the average UL and DL throughput over the given time interval.

Detailed Description

This example considers two APs and a server connected to a CSMA bridge.

A STA is initially associated with AP 1 and can be configured to move closer to and associate with AP 2 at a given point in time. It is possible to configure whether or not the STA notifies the disassociation to AP 1 when roaming. DL and/or UL UDP (or TCP) traffic can be exchanged between STA and the server.

Network (logical) topology

   ┌─────────────────────┐
   │     CSMA bridge     │
   └┬─────────┬─────────┬┘
    │         │         │ <-- CSMA links
   AP 1      AP 2    Server

Implementation

                   CSMA bridge
          ┌───────────────────────────────────┐
          │               Bridge              │
          ├───────────┬───────────┬───────────┤
          │CSMA NetDev│CSMA NetDev│CSMA NetDev│
          └──┬────────┴──────┬────┴──────┬────┘
             │               │           │
   ┌──────┬──┴───┐ ┌──────┬──┴───┐    ┌──┴───┐
   │ WiFi │ CSMA │ │ WiFi │ CSMA │    │ CSMA │
   │NetDev│NetDev│ │NetDev│NetDev│    │NetDev│
   ├──────┴──────┤ ├──────┴──────┤    └──────┘
   │   Bridge    │ │   Bridge    │     Server
   └─────────────┘ └─────────────┘
        AP 1            AP 2

The association messages and the throughput reports printed before and after the roam are the most interesting output. The time between the disassociation from AP 1 and the association with AP 2 is the roaming interruption. The subsequent block acknowledgment (BA) agreement messages indicate when the link is ready for aggregated QoS data. Compare the throughput on the two sides of the roam, and inspect the final per-device drop statistics and the queue sizes printed at the roam for packets that could not follow the STA.

For example, the command used by the regression tests is:

./ns3 run "wifi-roaming --simulationTime=5s --disassocTime=2.5s --dlLoad=10Mbps --udp=0"

It produces output similar to the following excerpt (exact times can vary):

At time +2.5s, STA disassociated from BSSID 00:00:00:00:00:03 From +1s to +2.5s: Wi-Fi STA received 1858000 bytes, DL throughput = 9909.33 kbps At time +2.50063s, STA completed association with BSSID 00:00:00:00:00:04 At time +2.50135s, AP 2 established BA agreement with 00:00:00:00:00:05 for TID 0 From +2.5s to +6s: Wi-Fi STA received 4374000 bytes, DL throughput = 9997.71 kbps

Thus, in this run the STA moves from AP 1 to AP 2 in less than a millisecond, and TCP downlink throughput remains close to the offered 10 Mbps load after the roam.

The following command-line arguments have particularly visible effects on this output:

  • simulationTime is the traffic duration after applications start at +1s; the simulation ends at +1s plus this value. It must leave enough time after disassocTime to observe recovery.
  • disassocTime sets the absolute simulation time of the roam and hence moves the association messages and the boundary between the two throughput reports. A value of zero disables the roam and the move toward AP 2.
  • dlLoad and ulLoad select the traffic direction and offered rate; a zero rate disables that direction and its throughput report. Higher loads can make packets queued or dropped during the interruption visible.
  • notifyAp=1 makes the STA send a Disassociation frame. AP 1 then knows immediately that it can no longer forward frames to the STA, which can increase AP 1's final "Dropped because cannot be forwarded" count for downlink packets that still reach it.
  • forwardFrameOnAssoc=1 (the default for this example) lets AP 2 update the CSMA bridge's learned port for the STA as soon as it associates. With downlink-only UDP traffic, setting forwardFrameOnAssoc=0 leaves no reverse traffic to update the bridge: the association with AP 2 is still reported, but the example terminates because the post-roam downlink throughput is zero. TCP ACKs or traffic enabled by ulLoad can eventually update the bridge, so TCP typically shows a delayed BA agreement and reduced post-roam throughput instead of a complete outage.
  • ap2Channels and staChannels control whether the STA can discover AP 2. If they select no common channel, the STA may reassociate with AP 1 instead, and post-roam throughput drops.

Definition in file wifi-roaming.cc.