1/53
Looks like no tags are added yet.
Name | Mastery | Learn | Test | Matching | Spaced | Call with Kai | Chat |
|---|
No analytics yet
Send a link to your students to track their progress
Transport Layer Purpose
Purpose is logical process to process communication
Transport layer
Provides service to the applications - implements service models widely used by applications. Uses the service of the network layer - IP datagram service.
(Semi-) Simplex & Duplex
Only send data one direction. Semi-simplex can send data both directions, but not simultaneously. Full-Duplex can send both directions simultaneously
Mux-Demux - Multiplexing
Multiplexing is at sender side. UDP for example accepts messages from different processes, differentiated by their assigned port numbers and adds the header.
Mux-Demux - Demultiplexing
Demultiplexing is reciever side. After error checking and dropping header deliver each message to correct process based on the port numbers.
Socket
IP address and port number
Three groups of port numbers
0 -1023 - well known ports. Assigned and controlled by IANA- Normally for servers / services
1024-49151 - Registered ports. Registered by IANA - non-excliusive. Normaly for apps
49152-65535 - Dynamic ports. Ephemeral, can be used by any process, typically client processes.
User Datagram Protocol (UDP)
Best-effort datagram service. Connectionless, message-oriented and unreliable. Provides error detection, multi and demultiplexing.
Message Oriented
Messages are sent in chunks and are recieved in the same chunks
Unreliable service
Sender wont know if data is recieved
UDP Mux/Demux
UDP data delivery is based on reciever port number and reciever IP address
UDP Segment Format
UDP header is 8 bytes. First is src port 2 byte, dst port 2 byte, udp length 2 byte and 2 byte UDP checksum
UDP Error Detection
Uses UDP checksum and ones complement. Coveres the pseudo-header, header and application data padded to be multiple of 2 bytes. Checksum optional in IPv4 (set all 0’s checksum field), mandatory in IPv6 since no error detection at network layer.
UDP Pseudoheader
4 byte src IC, 4 byte dst IP, 1 byte all 0, 1 byte protocol and 2 byte UDP length field.
UDP-lite
Replace UDP length field with checksum coverage field. Useful for multimedia where some corruption can happen, coverage ensure important part not corrupted.
TCP Service Model
Connection-oriented
Between EXACTLY two endpoints
Full-Duplex
Reliable and in-order
Byte Stream Service
Byte Stream Service
Stream of 8-bit bytes are transmitted over TCP connection
TCP functions
Multiplexing/Demultiplexing
Segmentation
Error Control
Flow Control
Connection Management
Congestion Control
TCP Mux/Demux
TCP conneciton identification is based on reciever port, IP AND sender port, IP.
TCP Segmentation
Data arrives and is delivered as byte stream. There is a buffer sender and reviever side. Try to send as big segments as possible and need one buffer for each TCP connection. Convert the bytestream into datagram segments using buffer.
Maximum Segment Size (MSS)
Largest chunk of data TCP will send to other side. Can be announced in option field of TCP header. IPv4 default 536 bytes, IPv6 default 1220 bytes of data for 1280 MTU.
Error Control
Provide reliable transmission over error prone channel. Error-prone channel can be noise causes bit error causes packet corruption causes packet drop or congestion causes packet drop. Can use Automatic Repeat Request (ARQ) either with ACK - communicate data recieved or NACK - Expected data, didnt get data.
Propagation vs Transmission
How long to transmit L bits with bandwidth B bits/sec, length P meters, v m/s? P/v is propagation time, L/b is transmission time. The total is the sum of the two.
Stop-and-wait
Start with data 0 and alternate with 0 and 1 for data number. Start a timer, if data i doesnt get Ack i before timeout then retransmit data i again. Pro is simple operation and only need m = 1 bit counter to detect duplicate data & ACK. Reciever needs no buffer. Has pad performance, Util is L/B/(RTT + L/B)
Go-Back-N
Sort of like stop & wait but more parallell. N is how many messages can be sent before ACK. Can’t have as many sequence numbers as N. Needs m-bit counter to avoid duplicates, then need N <= 2^m-1. No buffer needed in reciever. Util is now min(1, N*L/B/(RTT+L/B)). (N = 3 Example data 0,1,2 sent, data 0, 1 ACK and sends 3, 0 then but eventually 2 timesout. Then retransmit 2 AND 3 and 0 and continue from there)
Selective Repeat-N
More complex Go-Back-N. Need m bit counter to avoid duplicate and sender window N <= 2^(m-1). Reciever also needs a same size buffer to store out-of-order packets. Instead of cummulative ACK, use ACK for each individual packet and only retransmit packets that aren’t ACK’d instead of retransmit everything after aswell. Only improves performance if data is lost.
Reliability in TCP
Purpose is providing reliable transmission over datagram channel. Solution is Go-Back-N with cumulative ACK & reciever side buffering. Does not discard data unless its duplicate.
TCP Reliability - Sender Side Operation
Breaks app data into segments.
Assign sequence number to every byte
Create e2e checksum of the header and data
Start timer for each sent segment
Wait for ACK
if ACK not recieved before timeout (RTO), retransmit segment
TCP Reliability - Reviever Side Operation
Verify e2e checksum of header and data, discard if wrong.
Send cumulative ACK when it recieves data
If necessary, reorder data and discard duplicate data
Retransmission Timer
Retransmission Time-Out(RTO): Time to wait for ACK. Cannot be fixed for all connection and segments in a connection. RTO calculated dynamically based on measured RTT. Use binary exponential backoff, double RTO for each retransmission, if RTO gets to 1-2 minutes terminate connection.
RTO Calculation
RTTvar[k+1] = (1-B)*RTTvar[k] + B*|sRTT[k]-mRTT[k]|
sRTT[k+1] = a*sRTT[k]+(1-a)*mRTT[k]
RTO = sRTT[k+1]+4*RTTvar[k+1]
Karns Algorithm
Scenario is when segment is not ACK’d and retransmitted. When ACK is recieved sender doesn’t know if ACK was for original segment of the retransmitted segment. Karn’s algorithm is to not consider the RTT of a retransmitted segment and don’t update RTT value until you get an ACK without need for retransmission.
TCP Flow Control
Ensure reciever not overwheled with data from sender. Control the data amount sender can send before ACK recieved.
TCP Sliding Window Protocol
Window controls the amount of unACK’d data in the network. Do this for each TCP connection in each direction. Reciever offers window together with ACK. This says how much data it can recieve beyond what was ACK’d. Can be 0, then sender waits for window update with offer window size > 0. The sender can maintain usable window, data it can send immediately.
Persistance Timer
Periodically send window probes to find out if window size has increased example every 60 seconds. This is since a scenario that is bad is reciever annouces RWND = 0, so sender stops and waits. Then reciever sends ACK and RWND > 0 which gets lost. Then sender waits for the ACK and reciever waits for data, which is solved by persistance timer.
Delayed ACK
Do not send ACK immediately. Send atleast one ACK per two full-size segments. Delay must be less than 500 ms, typically >= 200 ms. This reduces ACK traffic and more chances you can piggyback data on ACK. Key is retransmission timer should not be triggered.
Silly Window Syndrome (Sender initiated)
Problem is a slow sender application. Example 1 byte sent per keystroke. So 1 datagram (41 bytes) for each 1 byte of user data (tinygram). This adds alot of congestion on WANs. Solved by Nagle’s Algorithm
Nagle’s Algorithm
Solves Sender Willy Window Syndrome. TCP connection can only have on unACK’d tinygram. Data accumulates while waiting and sent as one segment when ACK arrives, or when MSS can be filled. The faster ACKs come, the more often data is sent.
Silly Window Syndrom - Reciever Initiated
Problem is a slow reciever app. Sender sends big segments but recieving app consumes data slowly so buffer gets full. Reciever window size gets announced for each byte read from buffer if it reads 1 byte at a time then. Solved by Clark’s Solution
Clark’s Solution
Solution to Silly Window Syndrome - Reciever Initiated. Do not advertise small increments of RWND size. Increment atleast by MSS or ½ reciever buffer size.
Self-Clocking
When bulk-sending data eventually the sending rate will adjust to the slowest link bottleneck.
Bandwidth-delay product
Capacity of the pipe. Capacity = Bandwidth * RTT. RWND should be higher or it will not be fully utilized.
TCP Connection Establishment
Uses three-way handshake to establish connection. The three-way handshake guarantees both sides ready to transfer data and allows both side to agree on ISN, MSS and window size in the ACK messages. ISN must be chosen so each incarnation of a specific TCP connection between two end-points has different ISN.
Three-Way Handshake - Establishment
Client sends SYN packet with SYN seq = x. Server then responds with their own syn message SYN seq = y, ACK x+1 to also acknowledge the client SYN and send RWND. Then client finally responds with seq = x+1, ACK y+1 to ACK server SYN, ACK. Then can send data.
Keepalive Timer
Prevent TCP connection existing forever. (Ex. client connects, transmits then crashes. Connection would stay active and consume resources). Solution is TCP gets keepalive time-out after some time, usually 2 hours. Afterwards server probes client ex. 10 probes each 75 seconds. If no response, tear-down connection.
TCP Connection Teardown
TCP client gets close command from client process, sends FIN, seq = x to TCP server. TCP server sends ACK (seq=x+1) of FIN and deliver EOF to app. When app closed, Server sends ACK (seq=x+1), FIN, seq = y. Then finally TCP client sends ACK (seq=y+1) of FIN and then the connection is closed
Time-Wait Timer
Connection is held in TIME-WAIT state while closing. When FIN or ACK of FIN is sent Time-Wait Timer started which is twice the maximum lifetime of segment. if ACK or FIN gets lost then it is retransmitted when timer expires. This is done since server can’t close the connection until it recieves ACK of FIN. Typically MSL = 0,5 to 2 minutes (IP TTL limit)
Congestion
If router recieves packets faster than it can process then packets get dropped. Packets need a buffer to decrease drop rate. Delay and missing ACK’s cause retransmission which will add to congestion which leads to network collapses. Window size must therefore depend on networks state aswell.
Congestion Window
Maintained by the sender and updated in response to losses / delay. Sender maintains 2 window sizes, Reciever-advertised window (RWND) and Congestion Window (CWND). The actual window size is the min(RWND, CWND). There are two phases, slow start and congestion avoidance.
Slow Start Phase
All TCP operations MUST implement slow start. Operation: At beginning of connection, CWND <= [1..4] x MSS. For each incoming ACK: CWND += min(N, MSS) where N is the new data (in bytes) acknowledged by ACK. Window size grows exponentially, but with delayed ACK it slows down since its bound by MSS.
Congestion Avoidance phase
Increase CWND additively. On every acked byte, CWND += MSS/CWND (+1 MSS per RTT). Linear growth continues until RWND is reached or ACK timeout occurs which TCP assumes is congestion. Upon timeout (TCP Tahoe), ssthresh = CWND/2 and set CWND = 1 MSS (enter slow start). As for choice of ssthresh, initial value 65535, minimum value 512 bytes.
TCP Reno
Problem is out of order and losing single segment can trigger slow start. Solution is TCP Reno. Generate immediate ACK when out of order segment recieved. If 3 or more duplicate ACKs in a row, retransmit immediately (Fast Retransmit) and do congestion avoidance phase (Fast recovery). Set CWND to ssthresh + 3*MSS after halving ssthresh. When new data is ACK’d, set CWND = ssthresh.
TCP Throughput Model
Congestion avoidance phase only, using Fast Recovery. Approximate using constant RTT and maximum window size W. Then R = MSS ¾ * W/RTT
TCP Segment
2 byte source port, 2 byte dst port, 4 byte sequence number, 4 byte ACK number, 4 bit header length, 6 bit reserved, 6 bit flags, 2 byte window size, 2 byte TCP checksum, 2 byte urgent pointer, options (if any), data (if any).