EECS 122 Introduction to Computer Networks Transport UDP
- Slides: 41
EECS 122: Introduction to Computer Networks Transport: UDP and TCP Computer Science Division Department of Electrical Engineering and Computer Sciences University of California, Berkeley, CA 94720 -1776 EECS 122 - UCB Katz, Stoica F 04
Teaching Plan § Two general approaches - Bottom-up - Top-down Application Transport Network (IP) Link Physical Katz, Stoica F 04 2
Bottom-up § § § Classic approach – start from the physical layer all the way up to the application layer Advantages – allow “natural” explanation of protocols, algorithms; lower layers provide assumptions for higher layers Disadvantages – harder to justify the goals, i. e. , what are the algorithms/protocols good for Application Transport Network (IP) Link Physical Katz, Stoica F 04 3
Top-down § § § New approach (E. g. , Kurose & Ross) – start from the application layer all the way down to the physical layer Advantages – goals are very clear start from application needs Disadvantages – harder to understand some assumptions made about lower layers (e. g. , packet losses in the Internet are because congestion) Application Transport Network (IP) Link Physical Katz, Stoica F 04 4
Mixed § § § Our approach Advantages: hope to combine the advantages of both “Bottom-up” and “Top-down” approaches Disadvantage: more confusing Katz, Stoica F 04 5
Mixed Approach: The Map 2 17, 18, 19 6 Transport 10, 11 14, 15, 16 7, 8, 9 21, 22, 23 25 Application Network (IP) Link Physical Katz, Stoica F 04 6
Today’s Lecture: 6 2 17, 18, 19 6 Transport 10, 11 14, 15, 16 7, 8, 9 21, 22, 23 25 Application Network (IP) Link Physical Katz, Stoica F 04 7
Outline Ø § § § Motivation Transport layer TCP UDP Katz, Stoica F 04 8
Motivation § IP provides a weak, but efficient service model (best-effort) - Packets can be delayed, dropped, reordered, duplicated - Packets have limited size (why? ) § IP packets are addressed to a host - How to decide which application gets which packets? § How should hosts send into the network? - Too fast is bad; too slow is not efficient Katz, Stoica F 04 9
Outline § Ø § § Motivation Transport layer TCP UDP Katz, Stoica F 04 10
Transport Layer § § Can provide more reliability, in order delivery, at most once delivery Supports messages of arbitrary length Provide a way to decide which packets go to which applications (multiplexing/demultiplexing) Govern when hosts should send data can implement congestion and flow control Katz, Stoica F 04 11
Congestion & Flow Control § Flow Control – avoid overflowing the receiver Congestion Control – avoid congesting the network § What is network congestion? § Katz, Stoica F 04 12
Transport Layer (cont’d) ports HTTP RA DNS Application p 1 p 2 p 3 p 1 p 2 Transport IP A B C [A | B | p 1 | p 2 | …] UDP: Not reliable TCP: Ordered, reliable, well-paced Katz, Stoica F 04 13
Ports § § Need to decide which application gets which packets Solution: map each socket to a port Client must know server’s port Separate 16 -bit port address space for UDP and TCP - (src_IP, src_port, dst_IP, dst_port) uniquely identifies TCP connection § § Well known ports (0 -1023): everyone agrees which services run on these ports - e. g. , ssh: 22, http: 80 - on UNIX, must be root to gain access to these ports (why? ) Ephemeral ports (most 1024 -65535): given to clients - e. g. chat client gets one of these Katz, Stoica F 04 14
Headers § § § IP IP header used for IP routing, fragmentation, error detection… (we study that when we explore IP) UDP header used for multiplexing/demultiplexing, error detection TCP header used for multiplexing/demultiplexing, flow and congestion control Receiver data Sender Application TCP/UDP data TCP UDP TCP/UDP data IP IP data IP TCP/UDP data Katz, Stoica F 04 15
Outline § § Ø § Motivation Transport Layer UDP TCP Katz, Stoica F 04 16
UDP § § § § User Datagram Protocol Minimalist transport protocol Same best-effort service model as IP Messages up to 64 KB Provides multiplexing/demultiplexing to IP Does not provide flow and congestion control Application examples: video/audio streaming Katz, Stoica F 04 17
UDP Service & Header § Service: - Send datagram from (IPa, Port 1) to (IPb, Port 2) - Service is unreliable, but error detection possible § Header: 0 16 Source port UDP length 31 Destination port UDP checksum Payload (variable) • UDP length is UDP packet length (including UDP header and payload, but not IP header) • Optional UDP checksum is over UDP packet Why have UDP checksum in addition to IP checksum? Why not have just the UDP checksum? Why is the UDP checksum optional? Katz, Stoica F 04 18
Outline § § § Ø Motivation Transport Layer UDP TCP Katz, Stoica F 04 19
TCP § § § Transmission Control Protocol Reliable, in-order, and at most once delivery Messages can be of arbitrary length Provides multiplexing/demultiplexing to IP Provides congestion control and avoidance Application examples: file transfer, chat Katz, Stoica F 04 20
TCP Service 1) 2) Open connection Reliable byte stream transfer from (IPa, TCP Port 1) to (IPb, TCP Port 2) • 3) Indication if connection fails: Reset Close connection Katz, Stoica F 04 21
Timing Diagram Open connect. SYN k 3 -way handshake SYN n; ACK k+1 DATA k+1; ACK n+1 ACK k+n+1 data exchange Transfer FIN Close connect. ½ close FIN ACK ½ close Katz, Stoica F 04 22
Open Connection: 3 -Way Handshaking § Goal: agree on a set of parameters: the start sequence number for each side - Starting sequence numbers are random. Server Client (initiator) Active connect() Open listen() SYN, Seq Num = x eq. Num S , K C A YN and =x+ k c A d n =ya 1 accept() Passive Open S ACK, Ack =y+1 allocate buffer space Katz, Stoica F 04 23
3 -Way Handshaking (cont’d) § § Three-way handshake adds 1 RTT delay Why? - Congestion control: SYN (40 byte) acts as cheap probe - Protects against delayed packets from other connection (would confuse receiver) Katz, Stoica F 04 24
Close Connection (Two-Army Problem) § § Goal: both sides agree to close the connection Two-army problem: - “Two blue armies need to simultaneously attack the white army to win; otherwise they will be defeated. The blue army can communicate only across the area controlled by the white army which can intercept the messengers. ” § What is the solution? Katz, Stoica F 04 25
Close Connection § 4 -ways tear down connection Host 1 Host 2 FIN close FIN ACK timeout § Avoid reincarnation § Can retransmit FIN ACK if it is lost closed Katz, Stoica F 04 26
Reliable Transfer § Retransmit missing packets - Numbering of packets and ACKs § Do this efficiently - Keep transmitting whenever possible - Detect missing ACKs and retransmit quickly § Two schemes - Stop & Wait - Sliding Window (Go-back-n and Selective Repeat) Katz, Stoica F 04 27
Stop & Wait § § Send; wait for ack If timeout, retransmit; else repeat TRANS DATA Receiver Sender RTT ACK Inefficient if TRANS << RTT Time Katz, Stoica F 04 28
Sliding Window § window = set of adjacent sequence numbers The size of the set is the window size § Assume window size is n § Let A be the last ack’d packet of sender without gap; then window of sender = {A+1, A+2, …, A+n} § Sender can send packets in its window § Let B be the last received packet without gap by receiver, then window of receiver = {B+1, …, B+n} § Receiver can accept out of sequence, if in window § Katz, Stoica F 04 29
Go-Back-n (GBN) § § Transmit up to n unacknowledged packets If timeout for ACK(k), retransmit k, k+1, … Katz, Stoica F 04 30
GBN Example n = 9 packets in one RTT instead of 1 Fully efficient Time Katz, Stoica F 04 31
GBN Example with Errors Window size = 3 packets 1 2 3 Timeout Packet 5 4 5 6 7 Sender Time Receiver Katz, Stoica F 04 32
Selective Repeat (SR) § § § Sender: transmit up to n unacknowledged packets Receiver: indicate packet k is missing Sender: retransmit packet k Katz, Stoica F 04 33
SR Example with Errors Window size = 3 packets 1 2 3 4 5 6 7 5 8 Sender nack = 5 Time Receiver Katz, Stoica F 04 34
Observations § With sliding windows, it is possible to fully utilize a link, provided the window size is large enough. Throughput is ~ (n/RTT) - Stop & Wait is like n = 1. § § Sender has to buffer all unacknowledged packets, because they may require retransmission Receiver may be able to accept out-of-order packets, but only up to its buffer limits Katz, Stoica F 04 35
Setting Timers § § The sender needs to set retransmission timers in order to know when to retransmit a packet the may have been lost How long to set the timer for? - Too short: may retransmit before data or ACK has arrived, creating duplicates - Too long: if a packet is lost, will take a long time to recover (inefficient) Katz, Stoica F 04 36
Timing Illustration 1 1 Timeout RTT 1 Timeout too long inefficiency Timeout too short duplicate packets Katz, Stoica F 04 37
Adaptive Timers § § § The amount of time the sender should wait is about the round-trip time (RTT) between the sender and receiver For link-layer networks (LANs), this value is essentially known For multi-hop WANS, rarely known Must work in both environments, so protocol should adapt to the path behavior Measure successive ack delays T(n) Set timeout = average + 4 deviations Katz, Stoica F 04 38
Timer Algorithm § Use exponential averaging: A(n) = b*A(n- 1) + (1 – b)*T(n) D(n) = b*D(n-1) + (1 – b)*(T(n) – A(n)) Timeout(n) = A(n) + 4*D(n) Notes: 1. Measure T(n) only for original transmissions 2. Double Timeout after timeout … Justification: timeout indicates likely congestion; Further retransmissions would make things worse 3. Reset Timeout = A + 4 D for new packet and when receive ACK Katz, Stoica F 04 39
TCP Header § § Sequence number, acknowledgement, and advertised window – used by sliding-window based flow control Flags: - SYN, FIN – establishing/terminating a TCP connection - ACK – set when Acknowledgement field is valid - URG – urgent data; Urgent Pointer says where non-urgent data starts - PUSH – don’t wait to fill segment - RESET – abort connection 0 4 10 16 31 Destination port Source port Sequence number Acknowledgement Advertised window Hdr. Len Flags Checksum Urgent pointer Options (variable) Payload (variable) Katz, Stoica F 04 40
Summary § § UDP: Multiplex, detect errors TCP: Reliable Byte Stream - 3 -way handshaking Reliable transmissions: ACKs… S&W not efficient Go-Back-n What to ACK? (cumulative, …) Timer Value: based on measured RTT Katz, Stoica F 04 41
- Eecs 122
- Eecs 122
- Difference between virtual circuit and datagram network
- Backbone networks in computer networks
- Internet transport protocol in computer networks
- Transport udp
- Symport
- Membrane structures that function in active transport
- Passive transport vs active transport venn diagram
- Active transport vs passive transport venn diagram
- Pinocytosis vs phagocytosis
- Primary active transport vs secondary active transport
- Bioflix activity membrane transport active transport
- Active transport and passive transport
- Selectively permeable definition biology
- 8dar8
- Nec 250-94
- Http://122
- Homework 122
- Ece 122
- Notice to amend assessment
- Ivy tech math 136
- Nec 250 122
- Psalm 84 the passion translation
- Psalms of ascent background
- Ee 122 berkeley
- Ee 122
- Ee 122
- W-122 airspace
- Psalms 68 tpt
- 50000/122
- Hist 122
- 749 to the nearest 10
- Psalm 22:15
- Nrs 122
- A traffic light weighing 122 n
- 122+105
- Texto en 3ra persona
- Convenio 122 oit
- You buy a package of 122 smarties
- Ece 122
- Ee 122