CSCI 6433 Internet Protocols Class 5 Dave Roberts 1 Internet Protocol Principles 0 Good Citizen Principle 0 When a resource is scarce, use less of it 0 Conservation of Router Time 0 Minimize the work done by routers 0 Soft State 0 Save information that takes traffic to obtain that might be used again; age and replace it 2 Tonight 0 User Datagram Protocol (UDP) 0 Reliable Stream Transfer Service (TCP) 0 Network Address Translation (NAT) 3 What Does IP Do? 0 Addressing 0 Data encapsulation 0 Fragmentation and reassembly 0 Routing/indirect delivery 4 UDP and TCP 5 Ports 0 Destination of a datagram is a program 0 Selection is by protocol port number 0 Messages carry source and destination port numbers 0 UDP and TCP provide protocol ports, provide ability to distinguish among destinations within a given host 6 UDP and TCP in Operation 7 UDP--User Datagram Protocol 0 UDP provides unreliable, best-effort, connectionless datagram delivery services to multiple destinations within a single host computer, using IP to carry messages 8 UDP Message Format 9 UDP Message Format Question: How many different UDP ports can there be on a PC? 10 UDP Layering Application programs access UDP, and UDP uses IP to send and receive datagrams UDP message is encapsulated in an IP datagram 12 UDP Demultiplexing 13 Question 0 What good is data that’s not delivered correctly? 0 Why would we want errors in data? 0 What is UDP used for? 0 Does ICMP use UDP? 14 Well-Known Port Assignments 15 Summary 0 UDP is a “thin” protocol 0 Unreliable 0 Best-effort 0 Distinguishes between applications 0 16-bit port number is used 0 UDP lies in the transport layer 16 On to TCP! 17 What TCP Does 0 Addressing and multiplexing 0 Connection establishment, management and termination 0 Data handling and packaging 0 Provides reliability and transmission quality services 0 Provides flow control and congestion avoidance features 18 How TCP Does Its Job 0 Connection-oriented 0 Bidirectional 0 Multiply-connected 0 Reliable 0 Acknowledged 0 Stream-oriented 0 Data-unstructured 0 Data flow managed 19 Why Stream Delivery? 0 Using stream delivery protocol frees the application from any concern about network delivery of data 0 Packets may arrive out of order 0 Packet data may contain errors 0 Application program doesn’t want to know optimal packet size 20 TCP—Reliable Stream Transport Service 0 Stream orientation—receiver gets the same sequence of octets sent by the sender 0 Unstructured stream—no way to mark boundaries, applications must use a stream 0 Virtual circuit connection—source and destination operate at the same time, interact during the transfer 0 Buffered transfer—large blocks can be transferred, fed to receiver as needed 0 Full duplex connection—communication can take place in both directions 21 Reliable Delivery, Unreliable Transport 0 Ethernet is unreliable 0 IP is unreliable 0 But TCP, that runs over IP, is reliable 0 How? 22 Unreliable Transport 23 Positive Acknowledgement with Retransmission 0 Sender starts a timer when sending, saves data 0 Receiver sends acknowledgement (ACK) when data arrives successfully 0 When ACK arrives, sender cancels timer, deletes data 0 If timer expires, sender retransmits data, starts another timer 24 Reliable Transport 25 Delays A positive acknowledgement protocol introduces a number of delays because it delays sending a new packet until it receives an acknowledgement for the previous packet. 26 Sliding Windows To solve the problem, we use the sliding window approach to decouple transmissions from reception of acknowledgements. The sender transmits multiple packets before waiting for an acknowledgement. The number of packets is said to be the window size. 27 Sliding Window Approach 28 Sliding Window Example 29 Enhanced Positive Acknowledgement 30 Sliding Window Approach Question: Suppose the IP link travels over a very high-capacity satellite connection that has ¼ second latency in each direction. What is the effect on throughput if the window size is set to 1? What if it is set to, say, 1,000? 31 TCP Protocol Enhancements 0 There are a number of protocol extensions and hardware products designed to speed up TCP in the presence of delays 0 Generally they involve some form of providing ACKs to the sender before the receiver has received the packet 0 The extension then has to provide some form of retransmission itself, since TCP counts success when it receives an ACK 32 TCP and UDP Layering 33 Ports and Connections 0 UDP uses the port as a queue to process incoming data 0 TCP uses port numbers, but the port number is part of identifying a connection 0 A connection is identified as a pair of pairs in the form <host, port> • Question: can two programs both use the same TCP port on the same machine at once? 34 TCP Segments and Streams Data stream divided into segments. Window used to send multiple segments before acknowledgement arrives. Allows receiver to restrict transmission until it has buffer space. 35 Flow Control 0 Each ack includes a window advertisement, giving the number of additional octets the receiver is willing to accept 0 Sender increases or decreases its window size based on the window advertisement 0 The sliding window provides end-to-end flow control 0 Congestion, that can occur at intermediate points, is dealt with by congestion control mechanisms 36 MSS 0 MSS—maximum segment size is negotiated 0 MSS may be the MTU of a single connecting network, if both ends are on the same network 0 MSS may be the MTU of path if sender and receiver are on different networks 0 Risk of poor performance if MSS is too large or too small 37 Problems with Wrong MSS 0 If too large: segments will be fragmented, requiring extra network messages and routing 0 If too small: fixed size of TCP header, IP header, Ethernet header all are still required for a small amount of data Question: what’s the right size for a TCP segment? 38 TCP Segment Format 39 Code Bits Code bits determine purpose, contents of the segment 40 Urgent TCP Data 0 Programs may need to send “out of band” data 0 That is, data is treated as being sent through another connection 0 In TCP, this can be done by setting the urgent flag 0 Receiving program processes urgent data ahead of the rest of the data stream 41 TCP Acknowledgements 0 TCP acknowledgements can’t refer to datagram or segment numbers, since retransmission can change message size 0 TCP ack specifies sequence number of the next octet the receiver expects to receive 0 Called a cumulative acknowledgement 0 Both efficient and inefficient 42 Timeout, Retransmission 0 Great variation in transit times, from local net to distant network 0 Adaptive retransmission algorithm—monitors the performance of each connection, deduces reasonable timeout value 0 Stores round trip time, uses new RTT to change stored RTT slowly 0 Timeout is some constant times RTT 0 Note that acknowledgements are ambiguous in case of retransmissions 43 Karn’s Algorithm 0 Timer backoff strategy 0 Compute an initial timeout 0 If retransmission, then increase timeout 0 Often, double the timeout 0 Timeout increases have an upper limit 0 Karn uses only unambiguous acknowledgements to compute RTT new_timeout = γ * old_timeout 44 Response to Congestion 0 No way for TCP to directly know about congestion, which causes retransmission, increasing congestion even further 0 Multiplicative decrease congestion avoidance—when Karn’s Algorithm is an example of segment is lost, sender congestion window is reduced by half which principle of Internet protocols? (starts same as receiver advertisement), ack timer is increased 0 Allowed window=min(receiver_advertisement, congestion_window) 0 Slow-start recovery—start congestion window at single segment size, increase by one for each ack 45 Explicit And Explicit Notification 0 Most versions of TCP use implicit feedback mechanisms—using timeout and multiple ACKs to detect loss and congestion 0 Some versions of explicit feedback have been developed for TCP/IP 0 Selective acknowledgement—receiver identifies left edge, right edge of received segments 0 Explicit congestion notification—routers add notification to TCP header, then receiver notifies sender in next ACK 46 Global Synchronization 0 When router is congested, early routers used tail- drop strategy 0 Tail-drop—drop most recent datagram 0 This can cause drops from many TCP sources at the same time, leads to global synchronization 0 Random Early Discard (RED)—uses min and max. If fewer than min datagrams in queue, add it. If more than min, randomly discard one datagram. More than max, then drop new datagram. 47 Establishing TCP Connections Three-way handshake is used to establish TCP connection. 48 Close TCP Connection 49 The TCP FSM 50 Well-Known Port Assignments 51 Silly-Window Syndrome 0 Receiver reports buffer space available as WINDOW field in ACK 0 Advertising single byte window causes sender to send one-octet segment 0 Avoid it by: 0 Receiver doesn’t advertise until space has accumulated 0 Sender doesn’t send unless enough data to fill medium- size segment. But sends data when an ack arrives, even if still accumulating 52 NAT 0 Developed in order to extend life of IP address pool 0 Used these characteristics of Internet connections: 0 Most hosts are clients that don’t need to be publicly accessible 0 Not all hosts access the Internet at the same time 0 Internet connections are routed 0 NAT shares globally unique IP addresses among the hosts that are actually using an Internet connection 53 Analogy 0 Think of a NAT router as a company’s telephone operator 0 Connects outside callers to local extensions 0 Connects local extensions to the outside network 54 Summary 0 TCP provides an important service: Full duplex, reliable connection between two machines 0 Segment as basic unit of interchange 0 Flow control through advertising, backoff 0 Many additional techniques to increase performance Since TCP provides reliable communication, why do we need UDP? Why not just use TCP for all Internet communication? 55 Network Address Translation 0 Extends the pool of addresses 0 Creates a form of two-level addressing 0 Could be used even more widely to extend the pool of IPv4 addresses 0 Does not allow for a server inside the NAT network to hosts outside 0 Can be port-based or not 56 What NAT Does 0 NAT maps IP addresses at a router 0 NAT allows a network to have local IP addresses that do not conform to Internet standards 0 NAT has a pool of valid IP addresses, and shares them among local hosts 0 NAT changes IP addresses in messages that it exchanges through the router 57 How NAT Works 58 Limitation 0 Traditional NAT is said to be “unidirectional”, allows only for transactions originated inside the network 0 No allowance for a server inside the network that serves users across the Internet 0 If each host on a network has many sessions open, pool of IP addresses may become exhausted 59 Port-Mapped NAT 0 UDP and TCP offer ports; connection is named by IP address and port number 0 NAT can map UDP and TCP messages to IP address and port numbers 0 This greatly increases the number of simultaneous connections that can be handled using one valid IP address Question: how many simultaneous connections can be handled by a NAT box for each valid IP address? 60 NAT Saving IP Addresses 0 ISPs, large organizations can solve the IP address shortage 0 Every ISP gets just one IP address per 10,000 customers 0 Same for large organizations 0 Port-mapped NAT is used for ISP customers 0 Excess IP addresses are returned for reuse So why do we need IPv6? Why not use NAT to increase effective number of IP addresses by 10,000 (or more)? 61 The Problem with NAT 0 First, NAT changes messages, does not operate truly end-to-end, violates a basic idea of Internet protocols 0 Some applications have IP addresses other than in the IP header 0 These applications won’t work with NAT unless NAT knows about them and changes the IP addresses 0 FTP is an example 0 NAT works only for sessions started from inside the network How can I run a server on a network that is behind a NAT box? 62 Summary 0 NAT can extend the pool of IP addresses 0 NAT has limitations 0 NAT must violate layering to be useful 0 Over time, NAT will become more and more complex 0 NAT does not operate end to end 63
© Copyright 2026 Paperzz