The Transport Layer: UDP and TCP

Learn how the transport layer turns the internet's best-effort delivery between hosts into communication between application processes. See how port numbers deliver each segment to the right socket, what UDP adds to IP and when an application should choose it, and how a reliable protocol is built step by step from checksums, acknowledgments, sequence numbers, timers and sliding windows, with go-back-N and selective repeat. Then follow TCP in detail: its segment format, byte-based sequence and acknowledgment numbers, the handshake and connection teardown, round-trip time estimation and timeouts, retransmission and fast retransmit, and flow control with the receive window.

IntermediateLesson 3 of 8 in Computer Networks Course

What you will learn

  1. Describe the services the transport layer adds on top of the network layer, and trace how each arriving segment reaches the right application process through port numbers and sockets.
    • Describe transport-layer services and their limits
      Explain how the transport layer turns host-to-host delivery into process-to-process communication, and compare what TCP and UDP offer applications.
    • Deliver segments to the right socket with ports
      Use port numbers to explain multiplexing and demultiplexing, and identify which socket receives a UDP or TCP segment.
  2. Read the UDP header, compute and check its checksum, and decide for a given application whether UDP's minimal service is a better choice than TCP.
    • Read the UDP header and compute its checksum
      Interpret the four fields of the UDP header and compute the Internet checksum with one's complement arithmetic.
    • Decide when UDP is the right transport
      Weigh UDP's speed and control against its lack of reliability, flow control and congestion control, and match the transport protocol to the needs of an application.
  3. Design, step by step, a protocol that delivers data correctly over a channel that corrupts and loses packets, then make it efficient with pipelining using go-back-N and selective repeat.
    • Recover from bit errors with acknowledgments and sequence numbers
      Build a stop-and-wait protocol for a channel that corrupts bits, and explain why it needs checksums, acknowledgments, retransmissions and sequence numbers.
    • Handle packet loss with timers and measure stop-and-wait performance
      Add a countdown timer to cope with lost packets, trace the alternating-bit protocol through loss scenarios, and calculate why stop-and-wait wastes a fast link.
    • Pipeline packets with go-back-N
      Trace the go-back-N sender and receiver with cumulative acknowledgments and a single timer, and explain its window-size limit.
    • Retransmit only lost packets with selective repeat
      Trace selective repeat with individual acknowledgments, per-packet timers and receiver buffering, explain its stricter window limit and compare it with go-back-N.
  4. Describe the TCP connection and segment format, work out sequence and acknowledgment numbers in a byte stream, and trace how connections are opened and closed.
    • Describe TCP's connection and segment structure
      Explain what a TCP connection is, how TCP treats application data as a byte stream, and what each field of the TCP header is for.
    • Number bytes with sequence and acknowledgment numbers
      Work out the sequence and acknowledgment numbers of segments in both directions of a connection, including out-of-order arrivals and wraparound.
    • Open and close TCP connections
      Trace the three-way handshake and connection teardown with sequence numbers and states, and explain TIME_WAIT, resets and SYN flooding.
  5. Estimate the round-trip time and set TCP's timeout, trace how TCP detects and repairs losses, and use the receive window to keep the sender from overflowing the receiver's buffer.
    • Estimate round-trip time and set the timeout
      Compute TCP's smoothed round-trip time, its variation and the retransmission timeout, and explain how the timeout grows after a loss.
    • Trace TCP's retransmissions and acknowledgments
      Follow TCP's sender and receiver through lost, delayed and duplicated acknowledgments, apply its acknowledgment rules and use fast retransmit.
    • Prevent receive-buffer overflow with flow control
      Compute the receive window, apply the sender's limit on unacknowledged data, and explain zero windows, window scaling and the throughput limit a window sets.

Transport Layer study guide

5 chapters

1

From hosts to application processes

A host can run a browser, a call and a file transfer at the same time. Each application needs its own data even though they share a network interface. Transport protocols provide that process-level service above IP. Follow a segment from the sending socket to the receiving socket, then use ports and addresses to distinguish UDP delivery from the separate connections a TCP server maintains.

1.1 What TCP and UDP add to IP

An application sends through a socket, the interface between its process and the transport layer. The transport layer makes processes on different hosts appear to communicate directly. This is logical communication: the data still crosses links and routers, but the application works through its local socket.

Follow the data through the layers

At the sender, the transport protocol takes application data, divides it into chunks when needed and adds a transport header. The resulting segment goes to IP. IP adds its own header, producing an IP datagram for the network to carry. At the destination, IP hands the segment to the transport protocol, which interprets the transport header and delivers the data to a socket.

The protocol logic runs in the end hosts. Ordinary routers forward IP datagrams; they do not perform TCP acknowledgment and retransmission on behalf of the applications. Think of an IP address as a building's address and the receiving socket as the intended recipient inside. Getting a letter to the building and getting it to the right person are separate jobs.

IP offers best-effort host-to-host delivery. Datagrams can be lost, duplicated, reordered or corrupted. Transport extends delivery to processes, and it may add mechanisms that repair these failures.

Compare the services
ServiceUDPTCP
Communication styleIndependent messagesConnection with a byte stream
Reliable, in-order deliveryNoYes
Receiver flow controlNoYes
Network congestion controlNo built-in mechanismYes
Maximum delay or minimum throughputNo guaranteeNo guarantee
Encryption by itselfNoNo

UDP, the User Datagram Protocol, adds ports and an error check to IP's delivery. A segment can arrive without any earlier setup exchange. UDP does not recover a lost segment or hold a later segment until an earlier one arrives.

TCP, the Transmission Control Protocol, sets up connection state before normal data transfer. It numbers bytes, checks for errors, obtains acknowledgments and retransmits missing data. The receiving application gets a reliable, in-order byte stream. Flow control protects its buffer; congestion control responds to network load.

Reliability does not make the network underneath reliable. If an IP datagram disappears, TCP sends another copy of the missing data. If later bytes arrive first, the receiver can hold them until the gap is filled. The application sees repaired delivery, but it may wait longer. Neither TCP nor UDP can promise a delivery deadline or reserve network capacity merely by running over best-effort IP.

Choose the service at the socket

A stream socket normally selects TCP; a datagram socket selects UDP. HTTP/1.1 and HTTP/2, SMTP email transfer and SSH remote login use TCP. Ordinary DNS queries commonly use UDP. HTTP/3 uses QUIC over UDP: QUIC supplies reliable streams and security above UDP's minimal service.

A TCP connection alone does not keep a password secret. TLS adds encryption and authentication above TCP; QUIC integrates TLS into its design. Reliability answers whether bytes reach the application correctly and in order. Confidentiality answers whether an observer can read them.

Key Takeaways

  • IP delivers between hosts; transport delivers between application processes.
  • TCP repairs loss and ordering at the end hosts.
  • UDP provides message delivery without built-in recovery or flow control.
  • Neither TCP nor UDP alone guarantees a deadline, throughput or encryption.

1.2 Ports and socket selection

A host often has many sockets open. Multiplexing gathers outgoing data from those sockets and adds transport headers. Demultiplexing selects the receiving socket for each arriving segment.

Read the addressing information

Both TCP and UDP carry a 16-bit source port and a 16-bit destination port. Values run from 0 to 65,535. The destination port identifies the receiving service; the source port helps the peer address its reply. IANA groups ports as system ports 0–1023, user ports 1024–49151 and dynamic ports 49152–65535.

Servers listen on agreed ports: SSH uses 22, SMTP 25, DNS 53, HTTP 80 and HTTPS commonly 443. Clients usually get a temporary, ephemeral port from the operating system. Its configured range need not equal IANA's dynamic range: a common Linux default is 32768–60999, while Windows commonly uses 49152–65535.

For an arriving IP datagram, the host first identifies the transport protocol. IPv4 protocol value 6 means TCP and 17 means UDP; IPv6 identifies the upper-layer protocol through its Next Header chain. TCP port 53 and UDP port 53 belong to different transport namespaces. The receiver then uses addresses and ports to select a socket and queues the data for the application.

UDP: many clients, one receiving socket

In the basic unconnected UDP server model, the receiving socket is selected by destination IP address and destination port. Different clients can all send to that same socket.

A server at 203.0.113.53 listens on UDP port 53. Requests from 198.51.100.7:51000 and 192.0.2.44:62011 reach this one server socket. The first reply travels from 203.0.113.53:53 to 198.51.100.7:51000. The application obtains each request's source address and port so that it can reply to the right client. A connected UDP socket can also restrict the peer it receives from; no UDP handshake is added.

TCP: distinguish connections by four values

A TCP server has a listening socket and separate connection sockets. A connection is identified by the four-tuple of source IP, source port, destination IP and destination port.

For a server at 203.0.113.10:80, these are different connections:

  • 198.51.100.7:50312 → 203.0.113.10:80
  • 198.51.100.7:50313 → 203.0.113.10:80
  • 192.0.2.44:50312 → 203.0.113.10:80

The first two differ in source port. The first and third share a source port but differ in source address. All three use server port 80. A separate server port per client is unnecessary because the full four-tuple distinguishes their connection sockets. One process can handle many such sockets.

When no socket matches

A SYN sent to a closed TCP port normally receives a reset, with the RST flag set. A UDP segment sent to a port with no receiver normally triggers an ICMP “port unreachable” message. Firewalls, filtering and response limits can affect what returns. In a port probe, SYN-ACK is evidence of a listening TCP service; RST indicates refusal. Silence alone cannot distinguish filtering from loss or a host that is unavailable.

Key Takeaways

  • Multiplexing combines outgoing socket traffic; demultiplexing selects a receiving socket.
  • Port numbers have 16 bits and belong to a transport protocol.
  • A basic UDP server can receive many clients through one socket.
  • TCP distinguishes connection sockets with both IP addresses and both ports.
  • Closed TCP and UDP ports normally produce different responses.
2

UDP messages, checksums and application choices

UDP keeps the transport service small: a short header, delivery to a socket and a checksum. That simplicity is useful when an application wants control over message timing, but it leaves recovery and rate management to the application or a protocol above UDP. Read the header and work through wraparound checksum addition, then judge an application by its deadlines and delivery needs instead of treating every real-time service as the same case.

2.1 The UDP header and Internet checksum

UDP sends each message independently, with no handshake or shared connection sequence state. Its fixed 8-byte header contains four fields, each 16 bits wide: source port, destination port, length and checksum.

Count the correct bytes

The length covers the UDP header plus its data. It is at least 8 bytes. A message with 40 data bytes has UDP length 48. With a 20-byte IPv4 header and no IP options, the complete IP datagram is 68 bytes. The IP header is outside the UDP length.

The checksum detects some bit errors across the UDP header and data. It also covers a pseudo-header built from IP addressing information, the protocol number and UDP length. Those values help detect a segment delivered under the wrong addressing information. The pseudo-header is calculation input; it is not an extra transmitted part of the UDP header.

Add with end-around carry

Treat the calculation input as 16-bit words. Set the checksum field to zero while computing. Add the words, wrapping any carry beyond bit 16 back into the low end. This is one's complement addition. Finally flip all 16 bits of the folded sum to obtain the checksum. If the byte count is odd, append a zero byte for the calculation only.

For three illustrative words, use hexadecimal to make the carry visible:

  1. Add A35C and 69C3 to get 10D1F. The leading 1 is a carry outside 16 bits.
  2. Fold it back: 0D1F + 1 = 0D20.
  3. Add 1234: 0D20 + 1234 = 1F54.
  4. Complement every bit: FFFF − 1F54 = E0AB.

The checksum is E0AB. Simply dropping the leading carry would give the wrong sum. In binary, the final sum is 0001 1111 0101 0100 and its complement is 1110 0000 1010 1011.

Check at the receiver

The receiver repeats the folded addition over the pseudo-header and received segment, now including the checksum field. An unchanged segment gives all ones, FFFF. Here, 1F54 + E0AB = FFFF. A result containing a zero bit detects an error. UDP silently discards a segment whose supplied, nonzero checksum fails; it does not send a replacement or repair the data.

All ones means that the check passed, not that every possible error was excluded. Compensating changes in different words can leave the sum unchanged. The checksum detects errors; it neither locates the bad bits nor corrects them.

Why the end hosts check again

A link check protects a particular link. Some links may lack that check, and corruption can also happen inside equipment between links. An end-to-end check tests what reached the destination host. This illustrates the end-to-end principle: a property needed across the full path must be checked at its endpoints.

Over IPv4, a zero UDP checksum field signals that the sender omitted the checksum. A computed checksum of zero is transmitted as all ones to preserve this distinction. IPv6 normally requires a UDP checksum, with narrowly specified tunnel exceptions. TCP also uses an Internet checksum with a pseudo-header, and requires its checksum.

Key Takeaways

  • UDP length includes its 8-byte header and excludes the IP header.
  • Fold each carry into the low 16 bits, then complement the sum.
  • A receiver checksum sum of all ones means the check passed.
  • UDP discards a segment with a failed nonzero checksum without retransmitting it.
  • The checksum can miss errors and cannot correct them.
  • An IPv4 checksum field of zero means the UDP checksum was omitted.

2.2 Choose UDP by the application’s needs

UDP's small service gives an application control over its messages. There is no transport handshake before the first message, no UDP retransmission queue and no UDP mechanism that holds later data behind a missing earlier message. The application decides what to send and which losses matter.

Match recovery to useful arrival time

Consider voice audio sent in 20 ms chunks: 50 messages per second. A missing chunk is due for playback in 60 ms, but detecting the loss and obtaining another copy takes about 150 ms. That recovered chunk would arrive too late. A voice application can play later chunks on time and conceal the missing sound, for example by smoothing the gap.

The decisive quantity is time remaining before playback, not the 20 ms duration of one chunk. If recovery can finish before the deadline, retransmission may help. TCP must deliver bytes in order, so a missing earlier byte can also delay delivery of later bytes already received. This wait is often called head-of-line blocking within the stream.

A file transfer has a different priority: every byte must arrive correctly, and waiting for recovery is acceptable. TCP already provides that service. Using UDP would move the work of detecting loss, requesting replacement data and restoring order into the application or another protocol.

What the small header buys

UDP's header is 8 bytes; TCP's is at least 20. A UDP server can receive messages from many clients without setting up per-client transport connections. There are still socket buffers and application resources, so “connectionless” does not mean that the host stores nothing.

Common UDP uses include ordinary DNS queries on port 53, NTP time synchronization on 123, SNMP management on 161 and DHCP address assignment on 67 and 68. Calls and games often choose UDP for timely messages. On-demand video commonly uses HTTP over TCP or QUIC, so “video uses UDP” is too broad a rule.

QUIC shows how much a protocol can add above UDP: reliable streams, congestion control and TLS 1.3 security. It was standardized in 2021 and commonly uses UDP port 443; HTTP/3 runs over QUIC. UDP itself has not acquired those services.

Keep messages small enough

UDP preserves message boundaries. A receive operation reads one message, not a byte stream assembled from several sends. The application must supply a large enough read buffer; a smaller buffer can truncate the message.

For IPv4 with a 20-byte IP header, the theoretical maximum payload is 65,535 − 20 − 8 = 65,507 bytes. Sending near that limit may require IP fragmentation. On a path supporting 1,500-byte IPv4 datagrams, 1,500 − 20 − 8 = 1,472 data bytes fit without fragmentation when there are no IP options. Other paths and headers can reduce that value.

Account for the missing controls

UDP has no built-in flow control to protect a slow receiver. If its socket buffer fills, arriving messages can be dropped. It also lacks built-in congestion control. Responsible UDP applications provide suitable rate control so that they do not overwhelm a shared path. Some networks filter UDP, so applications may need a fallback.

Skipping setup and recovery can reduce delay, but UDP does not increase a link's capacity or prevent IP loss. Judge the whole application protocol: the work it adds above UDP can matter more than the header size.

Key Takeaways

  • Choose recovery by whether the recovered data can still be used.
  • UDP preserves messages but supplies no loss recovery or ordering.
  • Applications above UDP must handle receiver capacity and network load.
  • QUIC supplies reliable, secure streams above UDP.
3

Build reliability and keep data in flight

A reliable protocol needs evidence about what arrived and a plan for what to do when that evidence is missing. Start with a channel that flips bits, then add packet loss and delayed feedback. Once correctness is in place, calculate how much time stop-and-wait leaves a sender idle. Sliding windows let several packets travel at once; go-back-N and selective repeat make different choices about acknowledgments, buffering and retransmission.

3.1 Checksums, feedback and duplicate detection

A reliable data transfer protocol gives the receiving application correct data, in order and without duplicates, even when the channel below it damages packets. Build the design by asking what can go wrong at each stage. For these protocols, application data moves one way and control feedback travels back.

Describe behavior with states

A finite-state machine (FSM) records the sender's or receiver's current state. Each transition has a triggering event and the actions to perform. A state such as “waiting for ACK 0” captures what evidence the sender needs before moving on. In FSM notation, Λ marks no event or no action; a dashed incoming arrow marks the initial state.

With a perfectly reliable channel, version 1.0 needs only sending and delivery. The sender packages data, the receiver extracts it, and neither needs feedback. Adding bit errors changes the design.

Detect an error and ask for another copy

Version 2.0 uses three mechanisms:

  • A checksum lets the receiver test a packet for corruption.
  • An ACK reports successful receipt; a NAK reports damaged data.
  • Retransmission sends another copy when needed.

Together these form automatic repeat request (ARQ). The sender sends one packet and waits for feedback before sending the next: stop-and-wait. It keeps a copy of the current packet because it may need to resend it.

But feedback packets cross the same unreliable channel. A damaged ACK leaves the sender unsure: did the receiver accept the data, or is another copy needed? Resending is safe only if the receiver can distinguish a replacement copy from fresh application data. A checksum alone does not identify duplicates; two valid copies have the same valid contents.

Give each outstanding packet an identity

Version 2.1 adds a sequence number. With only one packet outstanding, a one-bit number alternating 0, 1, 0, 1 is sufficient in this stop-and-wait channel model. The receiver remembers which number it expects. It delivers a valid packet with that number once and then changes its expectation. A packet with the previous number is a duplicate: acknowledge it again, but do not deliver its data again.

The sender retains the current number while retransmitting. It advances to the other number only after the matching, readable ACK. Corrupted feedback or a NAK causes a retransmission in this error-only design.

Replace NAKs with repeated ACKs

Version 2.2 removes NAKs. The receiver responds to a damaged or duplicate packet with an ACK for the last packet it accepted. The ACK therefore needs a number.

Suppose packet 0 carries “A” and arrives correctly. The receiver delivers “A” and sends ACK 0. Packet 1 carrying “B” is corrupted, so the receiver repeats ACK 0. The sender is waiting for ACK 1; this duplicate ACK signals that it should resend packet 1. The valid replacement is delivered as “B” and acknowledged with ACK 1.

Discarding duplicate data and acknowledging the duplicate packet are different actions. If the receiver silently ignored a replacement whose earlier ACK was unreadable, the sender could never learn that delivery had succeeded. TCP also avoids NAKs, although its byte numbering and fast-retransmit rules differ from this simple protocol.

Key Takeaways

  • A checksum detects corruption but cannot identify a duplicate by itself.
  • ARQ combines error detection, receiver feedback and retransmission.
  • Stop-and-wait keeps one data packet outstanding.
  • Alternating sequence numbers let the receiver deliver each packet once.
  • A duplicate is acknowledged again without redelivering its data.

3.2 Timers and stop-and-wait efficiency

Feedback cannot help if it never arrives. When the channel can lose a data packet or an ACK, the sender needs a way to resume without receiving a message. Version 3.0 adds a countdown timer to the alternating-bit protocol.

Handle silence without delivering twice

The sender starts the timer whenever it sends the current packet, including a replacement. A matching, intact ACK stops the timer and permits the next packet. A corrupted ACK or an ACK with the wrong number is ignored. If the timer expires first, the sender resends the same packet and restarts the timer.

For a lost data packet, the receiver has nothing to acknowledge; timeout supplies the replacement. For a lost ACK, the receiver has already delivered the data. When the replacement arrives, the sequence number identifies a duplicate. The receiver discards its data and sends the ACK again.

A premature timeout occurs when the original packet or ACK was only slow. The replacement wastes transmission effort, but duplicate detection preserves correct delivery. A useful timeout must allow the expected round trip and receiver processing. Too short produces needless retransmissions; too long delays recovery from real loss.

Separate transmission time from waiting time

Let packet length be L bits and link rate be R bit/s. The sender needs L/R seconds to put one packet onto the link. Ignoring ACK transmission and processing time, one stop-and-wait cycle takes RTT+L/R. The fraction of time spent sending is

U=L/RRTT+L/R.

For 1,500-byte packets on a 1 Gbit/s link, first convert bytes to bits:

L=1,500×8=12,000 bits.

Then L/R=12 μs=0.012 ms. With an RTT of 40 ms,

U=0.01240.012≈0.000300.

The sender is active about 0.03% of the time. Throughput is about 12,000 bits every 0.040012 s, or 300 kbit/s. A very fast link still carries little useful traffic because the sender spends almost the entire cycle waiting.

Pipeline the packets

Pipelining allows multiple unacknowledged packets in flight. If up to N packets fit in the sending window, the ideal utilization becomes

U=min⁡(1,N(L/R)RTT+L/R).

With the same link, 1,000 packets give utilization about 0.30. To keep it fully busy requires at least 40.012/0.012≈3,334.33 packet transmission times, so round up to 3,335 packets. Rounding down leaves a small idle interval before the first ACK.

A larger pipeline needs enough sequence numbers to distinguish its packets and enough buffer space to retain unacknowledged data. The receiver may also need buffering, depending on the protocol. Go-back-N and selective repeat solve these design choices differently.

Increasing the link rate alone shortens the already brief transmission time. For a fixed packet size and RTT, it reduces stop-and-wait utilization. More data in flight is what lets the sender use the available capacity.

Key Takeaways

  • A timer allows progress when data or feedback is lost.
  • A premature timeout wastes capacity but sequence numbers prevent duplicate delivery.
  • Use bits for packet length when the link rate is in bit/s.
  • Stop-and-wait utilization is transmission time divided by the full cycle time.
  • Pipelining improves utilization by allowing several outstanding packets.
  • Round a required whole-packet window up, and cap utilization at 1.

3.3 Go-back-N windows and cumulative ACKs

Go-back-N (GBN) allows up to N sent but unacknowledged packets. The sender's sliding window moves forward when acknowledgments confirm delivery. The receiver stays simple: it accepts only the next packet in order.

Keep the sender's ranges separate

The variable base identifies the oldest unacknowledged packet. nextseqnum identifies the next new packet to send. Before sequence-number wraparound, the ranges are:

  • Below base: already acknowledged.
  • From base through nextseqnum − 1: sent, awaiting acknowledgment.
  • From nextseqnum through base + N − 1: available for new data.
  • At or above base + N: blocked until the window advances.

For base = 10, nextseqnum = 13 and N=5, packets 10–12 are outstanding. Packets 13 and 14 can be sent. Packet 15 cannot. A window limits outstanding data, not the total number of packets in a transfer.

Cumulative acknowledgments move the base

GBN ACK n confirms all packets through n. It moves base to n+1. One later cumulative ACK can therefore cover earlier ACKs that were lost. This numbering convention identifies the last accepted packet; TCP's ACK convention identifies the next expected byte.

GBN keeps one timer for the oldest outstanding packet. Sending the first outstanding packet starts it. An advancing ACK restarts it if data is still outstanding; acknowledgment of everything stops it. When the timer expires, the sender retransmits every packet that has been sent but remains unacknowledged. That number may be smaller than the maximum window N.

Trace a missing packet

Use a window of four and send packets 0, 1, 2 and 3. Packet 2 is lost. The receiver delivers 0 and 1 and sends ACK 0 and ACK 1. Packet 3 arrives beyond the gap: the receiver discards it and repeats ACK 1.

The first two ACKs open space for packets 4 and 5. They also arrive beyond missing packet 2, so both are discarded and answered with ACK 1. The sender's base remains 2. On timeout it retransmits 2, 3, 4 and 5. They now arrive in order and can all be delivered.

The copies of 3, 4 and 5 were intact the first time. GBN resends them because its receiver chose not to buffer out-of-order packets. That saves receiver state at the cost of extra traffic after a loss.

Leave one sequence number outside the window

A k-bit field provides 2k packet numbers, reused cyclically. GBN requires

N≤2k−1.

With three bits, the numbers are 0–7 and the largest sender window is seven. If all eight were allowed, the receiver could accept 0–7 and return to expecting 0. If all ACKs were lost, a retransmitted old 0 would then look new. With only 0–6 sent, the receiver instead expects 7 and can recognize the retransmitted 0 as old. Window arithmetic near wraparound follows the cyclic order, not ordinary numerical size.

Key Takeaways

  • GBN ACK n confirms every packet through n.
  • The receiver discards packets that arrive beyond a gap.
  • One timer tracks the oldest outstanding packet.
  • A timeout resends the sent, unacknowledged packets.
  • The largest GBN window with k-bit numbers is 2^k − 1.

3.4 Selective repeat and sequence-number reuse

Selective repeat (SR) saves correctly received packets even when earlier ones are missing. Each valid packet receives its own ACK. The sender can then replace just a packet whose timer expires.

Track each packet separately

The sender's window begins at send_base, the oldest unacknowledged packet, and contains N allowed sequence numbers. Each outstanding packet has a logical timer. An ACK marks that particular packet as received. An ACK beyond the base does not by itself move the window: the base stays at the first hole. Once that hole is acknowledged, the base skips past any following packets already acknowledged.

The receiver's window starts at rcv_base, the next packet needed for delivery. A valid packet inside the window is acknowledged. Out-of-order data is buffered. When the base packet arrives, the receiver delivers it and every consecutive buffered packet after it, stopping at the next gap.

A packet in the immediately preceding window is an old duplicate. The receiver acknowledges it again without delivering it. This rule is essential when the original ACK was lost: the sender may still be waiting even though the receiver has moved on.

Recover one loss

Use N=4 and let packet 2 be lost after the sender sends 0–3. The receiver delivers and acknowledges 0 and 1, then buffers and acknowledges 3. Those first two ACKs let the sender transmit 4 and 5. Both are buffered and individually acknowledged, but send_base stays at 2.

When packet 2's timer expires, only 2 is resent. Its arrival lets the receiver deliver 2, 3, 4 and 5 together and move rcv_base to 6. Once ACK 2 reaches the sender, its base also advances to 6, passing packets 3–5 whose ACKs it already holds.

Why the window is at most half the number space

The receiver may be ahead of the sender because ACKs are delayed or lost. New acceptable numbers must not overlap numbers that might still be retransmitted as old packets.

With two-bit numbers 0–3 and a window of three, suppose the receiver accepts 0, 1 and 2. Its new window is {3, 0, 1}. If all ACKs disappear, a retransmitted old 0 fits this window and looks new. The receiver cannot distinguish it from a genuinely new 0 sent after a lost 3.

For equal-sized sender and receiver windows, the safe bound is

N≤2k−1.

Three-bit numbering therefore allows SR windows up to four, while GBN permits seven.

FeatureGo-back-NSelective repeat
ACK meaningAll packets through nPacket n alone
Timer stateOne oldest-packet timerOne logical timer per packet
Out-of-order receiver actionDiscardBuffer and ACK
Timeout recoveryAll outstanding packetsThe timed-out packet
Distinguish an old copy after wraparound

Window limits handle the current windows, but a real network can also keep an old copy in transit until numbers are reused. A maximum packet lifetime bounds how long such copies can survive. TCP calls this the maximum segment lifetime (MSL). At high rates, TCP can reuse its 32-bit sequence space quickly, so timestamp-based Protection Against Wrapped Sequences (PAWS) helps reject stale data.

Key Takeaways

  • SR acknowledges and times each outstanding packet individually.
  • Out-of-order packets are buffered until the delivery gap is filled.
  • A later ACK marks receipt but the sender base stays at the first unacknowledged packet.
  • Old duplicates must be acknowledged again.
  • Equal SR windows may occupy at most half the sequence-number space.
  • Long-delayed copies also require protection when numbers are reused.
4

TCP segments, byte numbers and connections

TCP maintains a separate byte stream in each direction of a connection. Its header ties those streams to ports, identifies their bytes and carries acknowledgments and control signals. Read the segment format, then trace numbers through data transfer, setup and closing. Keeping the two directions separate makes piggybacked acknowledgments, half-closes and the extra sequence numbers used by SYN and FIN much easier to follow.

4.1 The TCP byte stream and segment header

A TCP connection is state held in two end hosts: buffers, byte counters and other variables created during setup. It is point-to-point, between two endpoints, and full-duplex, allowing both to send at once. Ordinary routers forward its IP datagrams without maintaining TCP's endpoint state.

Bytes have no message boundaries

TCP preserves the order of bytes, but not application write boundaries. Three writes of 100 bytes can reach the application in a single 300-byte read, or in reads of 50 and 250 bytes. An application that exchanges messages must provide framing, such as a length field or a delimiter. A short read does not establish that a complete message has arrived.

Application writes enter a send buffer. TCP chooses chunks to transmit, retaining unacknowledged data for possible retransmission. Incoming data enters a receive buffer until the receiving application reads it.

Size the data separately from the headers

The maximum segment size (MSS) limits application data in a segment. It excludes both TCP and IP headers. For a path supporting 1,500-byte IP datagrams with 20-byte IPv4 and 20-byte TCP headers,

MSS=1,500−20−20=1,460 bytes.

Options take more space, so a sender must allow for their actual header lengths. Each endpoint announces the MSS it can receive during the handshake; path limits may further restrict what can be sent. Without an MSS option, the default assumptions are 536 data bytes for IPv4 and 1,220 for IPv6.

Read the header fields
FieldSizePurpose
Source and destination ports16 bits eachIdentify the applications' endpoints
Sequence number32 bitsIdentify the first data byte
Acknowledgment number32 bitsName the next expected byte
Data offset4 bitsGive header length in 32-bit words
Receive window16 bitsAdvertise receiver capacity
Checksum16 bitsDetect errors with a pseudo-header
Urgent pointer16 bitsLocate urgent data when URG is set

The minimum header is five 32-bit words, or 20 bytes. A data offset of 8 means 32 bytes, including 12 bytes beyond the fixed header. The maximum offset is 15: 60 bytes total, allowing up to 40 bytes of options.

Interpret flags and options

SYN synchronizes sequence numbers during opening. FIN closes one sending direction. RST aborts or refuses a connection. ACK makes the acknowledgment field valid. PSH requests prompt delivery toward the application; it does not create a message boundary. URG makes the urgent pointer meaningful, although new applications are advised to avoid that mechanism. ECE and CWR carry explicit congestion-notification signals.

Common options include MSS, window scaling, timestamps and selective acknowledgment (SACK). Scaling extends the receive-window range. Timestamps help measure RTT and reject stale segments. SACK describes received blocks beyond a gap.

Without options, TCP plus IPv4 adds 40 bytes. A full 1,460-byte data segment occupies a 1,500-byte IP datagram, about 97.3% application data. A pure ACK has no data but still occupies those 40 header bytes.

Key Takeaways

  • TCP is a full-duplex, point-to-point byte stream.
  • Applications supply their own message framing.
  • MSS counts application data only; data offset counts 32-bit header words.
  • SYN, FIN and RST have different connection-management roles.
  • Options extend TCP without changing the fixed header fields.

4.2 Sequence numbers and the next expected byte

TCP sequence numbers count bytes, not segments. A segment's sequence number names its first data byte. Its acknowledgment number describes the opposite direction: the next byte that this sender expects to receive.

Split a stream into segments

An initial sequence number (ISN) of 3,000 is used by the SYN. The first data byte is therefore 3,001. A 10,000-byte file with an MSS of 1,460 needs six full data segments and one shorter segment:

SegmentFirst byteData bytes
13,0011,460
24,4611,460
35,9211,460
47,3811,460
58,8411,460
610,3011,460
711,7611,240

Each next sequence number adds the preceding segment's data length. The final byte is 13,000, so successful receipt of the whole file produces cumulative ACK 13,001.

Acknowledge a continuous prefix

ACK n confirms all bytes through n−1. It does not confirm byte n. If the receiver has bytes through 4,460, it expects 4,461. A segment starting at 5,921 leaves a gap. A receiver that buffers that segment still sends ACK 4,461 because its continuous prefix has not grown.

This is why the acknowledgment cannot simply be the largest sequence number observed. Later bytes show that something arrived beyond the gap; they do not fill it. When the missing range arrives, a cumulative ACK can jump over data already buffered.

Track both directions independently

Suppose a client's next byte is 1,000 and a server's next byte is 5,000. The client sends 200 data bytes with sequence 1,000 and acknowledgment 5,000. The server's reply carries 1,200 bytes with sequence 5,000 and acknowledgment 1,200. The client's next pure ACK has sequence 1,200 and acknowledgment 6,200.

The server did not derive its own sequence number from the request's length. Each direction has its own numbering. Carrying an ACK with outgoing data is piggybacking. A pure ACK consumes no sequence space; SYN and FIN each consume one number even without data.

Manage initial values and wraparound

Endpoints choose an ISN when opening a connection. A clock and a keyed pseudo-random function of the connection addresses and ports help separate a new connection from old delayed segments and make valid numbers difficult for an outsider to guess. Starting every connection at zero would weaken both protections.

The fields are 32 bits, so numbering wraps modulo 232, about 4.3 billion bytes. At 1 Gbit/s, cycling through that space takes about 34 s; at 10 Gbit/s, about 3.4 s. Timestamp-based PAWS provides an additional stale-segment check on fast paths.

For ordinary arithmetic away from wraparound, the next byte after a data segment is its sequence number plus its data length. When a SYN or FIN is present, include the one extra number that control flag consumes. Apply the calculation separately to each direction.

Key Takeaways

  • A segment sequence number identifies its first byte.
  • ACK n confirms bytes through n − 1 and names the next expected byte.
  • A gap keeps the cumulative ACK fixed even when later data is buffered.
  • Each direction has independent numbering.
  • Data, SYN and FIN consume sequence space; pure ACKs do not.
  • Sequence numbers wrap modulo 2^32.

4.3 Opening, half-closing and releasing a connection

TCP setup lets both endpoints announce a starting sequence number and learn that the peer received it. Closing later releases each direction separately. These control exchanges use the same sequence space as data.

Trace the three-way handshake
  1. The client creates connection state, sends SYN with ISN 7,000 and enters SYN_SENT.
  2. The server replies with SYN-ACK, sequence 21,000 and acknowledgment 7,001. It is in SYN_RCVD while waiting for confirmation.
  3. The client records the server's number and sends ACK with sequence 7,001 and acknowledgment 21,001. The client enters ESTABLISHED; the server does so when that ACK arrives.

Each SYN consumes one number. The third segment can already carry application data. The ordinary handshake costs one round trip before the client can send that first data. A two-message exchange would not tell the server that the client received its ISN and could leave it accepting a delayed old SYN as a fresh request.

At the socket interface, connect starts an active open. A server listens for requests, and accept returns a new connection socket after setup. The listening socket remains available for other clients.

Close each direction

An endpoint sends FIN when it has no more bytes to send. The peer acknowledges that FIN by advancing its ACK one beyond it. The peer can still send its own remaining bytes: this is a half-close. Its later FIN closes the other direction and needs an ACK too. Closing commonly uses four segments, although a FIN and ACK can be combined.

For a client that closes first, the usual state path is ESTABLISHED → FIN_WAIT_1 after sending FIN → FIN_WAIT_2 once that FIN is acknowledged → TIME_WAIT after receiving and acknowledging the peer's FIN → CLOSED. The peer passes through CLOSE_WAIT while its application finishes, then LAST_ACK after sending its own FIN, and finally CLOSED on receiving the ACK.

Keep the last ACK recoverable

In the usual active-close path, TIME_WAIT lasts twice the maximum segment lifetime. If the final ACK disappears, the other endpoint can resend its FIN and receive another ACK. Waiting also gives old segments time to expire before the connection's four-tuple is reused. The standard's MSL value of two minutes yields four minutes; implementations can use different durations, with 60 seconds a familiar Linux value.

An RST is different from FIN: it aborts the connection or refuses a request. A closed-port SYN normally receives RST. SYN-ACK indicates a listener; silence can result from filtering, loss or an unavailable destination.

Protect incomplete handshakes

A SYN flood sends many opening requests without completing them. A server that reserves resources for every half-open connection can exhaust its available state. SYN cookies delay allocating that per-connection state. The server encodes verifiable connection information into its chosen ISN using a secret and time-dependent input. A valid final ACK returns the cookie through its acknowledgment number, allowing the server to check it and create state. The server still has a listener and shared resources; it avoids storing an individual unfinished connection for every SYN.

Key Takeaways

  • The handshake confirms both initial sequence numbers.
  • SYN and FIN each consume one sequence number.
  • A FIN closes one direction; the peer may continue sending.
  • TIME_WAIT supports recovery of the final ACK and expiry of old segments.
  • RST aborts or refuses a connection.
  • SYN cookies reduce per-request state before the handshake completes.
5

TCP recovery and the receiver’s pace

An ACK can be delayed, a segment can disappear and the receiving application can stop reading. TCP needs separate responses to these events. RTT estimates guide how long to wait, duplicate ACKs can expose a gap before timeout, and the receive window reports available buffer space. Trace the sender's outstanding bytes alongside the receiver's stored bytes to see why a recovered connection can still have to wait before sending more data.

5.1 Measure RTT and choose a retransmission timeout

TCP needs a retransmission timeout long enough to allow normal round trips, but short enough to recover promptly from loss. RTT varies as queues and paths change, so the timeout follows both a smoothed estimate and the size of recent deviations.

Take an unambiguous sample

SampleRTT measures the interval from sending data to receiving an ACK that covers it. In a basic implementation, TCP times one eligible segment at a time. Karn's algorithm excludes retransmitted data from ordinary RTT sampling: an ACK might refer to the original copy or the replacement. Negotiated timestamps can remove this ambiguity.

The first valid sample R initializes EstimatedRTT to R and DevRTT to R/2. Before a sample exists, the recommended initial timeout is 1 s.

Update variation before the average

For a new sample, use the previous EstimatedRTT to measure the deviation:

DevRTTnew=0.75DevRTTold+0.25∣SampleRTT−EstimatedRTTold∣.

Then update the exponentially weighted moving average:

EstimatedRTTnew=0.875EstimatedRTTold+0.125SampleRTT.

The recommended weights are β=1/4 and α=1/8. Older samples retain less influence after each update. Updating the average first would change the deviation used in the first equation.

Work through one update

Start with EstimatedRTT = 100 ms and DevRTT = 10 ms; take a 120 ms sample.

  1. Absolute deviation: ∣120−100∣=20 ms.
  2. New DevRTT: 0.75(10)+0.25(20)=12.5 ms.
  3. New EstimatedRTT: 0.875(100)+0.125(120)=102.5 ms.
  4. Basic timeout: 102.5+4(12.5)=152.5 ms.

The basic rule is

TimeoutInterval=EstimatedRTT+4DevRTT.

The full standard uses EstimatedRTT + max(G, 4 DevRTT), where G is clock granularity. When the four-deviation margin exceeds the clock interval, the basic rule gives the same result.

The standard recommends raising a computed value below 1 s to 1 s. Real implementations may use a smaller floor; a common Linux minimum is 200 ms. The calculated 152.5 ms is therefore a raw estimate, not necessarily the timer a host installs. An optional upper limit must be at least 60 s.

Back off after timeout

When the timer expires, TCP resends the earliest unacknowledged data and doubles the timeout. A current value of 0.75 s becomes 1.5 s, then 3 s after another expiration. Repeated immediate retries would add traffic to a path already failing to deliver feedback.

A newly arriving ACK does not necessarily collapse that backed-off timeout. TCP needs a valid new RTT measurement to recompute the estimate. Without timestamps, retransmission ambiguity prevents using an ACK for the resent data as that new sample. Once eligible new data is sent and acknowledged, a fresh sample can bring the computed timeout down.

Key Takeaways

  • Karn’s algorithm avoids ambiguous samples from retransmitted data.
  • Update DevRTT using the old EstimatedRTT, then update EstimatedRTT.
  • The timeout includes a variation margin and implementation limits.
  • Timeout doubles the current retransmission interval.
  • A valid new RTT measurement permits recomputing a backed-off timeout.

5.2 Cumulative ACKs, timers and fast retransmit

TCP combines a checksum, byte sequence numbers, cumulative ACKs and retransmission to deliver a reliable stream. The sender must distinguish an ACK that advances delivery from one that repeats the current boundary.

Follow the sender's events

SendBase is the first unacknowledged byte; NextSeqNum is the next unused byte number. New application data is sent with sequence NextSeqNum, which then advances by the data length. If no retransmission timer is running, sending outstanding data starts it.

The recommended basic timer algorithm uses one retransmission timer for the oldest unacknowledged segment. A timeout retransmits that earliest outstanding segment, doubles the interval and restarts the timer. An ACK greater than SendBase advances the base and restarts the timer if data remains outstanding. If everything is acknowledged, the timer stops. A duplicate ACK does not advance the base.

Lost ACKs can disappear from the problem

A sends 500 bytes starting at 501. B receives them and sends ACK 1,001, which is lost. If nothing else confirms those bytes, A times out and resends them. B recognizes the duplicate, delivers no extra data and sends ACK 1,001 again.

Now suppose A had also sent the next 500 bytes, starting at 1,001. If ACK 1,501 arrives before timeout, it confirms both segments. The loss of ACK 1,001 requires no retransmission. An ACK is cumulative, so the sender does not need a separate surviving ACK for every segment.

For a premature timeout, A resends only the oldest segment. If delayed ACKs subsequently confirm both original segments, A need not resend the second one. A timeout is evidence that feedback did not arrive in time, not proof that every outstanding segment vanished.

Use ACK timing to report gaps

For in-order data with no ACK pending, the receiver may delay an ACK briefly, for less than 0.5 s, to combine acknowledgments. It should acknowledge at least every second full-sized segment. A second in-order arrival while an ACK is pending triggers a cumulative ACK. An out-of-order arrival beyond a gap triggers an immediate duplicate ACK; filling all or part of a gap also triggers an immediate ACK.

Repair a gap before timeout

Suppose A sends five 1,000-byte segments beginning at 1,001, 2,001, 3,001, 4,001 and 5,001. The second is lost. B's ACK after the first is 2,001. The three later arrivals each produce another ACK 2,001.

After three duplicate ACKs, A uses fast retransmit to resend the segment beginning at 2,001 without waiting for timeout. With the later data buffered, filling that gap lets B acknowledge 6,001. The first ACK 2,001 is the original ACK; the next three are duplicates. One or two duplicates can result from ordinary reordering, which explains waiting for more evidence.

TCP combines ideas from both window protocols. Its cumulative ACKs and basic single timer resemble GBN, but its buffering and targeted retransmission resemble SR. Negotiated SACK reports byte blocks held beyond the cumulative boundary so that the sender can identify several holes more precisely. TCP sends no NAK for a failed checksum; the resulting gap is exposed by later ACKs or timeout.

Key Takeaways

  • A cumulative ACK can cover an earlier ACK that was lost.
  • The basic retransmission timer protects the oldest unacknowledged data.
  • A timeout does not require retransmitting all outstanding segments.
  • Three duplicate ACKs trigger fast retransmit in the basic algorithm.
  • SACK reports received blocks beyond a gap without changing cumulative ACK meaning.

5.3 Receive windows and buffer space

Flow control keeps a TCP sender from overflowing the receiver's buffer. It responds to how quickly the receiving application reads. Congestion control responds to load in the network; the two controls protect different resources.

Calculate available space

Let RcvBuffer be the buffer capacity, LastByteRcvd the last in-order byte stored and LastByteRead the last byte read by the application. In this contiguous-data model, occupied space is LastByteRcvd − LastByteRead. The receive window is

rwnd=RcvBuffer−(LastByteRcvd−LastByteRead).

The receiver advertises available space in the window field of its returning segments. The sender keeps its unacknowledged byte count within that allowance:

LastByteSent−LastByteAcked≤rwnd.

For RcvBuffer = 40,000 bytes, LastByteRcvd = 30,000 and LastByteRead = 18,000, occupancy is 12,000 and rwnd is 28,000 bytes. ACK 30,001 with this window permits unacknowledged bytes through 58,000. If the sender has already sent through 34,000, it has 4,000 outstanding bytes and may send 24,000 more. The window is an allowance for all outstanding bytes, not an extra allowance on top of them.

Restart after a zero window

When no space remains, the receiver advertises rwnd = 0 and the sender stops normal new-data transmission. When the application reads, the receiver advertises the newly available space in a window update.

That update may be a pure ACK, which is not reliably delivered by itself. If it is lost, the sender could keep waiting although space exists. Zero-window probes, commonly carrying a byte, prompt the receiver to return its current window. Probes are spaced with growing intervals; they are not normal bulk sending through a closed window.

Relate the window to throughput

With a fixed window and RTT, the ideal window-limited throughput satisfies

throughput≤rwndRTT.

Use bytes and seconds to get bytes/s. A 65,535-byte window over a 0.1 s RTT allows about 655,350 bytes/s, or 5.2 Mbit/s. A higher link rate cannot remove this window limit.

To fill a path, the window must cover its bandwidth-delay product. At 1 Gbit/s and 0.1 s, the required in-flight data is 100 million bits, or 12.5 MB. This is a necessary window size for that ideal rate, not a guarantee of achieving it.

Scale the field and avoid tiny updates

The 16-bit field alone cannot represent such a large window. A window scale option negotiated in SYNs multiplies later window values by 2s, with s≤14. The largest scale gives a little under 1 GiB. A shift of 7 allows at most 8,388,480 bytes; shift 8 allows 16,776,960, enough for the 12.5 MB example. The scale stays fixed for its direction, while the advertised space changes. SYN window fields themselves are not scaled.

Advertising every few newly freed bytes can cause silly window syndrome: many tiny segments with large header overhead. Receiver avoidance waits for a useful amount of free space, commonly one MSS or half the buffer, whichever is smaller. Nagle's algorithm addresses small sender writes by holding them while earlier data remains unacknowledged, or until enough data forms a full segment.

Key Takeaways

  • Flow control protects the receiver; congestion control protects the network.
  • Subtract buffered unread data from capacity to find rwnd.
  • Subtract existing outstanding data from rwnd before sending more.
  • Zero-window probes recover from a lost reopening update.
  • Window divided by RTT bounds ideal window-limited throughput.
  • Window scaling fixes the multiplier at setup while free space keeps changing.
  • Receiver update rules and Nagle’s algorithm address different causes of tiny segments.

Transport Layer examples

5 Walkthroughs

1

Follow data from one socket to another

9 steps
Trace transport delivery, select receiving sockets and explain how TCP and UDP serve applications.
  1. 1
    IntroductionOne host, several conversations

    A laptop can browse a page while making a call. Both applications share IP delivery, but each needs its own incoming data.

    Follow a message down from one application socket, across the network and up to the destination socket. Then compare how a UDP server handles several sources with how a TCP server distinguishes established connections.

  2. 2
    ExplanationBuild and unpack a segment

    The sending transport protocol takes application data and adds its header, forming a segment. IP places that segment inside an IP datagram.

    At the destination, IP identifies the upper protocol and passes the segment up. TCP or UDP interprets the transport header and selects a socket. The application reads through that socket; ordinary routers only forward the IP datagrams along the path.

  3. 3
    AnalogyAn address and a recipient

    A building address gets a letter to the right building. A recipient name lets someone inside route it to the right person. Similarly, IP addresses support host delivery, while transport ports help select an application socket.

    The analogy separates two jobs. Actual transport protocols also provide defined services: TCP can recover missing bytes, while UDP leaves recovery to software above it.

  4. 4
    ChallengeCan TCP promise an arrival time?

    An application needs every byte intact and also needs a guaranteed arrival within 25 ms. Does selecting TCP provide both requirements?

    ---reveal---

    TCP supplies reliable, in-order byte delivery, but does not guarantee that 25 ms deadline. Recovery can add delay, and the best-effort IP path provides no fixed maximum waiting time. A delivery guarantee and a deadline guarantee are separate requirements.

  5. 5
    ExplanationSelect a UDP receiving socket

    A basic unconnected UDP server socket is selected by its destination IP address and destination port. Messages from different clients can all reach that socket.

    Suppose 203.0.113.20:7000 receives messages from 192.0.2.5:55010 and 198.51.100.9:55010. The source port matches, but the sources differ. The server reads the source endpoint with each message to address the appropriate reply.

  6. 6
    ExampleReuse a TCP server port

    A TCP server at 203.0.113.20:443 has two clients: 192.0.2.5:55010 and 198.51.100.9:55010.

    Each established connection has a distinct four-tuple. Both share the server address and port; their source addresses distinguish them. The listener accepts further clients while the connection sockets carry existing streams. No extra listening port is needed for each client.

  7. 7
    ChallengeCount the connection sockets

    A server at 203.0.113.30:443 accepts connections from 192.0.2.7:56000, 192.0.2.7:56001 and 198.51.100.7:56000. How many connection sockets distinguish these streams?

    ---reveal---

    Three. The first two differ in source port; the first and third differ in source address. Their shared destination port does not merge them. The listening socket is separate and is not one of these three connection sockets.

  8. 8
    ChallengeChoose the transport and receiving endpoint

    A service needs separate messages without setup. Two clients send to its unconnected socket at 203.0.113.40:8000. Which transport fits, and what selects that server socket?

    ---reveal---

    UDP fits the message service with no transport handshake. The destination address 203.0.113.40 and port 8000 select the basic server socket. The source endpoints identify where replies go; they do not require separate TCP-style connections.

  9. 9
    RecapRead a delivery trace in order

    For an incoming trace, first identify the transport protocol, then its endpoint information, then the service the application receives.

    A UDP message and a TCP byte stream can share the same numeric server port because they belong to different protocols. Within TCP, both addresses and both ports distinguish a connection. Reliability, timing and encryption must each be checked as separate application needs.

2

Check a UDP message and choose its service

11 steps
Read UDP fields, fold a checksum carry and decide whether loss recovery can meet an application deadline.

Save this lesson to follow every Walkthrough step by step.

  1. 1
    IntroductionA small header with a specific job
  2. 2
    ExplanationCount a UDP segment’s bytes
  3. 3
    ExplanationPrepare checksum input
  4. 4
    ExampleFold the carry before continuing
  5. 5
    ExampleComplement, then verify
  6. 6
    ChallengeHandle another carry
  7. 7
    ExplanationKeep recovery within the deadline
  8. 8
    Key InsightA UDP application can add more
  9. 9
    ChallengeWould a replacement still help?
  10. 10
    ChallengeCombine message size and service choice
  11. 11
    RecapCheck what each layer supplies
3

Build a reliable sliding-window transfer

20 steps
Develop duplicate handling, timers and pipelining, then trace go-back-N and selective repeat through the same loss.

Save this lesson to follow every Walkthrough step by step.

  1. 1
    IntroductionMake failure cases visible
  2. 2
    ExplanationRepresent what each endpoint is waiting for
  3. 3
    AnalogyGive a replacement the same identity
  4. 4
    ChallengeAnswer a duplicate without repeating delivery
  5. 5
    ExplanationGive silence a response
  6. 6
    ExampleMeasure sending and waiting separately
  7. 7
    ExampleFill that waiting interval
  8. 8
    ChallengeFind a pipeline window
  9. 9
    ExplanationRead the go-back-N window
  10. 10
    ExampleLose one packet in go-back-N
  11. 11
    ChallengeRetransmit the outstanding range
  12. 12
    Key InsightKeep an unused number outside GBN’s window
  13. 13
    ExplanationSelective repeat saves later arrivals
  14. 14
    ExampleRecover the same loss with one replacement
  15. 15
    ChallengeMove the SR base after a late ACK
  16. 16
    ExampleExpose overlapping old and new numbers
  17. 17
    TipSeparate windows before reusing numbers
  18. 18
    ChallengeChoose between window designs
  19. 19
    ConnectionHandle copies that survive a full cycle
  20. 20
    RecapTrace state before choosing a resend
4

Trace TCP from SYN to FIN

16 steps
Read the header, number both byte streams and work through connection opening and closing.

Save this lesson to follow every Walkthrough step by step.

  1. 1
    IntroductionKeep two byte streams separate
  2. 2
    ExplanationRead a stream, not a row of messages
  3. 3
    ExampleInterpret header size before payload size
  4. 4
    ChallengeAllow for actual headers
  5. 5
    ExplanationName the first data byte
  6. 6
    ExampleAdvance through differently sized segments
  7. 7
    ExamplePiggyback an acknowledgment
  8. 8
    ChallengeHold an ACK at a gap
  9. 9
    ExampleConfirm both initial numbers
  10. 10
    ChallengeCheck the final handshake fields
  11. 11
    ExplanationClose one direction at a time
  12. 12
    Key InsightWait where the final ACK can be repeated
  13. 13
    ConnectionRefuse or defend an opening request
  14. 14
    ChallengeAcknowledge data and closing together
  15. 15
    TipRecognize number reuse
  16. 16
    RecapAccount for every consumed number
5

Recover TCP loss without overrunning the receiver

18 steps
Update a timer, identify missing bytes, compute available receive space and explain window reopening.

Save this lesson to follow every Walkthrough step by step.

  1. 1
    IntroductionDecide what is holding up progress
  2. 2
    ExplanationChoose a usable RTT measurement
  3. 3
    ExampleUpdate the deviation first
  4. 4
    ExampleUpdate the average and apply limits
  5. 5
    ChallengeContinue with a second sample
  6. 6
    TipBack off without inventing a sample
  7. 7
    ExampleLet a later ACK cover a lost one
  8. 8
    ExplanationReport a hole with repeated ACKs
  9. 9
    ChallengeFill a hole and advance over buffered bytes
  10. 10
    Key InsightUse the basic timer for the oldest gap
  11. 11
    ExplanationCount the unread bytes first
  12. 12
    ExampleSubtract data already outstanding
  13. 13
    ChallengeCalculate the next sending allowance
  14. 14
    ConnectionRecover a lost reopening update
  15. 15
    ExampleSize a window for the path
  16. 16
    TipKeep scaling and tiny updates distinct
  17. 17
    ChallengeRecover data but wait for space
  18. 18
    RecapMatch each response to its evidence

Transport Layer practice questions

50 Practice Questions in 5 sets

Set 1: Sliding windows and loss recovery10 Practice Questions

Question 1 of 10

In go-back-N, what does ACK 12 confirm?
  1. Only packet 12
  2. All packets through 12
  3. All packets before 12
  4. Only packets after 12
Show answerHide answer
Answer: B
Go-back-N uses cumulative ACKs naming the last packet received in order. ACK 12 confirms packets through 12 and permits the sender base to become 13. Treating it as confirmation only of packet 12 confuses go-back-N with selective repeat’s individual acknowledgments.

Question 2 of 10

A go-back-N sender has window size 6, base 20 and nextseqnum 24. No wraparound occurs. Which new packets can it send before another ACK?
  1. 24 through 29
  2. 20 and 21
  3. 24 and 25
  4. 25 and 26
Show answerHide answer
Answer: C
The allowed window is 20–25. Packets 20–23 are already outstanding, leaving 24 and 25 available for new data. Starting a fresh six-packet allowance at 24 would ignore the four packets still occupying the current window.

Question 3 of 10

A go-back-N sender uses window 5 and sends packets 10–14; packet 12 is lost. ACKs for 10 and 11 arrive, so it sends 15 and 16. All later data arrives before packet 12’s timeout. What is retransmitted on that timeout?
  1. 12, 13, 14, 15 and 16
  2. 12 alone
  3. 12, 13 and 14 only
  4. 10, 11, 12, 13 and 14
Show answerHide answer
Answer: A
The receiver discarded packets 13–16 because packet 12 was missing, so none of those later packets advanced the cumulative ACK. The sender base remains 12 and its outstanding range is 12–16. Resending only the originally sent group would omit newly sent packets that are also unacknowledged.

Question 4 of 10

A selective-repeat sender has base 30 and packets 30–33 outstanding. ACKs 31, 32 and 33 arrive, but ACK 30 does not. Where is the sender base?
  1. 31
  2. 33
  3. 34
  4. 30
Show answerHide answer
Answer: D
Selective repeat records packets 31–33 as acknowledged but leaves the base at the oldest unacknowledged packet, 30. Their ACKs do not cumulatively confirm packet 30. Moving the base to 34 would allow the sender to forget data whose delivery is still unconfirmed.

Question 5 of 10

An SR receiver has window size 4. It accepts packets 8–11 and moves its base to 12. ACK 9 is lost, so packet 9 is retransmitted. What response lets the sender recover correctly?
  1. Ignore packet 9 because it is outside the current window.
  2. Send ACK 11 because all four packets were received.
  3. Send ACK 9 without delivering packet 9 again.
  4. Buffer packet 9 until the sequence numbers wrap.
Show answerHide answer
Answer: C
Packet 9 is an old duplicate in the immediately preceding receiver window. Re-ACKing it gives the sender the individual confirmation that was lost, without duplicating application data. ACK 11 cannot replace ACK 9 in SR because acknowledgments are not cumulative.

Question 6 of 10

A protocol designer needs an equal-sized selective-repeat sender and receiver window of 10 packets. What is the minimum sequence-number field size?
  1. 3 bits
  2. 5 bits
  3. 4 bits
  4. 6 bits
Show answerHide answer
Answer: B
Selective repeat needs at least twice the window size in distinct sequence numbers. Ten-packet windows require at least 20 numbers: 4 bits provide only 16, while 5 provide 32. Applying the go-back-N bound would wrongly allow 4 bits despite the overlap between old and new SR windows.

Question 7 of 10

A pipeline sends 1,250-byte packets on a 10 Mbit/s link with 9 ms RTT. Ignore ACK transmission and processing. What is the smallest window that can keep the sender continuously busy?
  1. 9 packets
  2. 11 packets
  3. 90 packets
  4. 10 packets
Show answerHide answer
Answer: D
Each packet contains 10,000 bits and takes 1 ms to transmit. The send-and-feedback cycle is 9 + 1 = 10 ms, so ten packet transmission times cover it. Using only RTT gives nine and leaves the initial packet transmission time out of the cycle.

Question 8 of 10

Which mechanism lets a receiver distinguish a replacement packet from new data in stop-and-wait?
  1. A sequence number
  2. A longer timeout
  3. A larger link rate
  4. A checksum alone
Show answerHide answer
Answer: A
The receiver uses the packet’s sequence number to identify whether its data was already accepted. A checksum can pass for both the original and the replacement because both copies may be intact. It checks for corruption, not whether the application has already received that data.

Question 9 of 10

Two stop-and-wait paths use identical packet sizes and RTTs. The second link rate is doubled. How do utilization and useful throughput change, ignoring loss and ACK transmission?
  1. Both double.
  2. Utilization falls; throughput rises by less than twice.
  3. Utilization stays fixed; throughput doubles.
  4. Utilization rises; throughput stays fixed.
Show answerHide answer
Answer: B
Doubling the rate halves transmission time while leaving RTT unchanged, so the fraction of the cycle spent sending falls. The cycle becomes shorter, so throughput rises, but the unchanged RTT prevents a doubling. Link capacity and the fraction of capacity used are different quantities.

Question 10 of 10

TCP sends three consecutive segments. The ACK for the first is lost, but a later ACK covering all three arrives before timeout. What data must be resent because of that lost ACK?
  1. The first segment only
  2. The last segment only
  3. None of the three segments
  4. All three segments
Show answerHide answer
Answer: C
The later cumulative ACK confirms every byte before its acknowledgment number, including bytes covered by the lost ACK. No retransmission is needed once all three segments are confirmed before timeout. Requiring one surviving ACK per segment would treat TCP feedback as individual SR acknowledgments.
Set 2: Transport services and message delivery10 Practice Questions

Save this lesson to see every answer and practice every set.

Question 1 of 10

A UDP message carries 72 data bytes. What value belongs in its length field?
  1. 72 bytes
  2. 92 bytes
  3. 80 bytes
  4. 100 bytes
Show answerHide answer

Save this lesson to see this answer.

Question 2 of 10

Which TCP service lets a receiving application obtain file bytes in their original order?
  1. A guaranteed maximum network delay
  2. A reliable, in-order byte stream
  3. One message per application write
  4. A built-in encrypted connection
Show answerHide answer

Save this lesson to see this answer.

Question 3 of 10

Two TCP clients use source port 54000 to connect to the same server address and port. Their source IP addresses differ. How does the server distinguish their traffic?
  1. It assigns a new listening port to one client.
  2. It combines both clients into one byte stream.
  3. It selects sockets using destination ports alone.
  4. It selects different four-tuple connection sockets.
Show answerHide answer

Save this lesson to see this answer.

Question 4 of 10

A UDP reply goes from 203.0.113.8:123 to 192.0.2.18:57320. What is its destination port?
  1. 57320
  2. 123
  3. 17
  4. 192
Show answerHide answer

Save this lesson to see this answer.

Question 5 of 10

A game position update expires 35 ms from now. Recovering a lost copy would take 90 ms, and a newer position is already available. Why might the application skip that recovery?
  1. The replacement would arrive after its useful deadline.
  2. UDP guarantees that the newer position is accurate.
  3. The network must already have delivered the lost update.
  4. A UDP header prevents old positions from being sent.
Show answerHide answer

Save this lesson to see this answer.

Question 6 of 10

A stop-and-wait receiver has delivered packet 0 and now expects packet 1. Another intact packet 0 arrives. What should it do?
  1. Deliver it again and send ACK 0.
  2. Discard its data and send ACK 1.
  3. Discard its data and send no feedback.
  4. Discard its data and send ACK 0.
Show answerHide answer

Save this lesson to see this answer.

Question 7 of 10

An error-only stop-and-wait protocol has checksums and ACK/NAK feedback but no sequence numbers. Why is resending after corrupted feedback unsafe?
  1. The replacement cannot carry a valid checksum.
  2. The receiver may deliver an already accepted packet twice.
  3. The sender must change its source port for every retry.
  4. The feedback channel cannot carry any useful information.
Show answerHide answer

Save this lesson to see this answer.

Question 8 of 10

A stop-and-wait sender uses 1,000-byte packets on an 8 Mbit/s link with 19 ms RTT. Ignore ACK transmission and processing. What is its utilization?
  1. 0.005
  2. 0.95
  3. 0.05
  4. 0.50
Show answerHide answer

Save this lesson to see this answer.

Question 9 of 10

A TCP data offset field contains 9. How long is the TCP header?
  1. 36 bytes
  2. 9 bytes
  3. 29 bytes
  4. 72 bytes
Show answerHide answer

Save this lesson to see this answer.

Question 10 of 10

An alternating-bit sender sends packet 1. Its ACK is delayed beyond timeout, so a replacement is sent. The original ACK then arrives before the replacement reaches the receiver. The sender sends new packet 0. With no reordering of data packets, what does the receiver deliver from the replacement 1 and new 0?
  1. Both packets, because each arrived intact.
  2. Neither packet, because the sender timed out.
  3. Only packet 1, because its ACK arrived first.
  4. Only packet 0, after discarding duplicate 1.
Show answerHide answer

Save this lesson to see this answer.

Set 3: TCP bytes and connection state10 Practice Questions

Save this lesson to see every answer and practice every set.

Question 1 of 10

A client sends SYN with sequence 4600. The server responds with SYN-ACK at sequence 17000. What acknowledgment belongs in the client’s final handshake ACK?
  1. 17000
  2. 17001
  3. 4601
  4. 17002
Show answerHide answer

Save this lesson to see this answer.

Question 2 of 10

A program writes 60 bytes and then 90 bytes to a TCP socket. What can a single receiving read return?
  1. Only 60 bytes until a second read
  2. Exactly one 150-byte message with a boundary marker
  3. Only 90 bytes because the later write replaces the first
  4. All 150 bytes without a write-boundary marker
Show answerHide answer

Save this lesson to see this answer.

Question 3 of 10

A TCP segment starts at byte 8401 and carries 640 data bytes, with no SYN or FIN. What ACK confirms this entire segment when all earlier bytes have arrived?
  1. 9040
  2. 9041
  3. 8402
  4. 640
Show answerHide answer

Save this lesson to see this answer.

Question 4 of 10

A receiver expects byte 12001. It buffers 400 bytes starting at 12401, then receives 250 bytes starting at 12001, then 150 bytes starting at 12251. What ACK follows each of the last two arrivals?
  1. 12251, then 12801
  2. 12401, then 12801
  3. 12251, then 12401
  4. 12801, then 12801
Show answerHide answer

Save this lesson to see this answer.

Question 5 of 10

A client’s next byte is 3001 and a server’s next byte is 9101. The client sends 180 bytes; the server receives them and sends 420 bytes with no earlier server data outstanding. What sequence and ACK numbers are in that server segment?
  1. Sequence 3281; ACK 9521
  2. Sequence 9521; ACK 3181
  3. Sequence 9101; ACK 3181
  4. Sequence 3181; ACK 9101
Show answerHide answer

Save this lesson to see this answer.

Question 6 of 10

A has sent data through byte 7199 and then sends FIN. B acknowledges that FIN and still has 300 unsent application bytes. What is the correct next behavior?
  1. B sends its data and may send its own FIN afterward; its ACK is 7201.
  2. B must discard its unsent data; its ACK is 7201.
  3. B sends its data only after a new handshake; its ACK is 7200.
  4. B closes both directions immediately; its ACK is 7200.
Show answerHide answer

Save this lesson to see this answer.

Question 7 of 10

A closes first and reaches TIME_WAIT after receiving B’s FIN. A’s final ACK is lost. B retransmits its FIN. Why is retaining A’s connection state useful now?
  1. It lets A reopen B’s sending direction.
  2. It lets A resend B’s missing data.
  3. It lets A acknowledge the FIN again.
  4. It lets A set B’s next sequence number.
Show answerHide answer

Save this lesson to see this answer.

Question 8 of 10

A TCP sender has received one ACK 4401 followed by three more ACKs 4401 caused by later data arriving beyond a gap. Which segment does basic fast retransmit resend?
  1. The segment ending at byte 4400
  2. The most recently sent segment
  3. Every segment after byte 4401
  4. The segment starting at byte 4401
Show answerHide answer

Save this lesson to see this answer.

Question 9 of 10

A receiver has capacity 24000 bytes and holds 6500 unread bytes. The sender already has 5500 bytes outstanding under the current advertisement. How many additional bytes fit?
  1. 17500 bytes
  2. 12000 bytes
  3. 18500 bytes
  4. 6500 bytes
Show answerHide answer

Save this lesson to see this answer.

Question 10 of 10

TCP sends segments starting at 2001, 2501 and 3001, each 500 bytes. All data arrives, but every ACK is delayed past timeout. The sender resends 2001; then ACK 3501 arrives before the new timer expires. What remains to retransmit?
  1. Nothing; ACK 3501 confirms all three data segments.
  2. Only 2501; 2001 was the sole replacement sent.
  3. Both 2501 and 3001; each needs its own timer event.
  4. All three; an ACK after timeout cannot confirm original data.
Show answerHide answer

Save this lesson to see this answer.

Set 4: TCP timeouts, gaps and receive space10 Practice Questions

Save this lesson to see every answer and practice every set.

Question 1 of 10

A retransmission timer is set to 1.2 s. What interval follows one timeout with exponential backoff?
  1. 0.6 s
  2. 1.2 s
  3. 2.4 s
  4. 4.8 s
Show answerHide answer

Save this lesson to see this answer.

Question 2 of 10

EstimatedRTT is 200 ms and DevRTT is 20 ms. A new sample is 240 ms. Using the recommended weights and update order, what is the raw timeout when clock granularity is negligible?
  1. 305 ms
  2. 300 ms
  3. 285 ms
  4. 320 ms
Show answerHide answer

Save this lesson to see this answer.

Question 3 of 10

EstimatedRTT is 240 ms and DevRTT is 20 ms. A sender without timestamps has backed its timeout off to 2 s. An ACK for retransmitted data arrives 150 ms after the retry. Later, previously un-retransmitted data yields a valid 320 ms sample. With negligible clock granularity, what raw timeout should be computed from these events?
  1. 390 ms
  2. 444 ms
  3. 350 ms
  4. 2000 ms
Show answerHide answer

Save this lesson to see this answer.

Question 4 of 10

A receiver gets an intact TCP segment beyond a missing byte range. What should its immediate ACK report?
  1. The end of the newly arrived segment
  2. The first byte still missing from the continuous stream
  3. The length of the out-of-order segment
  4. The first byte after all data sent by the peer
Show answerHide answer

Save this lesson to see this answer.

Question 5 of 10

A receiver expects byte 6001. It buffers three consecutive 800-byte segments starting at 6801, 7601 and 8401, sending immediate duplicate ACKs. A replacement 800-byte segment starting at 6001 then arrives. What cumulative ACK follows?
  1. 6801
  2. 8401
  3. 9201
  4. 6001
Show answerHide answer

Save this lesson to see this answer.

Question 6 of 10

A TCP sender has segments starting at 10501, 11001, 11501 and 12001 outstanding. Its current cumulative ACK boundary is 10501. It receives ACK 10501 twice, then ACK 11001 once, then ACK 11001 three more times. No timer expires. Which segment does basic fast retransmit resend?
  1. The segment starting at 10501
  2. The segment starting at 11501
  3. The segment starting at 12001
  4. The segment starting at 11001
Show answerHide answer

Save this lesson to see this answer.

Question 7 of 10

After advertising a zero window, a receiver’s application reads data. The reopening window update is lost. What lets the sender discover the available space?
  1. An automatic retransmission of every pure ACK
  2. A new three-way handshake on the same stream
  3. A fixed timeout that resets the window to its maximum
  4. A zero-window probe and the receiver’s current-window reply
Show answerHide answer

Save this lesson to see this answer.

Question 8 of 10

A path has RTT 80 ms and can carry 200 Mbit/s. A receiver can advertise up to 65535 × 2^s bytes. Ignoring other limits, what is the smallest scale shift that permits enough in-flight data to fill the path?
  1. 4
  2. 5
  3. 6
  4. 7
Show answerHide answer

Save this lesson to see this answer.

Question 9 of 10

A receiver advertises ACK 51001 and rwnd 18000 while the sender has sent through byte 57000. The sender then transmits 8000 more bytes and receives ACK 59001 with rwnd 12000. How many additional bytes may it now send under the new advertisement?
  1. 4000 bytes
  2. 12000 bytes
  3. 6000 bytes
  4. 10000 bytes
Show answerHide answer

Save this lesson to see this answer.

Question 10 of 10

A service uses UDP but needs complete, ordered delivery and sends substantial traffic on a shared path. What must the service or a protocol above UDP provide?
  1. Recovery, ordering and suitable congestion control
  2. Only a larger checksum field and a longer IP header
  3. Only receive-buffer growth and permanent source ports
  4. An assumption that all shared-path loss is harmless
Show answerHide answer

Save this lesson to see this answer.

Set 5: Diagnose complete transport traces10 Practice Questions

Save this lesson to see every answer and practice every set.

Question 1 of 10

After a handshake with client ISN 15000, the client sends 2300 bytes split into 1000, 1000 and 300 bytes, then FIN. All arrive in order. What ACK confirms the FIN?
  1. 17300
  2. 17301
  3. 17302
  4. 18002
Show answerHide answer

Save this lesson to see this answer.

Question 2 of 10

A supplied nonzero UDP checksum fails at the receiver. What does UDP do with the segment?
  1. It corrects the bits, then delivers.
  2. It silently discards the segment.
  3. It requests a resend with a UDP NAK.
  4. It delivers two copies to compare.
Show answerHide answer

Save this lesson to see this answer.

Question 3 of 10

Two 16-bit checksum input words are FFFE and 0002. What is their Internet checksum?
  1. FFFF
  2. 0000
  3. FFFE
  4. 0001
Show answerHide answer

Save this lesson to see this answer.

Question 4 of 10

An equal-window selective-repeat protocol uses numbers 0–7 and window size 5. The receiver accepts 0–4, but every ACK is lost. Which old packet numbers would fit the receiver’s new window if retransmitted?
  1. 0 and 1
  2. 3 and 4
  3. 5 and 6
  4. 0 through 4
Show answerHide answer

Save this lesson to see this answer.

Question 5 of 10

A go-back-N sender has four-bit numbers and needs at least 16 packets in flight to fill a path. What is the smallest change that supports that pipeline safely without changing protocol type?
  1. Keep four bits and use all 16 numbers.
  2. Keep four bits and increase only the receive buffer.
  3. Keep four bits and replace cumulative ACKs with individual ACKs.
  4. Use five-bit numbers and a window of at least 16.
Show answerHide answer

Save this lesson to see this answer.

Question 6 of 10

A path permits 1400-byte IPv4 datagrams. The IP header is 20 bytes and the TCP data offset is 8. How many data bytes fit without exceeding that limit?
  1. 1360 bytes
  2. 1348 bytes
  3. 1372 bytes
  4. 1380 bytes
Show answerHide answer

Save this lesson to see this answer.

Question 7 of 10

EstimatedRTT is 400 ms and DevRTT is 60 ms. A valid new sample is 240 ms after an earlier backoff. With negligible clock granularity and a 1 s minimum, what timeout results from this new measurement?
  1. 560 ms
  2. 640 ms
  3. 1120 ms
  4. 1000 ms
Show answerHide answer

Save this lesson to see this answer.

Question 8 of 10

A receiver advertises ACK 8001 with rwnd 9000. The sender has sent through 11000. The application then reads 2000 bytes, but no updated advertisement reaches the sender. How many new bytes may the sender send using its known window?
  1. 6000 bytes
  2. 8000 bytes
  3. 9000 bytes
  4. 11000 bytes
Show answerHide answer

Save this lesson to see this answer.

Question 9 of 10

A server uses SYN cookies during a flood of incomplete handshakes. What event normally permits it to allocate the new connection’s state?
  1. Receiving any SYN aimed at the listening port
  2. Sending the first SYN-ACK to an apparent client
  3. Validating the cookie returned by the final ACK
  4. Waiting one maximum segment lifetime after the SYN
Show answerHide answer

Save this lesson to see this answer.

Question 10 of 10

A receiver expects byte 16001. Of four 600-byte segments starting at 16001, 16601, 17201 and 17801, the first and third are lost. The second and fourth arrive and are buffered; only two duplicate ACKs reach the sender. On timeout, the first is retransmitted and arrives. What ACK follows, and which gap remains?
  1. ACK 18401; no gap remains.
  2. ACK 17201; the gap starting at 17201 remains.
  3. ACK 16601; both later segments must be resent.
  4. ACK 17801; the gap starting at 17801 remains.
Show answerHide answer

Save this lesson to see this answer.

Stuck on your own question? Homework Help

Key Terms

75 Key Terms, each with its definition

A

Acknowledgment
An acknowledgment is receiver feedback confirming data receipt; its meaning can be individual or cumulative depending on the protocol.
SR ACK 14 confirms packet 14 alone, while GBN ACK 14 also confirms all preceding packets.
Acknowledgment number
A TCP acknowledgment number identifies the next byte expected from the peer and confirms all bytes before it in the continuous stream.
ACK 4001 confirms bytes through 4000 even if the receiver has also buffered data beyond a later gap.
Alternating-bit protocol
The alternating-bit protocol uses sequence numbers 0 and 1 with stop-and-wait, acknowledgments and a timer to handle errors and loss.
After a lost ACK, a repeated packet number lets the receiver avoid delivering the same data twice.
Automatic repeat request
Automatic repeat request is reliable-transfer recovery that combines error detection, receiver feedback and replacement transmissions.
After a NAK reports damage, the sender uses its stored packet copy to make another transmission.

B

Bandwidth-delay product
The bandwidth-delay product is link or path rate multiplied by round-trip time, estimating the data in flight needed to sustain that rate.
A 100 Mbit/s path with 0.1 s RTT needs about 10 million bits, or 1.25 MB, in flight to stay busy.
Best-effort delivery
Best-effort delivery attempts to carry data without guaranteeing its arrival, ordering, integrity, delay or a minimum throughput.
TCP can recover a lost segment even though the underlying IP service remains best-effort.
Byte stream
A byte stream is an ordered sequence of bytes without built-in application message boundaries, as delivered by TCP to its receiver.
A read can return bytes from several earlier writes, so the application checks its own message framing.

C

Cumulative acknowledgment
A cumulative acknowledgment confirms an entire continuous prefix of received data, allowing one ACK to cover several earlier transmissions.
A later cumulative ACK can make the loss of a previous ACK harmless if it arrives before timeout.

D

Data offset
The TCP data offset gives the total TCP header length in 32-bit words, identifying where the application payload begins.
A data offset of 6 gives a 24-byte header, containing four bytes beyond the fixed TCP header.
Delayed ACK
A delayed ACK briefly postpones acknowledgment of in-order TCP data so feedback can be combined, subject to timing and frequency limits.
A second full-sized in-order segment prompts a cumulative ACK instead of starting another long wait.
Demultiplexing
Demultiplexing selects the receiving application socket for an arriving transport segment using the protocol and endpoint information.
The host sends a DNS reply to the requesting socket instead of placing it in a browser’s stream.
DevRTT
DevRTT is a smoothed measure of how far recent RTT samples differ from the prior estimate, used to set the timeout margin.
A varying path delay raises the deviation margin even when its average RTT changes only slightly.
Duplicate ACK
A duplicate ACK repeats an existing cumulative acknowledgment without confirming new bytes, often because later data arrived beyond a gap.
Three qualifying duplicate ACKs can trigger replacement of a missing segment before its timer expires.

E

Encapsulation
Encapsulation places one layer’s data unit inside another layer’s unit, with a new header describing that layer’s delivery information.
IP encapsulates a transport segment by adding the IP header used to deliver it to the destination host.
End-around carry
End-around carry adds any overflow beyond a word’s highest bit back into its lowest positions during one’s complement addition.
Adding FFFF and 0001 gives 10000 before folding, then 0001 after the carry is added back.
End-to-end principle
The end-to-end principle places checks for a required complete-path property at the endpoints that can verify whether that property holds.
A transport checksum still checks the received data even when individual links have their own error checks.
Ephemeral port
An ephemeral port is a temporary local port usually selected by the operating system for a client’s network communication.
The client’s request uses temporary source port 55120, and the reply uses that value as its destination port.
EstimatedRTT
EstimatedRTT is TCP’s smoothed round-trip estimate, updated by weighting the old estimate and each new valid measurement.
Using weight 1/8 for a new sample makes one delayed ACK change the estimate less than replacing it outright.
Exponential backoff
Exponential backoff doubles the current retransmission timeout after expiration, increasing the wait between repeated failed attempts.
Successive timeouts can increase a waiting interval from 1 s to 2 s, then to 4 s.

F

Fast retransmit
Fast retransmit resends TCP’s suspected missing segment after three duplicate ACKs in the basic algorithm, without waiting for timeout.
Later segments arriving past a gap supply feedback that lets the sender act sooner than its timer would.
Finite-state machine
A finite-state machine describes a system as a current state with event-triggered transitions that specify the actions to perform.
A sender waiting for ACK 1 handles a matching ACK differently from feedback that contains the wrong number.
Flow control
Flow control limits a sender’s outstanding data according to the receiver’s available buffer space, protecting a slow-reading application.
A receiver with a full buffer can advertise a zero window even when the network path has spare capacity.
Four-tuple
A TCP connection’s four-tuple is the combination of its source IP address, source port, destination IP address and destination port.
Two connections to one web server remain distinct when their clients use different source addresses.
Full-duplex connection
A full-duplex connection allows both endpoints to transmit at the same time, maintaining independent stream numbering in each direction.
A server can send response bytes while the client is still sending additional data on the same connection.

G

Go-back-N
Go-back-N is a pipelined reliable-transfer protocol with cumulative ACKs, one oldest-packet timer and an in-order-only receiver.
A missing packet causes later out-of-order arrivals to be discarded and then resent after timeout.

H

Half-close
A half-close ends one TCP sending direction with FIN while allowing data to continue in the connection’s other direction.
A client can finish sending a request yet continue receiving the server’s remaining response bytes.
Head-of-line blocking
Head-of-line blocking in a TCP stream occurs when missing earlier bytes delay delivery of later bytes that have already arrived.
A receiver may hold later audio data while TCP waits for replacement bytes from an earlier segment.

I

Individual acknowledgment
An individual acknowledgment confirms one identified packet without also confirming all earlier packets in the sequence.
Receiving SR ACK 22 does not tell the sender whether packet 21 arrived or still needs replacement.
Initial sequence number
An initial sequence number is the starting TCP number selected by an endpoint and carried in its SYN before application data begins.
When SYN uses 27000, the first application byte normally uses sequence number 27001.
Internet checksum
The Internet checksum is the bitwise complement of a folded one’s complement sum of 16-bit words, used to detect transmission errors.
A receiving host includes the checksum in the folded sum and checks whether the result is all ones.

K

Karn’s algorithm
Karn’s algorithm excludes ambiguous RTT measurements from retransmitted data unless information such as timestamps identifies the transmission.
An ACK after a retry might reflect the original copy, so its arrival time alone cannot give a fresh sample.

L

Logical communication
Logical communication lets peer processes interact as if directly connected while lower layers carry their data across a network.
Two applications on different hosts use sockets without managing every router and link on the path between them.

M

Maximum segment lifetime
The maximum segment lifetime is an upper lifetime used to reason about how long a TCP segment may remain in the network before expiring.
TIME_WAIT uses twice MSL to allow old connection traffic to expire and the final ACK to be repeated.
Maximum segment size
The maximum segment size is the largest application-data payload announced for TCP segments, excluding transport and network headers.
A 1500-byte IPv4 datagram with two 20-byte headers leaves 1460 bytes for application data.
Message boundary
A message boundary separates one application message from another; UDP preserves these divisions while TCP carries an unframed byte stream.
Two UDP sends create two messages, so the receiver does not combine them into a single UDP message.
Multiplexing
Multiplexing gathers outgoing data from multiple application sockets and adds transport information so the traffic can share the network.
A host sends browser and email traffic through the same interface with different port information.

N

Nagle’s algorithm
Nagle’s algorithm coalesces small sender writes while earlier data is unacknowledged, or until enough buffered data can form a full segment.
A sequence of one-byte writes can be collected instead of sending a separate header-heavy segment for each.
Negative acknowledgment
A negative acknowledgment is feedback reporting that data was not received correctly and that a replacement transmission is needed.
A stop-and-wait design that handles only bit errors sends a NAK after its checksum detects a damaged packet.

O

Out-of-order buffering
Out-of-order buffering stores valid data received beyond a gap until missing earlier data arrives and ordered delivery can continue.
Once packet 4 fills the gap, buffered packets 5 and 6 can be delivered without another transmission.

P

PAWS
Protection Against Wrapped Sequences uses TCP timestamps to reject stale segments when reused byte numbers alone could look current.
A fast connection may cycle through its 32-bit byte numbers before an old delayed copy has disappeared.
Piggybacking
Piggybacking carries acknowledgment information for received data in a TCP segment that also sends data in the reverse direction.
A server’s response can acknowledge the request while carrying its own independently numbered bytes.
Pipelining
Pipelining allows several data packets to remain unacknowledged at once, using the link while earlier packets await feedback.
A sender can launch a second packet before the first packet’s ACK completes its round trip.
Playout deadline
A playout deadline is the time by which a received audio or video chunk must be available for its scheduled presentation.
A missing audio chunk recovered after its playback time cannot fill the gap that the listener already heard.
Port number
A port number is a 16-bit transport identifier that helps select an application endpoint on a host; TCP and UDP have separate port spaces.
A DNS service can receive queries on UDP port 53 and also listen for TCP connections on port 53.
Premature timeout
A premature timeout occurs when a sender retries before confirmation of a successful original transmission has had time to return.
The receiver discards the unnecessary replacement’s data but acknowledges it again to keep the sender moving.
Pseudo-header
A pseudo-header is IP addressing and protocol information included in a transport checksum calculation without becoming an extra transport header.
The UDP checksum includes destination addressing information as well as the UDP header and data.

Q

QUIC
QUIC is a secure transport protocol over UDP that supplies reliable streams and congestion control, and carries HTTP/3 traffic.
A web connection using HTTP/3 gets reliable delivery from QUIC even though UDP itself supplies no recovery.

R

Receive window
The receive window is the receiver’s advertised capacity for outstanding TCP data, changing as stored data arrives and the application reads.
If the advertisement is 10000 bytes and 4000 are already outstanding, only 6000 more fit.
Receiver window
A receiver window in selective repeat is the range of sequence numbers currently acceptable for new data, beginning at the delivery base.
A packet beyond a gap can be accepted if its number lies within the current SR receiver window.
Reliable data transfer
Reliable data transfer delivers correct application data in order without losses or duplicates, using recovery above an unreliable channel.
A replacement packet repairs a failed transmission without creating a second copy in the delivered data.
Reset
A TCP reset is a segment with RST set that refuses or abruptly aborts a connection instead of completing an orderly FIN exchange.
A SYN sent to a TCP port without a listener normally receives a reset from the destination host.
Retransmission timeout
A retransmission timeout is a waiting interval whose expiration triggers another transmission when expected confirmation has not arrived.
A lost data packet produces no feedback, but timeout still gives the sender a reason to try again.

S

SampleRTT
SampleRTT is a measured interval from sending data until receiving an ACK that covers it, provided the timing is unambiguous.
Without timestamps, an ACK covering retransmitted data cannot reveal which copy triggered the response.
Segment
A segment is a transport-layer unit containing a transport header and application data, carried inside an IP datagram.
A TCP sender adds a header to a chunk of file bytes before passing the segment to the IP layer.
Selective acknowledgment
Selective acknowledgment is a TCP option reporting received byte blocks beyond a gap, supplementing the cumulative acknowledgment boundary.
SACK can show that two later blocks are already buffered while a middle byte range still needs recovery.
Selective repeat
Selective repeat is a reliable-transfer protocol with individual packet ACKs, per-packet logical timers and out-of-order receiver buffering.
If only packet 7 times out, its sender can replace 7 without resending the successfully acknowledged packets.
Sender base
A sender base marks the oldest unacknowledged data at the beginning of a sending window, limiting how far new transmissions can extend.
In GBN, receiving ACK 19 moves the base to 20 and can make room for additional packets.
Sender utilization
Sender utilization is the fraction of elapsed time during which a sender is actively placing packet bits onto its outgoing link.
A utilization of 0.1 means the sender transmits for one tenth of the measured time and waits for the rest.
Sequence number
A TCP data segment’s sequence number identifies its first data byte in that direction’s stream, with arithmetic modulo 2^32.
A 700-byte segment beginning at 2001 is followed by new data beginning at 2701 when no control flag intervenes.
Sequence wraparound
Sequence wraparound reuses the lowest number after the highest value in a finite sequence space, requiring cyclic comparison rules.
After TCP uses all 2^32 byte values, numbers repeat even though the connection can continue carrying data.
Sequence-number space
A sequence-number space is the finite set of available packet or byte identifiers, reused cyclically when its maximum value is passed.
With three-bit packet numbers, the sequence after 6 is 7 and the next value after 7 is 0.
Silly window syndrome
Silly window syndrome is inefficient transfer in many tiny TCP segments, often encouraged by very small writes or advertised window increases.
Advertising a few newly freed bytes at a time can make header overhead dominate the useful data.
Sliding window
A sliding window is a moving range of sequence numbers that limits which packets may be outstanding or acceptable at a given time.
An advancing GBN ACK frees a position at the right edge for another new packet to be sent.
Socket
A socket is an endpoint interface through which an application process sends data into a network and receives data from it.
A TCP server keeps a listening socket while accepted clients communicate through connection sockets.
Stop-and-wait
Stop-and-wait is a transfer method in which the sender keeps only one data packet outstanding and waits for confirmation before advancing.
A long round trip can leave the sender idle even when its link can transmit the packet very quickly.
SYN cookie
A SYN cookie encodes verifiable connection information into a server’s ISN so individual state can be allocated after a valid final ACK.
The server checks the returning acknowledgment before reserving resources for that particular connection.
SYN flood
A SYN flood is an attack that sends many connection-opening requests without completing their handshakes, consuming server resources.
A backlog of unfinished requests can prevent a server from accepting connections from legitimate clients.

T

TCP
TCP is a connection-oriented transport protocol providing a reliable, in-order, full-duplex byte stream between two application endpoints.
The application receives one ordered stream even when IP datagrams arrived in a different order.
TCP option
A TCP option is variable header information extending the fixed header, such as MSS, window scaling, timestamps or selective acknowledgments.
A timestamp option makes the header longer, reducing payload space within a fixed-size IP datagram.
Three-way handshake
The three-way handshake is TCP’s SYN, SYN-ACK and ACK exchange for establishing endpoint state and confirming both initial sequence numbers.
The final ACK confirms the server’s SYN and may carry the client’s first application data at the same time.
TIME_WAIT
TIME_WAIT is a TCP closing state that retains connection information to repeat the final ACK and allow old segments to expire.
If the final ACK is lost, a retransmitted peer FIN can still be answered by the endpoint that closed first.
Transport layer
The transport layer provides logical communication between application processes on different hosts, above IP’s host-to-host service.
A browser receives its own response bytes through a socket while another application uses the same host.

U

UDP
UDP is a connectionless transport protocol that carries separate messages using port-based delivery and an Internet checksum field.
A DNS client can send its initial UDP query without exchanging transport setup messages first.

W

Window scaling
Window scaling multiplies later TCP window fields by a power of two negotiated during setup, allowing receive windows above 65535 bytes.
A scale shift of 3 interprets a later field value of 12000 as an advertised window of 96000 bytes.

Z

Zero-window probe
A zero-window probe is a small sender transmission that elicits the receiver’s current window while ordinary new-data sending is paused.
Probing lets a sender discover reopened space if the receiver’s earlier window update was lost.

About this lesson

By StudeliReport a mistake

Make your own Study Materials

Turn your notes, slides and documents into Study Guides, Practice Questions, Flashcards and 6 more tools.

Get Started