Transport Layer FTP HTTP SMTP TCP DNS Finger

  • Slides: 24
Download presentation
Transport Layer FTP HTTP SMTP TCP DNS Finger transport layer UDP network layer IP

Transport Layer FTP HTTP SMTP TCP DNS Finger transport layer UDP network layer IP Ethernet ATM application layer modem SHRIMP data link layer COS 461 Fall 1997

UDP (User Datagram Protocol) u unreliable, unordered datagrams u the main difference from IP:

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 32 bits IP header src port checksum dest port length data follows » port is 16 -bit identifier COS 461 Fall 1997

UDP and Acme. Net u an Acme. Net. Address is a (machine, port) pair

UDP and Acme. Net u an Acme. Net. Address is a (machine, port) pair u Acme. Network. Interfaces communicate via UDP – very simple layering – look at Network. Interface source code if you’re interested in how this works COS 461 Fall 1997

TCP u stands for Transmission Control Protocol u reliable, bidirectional byte stream – hides

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 isn’t overwhelmed – congestion control: slows down sender so network isn’t overwhelmed COS 461 Fall 1997

Challenges for TCP u robust connection setup and shutdown u high variance in round-trip

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 other’s needs, and adapt u robust congestion control COS 461 Fall 1997

Byte Streams and Segments u data not divided into chunks; functions like a continuous

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 COS 461 Fall 1997

Sequence Numbers u each packet carries a sequence number u seq nums identify bytes,

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 COS 461 Fall 1997

TCP Header Format 32 bits IP header src port dest port sequence number ack

TCP Header Format 32 bits IP header src port dest port sequence number ack sequence number hdr len 0 flags advertised window checksum urgent data ptr options (if any) data follows COS 461 Fall 1997

TCP Header u src port, dest port – same meaning as UDP u sequence

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 COS 461 Fall 1997

TCP Header u flags – URG: if 1, packet contains urgent data – ACK:

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 COS 461 Fall 1997

TCP Header u advertised window – number of bytes sender can accept at present

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 COS 461 Fall 1997

TCP Header u options: examples – negotiate packet size – window size larger than

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

How TCP Uses Ports Client machine connect Server machine accept server socket COS 461

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

Connection Setup u three-way handshake – client says “I want to connect”, gives seq

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 client’s seq num » SYN + ACK flags set – client says “OK”, acks server’s seq num » ACK flag set u careful handling of errors, timeouts, etc. u complex state transition diagram COS 461 Fall 1997

Sliding Window Protocol Sending Host Last. Byte. Written Last. Byte. Acked Last. Byte. Sent

Sliding Window Protocol Sending Host Last. Byte. Written Last. Byte. Acked Last. Byte. Sent Receiving Host Last. Byte. Read Next. Byte. Expected Last. Byte. Received Goals: reduce memory requirements; don’t overrun receiver’s buffers; keep the pipe full. COS 461 Fall 1997

Sliding Window Constraints u receiver decides how much memory to dedicate to this connection

Sliding Window Constraints u receiver decides how much memory to dedicate to this connection (call it M) u receiver advertises window of M -(Last. Byte. Received-Next. Byte. Read) u sender stops sending when Last. Byte. Sent-Last. Byte. Acked = Window u acks from receiver update the window size u special hack to get out of Window=0 case COS 461 Fall 1997

Keeping the Pipe Full u recall: optimum performance requires window size equal to latency-bandwidth

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 COS 461 Fall 1997

Timeout and Retransmission u use timeout and retransmission u optimal timeout is just more

Timeout and Retransmission u use timeout and retransmission u optimal timeout is just more than round-trip transmission time – don’t 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 COS 461 Fall 1997

Timeout: Original Algorithm u keep running average of round-trip time – interval between sending

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 COS 461 Fall 1997

Timeout: Better Algorithm u three improvements: – don’t include retransmitted packets in estimate »

Timeout: Better Algorithm u three improvements: – don’t 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 COS 461 Fall 1997

Using TCP in Java u classes in java. net package u on the client

Using TCP in Java u classes in java. net package u on the client side: – new Socket(server. Host. Name, server. Port) connects to a server – Socket: : get. Input. Stream and Socket: : get. Output. Stream get byte streams to use for communicating with server COS 461 Fall 1997

Using TCP in Java u on the server side: – new Server. Socket(port. Num)

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

Using TCP in C u uglier interface – form of IP addresses – hostname

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 course’s Miscellaneous Links page COS 461 Fall 1997

Well-Known Ports u many standard services live at the same port on almost all

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 COS 461 Fall 1997