Lab
The egress queue
A program sends UDP datagrams faster than its link takes them. Each datagram waits in the A queueing discipline: the queue of a network device in the kernel. It holds each packet until the device sends it, and it drops a packet when it is full. of the device, and a full qdisc drops it. With A qdisc that adds a delay, a loss or a rate to each packet. It imitates a slow or a bad network., the queue holds a count of packets. With The token bucket filter: a qdisc that sends at a rate. Its bucket holds the tokens of a burst, thus a burst of that size leaves at once., the queue holds bytes, and its bucket lets a burst leave at once. This page computes, in your browser, when each datagram leaves and which datagrams drop.
netem rate 1 Mbit/s limit 1,000 sends each of the 10 datagrams. The last frame leaves at 121.1 ms.
Ten full frames into netem at 1 Mbit/s, with IP_RECVERR off as in Linux.
- the fault
- the lane knows, at this time
- recovers
- a send again or a timer
- a probe
- measured median of a cell
The axis is linear, up to the last frame.
- in the queue
- leaves the qdisc
- dropped
- the limit of the queue: 1,000 packets, above the chart
The programA socket option. With it, a UDP socket gets the errors of its sends, and a drop at the qdisc gives ENOBUFS to the send. Linux sets it off.
Never knowsEach send succeeds, and each datagram leaves the host.
- Datagrams
- 10
- IP_RECVERR
- Off, the default
- SndbufErrors gains
- 0
A socket option. With it, a UDP socket gets the errors of its sends, and a drop at the qdisc gives ENOBUFS to the send. Linux sets it off.Maximum transmission unit: the largest packet on the link, in bytes.The qdiscA queueing discipline: the queue of a network device in the kernel. It holds each packet until the device sends it, and it drops a packet when it is full.
Never knowsThe queue holds at most 10 packets of its limit of 1,000 packets, thus no datagram drops.
- The qdisc
- netem rate 1 Mbit/s limit 1,000
- One frame
- 1,514 B in 12.1 ms
- The most it holds
- 10 packets of 1,000 packets
- Drops
- None
A queueing discipline: the queue of a network device in the kernel. It holds each packet until the device sends it, and it drops a packet when it is full.A qdisc that adds a delay, a loss or a rate to each packet. It imitates a slow or a bad network.The device
Recovers at 121.1 msThe first frame leaves at 12.1 ms and the last at 121.1 ms. The queue is empty again then.
- Frames sent
- 10 of 10
- The first frame leaves
- 12.1 ms
- The last frame leaves
- 121.1 ms
- The rate of the departures
- 1 Mbit/s
How to read the page
Section titled “How to read the page”- The headline tells how many datagrams drop, who knows of the drops, and when the last frame leaves.
- The timeline has three lanes. The program lane shows each burst and the first ENOBUFS. The qdisc lane shows the first drop. The device lane ends when the last frame leaves. Press Play to see the story.
- The chart under the timeline has one row for each datagram. A line goes from its send to its departure, and a cross marks a drop. The lower part shows what the qdisc holds, with its limit.
- The cards below the timeline give each lane, with its knobs. Change a knob, and each time on the page changes.
- The presets EQ.1 to EQ.7 are the settings of the cells of the harness.
Who knows of a drop
Section titled “Who knows of a drop”A full qdisc drops the datagram and gives an error to the kernel code of the send. What the program gets depends on the socket option A socket option. With it, a UDP socket gets the errors of its sends, and a drop at the qdisc gives ENOBUFS to the send. Linux sets it off..
- With IP_RECVERR off, the default of Linux, the send succeeds. The kernel counts the drop in A counter of UDP in /proc/net/snmp. It counts each send that found no room, also each datagram that a qdisc dropped., and the program does not learn of it.
- With IP_RECVERR on, the send gets The error of a send when the kernel has no room for the data. A UDP socket with IP_RECVERR gets it when a qdisc drops its datagram.. The cells of the harness set this option, thus each drop shows as an error.
The qdisc also counts each drop in its own statistics, in the output of tc -s qdisc show. That counter changes at the arrival of the datagram.
The law of the queue
Section titled “The law of the queue”The netem qdisc gives each frame the time of its length at its rate. A frame leaves at max(last, at + delay) + time. Here last is the departure of the frame before it, and time is the time of its length. At 1 Mbit/s, a full frame of 1,514 B takes 12.112 ms.
The netem qdisc holds each frame until it leaves, thus the delay counts in the limit. With a delay of 100 ms, a burst of 8 frames holds 8 of 12 places for 100 ms. A second burst 30 ms later finds 4 places, and it drops 4 frames.
The tbf qdisc counts its tokens in nanoseconds. Its bucket is full at the first frame, and it gains one token for each nanosecond, up to its depth. A frame leaves when the tokens cover the time of its length. Thus a bucket of 3,000 B at 1 Mbit/s sends 3 frames of 1,000 B at once, and then one frame each 8 ms. It drops a frame longer than its bucket before its queue. Its bfifo drops a frame that puts its bytes above the limit.
Where the numbers come from
Section titled “Where the numbers come from”The times are the law of netemSchedule and tbfSchedule of @mark1russell7/algebra. Each one follows the kernel: packet_time_ns of netem, and psched_l2t_ns of tbf. The kernel multiplies by a factor and does not divide, thus a time of tbf can be 1 ns short. The length of a frame is udpFrameLength: the payload, 8 B of UDP, 20 B of IPv4 and 14 B of Ethernet.
Each amount prints through format of @mark1russell7/quantity. The page does no queue arithmetic of its own.
Limits
Section titled “Limits”- The page sends the datagrams of a burst at one time. A real program sends them one after the other, a few microseconds apart.
- A payload above the MTU less 28 B leaves in fragments. The page counts one frame for it, and the device card shows a warning.
- The page shows one qdisc. A tbf with a netem child, or a qdisc on the other host, adds a queue of its own.
- A NIC with its own ring of frames adds its own delay after the qdisc. The page does not show that ring.
- The page shows no measured value yet. The cells EQ.1 to EQ.7 add their medians after their first records.