560 likes | 685 Views
CSCI 6433 Internet Protocols Class 5. David C. Roberts. Agenda. Network Address Translation (NAT) User Datagram Protocol (UDP) Reliable Stream Transfer Service (TCP). NAT. Developed in order to extend life of IP address pool Used these characteristics of Internet connections:
E N D
CSCI 6433Internet ProtocolsClass 5 David C. Roberts
Agenda • Network Address Translation (NAT) • User Datagram Protocol (UDP) • Reliable Stream Transfer Service (TCP)
NAT • Developed in order to extend life of IP address pool • Used these characteristics of Internet connections: • Most hosts are clients that don’t need to be publicly accessible • Few hosts access the Internet at the same time • Internet connections are routed
Analogy • Think of a NAT router as a company’s telephone operator • Connects outside callers to local extensions • Connects local extensions to the outside network
Limitation • Traditional NAT is said to be “unidirectional”, allows only for transactions originated inside the network • No allowance for a server inside the network • Domain Naming Services (DNS) can be used to make a name visible outside the local network (to be discussed)
NAT • Extends the pool of addresses • Creates a form of two-level addressing • Could be used even more widely to extend the pool of IPv4 addresses • Does not allow for a server inside the NAT network to hosts outside • Can be port-based or not
What Does IP Do? • Addressing • Data encapsulation • Fragmentation and reassembly • Routing/indirect delivery
Ports • Destination of a datagram is a program • Selection is by protocol port number • Messages carry source and destination port numbers • UDP and TCP provide protocol ports, provide ability to distinguish among destinations within a given host
UDP--User Datagram Protocol • UDP provides unreliable, best-effort, connectionless datagram delivery services to multiple destinations within a single host computer, using IP to carry messages
UDP Message Format • Question: How many different UDP ports are there on a PC?
UDP Layering Application programs access UDP, and UDP uses IP to send and receive datagrams UDP message is encapsulated in an IP datagram
Summary • UDP is a “thin” protocol • Unreliable • Best-effort • Distinguishes between applications • 16-bit port number is used • UDP lies in the transport layer
What TCP Does • Addressing and multiplexing • Connection establishment, management and termination • Data handling and packaging • Provides reliability and transmission quality services • Provides flow control and congestion avoidance features
How TCP Does Its Job • Connection-oriented • Bidirectional • Multiply-connected • Reliable • Acknowledged • Stream-oriented • Data-unstructured • Data flow managed
Why Stream Delivery? • Using stream delivery protocol frees the application from any concern about network delivery of data • Packets may arrive out of order • Packet data may contain errors • Application program doesn’t want to know optimal packet size
TCP—Reliable Stream Transport Service • Stream orientation—receiver gets the same sequence of octets sent by the sender • Unstructured stream—no way to mark boundaries, applications must use a stream • Virtual circuit connection—source and destination operate at the same time, interact during the transfer • Buffered transfer—large blocks can be transferred, fed to receiver as needed • Full duplex connection—communication can take place in both directions
Reliable Delivery, Unreliable Transport • Ethernet is unreliable • IP is unreliable • But TCP, that runs over IP, is reliable • How?
Positive Acknowledgement with Retransmission • Sender starts a timer when sending, saves data • Receiver sends acknowledgement (ACK) when data arrives successfully • When ACK arrives, sender cancels timer, deletes data • If timer expires, sender retransmits data, starts another timer
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.
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.
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?
TCP Protocol Enhancements • There are a number of protocol extensions and hardware products designed to speed up TCP in the presence of delays • Generally they involve some form of providing ACKs to the sender before the receiver has received the packet • The extension then has to provide some form of retransmission itself, since TCP counts success when it receives an ACK
Ports and Connections • UDP uses the port as a queue to process incoming data • TCP uses port numbers, but the port number is part of identifying a connection • 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?
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.
Flow Control • Each ack includes a window advertisement, giving the number of additional octets the receiver is willing to accept • Sender increases or decreases its window size based on the window advertisement • The sliding window provides end-to-end flow control • Congestion, that can occur at intermediate points, is dealt with by congestion control mechanisms
MSS • MSS—maximum segment size is negotiated • MSS may be the MTU of a single connecting network, if both ends are on the same network • MSS may be the MTU of path if sender and receiver are on different networks • Risk of poor performance if MSS is too large or too small
Problems with Wrong MSS • If too large: segments will be fragmented, requiring extra network messages and routing • 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?
Code Bits Code bits determine purpose, contents of the segment
Urgent TCP Data • Programs may need to send “out of band” data • That is, data is treated as being sent through another connection • In TCP, this can be done by setting the urgent flag • Receiving program processes urgent data ahead of the rest of the data stream
TCP Acknowledgements • TCP acknowledgements can’t refer to datagram or segment numbers, since retransmission can change message size • TCP ack specifies sequence number of the next octet the receiver expects to receive • Called a cumulative acknowledgement • Both efficient and inefficient
Timeout, Retransmission • Great variation in transit times, from local net to distant network • Adaptive retransmission algorithm—monitors the performance of each connection, deduces reasonable timeout value • Stores round trip time, uses new RTT to change stored RTT slowly • Timeout is some constant times RTT • Note that acknowledgements are ambiguous in case of retransmissions
Karn’s Algorithm • Timer backoff strategy • Compute an initial timeout • If retransmission, then increase timeout • Often, double the timeout • Timeout increases have an upper limit • Karn uses only unambiguous acknowledgements to compute RTT new_timeout = γ * old_timeout
Response to Congestion • No way for TCP to directly know about congestion, which causes retransmission, increasing congestion even further • Multiplicative decrease congestion avoidance—when segment is lost, sender congestion window is reduced by half (starts same as receiver advertisement), ack timer is increased • Allowed window=min(receiver_advertisement, congestion_window) • Slow-start recovery—start congestion window at single segment size, increase by one for each ack
Explicit And Explicit Notification • Most versions of TCP use implicit feedback mechanisms—using timeout and multiple ACKs to detect loss and congestion • Some versions of explicit feedback have been developed for TCP/IP • Selective acknowledgement—receiver identifies left edge, right edge of received segments • Explicit congestion notification—routers add notification to TCP header, then receiver notifies sender in next ACK
Global Synchronization • When router is congested, early routers used tail-drop strategy • Tail-drop—drop most recent datagram • Causes drops from many TCP sources, leads to global synchronization • 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.