transport layer Flashcards
Where does the transport layer run?
only on the host and destination
transport layer functions
provides a reliable data stream over an unreliable network
provides communication between processes
primitives used by transport layer to provide communication between processes
- listen - wait for another process to contact us
- connect - connect to a process that is listening
- send - send data over the established connection
- receive - receive data over the established connection
- disconnect - release the connection
- the interface exposed to the application layer
- connection-oriented service over (possibly) connectionless network
Berkley Socket primitives
the interface exposed to the application layer
used by TCP
1. socket- create a new communication endpoint
2. bind - assign a local address to an endpoint (socket)
3. listen
4. accept- passively establish an incoming connection
5. connect
6. send
7. receive
8. close
addressing
TSAP = Transport Service Access Point
NSAP = Network Service Access Point
internet uses IP addresses for NSAPs and ports for TSAPs
process servers
multiplexing
multiple transport connections over one network connection
servers typically hardcoded
inverse multiplexing
one transport connection over multiple network connections
a form of multihoming: multiple paths to the same destination
NAT
network address translation
Connection establishment using sequence numbers
- if a segment comes in with a sequence number that we have already seen, we discard it
- How do we ensure that there are never multiple packets with the same sequence number?
- If a machine crashes and reboots, what sequence number should it choose?
1. we use a packet hop limit to remove old packets; after time T, sequence numbers safe to wrap around
2. we use time-of-day clock to decide which sequence number to choose; keeps working when host crashes
How do sequence number affect performance?
they limit it
- x-bit sequence number
- y bytes per second sending rate
- sequence number wraps around after 2^x/y seconds
- sequence number that reappears within T seconds is retransmission
- sequence number that reappears later is new segment
- maximum sending rate: 2^x/T (bytes per second)
clock-based seq numbers
sequence numbers to use increase with clock, regardless of sending rate
forbidden region
three-way handashake
used by TCP
agreement on which seq num to use
connection release
when the exchange is complete, the connection should be closed
asymmetric connection release
connection ended by either participant without agreement → may result in data loss
symmetric connection release
the two armies problem
- the last party to send a message cannot know if it arrived
participants agree to end connection
the end-to-end argument
if the network(lower layers) are unable to provide a feature by itself, it should be removed from the network and provided by the hosts (transport layer or higher)
error control in transport layer
the transport layer is responsible for providing a reliable data stream over an unreliable network
transport layer check the end-to-end correctness of data
reliable delivery through retransmission
improving performance by using error control on lower layers
error control and crash recovery
protocol under normal circumstances:
1. segment
2. ACK
3. pass on to layer
4. segment
when machine fails:
1. segment
ACK not transmitted
2. pass on to layer
3. segment
crash recovery
machine fails:
1. segment
2. ACK
data not passed
3. segment
crash recovery on layer X
- recovery from layer X crash can only be done by layer >X
- when a crash occurs, the transport layer leaves it to the application layer to fix it
flow control
regulating sending rate
needed to slow down the sender if the receiver cannot handle the data rate
example: phone cannot handle data rate - small capacity receiver
stop-and-wait: a 1-bit sliding window protocol
bandwidth inefficient for high-latency channels
sliding window protocols
- send multiple frames at the same time before waiting for an acknowledgment (i.e., filling the pipe)
- ex: go-back-N, selective repeat
flow control and buffer management
received packets have to be buffered at the receiver
- we have to wait for the application to read the data
- used by TCP!
perform buffer management separately
regulating sending rate
- congestion control is needed to slow down the sender if the network cannot handle the data rate
- network cannot handle high data rate
- small capacity network
- this can also happen when many users share the same links
packet loss and end-to-end delay can be used to signal ….
congestion control
when foes congestion occur?
if the workload is too large for the available network resources
fair bandwidth allocation
max-min fairness
convergence
max-min fairness
maximises minimum bandwidth, then uses excess bandwidth where possible
convergence
when new connections enter the network, the bandwidth needs to be reallocated
Why is available bandwidth unknown
the transport layer isn’t aware of the network topology, or who else is using the network
solution for unknown bandwidth
dynamically adjust bandwidth using trial and error
keep trying to increase bandwidth usage → slow down when you receive congestion signal
can we send using this much bandwidth? → no
additive increase, additive decrease
multiplicative increase, multiplicative decrease
additive increase, multiplicative decrease
regulating sending rate - efficiency and fairness
internet protocols
transport layer: TCP and UDP
- all or nothing
- may not meet your application’d requirements
- insufficient separation between mechanism and policy
RFCs
(request for comment) are published by the Internet Engineering Task Force (IETF)
comparing complexity by number of RFCs
TCP > UDP ??
UDP
RFC: 768
very thin layer on top of IP
doesn’t do:
- flow control
- congestion control
UDP header
- provides ports needed to connect to remote applications
- 32 bits
- source port + destination port + UDP length + UDP checksum (includes fields from the IP header!)
TCP
one of the most important protocols on the internet
provides a reliable end-to-end byte stream over an unreliable network
TCP header
- 32 bits
- sequence number and acknowledgements allow reliable, in-order delivery and enable sliding window protocols
- TCP checksum uses same IP-header fields as the UDP checksum
- header length, options (o or more 32-bit words)
- how do we know how long the TCP segment is?
- window size: used for flow or congestion control??
flags used to establish/release TCP connections
ACK, SYN, FIN
connection establishment - three-way handshake
- every data byte has its own sequence number (SYN and FIN also have their own sequence numbers
- sequence number x+1: bytes 0 to x have been received, expecting byte x+1 next
- initial sequence numbers are randomly generated → ensures security
timestamp option
- use sequence number + timestamp to detect duplicates
- improves performance
TCP PAWS
TCP sequence numbers
- every data byte has its own sequence number
- initial sequence numbers are randomly generated
error control in TCP
reliable delivery through retransmissions
dynamic timeouts in TCP
setting retransmission timers
- how long to wait before retransmitting a frame?
- timer must be longer than round-trip time
- congestion makes round-trip variable
- if we set timer too high, bandwidth efficiency goes down
dynamic timeouts in TCP
- use a weighted moving average to smooth round trip time (SRTT)
- do the same for the round trip time variance (RTTVAR)
- calculate new retransmission timeout (RTO) based on these
- R: round trip time
fast retransmission
→ performance improvement
- packet loss detected when timers expire
- takes time by design
- duplicate ack can indicate packet loss
flow control in TCP
buffer management
window size
Nagle’s algorithm
TCP window size - Nagle’s algorithm
- do not send more than one small packet at a time: wait for ack
- a sender produces data in small amounts
- small segments cause large overhead
Silly-window syndrome
- do not send window updates if available space is too small
- a receiver that consumes data in small amounts
- tiny window sizes cause large overhead
TCP delayed ACKs
- try to improve bandwidth efficiency (e.g. through piggyback)
- wait up to 500 ms to send ack
- send ack for every second full-size segment
Congestion Control in TCP
- flags OWR and EOE used for explicit congestion notification
- additive increase multiplicative decrease in TCP (AIMD)
- AIMD used to prevent network congestion
- converges to fair and efficient bandwidth allocation
- TCP implements this using its congestion window
-
congestion window is tracked on the sender
- specifies how many segments can be transmitted
- how does TCP combine the two windows?
- we want fast convergence, but sending a large burst can occupy low-bandwidth links for a long time
- increase congestion window whenever acks arrive
- ack rate tells us data rate of slowest link
slow starts
- congestion window size grows based on ack rate
- arbitrary threshold switches from slow start to additive increase
slow start → congestion window growing over time
TCP Tahoe
- arbitrary threshold switches from slow start to additive increase
- wait 1 RTT for segments to leave the network
- additive increase
- packet loss detected → reset congestion window
- multiplicative decrease (threshold window)
fast retransmission
- packet loss detected when timers expire
- we can count the number of packets in the network
TCP Reno (Tahoe + fast recovery)
- calculates the number of segments in the network by counting the number of duplicate acks
- threshold reduced using multiplicative decrease
- congestion window set to new threshold value
TCP versions that have implicit congestion control
TCP
CUBIC TCP
FAST TCP
Compound TCP
TCP versions that have explicit congestion control
TCP with Explicit Congestion Notification
TCP explicitly tells sender what rate to use
CUBIC TCP
determines rate based on packet loss
used by default in Linux, Windows, MacOS
FAST TCP
determines rate based on end-to-end delay
Compound TCP
determines rate based on end-to-end delay and packet loss
how does TCP combine them (congestion window and window size)?
uses the smaller number
AIMD in TCP
we want fast convergence, but sending large burst can occupy low-bandwidth links for a long time
increase congestion window whenever acks arrive
slow start
- starts with congestion window 1 and window size 1
- after receiving the first ack double the number of segments allowed at the same time (exponential growth)
duplicate ack → packet loss or out of order arrival
- TCP fast retransmission detects lost segment after 3 duplicate acks; triggers retransmission and multiplicative decrease