Networks You Do Not Own

On Wi-Fi you do not own, one 150 ms stall can make a video sender cut its rate by a third. A bit-rate floor and a separate control flow keep the robot arm moving.

Learn how WebRTC finds a path, how Google Congestion Control reads delay, why it can be fooled, and how to design a teleop link that degrades gracefully.

Press the Repeat switch, then watch the video rate fall after each stall. Set a floor, then give the control flow its own priority. Then we build, piece by piece, every part of this link.

You need a feel for what a network packet is and a little C or Python. We build the rest from zero.

Built from primary sources: the Google Congestion Control draft (draft-ietf-rmcat-gcc), Carlucci, De Cicco, Holmer and Mascolo (MMSys 2016), the libwebrtc source, RFCs 3550, 8445, 8831, 8837, 9221 and 9330 to 9332, and the Transitive Robotics latency study. The chart is our model, not a recording.

Break the link

150 ms
none

A fluid model of one bottleneck (3 Mbit/s link, 1.5 Mbit/s of cross traffic) with the libwebrtc trendline filter, an adaptive threshold and an AIMD rate. Every number is illustrative, produced by this model. The 200 ms deadman is a toy choice.

Chapter 0

The Warehouse Wi-Fi Dead Zone

See why a robot arm on shared Wi-Fi needs a link that gets worse gracefully, and what that costs in milliseconds

An operator sits in an office and moves a robot arm in a warehouse across town. She sees the arm through a camera. The arm sees her commands through a network. Nobody on this team owns that network.

The warehouse has Wi-Fi that a different team runs. A forklift passes the access point and the signal dips. The robot rolls to a far aisle and joins a second access point. In the other building the link is cellular. At the customer site the traffic goes through a corporate VPN (a private tunnel) with firewall rules you cannot change.

The link will get worse. You cannot stop that. The design question is what happens next. The goal is graceful degradation: the video gets coarser, the arm keeps obeying, and if the link dies the arm stops safely.

Two streams with two different jobs

A teleop link carries two things. The first is video: a stream of pictures from the robot, large and hungry. The second is control: small packets that say where the arm is and what the operator wants, sent 50 times a second.

Video can be coarse. A blurry picture still shows the arm. Control cannot be late. A command that arrives 300 ms late moves the arm to a place the operator has already left.

Here is a detail that matters later. Commands travel from the operator to the robot. The robot sends back state reports (joint angles, a heartbeat) on the same path as the video. Those reports share the Wi-Fi uplink queue with the video. If they arrive late, the operator’s console treats the arm as lost. We call the delay of these reports the control delay.

The time budget

People who build teleop systems aim for a total delay of about 100 to 200 ms from a camera to the operator’s eyes. We use that as a design target, not a standard. Transitive Robotics measured the pieces on a real setup (their WebRTC latency study). A local WebRTC link took about 130 ms glass to glass. The same link through a relay server with a 30 ms ping took about 170 ms. Almost all of it was the camera and the USB bus, about 100 ms. With encode, decode and the jitter buffer, the pieces add up to about 127 ms, so the local network added only a few milliseconds.

So the network is not the usual cost. It is the cost that explodes. On a good local day it adds a few milliseconds. On a bad day, a single Wi-Fi hiccup adds 150 ms and a clumsy sender makes it worse. This lesson is about the bad day.

The instrument at the top of the page

The chart at the top is a small model of one bad day. A link of 3 Mbit/s carries 1.5 Mbit/s of someone else’s traffic, so 1.5 Mbit/s is yours. A Wi-Fi radio goes to sleep for 150 ms, and the access point holds your packets until it wakes. The sender runs a rate estimator in the style of Google’s. The dashed purple line is what the estimator believes. The orange line is what it sends. The teal line below is the control delay.

Here is what you should see. The first stall makes the estimate fall by about a third. The next stalls cut it again. After a few, the video is down to a trickle although the link never lost capacity. That is the first lesson: a delay spike is not less bandwidth, but the estimator cannot tell.

Count the cost of one stall

The bar shows one second of arm control packets, 50 of them. Slide the stall length. Each packet that waits past the 200 ms deadman is lost to the arm.

150 ms

Illustrative: one packet every 20 ms, a 15 ms base delay, and the radio holds every packet sent during the stall until it ends. No video queue yet; Chapter 4 adds it.

Count it by hand. The robot sends a state report every 20 ms. A 150 ms stall holds about 7 reports. The first one waits the full 150 ms, the last about 10 ms. Add the 15 ms base delay and the worst report arrives 165 ms late. That is under a 200 ms deadman, so the arm survives a lone stall. A 250 ms stall would not be survived.

The road

  1. WebRTC from the inside: how two machines behind NATs find a path and agree on keys.
  2. Google Congestion Control: the filter, the detector and the rate rule that the chart runs.
  3. Loss, SCReAM, NADA, BBR and L4S: other ways to read a queue, and how to shrink it.
  4. Prioritising control: two flows, one bottleneck, and the floor.
  5. Multipath, QUIC, SRT and MoQ: other transports and why head-of-line blocking hurts.
  6. SFU or P2P, simulcast or SVC: when a server sits in the middle.
  7. Debugging the link: RTCP, Wireshark and a capture at both ends.
  8. Field guide: numbers, a checklist and the estimator as code.
A Wi-Fi radio stalls for 150 ms and the video rate then falls by a third. What did the sender most likely get wrong?

Chapter 1

WebRTC From the Inside

Follow two machines behind two routers as they find each other, test paths in priority order and agree on encryption keys

Your robot sits behind the warehouse router. The operator sits behind the office router. Each machine knows only its private address, something like 192.168.1.20. That address means nothing outside its own building. How do they open a direct connection?

They cannot simply call each other. A router that does NAT (network address translation, a trick that lets many private machines share one public address) rewrites outgoing packets. It also throws away any packet that arrives from outside that nobody asked for. Think of an office phone system: staff can call out, but a stranger cannot dial an extension directly.

WebRTC solves this with a procedure called ICE (Interactive Connectivity Establishment, defined in RFC 8445). The idea is plain. Each side lists every address it might be reachable at. The two lists are swapped. Then both sides try the pairs, best first, until one works.

Candidates: the addresses on the list

Each address on the list is a candidate. There are four kinds. A host candidate is the machine’s own address, such as 192.168.1.20. A server-reflexive candidate is the public address the NAT shows to the world. A relayed candidate is an address on a helper server that forwards packets for you. A peer-reflexive candidate is one discovered during the checks themselves.

Two helper servers make this work. A STUN server answers one question: “what address did my packet come from?” That answer is your server-reflexive candidate. A TURN server (RFC 8656) goes further. It takes a public address for you and relays every packet. It is the last resort, because it adds a hop.

Priority: which pair to try first

ICE gives each candidate a number. RFC 8445 sets it as priority = 224 × type preference + 28 × local preference + (256 − component). The recommended type preferences are 126 for host, 100 for server-reflexive and 0 for relayed. A direct local path wins. A relay comes last.

Work it for one candidate. A host candidate with local preference 65,535 on component 1 gives 126 × 16,777,216 + 65,535 × 256 + 255. That is 2,130,706,431. A relayed candidate with the same local preference gives 0 + 16,776,960 + 255 = 16,777,215. The host number is about 127 times larger, so the host pair is tried first.

The pair list is sorted by a pair priority built from the two candidates. Then the connectivity checks begin. A check is a small STUN request sent from one candidate to the other, and the other side must answer. ICE starts a new check at most every 50 ms by default (the pacing value Ta, RFC 8445). The first pair whose request and answer both succeed is nominated. Media then flows on that pair.

Climb the ICE ladder

Choose the NAT type on each side, then press Run. The checks go down the list in priority order, one every 50 ms. Watch which pair is the first to pass.

Robot side
Operator side

The pass rule is the usual rule of thumb, simplified: a direct path works unless one side is symmetric and the other is symmetric or port restricted. Candidate priorities use the RFC 8445 formula. The 40 ms relay cost is Transitive Robotics’ measurement (170 ms against 130 ms), not a law.

Read the ladder. The host pair fails because the two private addresses cannot reach each other across the internet. The server-reflexive pair passes when both NATs let the probe through. When one side is symmetric (it gives each destination a different public port, so the address STUN reported is useless to anyone else), the direct probe fails. Only the relay pair is left.

The cost of a relay

A relay is an extra stop. Transitive Robotics measured it. Local WebRTC took about 130 ms from lens to screen. Through a TURN server in another state, with a 30 ms ping, it took about 170 ms. That is 40 ms more: about 30 ms of static network delay plus a little extra jitter buffering. For a teleop budget of 100 to 200 ms, a relay eats a large share. So you measure which pair won, every session.

Signaling: how the lists get swapped

The two machines need a side channel to swap their candidate lists before they can talk. WebRTC calls this signaling and leaves it to you. A web socket to your server is common. The message they swap is an SDP blob (Session Description Protocol), a plain text list of lines. One side sends an offer. The other sends an answer.

m=video 9 UDP/TLS/RTP/SAVPF 96 // one video stream, encrypted RTP
a=ice-ufrag:4Zkq // the name and password the checks must carry
a=ice-pwd:a8f2...
a=fingerprint:sha-256 3B:0C:... // a hash of the DTLS certificate
a=candidate:1 1 udp 2130706431 192.168.1.20 54321 typ host
a=candidate:2 1 udp 1694498815 203.0.113.7 40111 typ srflx

These lines are the whole contract. The ice-ufrag and ice-pwd lines make a stranger’s probe fail. The candidate lines are the list. The numbers 2130706431 and 1694498815 are exactly the priorities we computed. The fingerprint line comes next.

Keys: DTLS-SRTP

Video must be private, and the two ends have never met. Once ICE picks a pair, the machines run a DTLS handshake (TLS for datagrams) over that same path. It checks each side’s certificate against the fingerprint in the SDP. Then it produces keying material for SRTP, the encrypted form of the RTP packets that carry the video (RFC 5764). The keys never travel through your signaling server. DTLS keying happens on the media path.

Here is how you ask for all of this in code. The iceServers list names the helpers. A data channel for control is created next to the video.

javascriptconst pc = new RTCPeerConnection({
  iceServers: [
    { urls: 'stun:stun.example.com:3478' },
    { urls: 'turn:turn.example.com:3478', username: 'robot7', credential: '...' }
  ]
});
const ctl = pc.createDataChannel('ctl', { ordered: false, maxRetransmits: 0 });
pc.addTrack(cameraTrack, stream);
const offer = await pc.createOffer();      // the SDP text above
await pc.setLocalDescription(offer);       // starts gathering candidates
signal.send(pc.localDescription);          // your own channel, WebRTC does not define it
Two robots on a customer site cannot connect directly. Both sit behind symmetric NATs. What does ICE do?

Chapter 2

GCC: Delay-Based Congestion Control

Build the sender's guess about capacity from one signal, the way packets bunch up in time, and see exactly where a Wi-Fi stall fools it

You are filling a bath and you cannot see the tap’s limit. You open it a little more every second. At some point water arrives faster than the drain takes it, and the level starts to rise. That rise is your signal. You back off before the bath overflows.

A video sender does the same. It cannot see the link’s capacity. It pushes a little harder every second. When the sending rate passes the capacity, a queue (a line of packets waiting for the link) starts to grow. Each new packet waits a little longer than the one before. Google Congestion Control, or GCC, watches for that growing wait.

The signal: how packets bunch in time

The sender stamps each packet group with a send time. The receiver notes the arrival time. Take two neighbouring groups. The inter-departure time is how far apart they left. The inter-arrival time is how far apart they arrived. The draft writes the difference as d(i) = (t(i) − t(i−1)) − (T(i) − T(i−1)), where t is arrival and T is departure.

Work it. Two groups leave 10 ms apart. They arrive 12 ms apart. Then d = 12 − 10 = +2 ms. The second group waited 2 ms longer than the first, so the queue grew by 2 ms. If d stays positive group after group, the queue is building. If d is about zero, the queue is steady. If d is negative, the queue is draining.

How big is d? A queue grows by the gap between the sending rate S and the capacity C. In time, each millisecond adds (S − C)/C milliseconds of waiting. Send 6% over capacity and the wait grows by 0.06 ms every millisecond. So the slope of the delay is the congestion signal.

How the packets get timed: transport-cc

The receiver must tell the sender when each packet arrived. WebRTC does this with transport-wide congestion control feedback. The receiver records the arrival time and a sequence number for every packet and sends them back in an RTCP report. The draft recommends one report per video frame, or at least every 30 ms for audio, and allows up to 100 ms to save overhead. The sender then runs the estimator itself (WebRTC for the Curious, chapter 6).

Three stages: filter, detector, rate

GCC has three parts in a row. The arrival-time filter turns the noisy d(i) values into one smooth number that says “the queue is growing” or not. The over-use detector compares that number with a threshold. The rate controller turns the verdict into a new bit rate.

The 2016 draft uses a scalar Kalman filter for the first stage. Modern libwebrtc uses a trendline estimator instead, and our model follows it. It adds up the d values into an accumulated delay, smooths that with a factor of 0.9, and fits a line through the last 20 points. The slope of that line, times the smaller of the sample count and 60, times a gain of 4, is the modified_trend.

Try a number. The smoothed delay climbs 0.6 ms for every 10 ms. The slope is 0.06. After 60 samples, the modified trend is 60 × 0.06 × 4 = 14.4. The starting threshold is 12.5, so 14.4 is over it.

One reading is not enough. The detector declares over-use only when the trend stays above the threshold for more than 10 ms, on at least two samples, and the trend is not falling. The threshold also moves. It rises when the trend pushes through it and falls when the trend is small, with gains of 0.0087 (up) and 0.039 (down) in the libwebrtc code, and it stays between 6 and 600. The 2016 draft lists different constants, 0.01 and 0.00018, so read the code you run.

Fool the estimator

Top: the filter output against the threshold band. Bottom: the rate GCC allows against the rate that arrives. Slide the stall, then switch Wi-Fi power save off.

150 ms

Model: libwebrtc trendline constants (window 20, smoothing 0.9, gain 4, threshold 12.5 ms, k up 0.0087, k down 0.039, over-use after 10 ms), decrease to 0.85 of the received rate, +8% per second. The window size of 20 and the single stall start at 5 s are our choices. Real stacks group packets in bursts, which may soften a stall; the size of the dip here is illustrative.

The rate: AIMD

The rate controller is AIMD: additive increase, multiplicative decrease. It is the same shape that keeps TCP fair. On over-use, the new rate is A = 0.85 × R, where R is the rate the receiver actually measured over the last 0.5 to 1 s. The controller then holds until the queue drains. With no over-use, it raises the rate by at most 8% per second while far from its last known limit, and by small additive steps near it. A cap keeps the estimate under 1.5 times the received rate.

Count the recovery. After a bad hit the rate sits at 0.17 Mbit/s and the link can carry 1.31. At 8% per second that takes ln(1.31/0.17) / ln(1.08) = 2.04 / 0.077, about 26 s. A stall of 150 ms every 2.5 s keeps pushing the rate down faster than 8% per second lets it climb. That is the collapse in the hero chart.

Where the stall fools it

A Wi-Fi radio in power-save mode sleeps between beacons. The access point holds the packets for it. The usual beacon interval is 100 time units, which is 102.4 ms. The access point tells the sleeping client about waiting data in the beacon and the client fetches it. To GCC this looks like a step in the arrival times: packets from just before the stall arrive on time, packets from during it arrive late, then a burst. The filter sees a sudden rise in delay, the same shape as a queue. It cannot see that the cause is a sleeping radio.

The draft knows this class of problem. Its section on implementation experience says deployment revealed problems with congested or otherwise problematic Wi-Fi networks, and that this led to improvements. The pre-filter merges packets that arrive in a burst so that a pure outage does less harm. A stall that is slow enough to look like a ramp still gets through.

There are three defences. First, switch power save off on the robot’s radio (on Linux, iw dev wlan0 set power_save off). That removes the cause. Second, put a floor under the video bit rate so one false alarm cannot starve the picture. Third, keep the control flow out of the video’s fate, which is Chapter 4.

The trendline filter reports a modified trend of 14.4 against a threshold of 12.5 ms. What must also be true before the sender cuts its rate?

Chapter 3

Loss, SCReAM, NADA, BBR and L4S

Compare how loss, delay and marks each tell a sender about a queue, and why the cheapest fix is a shorter queue

Picture a checkout line with a rope that holds 300 people. A shopper at the back cannot see the front. She learns the line is long only when she reaches the till, a long time later. A network buffer works the same way. A deep buffer hides congestion until the wait is huge.

This effect has a name: bufferbloat. A router buffer sized for big file downloads holds hundreds of milliseconds of packets. Real-time video then sits in that line behind a download. The round trip, which should take 20 ms, takes 20 to 500 ms. The range here is illustrative, but it matches what a bloated home or warehouse uplink does.

Chapter 2 gave one way for a sender to learn about a queue: watch the delay rise. There are other signals, and each has a cost.

Loss, the slow signal

A queue that is full drops packets. A loss-based controller waits for those drops. By then the queue is already full and the wait is at its worst. GCC contains a loss-based controller as a backup. The draft gives the rule in three lines.

Work it. At 20% loss, p = 0.2, so the factor is 1 − 0.1 = 0.9: a 10% cut. At 40% loss, it is 0.8. This is gentle compared with the delay path, which cuts to 0.85 of the received rate. The sender uses the lower of the two estimates. The draft explains the 2% to 10% gap: a small, steady loss is probably not self-made congestion, so the sender should not react to it.

Other designs for real-time media

GCC is not the only one. SCReAM (RFC 8298) is a hybrid of loss and delay for conversational video. NADA (RFC 8698) regulates its rate from implicit signals (delay, loss) or explicit ones (ECN marks, defined below). Both fill the same job as GCC. They differ in the maths, not in the goal: keep the queue short while using the link.

BBR is different. It does not watch loss or the slope of delay. It tries to estimate the bottleneck bandwidth and the round-trip propagation time, and it sends at their product. It was built for bulk transfers such as video downloads and web pages. Interactive media needs the rate to follow the link within a fraction of a second, with frames that are never allowed to wait. That is why media stacks use GCC, SCReAM or NADA, and BBR belongs to bulk.

Make the queue short: AQM and ECN

The cheapest fix is not in the sender. It is in the router. An AQM (active queue management) algorithm drops or marks packets early, when the wait grows, not when the buffer is full. CoDel (RFC 8289) is the classic one. It tracks how long each packet has waited, tries to keep that near a target of 5 ms, and reacts when the wait stays above target for an interval of 100 ms. On Linux, fq_codel is available as a queueing discipline; the lesson Linux networking for robots covers the Linux side.

ECN (explicit congestion notification) lets the router mark a packet instead of dropping it. The packet still arrives, with a flag that says “the queue was getting long”. The sender learns without losing data.

L4S (low latency, low loss, scalable throughput, RFCs 9330, 9331 and 9332, January 2023) takes this further. A separate queue holds packets from senders that react to every mark in small steps. RFC 9332 describes an L4S queue whose average queuing delay is sub-millisecond, with a marking threshold that is typically sub-millisecond too. The catch is deployment. L4S needs the routers on the path to support it. We did not verify how widely it is deployed in 2026. On a network you do not own, assume it is absent and plan for a deep queue.

Shrink the queue

Pick what the router does. The chart shows the wait a packet sees in the uplink queue over 12 seconds. Slide the buffer depth to size the router’s buffer.

400 ms

Illustrative shapes, not a packet simulation. The deep buffer swings between 45% and 100% of its depth as a loss-based flow fills it. The AQM line sits near CoDel’s 5 ms target (RFC 8289). The L4S line sits below 1 ms, as RFC 9332 describes. The 20 ms base round trip is a toy value.

Look at the three traces. With a deep buffer, the queue is the whole story. With CoDel, the queue stays near 5 ms whatever the depth. With L4S marks, it stays below a millisecond. The buffer depth slider matters only for the first, which is why a router that runs a modern AQM is a gift to a teleop link.

You often cannot change the router. Then the sender must act. It can lower its own rate so the queue it builds is small. It can also shape its uplink slightly under the link rate on a Linux robot, which moves the queue from the router into your own machine, where you control it. That trick belongs to the networking lesson; here it is enough to know it exists.

Why does a loss-based controller react later than a delay-based controller?

Chapter 4

Prioritising Control Over Video

Put the small packets that move the arm in a lane of their own, so a video queue can never freeze them

The bottleneck shrinks. The robot drives into the far aisle and the Wi-Fi link falls from 1.5 Mbit/s of room for you to 0.6. The sender has a floor of 0.8 Mbit/s so the picture stays usable. The floor is now higher than the link. Where do the extra bits go?

They go into the queue. Work it. The queue grows by the excess rate: 0.8 − 0.6 = 0.2 Mbit/s. The wait it adds grows by 0.2 / 0.6 = 0.33 ms for every millisecond. A buffer that holds 300 ms is full after 300 / 0.33, about 900 ms. After that the router drops packets.

Now look at the arm’s state reports. They sit in the same first-in first-out line. Every one waits behind the video backlog. A report that should take 15 ms takes about 315 ms. The console sees no arm state for longer than its 200 ms deadman, and the arm freezes. The video and the control stream fail together because they share one queue.

The rule: control gets its own lane

Control packets are small. Fifty reports a second, each around 100 bytes, is about 40 kbit/s. That is a tiny share of any link. Video is big and flexible. When both wait in the same line, the big flexible one sets the pace for the small urgent one. Reverse that. Let the small urgent packets jump the line.

There are three places to put the lane. Use all that you can.

Lane 1: a separate data channel

WebRTC carries arbitrary messages in a data channel. It runs over SCTP (a message transport) inside the DTLS connection (RFC 8831). Each channel chooses its own reliability. For a stream of joint targets, old data is worthless. So the channel should be unordered and allow zero retransmissions: if a message is lost, the next one replaces it. That setting is ordered: false, maxRetransmits: 0 in the code of Chapter 1.

This removes one trap. A reliable, ordered channel retransmits a lost message and holds every later message until it arrives. One lost packet delays the next ten. That is head-of-line blocking, and Chapter 5 returns to it. But a data channel does not escape the shared queue on the wire. It is still the same path as the video.

Lane 2: a separate flow with a priority mark

So give control its own UDP flow, and mark it. Every IP packet has a field called DSCP (differentiated services code point), a number that asks routers for a class of service. RFC 8837 recommends values for WebRTC. Audio uses EF (46). Interactive video uses AF41 or AF42 at high priority. Data uses AF21 at high priority. Anything you want to be sent last uses LE (1).

A warning. DSCP is a request, not a command. On a network you do not own, some routers reset the field to zero at the edge. Test it by capturing at both ends (Chapter 7). Where it is ignored, the priority that always works is the one inside your own machine.

Lane 3: priority inside the robot

The queue that hurts is often the one in front of your own Wi-Fi radio. Linux lets you choose which packets leave first. The prio queueing discipline keeps several bands and always empties the highest first.

shell# band 1:1 is served first; send the control port there
tc qdisc replace dev wlan0 root handle 1: prio
tc filter add dev wlan0 parent 1: protocol ip prio 1 \
   u32 match ip dport 5005 0xffff flowid 1:1

Give control a lane

At 12 s the link falls to 0.6 Mbit/s. Slide the floor above 0.6 and watch the shared queue fill. The lower trace shows the same arm reports twice: in the video queue, and in a priority lane.

0.80 Mbit/s

Same fluid model as the first chart: a 300 ms buffer, a 15 ms base delay, strict priority for the control lane. The 200 ms deadman is a toy choice. A priority lane cannot remove a stall of the radio itself: the stalled packets wait either way.

Read the result. The shared queue drives the control delay up to the buffer limit, and the arm freezes. The priority lane keeps it at the base delay because the control packets never wait behind video. A stall still delays both, because the radio is asleep for both. Priority removes the part that you caused.

The last line: a deadman on the robot

Even the best lane fails sometimes. So the robot must decide for itself when to stop. A deadman is a timer that is reset by every valid command. If it expires, the robot makes a controlled stop. The firmware lesson fail-safe and functional safety covers how to make this trustworthy. The latency budget that sets its time is a topic of the real-time track.

c#define DEADMAN_MS 200
static volatile uint32_t last_cmd_ms;
void on_command_packet(const cmd_t *c) { if (crc_ok(c)) last_cmd_ms = now_ms(); apply(c); }
void control_tick_5ms(void) {            // from a hardware timer
    if (now_ms() - last_cmd_ms > DEADMAN_MS) enter_safe_stop(); // ramp velocity to zero
}

Choose the deadman time with care. Too short and a Wi-Fi blip stops the arm every few minutes. Too long and a real fault goes unchecked. It is the safety side of a budget you set from measured delays, not a number to copy.

A bit-rate floor of 0.8 Mbit/s runs on a link that shrinks to 0.6. Control shares the video queue. What happens, and what is the fix for the control part?

Chapter 5

Multipath, QUIC, SRT and MoQ

Choose a transport by asking one question: what happens to everything behind a lost packet

The robot drives out of the warehouse. Wi-Fi fades and the modem takes over. For two seconds nothing flows. Then the link comes back on a different interface with a different address. How long was the arm blind, and could the design have kept it shorter?

Failover is a sum of three times

Add up what the robot waits for. Detection: how long until the robot knows the path is dead. Switching: how long until a working path exists. Recovery: how long until the media is flowing again. The blind time is their sum.

Take toy numbers. A heartbeat every 100 ms and five missed beats means detection takes 500 ms. Setting up a new path with a fresh ICE round takes a few round trips; say 300 ms. Starting a video stream again takes a key frame, say 400 ms. Total: 1,200 ms, six times the 200 ms deadman. The arm will stop. That is correct: the deadman is there for this.

The way to shorten the blind time is to avoid failover. Keep both interfaces up and send the small control stream on both at once. The receiver uses whichever copy arrives first and drops the duplicate. Count the price. A 40 kbit/s control stream is 5,000 bytes a second, 18 MB per hour on the cellular link. Cheap. Video is too big to duplicate; it fails over.

Head-of-line blocking: the hidden cost of TCP

Many teams start with TCP, a WebSocket or RTMP because they work through every firewall. All three deliver bytes in order. If packet 5 is lost, packets 6 to 20 may arrive, but the application sees nothing until packet 5 is resent and arrives. That wait is head-of-line blocking. For a web page it is invisible. For live video or a control stream, everything behind the loss is stale by the time it is released.

Work it. The round trip is 100 ms, so a resend takes about 100 ms after the loss is noticed. At 30 frames per second a frame comes every 33 ms. A single lost packet holds back three more frames. Under steady loss, it happens again and again, and the buffer grows into seconds.

The options

QUIC (RFC 9000) runs over UDP and gives you many independent streams. A loss on one stream does not block the others. It also supports datagrams (RFC 9221): unreliable messages that are never retransmitted, but still counted by QUIC’s congestion control. A datagram is the right shape for “latest joint target wins”.

SRT (Secure Reliable Transport) is UDP with a time window for repairs. The receiver holds each packet for a fixed latency, 120 ms by default in live mode. If a packet is lost and the sender can resend it inside that window, the stream is repaired. If not, the receiver skips it (too-late packet drop, on by default in live mode). SRT is built for broadcast links with a known round trip.

MoQ (Media over QUIC Transport) is a publish and subscribe design over QUIC and WebTransport, with relays in the middle. It is a work in progress: at our check the datatracker showed draft-ietf-moq-transport at revision 23 on 2 November 2026, still an Internet-Draft, not an RFC. Treat it as a future option.

WebRTC’s own RTP is also a UDP design: lost video packets can be repaired with a NACK, a request to resend one packet, or skipped, and the receiver may ask for a new key frame with a PLI.

Choose a transport

Each bar is one frame of a two second stream. A tall bar is a late frame. A red mark is a frame that never arrived. Pick a transport, then raise the loss.

3%
100 ms

A toy model: 60 frames at 30 per second, one packet each, a 20 ms one-way base, losses drawn from a fixed seed. TCP resends after one round trip and holds all later frames. QUIC streams resend per frame. Datagrams never resend. SRT resends only if the repair fits in its 120 ms window (default in live mode, per the SRT socket options).

Look at TCP at 3% loss. A few lost frames drag many later frames into a tall block. QUIC streams pay only for the frame that was lost. Datagrams show red gaps and no delay. SRT shows a flat line at 120 ms plus the base, with small gaps once the round trip is too long to repair inside the window.

For a control stream the datagram wins, because a missed target is replaced by the next one. For video, a small repair window (SRT, or NACK in WebRTC) wins when the round trip is short. When the round trip is long, skipping is better than waiting.

python# control over QUIC datagrams (aioquic): a lost datagram is not retransmitted
def send_target(quic, joints):
    quic.send_datagram_frame(pack_cmd(seq=next_seq(), q=joints))   # ~100 bytes, 50 times a second

def on_event(ev):
    if isinstance(ev, DatagramFrameReceived):
        cmd = unpack_cmd(ev.data)
        if cmd.seq > last_seq: apply(cmd)               # ignore old or duplicate copies
A teleop console sends joint targets 50 times a second over a WebSocket. One packet is lost. What happens, and what is the better fit?

Chapter 6

SFU or P2P, Simulcast or SVC

Put a server in the middle so the robot uploads once, then keep the server from flipping quality up and down

One operator is fine. Now three people want the robot’s camera: the operator, a supervisor on a laptop and a trainer on a phone. The robot sits on 1.5 Mbit/s of uplink. How does it serve all three?

P2P: one copy per viewer

In a peer-to-peer design the robot opens a connection to each viewer and encodes and sends the video to each one. Count the cost. Three viewers at 1.5 Mbit/s each is 4.5 Mbit/s of uplink, three times what the link has. The robot also runs three congestion controllers, each fighting the others for the same radio.

SFU: upload once, the server fans out

An SFU (selective forwarding unit) is a server that receives each stream once and forwards copies to the viewers. It does not decode the video. It looks at the packet headers and decides who gets what. The robot sends one stream, 1.5 Mbit/s, and the SFU does the rest.

An SFU can also do work for a poor viewer. Discord describes its own SFU in its engineering write-up: it forwards audio and video inside a channel, drops the audio of users a moderator has server-muted, and reads the RTCP receiver reports to tell senders how much bandwidth is available. At the time of writing in 2018, Discord reported more than 2.6 million concurrent voice users, more than 220 Gbit/s of egress, 120 million packets per second and more than 850 voice servers in 13 regions. That is the scale this design reaches. Your robot fleet is far smaller, and the same ideas apply in miniature.

The trade-off is plain. The SFU adds one hop, which costs milliseconds, as the relay in Chapter 1 did. In return the robot uploads once and every viewer gets a stream that fits that viewer’s own link.

Simulcast and SVC: one picture, several sizes

Different viewers have different links. The supervisor on a laptop can take a large picture. The trainer on a phone cannot. The SFU needs more than one quality to choose from. Two designs give it that.

Simulcast makes the robot encode the picture several times at once, for example a small, a medium and a large stream. The SFU forwards the one that fits each viewer. The cost is the robot’s uplink and encoder: all three streams are sent.

SVC (scalable video coding) makes the robot encode one stream built in layers. The W3C names the layering modes. In L3T3, there are three spatial layers (each with half the width and height of the next, a 2:1 ratio) and three temporal layers (frame-rate steps). Each higher layer depends on the lower ones. The SFU drops the top layers for a weak viewer and nothing needs re-encoding.

Pick the layer

The purple line is the viewer’s bandwidth estimate. The bands are three layers. The orange line is the layer the SFU forwards. Turn hysteresis on and off and count the switches.

Illustrative values: layers of 0.15, 0.5 and 1.2 Mbit/s, a 15% headroom on the estimate, a 300 ms freeze to wait for a key frame at each simulcast switch and 50 ms at each SVC switch. The wobble is a fixed sum of two sines, standing in for a Wi-Fi link.

Without hysteresis, the layer follows every wobble in the estimate. The picture goes sharp, soft, sharp. In simulcast each flip also costs a freeze, since the SFU can only switch cleanly at a key frame of the new stream. With hysteresis (go down at once, go up only after the estimate has held a higher value for two seconds) the layer settles. You give up a little sharpness for a steadier picture.

pythondef pick_layer(est_bps, layers, cur, held_s):
    budget = 0.85 * est_bps                         # headroom
    fit = max([i for i, bps in enumerate(layers) if bps <= budget], default=0)
    if fit < cur:  return fit, 0.0                  # go down at once
    if fit > cur and held_s >= 2.0: return cur + 1, 0.0   # go up slowly, one step
    return cur, (held_s + 0.1) if fit > cur else 0.0

Who decides: the server or the viewer

An estimator that lives at the SFU sees the path to one viewer, but a dip at the viewer’s own Wi-Fi may look different from the SFU. A common fix is to let the viewer ask for a layer, or to give the viewer a say. Either way the rule from the chart holds: change slowly upward, quickly downward.

For a robot, the key viewer is the operator. Give the operator a stream that is never switched by guesswork: pin the operator to a fixed layer with a floor, and let the other viewers be the ones the SFU adapts. This is the same idea as the floor in Chapter 4, applied to the one person who must see.

The SFU flips a viewer between layers every few seconds after small dips in the estimate. What is the standard remedy?

Chapter 7

Debugging the Link

Read the counters the link already keeps, and capture at both ends so you know where the time went

The operator says the arm feels laggy. You run ping to the robot. It shows 12 ms. The link looks perfect and the arm is still laggy. What did the ping not see?

It did not see the camera, the encoder, the jitter buffer or the decoder. It also used a different packet type on a different queue. A ping is the wrong tool for a media link. The link itself keeps better counters. They arrive in a stream called RTCP.

RTCP: the link reports on itself

RTP carries the media packets. Its partner RTCP carries reports about them (RFC 3550). By default RTCP uses about 5% of the session bandwidth. The sender sends a sender report. The receiver answers with a receiver report. WebRTC for the Curious lists what the receiver report holds: the fraction of packets lost, the cumulative packets lost, the highest sequence number received, the interarrival jitter and the time of the last sender report.

Jitter, defined

Take two packets. The sender stamps them with times Si and Sj. The receiver notes arrival times Ri and Rj. RFC 3550 defines D(i,j) = (Rj − Ri) − (Sj − Si). This is the same quantity you met in Chapter 2: how much later the second packet arrived compared with how far apart they left. The receiver then keeps a running average of its size:

J
The interarrival jitter, a smoothed average of how uneven the packet spacing is.
|D|
The size of the spacing error for the newest pair of packets, in the same units as J.
16
The smoothing factor from RFC 3550: each new packet moves J by one sixteenth of the gap.

J = 0, then |D| = 8 ms → J = 0 + (8 − 0)/16 = 0.5 ms → next |D| = 8 ms → J = 0.5 + (8 − 0.5)/16 = 0.97 ms

Jitter is a mean of the size of the error, so a rare big spike moves it slowly. One 150 ms burst adds only 150/16 = 9.4 ms to J. You can read the jitter in the report and still miss the stall. That is why a counter is not enough; you also want the packets themselves.

Read the RTP stream

Top ticks: when the sender sent each packet. Bottom ticks: when it arrived. The line below is the running jitter J. Raise the jitter, add loss, or release a burst after a stall.

6 ms
0%

Illustrative: 60 packets, 20 ms apart, a 20 ms base delay, jitter drawn from a fixed seed. J follows the RFC 3550 formula in milliseconds; in the report it is stored in RTP timestamp units (90 kHz for video, so 1 ms is 90 ticks).

Round trip from the reports

The receiver report carries the time of the last sender report it saw (LSR) and how long it held before answering (DLSR). When the report arrives at time A, the sender computes RTT = A − LSR − DLSR (RFC 3550). Try it. A = 10.500 s, LSR = 10.400 s, DLSR = 0.040 s. Then RTT = 10.500 − 10.400 − 0.040 = 0.060 s, or 60 ms. The receiver’s own delay is subtracted, so only the wire is left.

One-way delay needs matching clocks

A round trip tells you the sum of both directions. The two directions are often unequal. Uplink Wi-Fi in a warehouse is usually worse than the downlink. To see one direction you must compare a send time on one machine with an arrival time on another. That is only meaningful if the two clocks agree to within a millisecond or two. Clock synchronisation is its own topic in the real-time track; for now, remember that a one-way number from unsynchronised clocks is not a measurement.

Capture at both ends

When counters disagree, take a packet capture (pcap) on the robot and another on the operator’s machine, at the same time. Open both in Wireshark. Its RTP stream analysis shows delta, jitter and lost packets per stream. Match one packet by sequence number in both files. The gap between its send time and arrival time, on synchronised clocks, is the one-way delay. If the packet is on the robot’s capture and missing on the other, the network dropped it. If both ends show it on time, the delay is inside an application.

shell# robot: capture the RTP port while the problem happens
sudo tcpdump -i wlan0 -w robot.pcap udp port 5004
# operator laptop: the same, at the same time
sudo tcpdump -i en0 -w op.pcap udp port 5004
# then in Wireshark: Telephony > RTP > RTP Streams > Analyze

The budget, stage by stage

Capture and playback add up, and the network is only one line. Transitive Robotics measured a typical stack: about 100 ms for the camera and its USB bus, about 10 ms to encode, about 7 ms of jitter buffer on a local link (10 ms through a relay), and about 10 ms to decode. A local WebRTC link came to about 130 ms from lens to screen and the relay case to 170 ms. When the operator reports lag, find which line moved.

Ping to the robot shows 12 ms but the operator says the video lags. What is the best next measurement?

Chapter 8

Field Guide

Keep the numbers, the checklist and the estimator in one place, and see where this link sits in the field

Here is the lesson in one paragraph. A teleop link runs on networks you do not own, so it will degrade. WebRTC finds a path with ICE and falls back to a relay when it must. GCC reads the growth of delay as congestion and cuts the rate, which a Wi-Fi stall can fake. Routers with a short queue help most. A bit-rate floor keeps the picture, a separate prioritised flow keeps the arm moving, and a deadman on the robot stops it safely when all else fails. Pick transports by what happens behind a lost packet. Debug with RTCP and captures at both ends. Go back to the instrument and try the three defences once more.

The numbers, with their sources

QuantityValueSource
Wi-Fi beacon interval, common default100 TU = 102.4 msWikipedia, Beacon frame
ICE check pacing Ta50 msRFC 8445
ICE type preferenceshost 126, peer-reflexive 110, server-reflexive 100, relayed 0RFC 8445
Relay cost, measured130 ms local, 170 ms through a relay (30 ms ping)Transitive Robotics
Stage costs, measuredabout 100 ms camera and USB, 10 ms encode, 10 ms decode, 7 to 10 ms jitter bufferTransitive Robotics
GCC feedback intervalonce per frame, or at least every 30 ms for audio; up to 100 msdraft-ietf-rmcat-gcc-02
Detector start and timingthreshold 12.5 ms, over-use after 10 msdraft-02; libwebrtc
Trendline constantssmoothing 0.9, gain 4, sample cap 60, k up 0.0087, k down 0.039, clamp 6 to 600libwebrtc trendline_estimator.cc (window 20 is our model setting)
Rate rulesdecrease to 0.85 of received rate; increase at most 8% per second; cap 1.5 times receiveddraft-ietf-rmcat-gcc-02
Loss rulesunder 2%: ×1.05; 2 to 10%: hold; over 10%: ×(1 − 0.5p)draft-ietf-rmcat-gcc-02
CoDeltarget 5 ms, interval 100 msRFC 8289
L4S queuesub-millisecond average queuing delayRFC 9332 (Jan 2023)
DSCP for WebRTCaudio EF 46; interactive video AF41/AF42; data AF21; least effort LE 1RFC 8837
RTCP share and jitter5% of session bandwidth; J moves 1/16 per packetRFC 3550
SRT default latency120 ms in live modeSRT socket options
MoQ transportInternet-Draft, revision 23 on 2 Nov 2026; not an RFCIETF datatracker
L3T33 spatial layers (2:1), 3 temporal layers, inter-layer dependencyW3C WebRTC SVC extension
Discord SFU (2018)more than 2.6 M voice users, 220 Gbit/s, 120 Mpps, 850+ serversDiscord engineering blog

The teleop link checklist

  1. Know the path. Log which ICE pair won, every session. Plan for a relay.
  2. Remove the cause. Turn Wi-Fi power save off on the robot. Pick a router with a modern AQM when you can.
  3. Floor the video. Set a minimum bit rate below the real worst-case capacity, so you never become the queue.
  4. Lane the control. Own flow, unreliable and unordered, DSCP marked, priority queue inside the robot.
  5. Deadman the arm. The robot stops itself when commands stop. Test it by pulling the cable.
  6. Duplicate the tiny stream across two interfaces; fail the video over.
  7. Measure with two captures, RTCP and matching clocks. Never trust a ping.

The core as code

This is the estimator of Chapter 2 in about thirty lines of Python, close to what the hero chart runs. Feed it one packet group at a time.

pythonclass Gcc:
    def __init__(self, rate):
        self.rate, self.acc, self.sm, self.hist = rate, 0.0, 0.0, []
        self.th, self.n, self.t_over, self.prev_tr, self.hold_until = 12.5, 0, 0.0, 0.0, 0.0

    def on_group(self, t_recv, d_ms, recv_rate, now):
        # d_ms = (t_recv - prev_recv) - (t_send - prev_send)
        self.acc += d_ms; self.sm = 0.9 * self.sm + 0.1 * self.acc; self.n += 1
        self.hist = (self.hist + [(t_recv, self.sm)])[-20:]
        tr = slope(self.hist) if len(self.hist) == 20 else 0.0   # least squares, ms per ms
        m = min(self.n, 60) * tr * 4                                # modified trend
        if abs(m) <= self.th + 15:                                # adapt the threshold
            k = 0.039 if abs(m) < self.th else 0.0087
            self.th = min(600, max(6, self.th + k * (abs(m) - self.th) * min(100, max(10, d_ms))))
        if m > self.th:
            self.t_over += 10
            if self.t_over > 10 and tr >= self.prev_tr:             # over-use: multiplicative decrease
                self.rate = 0.85 * recv_rate; self.hold_until = now + 0.3; self.t_over = 0.0
        else:
            self.t_over = 0.0
            if now >= self.hold_until:                            # increase, at most 8% per second
                self.rate = min(self.rate * 1.08 ** 0.01, 1.5 * recv_rate)
        self.prev_tr = tr
        return max(self.rate, FLOOR_BPS)                         # the bit-rate floor

Where it sits in the field

This lesson covers the robot’s own link: one sender, one or a few viewers. Large media systems, such as a SFU serving many thousands of rooms, are a different course. In the 78 robotics job postings we surveyed while planning this track, WebRTC, RTP, QUIC or SRT appeared in 6, two of them from media companies. That is our own small count, not a measure of the industry. Two open areas to watch are learned bandwidth estimation (a model replaces the hand-built filter) and AV1 scalable coding. Neither is settled, and we did not evaluate them here.

Keep going

Sources used: the Google Congestion Control draft (draft-ietf-rmcat-gcc-02, July 2016) and the libwebrtc trendline estimator source; Carlucci, De Cicco, Holmer and Mascolo, Analysis and design of the Google congestion control for WebRTC, MMSys 2016; RFCs 3550, 5764, 8289, 8298, 8445, 8656, 8698, 8831, 8837, 9000, 9221, 9330, 9331 and 9332; the SRT socket options reference; the IETF datatracker for MoQ transport; the W3C WebRTC SVC extension; WebRTC for the Curious; Transitive Robotics, WebRTC latency: a breakdown; the Discord engineering blog. Every sender model on this page is our own illustration. Wi-Fi power-save behaviour is described from general sources and not measured here; the idea that job postings ask for lower bit rate, prioritised control and a safe fallback comes from public teleop job postings we read while planning, which we did not re-open.

The takeaway. On a network you do not own, you cannot stop the link from degrading. You can decide how it degrades: a floor so the picture stays, a lane so the arm moves, and a deadman so a failure is safe.

Now press Present or Teach and explain the link out loud: how ICE finds a path, how GCC reads delay, why a stall fools it, and where you would put the floor, the lane and the deadman. Then go back to the instrument and break it once more.

Which set of three defences does this lesson recommend against a delay spike that makes GCC cut the rate and freezes the arm?
Networks You Do Not Own: WebRTC, GCC and the Teleop Link
Read the GCC draft · Back to low-latency video