Presentation is loading. Please wait.

Presentation is loading. Please wait.

COS 461 Fall 1997 Transport Layer FTPHTTPSMTPDNSFinger TCPUDP IP EthernetATMmodemSHRIMP application layer transport layer network layer data link layer.

Similar presentations


Presentation on theme: "COS 461 Fall 1997 Transport Layer FTPHTTPSMTPDNSFinger TCPUDP IP EthernetATMmodemSHRIMP application layer transport layer network layer data link layer."— Presentation transcript:

1 COS 461 Fall 1997 Transport Layer FTPHTTPSMTPDNSFinger TCPUDP IP EthernetATMmodemSHRIMP application layer transport layer network layer data link layer

2 COS 461 Fall 1997 UDP (User Datagram Protocol) u unreliable, unordered datagrams u the main difference from IP: –IP sends datagram to a machine –UDP sends datagram to (machine, port) pair »port is 16-bit identifier IP header src portdest port checksum length data follows 32 bits

3 COS 461 Fall 1997 UDP and AcmeNet u an AcmeNet NetAddress is a (machine, port) pair u AcmeNet NetworkInterfaces communicate via UDP –very simple layering –look at NetworkInterface source code if youre interested in how this works

4 COS 461 Fall 1997 TCP u stands for Transmission Control Protocol u reliable, bidirectional byte stream –hides datagram boundaries –handles connection setup and shutdown cleanly –acknowledgement, timeout, and retransmission –flow control: slows down sender so receiver isnt overwhelmed –congestion control: slows down sender so network isnt overwhelmed

5 COS 461 Fall 1997 Challenges for TCP u robust connection setup and shutdown u high variance in round-trip time u packets can hide in the net for a long time u varying resources available at endpoints –must learn each others needs, and adapt u robust congestion control

6 COS 461 Fall 1997 Byte Streams and Segments u data not divided into chunks; functions like a continuous byte-stream –sender buffers data »use largest buffer size that avoids IP fragmentation –data sent when buffer fills, or on periodic clock tick, or when explicitly flushed –receiver buffers data too u like buffering in Assignment 2

7 COS 461 Fall 1997 Sequence Numbers u each packet carries a sequence number u seq nums identify bytes, not datagrams u initial sequence numbers chosen randomly u each packet carries an acknowledgement (with sequence number acked) u no distinction between data/ack packets

8 COS 461 Fall 1997 TCP Header Format IP header src portdest port sequence number ack sequence number hdr len0flagsadvertised window checksumurgent data ptr options (if any) data follows 32 bits

9 COS 461 Fall 1997 TCP Header u src port, dest port –same meaning as UDP u sequence number –last byte of data sent, before this packet u ack sequence number –first byte of data not yet received u hdr len –length of TCP header, in 32-bit words

10 COS 461 Fall 1997 TCP Header u flags –URG: if 1, packet contains urgent data –ACK: if 1, ack seq num field is valid –PSH: if 1, tells receiver not to buffer this packet, or anything ahead of it –RST: if 1, denotes serious error –SYN: if 1, this is a connection-setup packet –FIN: if 1, this packet closes the connection

11 COS 461 Fall 1997 TCP Header u advertised window –number of bytes sender can accept at present »counts forward from ack seq num value u checksum –Internet checksum, covers TCP info + data u urgent pointer –location of end of urgent data in packet

12 COS 461 Fall 1997 TCP Header u options: examples –negotiate packet size –window size larger than 64k –modified ack/retransmit information

13 COS 461 Fall 1997 How TCP Uses Ports server socket Client machineServer machine socket connect socket accept

14 COS 461 Fall 1997 Connection Setup u three-way handshake –client says I want to connect, gives seq num »SYN flag set –server says I accept, gives seq num, acks clients seq num »SYN + ACK flags set –client says OK, acks servers seq num »ACK flag set u careful handling of errors, timeouts, etc. u complex state transition diagram

15 COS 461 Fall 1997 Sliding Window Protocol LastByteAckedLastByteSent LastByteWritten Sending Host NextByteExpectedLastByteReceived LastByteRead Receiving Host Goals: reduce memory requirements; dont overrun receivers buffers; keep the pipe full.

16 COS 461 Fall 1997 Sliding Window Constraints u receiver decides how much memory to dedicate to this connection (call it M) u receiver advertises window of M-(LastByteReceived-NextByteRead) u sender stops sending when LastByteSent-LastByteAcked = Window u acks from receiver update the window size u special hack to get out of Window=0 case

17 COS 461 Fall 1997 Keeping the Pipe Full u recall: optimum performance requires window size equal to latency-bandwidth product u receiver tries to allocate enough memory to keep window size large enough u with fast network, can overflow 16-bit advertised window field –use TCP header option to get bigger window

18 COS 461 Fall 1997 Timeout and Retransmission u use timeout and retransmission u optimal timeout is just more than round-trip transmission time –dont time out if no packets dropped –recover quickly if packets are dropped u for TCP –packet loss rate is nontrivial –round-trip time varies widely

19 COS 461 Fall 1997 Timeout: Original Algorithm u keep running average of round-trip time –interval between sending and arrival of ack u time out after twice the estimated RTT u problem: matching problem after retransmission u problem: bad if variance is high

20 COS 461 Fall 1997 Timeout: Better Algorithm u three improvements: –dont include retransmitted packets in estimate »avoids matching problem –estimate average and standard deviation; timeout after avg + 4 * deviation –on retransmission, double timeout (temporarily) for next retransmission

21 COS 461 Fall 1997 Using TCP in Java u classes in java.net package u on the client side: –new Socket(serverHostName, serverPort) connects to a server –Socket::getInputStream and Socket::getOutputStream get byte streams to use for communicating with server

22 COS 461 Fall 1997 Using TCP in Java u on the server side: –new ServerSocket(portNum) advertises a connection point –ServerSocket::accept accepts a connection from a client; returns a Socket »ServerSocket can accept many connections –after getting the Socket, treat it same as the client does

23 COS 461 Fall 1997 Using TCP in C u uglier interface –form of IP addresses –hostname lookup –arguments as structs –one kind of socket used for server-socket and ordinary sockets u usually write code by cut-and-paste u for a good source, see courses Miscellaneous Links page

24 COS 461 Fall 1997 Well-Known Ports u many standard services live at the same port on almost all machines –http on port 80 –telnet on port 23 u allows outside clients to find them u portmapper allows a level of indirection


Download ppt "COS 461 Fall 1997 Transport Layer FTPHTTPSMTPDNSFinger TCPUDP IP EthernetATMmodemSHRIMP application layer transport layer network layer data link layer."

Similar presentations


Ads by Google