Queueing, scheduling, and contention in 802.11 networks
This experiment shows how queueing, scheduling, and contention affect delay and throughput in an 802.11 network.
You'll observe some challenges that arise especially in WiFi networks: how queueing delay can increase dramatically for the same queue when the capacity of the air link drops, how a slow client can take most of the airtime away from a fast client, and how a client may wait hundreds of milliseconds to transmit a latency-sensitive frame on the channel. For each of these challenges, you'll then introduce a technique to mitigate it.
It should take about 2 hours to run this experiment, but you will need to have reserved that time in advance. This experiment uses wireless resources, and you can only use wireless resources on COSMOS during a reservation.
To reproduce this experiment on COSMOS, you will need an account, and you will need to have joined a project. You should have already uploaded your SSH keys to your profile. Finally, you must have reserved time on the sb5 or sb6 testbed at COSMOS, and you must run this experiment during your reserved time. (You can also use sb4, with some modifications to the experiment: see the "Using sb4" section at the end.)
- Skip to Results
- Skip to Run my experiment
Background
Any network that serves more than one user has to share its capacity among them. We would like the sharing to be fair, but users are not all alike. Some run applications that need low delay, and others need high throughput. And in a wireless network, some users have a much better signal than others, and can be served more efficiently at a much higher rate.
In a wired network, such as switched Ethernet, resource sharing mostly happens at a queue. Each host has its own link to the switch, and the link has a fixed rate. Users only compete with one another when their packets wait in a queue for the same outgoing link.
In a cellular network, users share the wireless medium, and the rate at which each user can send or receive depends on the quality of its signal. A user with a strong signal can be served with much better spectral efficiency than a user with a weak signal. But a cellular network is scheduled: the base station is in charge of the medium. It knows the signal quality and the service requirements of each user, and in each scheduling interval it decides which users will send and receive, and which resource blocks each one will use. So the scheduler at the base station can directly trade off fairness against the channel conditions and the requirements of each user, for both downlink and uplink traffic.
An 802.11 network is different from both of these. As in a cellular network, the users share the medium, and each one may have a different rate, which changes as its signal quality changes. (With the WiFi cards that we use in this experiment, the rate can be anywhere from 6.5 Mbit/s to 130 Mbit/s.) But nobody is in charge of the medium; each wireless device decides for itself when to transmit, using CSMA/CA. The access point (AP) can choose the order in which it sends downlink packets, but it doesn't tell its clients when to send. (Newer versions of 802.11, starting with 802.11ax, let an AP schedule transmissions from its own clients during the time that it holds the channel. But the AP still has to win the channel with CSMA/CA first.)
These networks also differ in how they provide quality of service (QoS), i.e. how they treat traffic differently according to what it needs. In a wired network, a router can put delay-sensitive packets in a separate queue and serve that queue first. In a cellular network, each traffic flow is assigned a QoS class with a priority and a delay budget (and, for some classes, a guaranteed bit rate), and the scheduler at the base station enforces it. But in an 802.11 network, there is no single place where the tradeoff between fairness and the needs of each client is made. Instead, it comes out of several mechanisms working together. In this experiment, we will look at three of them.
Queueing
As in a wired network, packets that arrive at the AP faster than it can send them wait in a queue. The AP keeps a queue for each of its clients. A queue that holds Q bits, for a client that is served at R bits per second, adds a delay of about Q/R.
In a wired network, the rate of the link is fixed, so we can choose a queue size that gives a reasonable delay. For example, on a 1 Gbit/s link, a queue with room for 1000 packets of 1500 bytes each (i.e. 12 Mbit) adds at most 12 ms of delay.
In an 802.11 network, the rate depends on the signal quality of the client, which changes. Suppose the AP has a first-in first-out (FIFO) queue with room for the same 1000 packets. A TCP flow will fill whatever queue is available at the bottleneck. For a client that is served at 27 Mbit/s, a full queue adds 0.44 seconds of delay. If the client's rate drops to 4.6 Mbit/s because its signal strength drops, the same queue adds 2.6 seconds of delay. A queue that is the right size for a client is the wrong size for another client, and potentially for the same client a moment later.
To address this, 802.11 networks may use an active queue management (AQM) algorithm. CoDel is a queue management algorithm that limits the time that packets spend in the queue, instead of the number of packets. It records the time at which each packet arrives, and if packets have been waiting for longer than a target (20 ms, in the Linux WiFi stack) for some time, it drops a packet so that the TCP sender will slow down. If the TCP flow uses explicit congestion notification (ECN), it marks the packet instead of dropping it.
The Linux WiFi stack uses FQ-CoDel for the packets waiting for each client. This design was introduced and evaluated in [1]. FQ-CoDel applies CoDel separately to each flow, and then takes turns among the flows. (A flow is a set of packets with the same source and destination IP addresses, the same source and destination ports, and the same transport protocol. For example, all of the packets of one TCP connection in one direction are a flow.) This helps with users' different requirements: a packet from an application that needs low delay does not have to wait in line behind a large file transfer to the same client.
In the first part of this experiment, we will send a TCP flow to one client at several link rates, with a FIFO queue at the AP and then with FQ-CoDel. (FQ-CoDel is already built in to the WiFi stack, so the disk image for this experiment has a modified kernel module that adds FIFO support.)
Scheduling
When the AP has packets waiting for transmission to more than one client, it must choose which client to send to each time it gets the channel. This is the closest thing in an 802.11 network to the scheduler at a cellular base station, but it only applies to downlink traffic, while a cellular base station also gets to schedule uplink traffic.
Suppose the AP serves its clients in round robin order: it sends one packet to each waiting client in turn. This seems fair, but a client with a weak signal is served at a low rate, and each of its packets takes much longer to send, so it will not be fair in terms of airtime: the slow client uses most of the time on the channel. This is known as the 802.11 performance anomaly, and it was first demonstrated in [2].
For example, suppose a "fast" client has a signal level that can support 34 Mbit/s and a "slow" client has a signal level that can support 4.9 Mbit/s. A packet of 1500 bytes (12,000 bits) takes
to send to the fast client, and
to send to the slow client. With round robin, the AP sends one packet to each client every 0.35 + 2.45 = 2.8 ms. So each client gets 12,000 bits every 2.8 ms, which is
Both clients get the same low throughput. Of every 2.8 ms, the AP spends 2.45 ms sending to the slow client, so the slow client uses
of the airtime.
The alternative is to give each client an equal share of the airtime, instead of an equal number of packets. This is called airtime fairness. In the example above, each client would get half of what it gets alone: 17 Mbit/s for the fast client and 2.45 Mbit/s for the slow client. The slow client loses some throughput, but the fast client is no longer punished for having a slow neighbor. An airtime fairness scheduler for the Linux WiFi stack was introduced in [1], which demonstrated that it eliminates the performance anomaly.
In the second part of this experiment, we will send traffic to a fast client and a slow client at the same time, without and then with an airtime fairness scheduler.
Contention
The AP's queue management and scheduler only apply to downlink packets, which are sent by the AP. Any packet that a client sends (even a small one, like a TCP ACK or a ping reply) has to compete for the channel with the AP and with the other clients. In a cellular network, the base station would give the client a grant to send, but in an 802.11 network, the client contends for the channel.
Before it sends a frame, an 802.11 device waits for the channel to be idle, and then waits for a random number of time slots, between zero and its contention window (CW). The device that finishes waiting first gets to send. If the transmission fails (for example, because another device sent at the same time), the device doubles its CW and tries again. The CW starts at a minimum value, CWmin, and can grow up to a maximum value, CWmax. After a successful transmission, it goes back to CWmin.
With this procedure, every device follows the same rules for getting the channel, no matter what it has to send. But that does not make sense when the devices have different requirements. For example, suppose one client is in a video call and another client is downloading software updates in the background. A delay of a few hundred milliseconds would disrupt the video call, but it would make no difference to the download.
Suppose a network uses a CWmin of 15 and a CWmax of 1023 for all traffic. A client can wait a long time for the channel. To see why, consider a client that wants to send one small frame, while the AP is sending a large transfer to another client.
The AP has more to send. Each time it gets the channel, the AP sends a burst of frames that can last for several milliseconds. Then it starts a new countdown, of between 0 and 15 slots (7 or 8, on average), and when that countdown ends, it sends another burst. So from the client's point of view, the channel alternates between long bursts from the AP and short idle gaps of about 8 slots.
As long as the client's CW is 15, like the AP's, its wait is short. But what happens when the client's frame fails several times in a row? Recall that a device doubles its CW after each failed transmission, and goes back to CWmin after a successful one. A transmission can fail because of a collision (when the client and the AP finish their countdowns in the same slot), or because the frame is not received correctly. After a collision, both the client and the AP double their CW. But the AP has many frames to send, so it has many opportunities for success, and as soon as it successfully transmits, its CW goes back to 15. The client has only one frame to send. Its CW stays large until that frame gets through, and it doubles again each time the frame fails: 31, 63, 127, and so on, up to 1023.
A time slot is very short (9 or 20 microseconds, depending on the type of network), so even 127 slots would take only a millisecond or two if the channel were idle the whole time. But the client can only count down during the idle gaps. It pauses its countdown during each burst from the AP, and continues in the next gap. Since each gap is about 8 slots long, a client that has to count 127 slots must wait through about 16 bursts from the AP before it can send:
| Client's CW | Slots to count (at most) | Bursts from the AP while the client waits | Wait, if each burst lasts 5 ms |
|---|---|---|---|
| 15 | 15 | about 2 | about 10 ms |
| 127 | 127 | about 16 | about 80 ms |
| 1023 | 1023 | about 128 | about 640 ms |
As a result, a client with only one small frame to send usually waits for a few milliseconds, but sometimes it waits for hundreds of milliseconds. Neither queue management nor the scheduler at the AP can reduce this delay.
To address this, 802.11 handles users' different requirements with four access categories: background, best effort, video, and voice. Each one has its own contention parameters, so that (for example) a voice packet waits for less time than a best effort packet. This scheme is called EDCA (Enhanced Distributed Channel Access). It was introduced in the 802.11e amendment in 2005, and it became part of the 802.11 standard in 2007. The AP advertises the parameters for each category, which the clients may then use. A packet is assigned to an access category according to the DSCP field in its IP header. For example, a packet that is marked for "expedited forwarding" is sent in the voice category, which has a CWmin of 3 and a CWmax of 7, so it never has to wait for long.
This works well for the traffic that is marked. But it depends on each application to mark its own packets, and most traffic is not marked, so it is sent as best effort.
An alternative approach [3] is to change the contention parameters for best effort traffic itself: keep the contention window from growing when a transmission fails, and limit how long any device may hold the channel. This trades off a little throughput for consistently low delay. The set of parameters that is proposed in [3] is called AC_N15:
| Parameter | Meaning | Best effort default | AC_N15 |
|---|---|---|---|
| AIFSN | idle slots before the countdown starts | 3 | 1 |
CWmin |
smallest contention window (slots) | 15 | 15 |
CWmax |
largest contention window (slots) | 1023 | 15 |
| TXOP limit | longest time a device may hold the channel | one burst of frames per turn (which can last several ms) | 1 ms |
With AC_N15, CWmax is equal to CWmin, so the contention window stays at 15 slots no matter how many times a transmission fails, and no device may hold the channel for more than 1 ms at a time, so the wait for the next turn is shorter.
We will investigate EDCA in the third part of this experiment.
Results
The following figures show representative results. The exact numbers that you see will vary, but you should see the same effects.
With a FIFO queue at the AP, the delay of a TCP flow increases dramatically as the link rate decreases. But with FQ-CoDel, the delay stays below 50 ms at every link rate, with no loss of throughput:

Without airtime fairness, a slow client uses most of the airtime and a fast client gets only a fraction of the throughput that its link could support, but with airtime fairness the fast client gets a larger share of the airtime and much higher throughput, at a small cost to the slow client:

With the default contention parameters, a client sometimes waits hundreds of milliseconds for a turn to send a ping reply, but its wait is much shorter when the pings are marked as voice traffic, or when the AP uses the AC_N15 parameters for best effort traffic (at some cost in throughput):

Run my experiment
This experiment uses three WiFi devices:
- an AP
- Client A
- and Client B
You may run it on sb5 or sb6, both of which have two nodes with two WiFi NICs each (allowing us to create up to four WiFi devices). We will set up these devices in the following configuration:
Prepare the testbed
At your reserved time, SSH with your username and associated keys into
sbX.cosmos-lab.org
where you substitute your sandbox number in place of X.
Load the wifi-queueing-lab.ndz disk image onto both nodes:
# runs on sb5 or sb6 console
omf load -i wifi-queueing-lab.ndz -t node1-1,node1-2(Note that the command above is all one line, and there are no spaces between the commas and the node names.)
After this process is finished, turn your nodes on:
# runs on sb5 or sb6 console
omf tell -a on -t node1-1,node1-2and wait a few minutes for them to boot.
Then open five terminals, and SSH into the console of your sandbox with your username and keys in each one.
- In four of them, SSH from the console into node1-1 (using the username "root"). We will call these the "AP" terminal, the two "server" terminals, and the "Client A" terminal.
- In the fifth, SSH from the console into node1-2. We will call this the "Client B" terminal.
Configure the access point
In the AP terminal, load the drivers for both WiFi cards, and set the regulatory domain:
# runs in AP terminal
modprobe ath9k
modprobe iwlwifi
iw reg set USThen run
# runs in AP terminal
iw devand verify that you see two interfaces, wlp3s0 (for the Atheros AR928X card) and wlp5s0 (for the Intel Centrino Advanced-N 6250). Make a note of the phy# number that is listed above wlp5s0; you will need it when you set up Client A. The two WiFi cards are not interchangeable; they use different drivers with different capabilities.
Create a configuration file for the AP. (The sb5 and sb6 sandboxes are in close enough proximity that their WiFi signals reach one another, so we have to configure sandbox-specific network names and WiFi channels using the SB variable, which will be filled with the name of the sandbox.)
# runs in AP terminal
SB=$(hostname -f | cut -d. -f2)
[ $SB = sb6 ] && CH=11 || CH=1
cat > hostapd.conf <<EOF
interface=wlp3s0
driver=nl80211
country_code=US
hw_mode=g
channel=$CH
ieee80211n=1
wmm_enabled=1
ssid=wifi-lab-$SB
wpa=2
wpa_key_mgmt=WPA-PSK
rsn_pairwise=CCMP
wpa_passphrase=secretpassword
bss=wlp3s0_1
bssid=02:00:00:00:0${SB#sb}:01
ssid=wifi-lab-$SB-slow
wmm_enabled=1
wpa=2
wpa_key_mgmt=WPA-PSK
rsn_pairwise=CCMP
wpa_passphrase=secretpassword
EOFThis sets up an 802.11n AP with two networks: one that is named for your sandbox (for example, "wifi-lab-sb5"), and a second network with "-slow" at the end of its name, that we will use later to create a slow client. You can see the file, with the name of your sandbox filled in, with
# runs in AP terminal
cat hostapd.confStart the AP with
# runs in AP terminal
hostapd -B hostapd.confYou should see
wlp3s0: AP-ENABLED
in the output.
Assign an IP address to the AP on each of the two networks:
# runs in AP terminal
ip addr add 192.168.100.1/24 dev wlp3s0
ip addr add 192.168.101.1/24 dev wlp3s0_1and limit the "slow" network to the lowest 802.11n rate, MCS 0:
# runs in AP terminal
iw dev wlp3s0_1 set bitrates legacy-2.4 1 ht-mcs-2.4 0Configure the server
In this experiment, the traffic to the WiFi clients will come from a "server" on the wired side of the AP, like a server on the Internet that a WiFi client downloads from. We will send TCP flows and pings from the server, and the AP will forward them to the clients over the WiFi link.
We do not want to send this traffic from the AP itself, because when the sender and the queue are on the same host, the sender reduces its sending rate so that the queue never fills, and this would hide the effect that we want to see in the first part of the experiment. Instead, we will use a network namespace on the same node as the AP. It behaves like a separate host that is connected to the AP by a (virtual) wired link.
In the AP terminal, create and configure the namespace:
# runs in AP terminal
ip netns add server
ip link add veth-ap type veth peer name veth-server
ip link set veth-server netns server
ip addr add 10.9.0.1/24 dev veth-ap
ip link set veth-ap up
sysctl -w net.ipv4.ip_forward=1
sysctl -w net.ipv4.conf.all.rp_filter=0Then, in each of the two server terminals, run
# runs in both server terminals
ip netns exec server bashto open a shell inside the "server" namespace. Every command that you run in these terminals from now on will run inside the namespace. (We use two server terminals so that we can send bulk traffic in one while we ping in the other.)
In the first server terminal, configure the server's end of the link:
# runs in first server terminal, inside namespace
ip link set lo up
ip addr add 10.9.0.2/24 dev veth-server
ip link set veth-server up
ip route add default via 10.9.0.1Configure the clients
Client A uses the Intel card on the same node as the AP. To make sure that traffic between the AP and Client A is sent over the air (and not delivered directly inside the Linux kernel), we first move this card into its own network namespace. In the Client A terminal, run
# runs in Client A terminal
ip netns add clientA
iw phy phy1 set netns name clientA
ip netns exec clientA bashbut in the second command, substitute the phy# number that you noted earlier for wlp5s0, if it is not phy1.
Now this terminal is inside the "clientA" namespace. Set up a WiFi config file with
# runs in Client A terminal, inside namespace
SB=$(hostname -f | cut -d. -f2)
wpa_passphrase wifi-lab-$SB secretpassword > wpa.confand connect to the network with
# runs in Client A terminal, inside namespace
ip link set lo up
wpa_supplicant -B -i wlp5s0 -c wpa.confUse
# runs in Client A terminal, inside namespace
iw dev wlp5s0 linkto verify that the WiFi interface is connected. It may take a few moments, and you can run this command as many times as you need to while you wait. When connected, the first line of the output will say Connected to, followed by the address of the AP.
Once you are connected, set up an IP address, add a route to the server through the AP, and turn off power saving on the WiFi interface:
# runs in Client A terminal, inside namespace
ip addr add 192.168.100.4/24 dev wlp5s0
ip route add 10.9.0.0/24 via 192.168.100.1
iw dev wlp5s0 set power_save offFinally, start an iperf3 server to receive traffic:
# runs in Client A terminal, inside namespace
iperf3 -s -DClient B uses the Intel card on node1-2.
Client B is not on the same node as the AP, so it does not need a network namespace.
In the Client B terminal, load the driver for the WiFi card, and set the regulatory domain:
# runs in Client B terminal
modprobe iwlwifi
iw reg set USWait a few seconds for the wlp5s0 interface to appear (you can check with iw dev). Then set up a WiFi config file, and connect to the network:
# runs in Client B terminal
SB=$(hostname -f | cut -d. -f2)
wpa_passphrase wifi-lab-$SB secretpassword > wpa.conf
wpa_supplicant -B -i wlp5s0 -c wpa.confUse
# runs in Client B terminal
iw dev wlp5s0 linkto verify that it is connected, and then run
# runs in Client B terminal
ip addr add 192.168.100.3/24 dev wlp5s0
ip route add 10.9.0.0/24 via 192.168.100.1
iw dev wlp5s0 set power_save off
iperf3 -s -DCheck the connection
In the first server terminal, verify that you can reach both clients through the AP:
# runs in first server terminal, inside namespace
ping -c 3 192.168.100.4
ping -c 3 192.168.100.3Queueing: FIFO vs. FQ-CoDel
In this first part of our experiment, we will send a TCP flow from the server to Client B, and see how the delay depends on the link rate, first with a FIFO queue at the AP and then with FQ-CoDel.
First, we'll set up the AP with a FIFO queue that holds up to 1000 packets. In the AP terminal, run
# runs in AP terminal
DBG=/sys/kernel/debug/ieee80211/$(basename $(readlink -f /sys/class/net/wlp3s0/phy80211))
echo Y > /sys/module/mac80211/parameters/wb_fifo
echo "fq_limit 1000" > $DBG/aqmNow, let's monitor the queues at the AP. Run
# runs in AP terminal
DBG=/sys/kernel/debug/ieee80211/$(basename $(readlink -f /sys/class/net/wlp3s0/phy80211))
watch -n 0.5 "grep -h '^0 ' $DBG/netdev:wlp3s0/stations/*/aqm"You will see one line for each client. For example, while the AP is sending a TCP flow to one of two clients, the output might look like this:
0 2 279163 190 387 0 0 4 0 131559494 85388 0x6(RUN AMPDU NO-AMSDU) 0 2 0 0 4 0 0 0 1 448 4 0x6(RUN AMPDU NO-AMSDU)
The fourth number in each line is the number of packets that are waiting in the queue for that client (190 for the first client in this example, and 0 for the second). The sixth number is the number of packets that the AP has dropped from that queue so far, and the seventh is the number of packets that it has marked. The second-to-last number is the total number of packets that the AP has sent to that client, so you can tell which line is which: the client that is receiving the TCP flow is the one whose count is increasing quickly.
Leave this running.
We will also monitor the delay that the TCP flow experiences. In the second server terminal, run
# runs in second server terminal, inside namespace
watch -n 1 "ss -tin sport = :5001 | grep -o ' rtt:[0-9.]*'"and leave it running, too. (Nothing will appear until the flow starts.) The ss command shows information about the TCP connections on this host, including the RTT (in milliseconds) that the sender measures for each one. The RTT includes the time that packets spend waiting in the queue at the AP.
In the first server terminal, send a TCP flow to Client B for 30 seconds:
# runs in first server terminal, inside namespace
iperf3 -c 192.168.100.3 --cport 5001 -t 30 -i 5While this is running, watch the round-trip time in the second server terminal and the queue length in the AP terminal. Make a note of the round-trip time and of the queue length near the end of the flow, when they stabilize.
When the flow has finished, also make a note of its throughput (in the line of the iperf3 output that ends with "receiver"). Then use Ctrl+C to stop the watch command in the AP terminal, and the watch command in the second server terminal.
Now, we will imagine that the link quality has suddenly dropped, and so the rate at which packets are transmitted to the client decreases. Since these devices do not move, we will mimic this effect by adjusting the modulation and coding scheme. Tell the AP to use only MCS 2:
# runs in AP terminal
iw dev wlp3s0 set bitrates legacy-2.4 1 ht-mcs-2.4 2Then repeat the test, starting from "Now, let's monitor the queues at the AP": start the watch command in the AP terminal and the watch command in the second server terminal again, send another TCP flow, note the round-trip time, the queue length, and the throughput, and then stop both watch commands. (Wait about ten seconds after one test finishes before you start the next one, so that the queue at the AP has time to empty.)
Then do the same for MCS 0: repeat the steps starting from "Tell the AP to use only MCS 2", but change the last number in the iw command to 0.
Then, return the AP to automatic rate selection, with
# runs in AP terminal
iw dev wlp3s0 set bitratesNow, we will do the same tests with FQ-CoDel at the AP. To turn FQ-CoDel back on, run
# runs in AP terminal
DBG=/sys/kernel/debug/ieee80211/$(basename $(readlink -f /sys/class/net/wlp3s0/phy80211))
echo N > /sys/module/mac80211/parameters/wb_fifo
echo "fq_limit 8192" > $DBG/aqmin the AP terminal. Then, repeat the steps above, starting from "Now, let's monitor the queues at the AP" and ending with the step that returns the AP to automatic rate selection. For the test at MCS 0 with FQ-CoDel, also make a note of how much the number of dropped packets for Client B increases during the flow, and of the number of retransmissions (the total in the "Retr" column of the iperf3 output). We will compare these to the next test.
Finally, we will see how FQ-CoDel uses ECN, if it is enabled. Set the AP to MCS 0 again:
# runs in AP terminal
iw dev wlp3s0 set bitrates legacy-2.4 1 ht-mcs-2.4 0Then start the watch command in the AP terminal and the watch command in the second server terminal again, and make a note of the number of dropped packets and the number of marked packets for Client B. (These count all of the packets that were dropped or marked since the client connected, so we will look at how much they increase.)
In the first server terminal, run:
# runs in first server terminal, inside namespace
sysctl -w net.ipv4.tcp_ecn=1
iperf3 -c 192.168.100.3 --cport 5001 -t 30 -i 5When it finishes, find out how much the number of dropped packets and the number of marked packets increased during this flow, and look at the "Retr" (retransmissions) column in the iperf3 output. Compare these to the previous run at MCS 0, which also used FQ-CoDel, but without ECN. Then use Ctrl+C to stop both watch commands.
When you are finished with this part, return the AP to automatic rate selection, and turn ECN off again:
# runs in AP terminal
iw dev wlp3s0 set bitratesin the AP terminal, and
# runs in first server terminal, inside namespace
sysctl -w net.ipv4.tcp_ecn=2in the first server terminal.
Scheduling: with and without airtime fairness
Now we will move on to the second part of our experiment, where we investigate the effect of the scheduling policy used by the AP.
In this part, we have two clients associated with the AP. Client A will be a "fast" client and Client B will be a "slow" client. To make Client B slow, we will move it to the "slow" network, which we limited to MCS 0.
In the Client B terminal, disconnect from the first network:
# runs in Client B terminal
pkill -f "wpa_supplicant -B"
ip addr flush dev wlp5s0Wait a few seconds, and then connect to the "slow" network:
# runs in Client B terminal
wpa_passphrase wifi-lab-$SB-slow secretpassword > wpa-slow.conf
wpa_supplicant -B -i wlp5s0 -c wpa-slow.confUse iw dev wlp5s0 link to verify that it is connected, then run
# runs in Client B terminal
ip addr add 192.168.101.3/24 dev wlp5s0
ip route add 10.9.0.0/24 via 192.168.101.1
iw dev wlp5s0 set power_save offFirst, find out what throughput each client gets when it has the AP to itself. In the first server terminal, run
# runs in first server terminal, inside namespace
iperf3 -c 192.168.100.4 -t 20 -i 5and, when it finishes,
# runs in first server terminal, inside namespace
iperf3 -c 192.168.101.3 -t 20 -i 5Make a note of the throughput of each.
Now, turn off airtime fairness. In the AP terminal, run
# runs in AP terminal
DBG=/sys/kernel/debug/ieee80211/$(basename $(readlink -f /sys/class/net/wlp3s0/phy80211))
echo 0 > $DBG/airtime_flagsWe will use the AP's airtime counters to see how much time it spends transmitting to each client. In the AP terminal, run
# runs in AP terminal
DBG=/sys/kernel/debug/ieee80211/$(basename $(readlink -f /sys/class/net/wlp3s0/phy80211))
grep -H "TX:" $DBG/netdev:*/stations/*/airtimeThe output shows the total airtime, in microseconds, that the AP has used to transmit to each client so far. (The client on wlp3s0 is Client A, and the client on wlp3s0_1 is Client B.) Make a note of these values.
Then send a TCP flow to both clients at the same time. In the first server terminal, prepare to run
# runs in first server terminal, inside namespace
iperf3 -c 192.168.100.4 -t 30 -i 5and in the second server terminal, prepare to run
# runs in second server terminal, inside namespace
iperf3 -c 192.168.101.3 -t 30 -i 5Try to start both running at the same time.
When they finish, run
# runs in AP terminal
DBG=/sys/kernel/debug/ieee80211/$(basename $(readlink -f /sys/class/net/wlp3s0/phy80211))
grep -H "TX:" $DBG/netdev:*/stations/*/airtimein the AP terminal again. Subtract the values that you noted earlier from the new values, to find the airtime that the AP used for each client during this test. Also note the throughput of each flow.
Turn airtime fairness on again, with
# runs in AP terminal
DBG=/sys/kernel/debug/ieee80211/$(basename $(readlink -f /sys/class/net/wlp3s0/phy80211))
echo 3 > $DBG/airtime_flagsin the AP terminal. Then repeat the steps above, starting from "We will use the AP's airtime counters" (where you note the airtime that the AP has used for each client) and ending with the airtime and the throughput for each client during the test.
Contention: default parameters, voice marking, and AC_N15
In this final part, we will observe the effect of contention for the channel. The server will send a bulk TCP flow to Client A, and at the same time we will ping Client B, to find out how long Client B has to wait for the channel.
First, return Client B to the first network (not the slow one). In the Client B terminal, run
# runs in Client B terminal
pkill -f "wpa_supplicant -B"
ip addr flush dev wlp5s0Wait a few seconds, and then connect to the first network again:
# runs in Client B terminal
wpa_supplicant -B -i wlp5s0 -c wpa.confUse iw dev wlp5s0 link to verify that it is connected, then run
# runs in Client B terminal
ip addr add 192.168.100.3/24 dev wlp5s0
ip route add 10.9.0.0/24 via 192.168.100.1
iw dev wlp5s0 set power_save offIn the AP terminal, run
# runs in AP terminal
DBG=/sys/kernel/debug/ieee80211/$(basename $(readlink -f /sys/class/net/wlp3s0/phy80211))
watch -n 0.5 "grep -h '^0 ' $DBG/netdev:wlp3s0/stations/*/aqm"again, so that you can see the queue at the AP for each client.
In the first server terminal, start a TCP flow to Client A:
# runs in first server terminal, inside namespace
iperf3 -c 192.168.100.4 -t 30 -i 5As soon as it starts, in the second server terminal, send 100 pings per second to Client B for 25 seconds:
# runs in second server terminal, inside namespace
ping -i 0.01 -w 25 192.168.100.3(This prints a line for each ping, 100 times per second. If your connection to the testbed is poor and the output cannot keep up, you can add the -q argument to the ping commands in this part, so that ping only prints the summary at the end.)
While this is running, look at the ping times, and at the queue length for each client in the AP terminal. You should see that there are packets waiting for Client A, but not for Client B.
When both have finished, make a note of the average and maximum ping time, and of the throughput of the TCP flow.
Next, we will mark the pings as voice traffic, and leave everything else the same. In the first server terminal, run
# runs in first server terminal, inside namespace
iperf3 -c 192.168.100.4 -t 30 -i 5and in the second server terminal, run
# runs in second server terminal, inside namespace
ping -Q 0xb8 -i 0.01 -w 25 192.168.100.3The -Q 0xb8 argument sets the DSCP field in the IP header of each ping to the "expedited forwarding" value, so that it is sent in the voice access category. Note the ping times and the TCP throughput as before.
Finally, we will see whether we can get a low delay for pings that are not marked. We will restart the AP with the AC_N15 parameters for best effort traffic. In the AP terminal, stop the watch command with Ctrl+C. Then make a copy of the configuration file for the AP:
# runs in AP terminal
cp hostapd.conf hostapd-n15.confOpen the copy in a text editor:
# runs in AP terminal
nano hostapd-n15.confand add the following eight lines for the AC_N15 parameters, directly after the first line that says wpa_passphrase=secretpassword (and before the line that says bss=wlp3s0_1):
wmm_ac_be_aifs=1
wmm_ac_be_cwmin=4
wmm_ac_be_cwmax=4
wmm_ac_be_txop_limit=31
tx_queue_data2_aifs=1
tx_queue_data2_cwmin=15
tx_queue_data2_cwmax=15
tx_queue_data2_burst=1.0Use Ctrl+O and then Enter to save the file, and Ctrl+X to exit.
The lines that start with wmm_ac_be are the parameters that the AP advertises to its clients for best effort traffic. Here, the contention window is given as an exponent (a value of 4 means a window of 24 - 1 = 15 slots) and the TXOP limit is in units of 32 microseconds (31 units is about 1 ms). The lines that start with tx_queue_data2 are the parameters that the AP itself uses for best effort traffic.
Stop the AP:
# runs in AP terminal
pkill hostapdWait a few seconds for it to stop, and then start it again with the new configuration:
# runs in AP terminal
hostapd -B hostapd-n15.conf
ip addr add 192.168.101.1/24 dev wlp3s0_1You should see wlp3s0: AP-ENABLED in the output again. (If you see driver initialization failed instead, the AP had not finished stopping; run the two commands again with a longer pause in between.)
The clients will reconnect to the AP by themselves within a few moments. Use iw dev wlp5s0 link in the Client A and Client B terminals to check.
Then run the first test of this part again, with pings that are not marked. In the first server terminal, run
# runs in first server terminal, inside namespace
iperf3 -c 192.168.100.4 -t 30 -i 5and in the second server terminal, run
# runs in second server terminal, inside namespace
ping -i 0.01 -w 25 192.168.100.3Note the ping times and the TCP throughput as before.
Lab report
For your lab report, fill in the table for each part of the experiment with your measurements, and then answer the questions about them.
Queueing
Fill in the following table with your measurements from the first part of the experiment. (A cell that is marked "-" does not need a value.)
| Queue at AP | Link rate | Throughput of TCP flow (Mbit/s) | RTT of TCP flow (ms) | Packets waiting in queue for Client B | Packets dropped at AP during flow | Packets marked at AP during flow | TCP retransmissions |
|---|---|---|---|---|---|---|---|
| FIFO | Best rate | - | - | - | |||
| FIFO | MCS 2 | - | - | - | |||
| FIFO | MCS 0 | - | - | - | |||
| FQ-CoDel | Best rate | - | - | - | |||
| FQ-CoDel | MCS 2 | - | - | - | |||
| FQ-CoDel | MCS 0 | ||||||
| FQ-CoDel, with ECN | MCS 0 |
Use this table to create a figure comparable to the reference example in "Results". (The figure does not need to include the test with ECN, or the last three columns of the table.)
Then answer the following questions:
- With the FIFO queue, how did the delay change as the link rate decreased? For each link rate, use the throughput that you measured to compute the delay that you would expect from a full queue of 1000 packets of 1500 bytes each. How do your measurements compare?
- With FQ-CoDel, how did the delay change as the link rate decreased? How did the number of packets waiting in the queue change? Explain why.
- At each link rate, compare the throughput of the TCP flow with the FIFO queue to its throughput with FQ-CoDel. With the FIFO queue, hundreds of packets were waiting at the AP. Did this long queue help the flow to get more throughput? Explain.
- What changed when the TCP flow used ECN? What is the benefit of marking a packet instead of dropping it?
Scheduling
Fill in the following table with your measurements from the second part of the experiment. (A cell that is marked "-" does not need a value.) Note that the AP's airtime counters are in microseconds; divide by 1000 to convert them to milliseconds for this table.
| Test | Throughput, fast client (Mbit/s) | Throughput, slow client (Mbit/s) | Airtime used for fast client during test (ms) | Airtime used for slow client during test (ms) | Slow client's share of airtime (%) |
|---|---|---|---|---|---|
| Fast client alone | - | - | - | - | |
| Slow client alone | - | - | - | - | |
| Both clients, airtime fairness off | |||||
| Both clients, airtime fairness on |
Use this table to create a figure comparable to the reference example in "Results". (The figure does not need to include the tests with each client alone.)
Then answer the following questions:
- Use the throughput of each client alone to compute the throughput that you would theoretically expect for each client, and the share of airtime that you would expect for the slow client, (a) with round robin scheduling and (b) with airtime fairness. Show your work.
- How do your measurements without airtime fairness compare to your computation for round robin? How do your measurements with airtime fairness compare to your computation for airtime fairness? (The schedulers in this experiment operate on bursts of packets, so it may not match your computation exactly.)
- Which client gets more throughput with airtime fairness than without it, and which one gets less? What happens to the total throughput of the two clients?
- Round robin scheduling and airtime fairness are both "fair" in some sense. Explain what each one shares equally between the clients.
Contention
Fill in the following table with your measurements from the third part of the experiment.
| Test | Ping time, average (ms) | Ping time, maximum (ms) | Throughput of TCP flow (Mbit/s) |
|---|---|---|---|
| Default parameters, pings not marked | |||
| Default parameters, pings marked as voice | |||
| AC_N15 parameters, pings not marked |
Use this table to create a figure comparable to the reference example in "Results".
Then answer the following questions:
- In the test with the default parameters, how many packets were waiting in the queue for Client B at the AP? If the pings were not waiting in a queue at the AP, where were they delayed? Use your understanding of the contention window to explain how a single small packet can be delayed for so long.
- Why was the ping time lower when the pings were marked as voice traffic? What happened to the throughput of the TCP flow? Would this approach still work if every application marked its packets as voice traffic?
- Why was the ping time lower with the AC_N15 parameters, even though the pings were not marked? What happened to the throughput of the TCP flow, and why?
- Could the queue management in the first part of this experiment, or the scheduler in the second part, have reduced the delay that you saw with the default parameters in this part? Explain.
References
[1] T. Høiland-Jørgensen, M. Kazior, D. Täht, P. Hurtig, and A. Brunstrom, "Ending the Anomaly: Achieving Low Latency and Airtime Fairness in WiFi," in Proceedings of the 2017 USENIX Annual Technical Conference (USENIX ATC '17), Santa Clara, CA, July 2017. https://www.usenix.org/conference/atc17/technical-sessions/presentation/hoilan-jorgesen
[2] M. Heusse, F. Rousseau, G. Berger-Sabbatel, and A. Duda, "Performance anomaly of 802.11b," in Proceedings of IEEE INFOCOM 2003, San Francisco, CA, 2003, vol. 2, pp. 836-843. https://doi.org/10.1109/INFCOM.2003.1208921
[3] C.-Y. Chang, W. Coomans, and K. De Schepper, "Breaking the Wi-Fi Latency Barrier by Combining L4S and EDCA Reconfiguration," IEEE Communications Magazine, early access, 2026. https://doi.org/10.1109/MCOM.001.2600169
Notes
Using sb4
You can also run this experiment on the sb4 sandbox at COSMOS, with the following changes to the instructions:
Prepare the testbed: SSH into sb4.cosmos-lab.org. Use node1-4 in place of node1-1 (for the AP, the server, and Client A) and node1-5 in place of node1-2 (for Client B), so the omf load and omf tell commands end with -t node1-4,node1-5. (On sb4, node1-4 and node1-5 have the required WiFi NICs.)
# runs on sb4 console
omf load -i wifi-queueing-lab.ndz -t node1-4,node1-5
omf tell -a on -t node1-4,node1-5Prepare the testbed: On sb4, the WiFi cards are connected to one another by cables through an RF matrix, instead of over the air. After you turn the nodes on, set the attenuation on the path between node1-4 (port 4) and node1-5 (port 5) to 0 dB. On the sb4 console, run
# runs on sb4 console
curl -s -X POST -H "Content-Type: application/json" -d '{"portA":4,"portB":5,"att":0}' http://am-rt1.cosmos-lab.org:5054/rfmatrix/setConfigure the clients: Client B must use the Atheros card on node1-5, instead of the Intel card. (On sb4, the Intel card does not work well as a client of an AP on a different node.) In the Client B terminal, run modprobe ath9k instead of modprobe iwlwifi, and use wlp3s0 instead of wlp5s0 in every command, in this section and in the rest of the experiment.
Everything else is the same, including the commands for Client A, which uses the Intel card on the same node as the AP.
Recreating this experiment from a base image
The wifi-queueing-lab.ndz disk image is the COSMOS baseline.ndz image (Ubuntu 24.04, with Linux kernel 6.8.0-149-generic at the time of writing), with two changes: some additional software is installed, and the mac80211 kernel module (the Linux WiFi stack) is replaced with a modified version. This section describes how to recreate the disk image.
Load baseline.ndz onto node1-1, turn the node on, and log in to it. Then install the software that we use in this experiment:
# runs on node1-1
apt-get update
apt-get install -y hostapd wpasupplicant iperf3 patchNext, we had to modify the mac80211 kernel module. In the Linux kernel, mac80211 always uses FQ-CoDel for the packets that are waiting for each client, and there is no setting to turn it off. Our modification adds a module parameter named wb_fifo. When wb_fifo is set to Y, the module skips the CoDel algorithm when it takes a packet out of the queue, and it puts all of the packets for a client in a single flow instead of a separate flow for each connection. The result is one FIFO queue for each client, whose size is set by fq_limit. When wb_fifo is set to N (the default), the module behaves exactly like the original.
Save the following patch in a file named wb_fifo.patch in the home directory on node1-1:
--- tx.c.orig 2026-12-01 19:32:09.381857993 +0000
+++ tx.c 2026-12-01 19:32:09.410857160 +0000
@@ -11,6 +11,7 @@
*/
#include <linux/kernel.h>
+#include <linux/moduleparam.h>
#include <linux/slab.h>
#include <linux/skbuff.h>
#include <linux/if_vlan.h>
@@ -1342,6 +1343,11 @@
return to_txq_info(txq);
}
+/* lab switch: 1 = plain FIFO per station/TID (no CoDel, no flow hashing) */
+static bool wb_fifo;
+module_param(wb_fifo, bool, 0644);
+MODULE_PARM_DESC(wb_fifo, "bypass CoDel and flow queueing in mac80211 TXQs");
+
static void ieee80211_set_skb_enqueue_time(struct sk_buff *skb)
{
struct sk_buff *next;
@@ -1413,6 +1419,9 @@
cparams = &local->cparams;
cstats = &txqi->cstats;
+ if (wb_fifo)
+ return fq_flow_dequeue(fq, flow);
+
if (flow == &tin->default_flow)
cvars = &txqi->def_cvars;
else
@@ -1462,7 +1471,7 @@
IEEE80211_TX_INTCFL_NEED_TXPROCESSING;
__skb_queue_tail(&txqi->frags, skb);
} else {
- flow_idx = fq_flow_idx(fq, skb);
+ flow_idx = wb_fifo ? 0 : fq_flow_idx(fq, skb);
fq_tin_enqueue(fq, tin, flow_idx, skb,
fq_skb_free_func);
}
@@ -3493,7 +3502,7 @@
max_amsdu_len = min_t(int, max_amsdu_len,
sta->sta.cur->max_tid_amsdu_len[tid]);
- flow_idx = fq_flow_idx(fq, skb);
+ flow_idx = wb_fifo ? 0 : fq_flow_idx(fq, skb);
spin_lock_bh(&fq->lock);
Get the source code for the kernel that is running on the node, and extract the mac80211 part of it:
# runs on node1-1
apt-get install -y linux-source-6.8.0=6.8.0-149.149
mkdir ~/build
cd ~/build
tar xjf /usr/src/linux-source-6.8.0.tar.bz2 linux-source-6.8.0/net/mac80211
cd linux-source-6.8.0/net/mac80211(If the base image has a newer kernel, check its version with uname -r and cat /proc/version_signature, and use that version of the linux-source package instead. The patch above was made for the tx.c file in version 6.8.0-149.149. With a different version, patch may not be able to apply all of it, and you may need to make the same changes to tx.c by hand.)
Apply the patch, and build the module:
# runs on node1-1
patch tx.c < ~/wb_fifo.patch
make -j8 -C /lib/modules/$(uname -r)/build M=$PWD modulesInstall the modified module in the updates directory, where it takes priority over the original module:
# runs on node1-1
mkdir -p /lib/modules/$(uname -r)/updates
cp mac80211.ko /lib/modules/$(uname -r)/updates/
depmod -a
modinfo -n mac80211The last command should print the path of the module in the updates directory.
The modified module only works with the kernel that it was built for, so we also prevent the kernel from being upgraded:
# runs on node1-1
apt-mark hold linux-image-$(uname -r) linux-modules-$(uname -r) linux-modules-extra-$(uname -r) linux-headers-$(uname -r)Finally, remove the files that should not be part of the image, prepare the node, and save the image. On node1-1, run
# runs on node1-1
apt-get purge -y linux-source-6.8.0
rm -rf ~/build /usr/src/linux-source-6.8.0*
/root/prepare.shand then, on the console of the sandbox, run
# runs on sb5 or sb6 console
omf save -n node1-1.sb5.cosmos-lab.org(substituting the name of your sandbox). The output of this command shows the name of the new image file, which is saved in /mnt/images on the console. You can rename it there with mv.