540 likes | 726 Views
CMPE 155. Week 3. Project 3: Basic Servers. Telnet Rlogin FTP Web In this context, let’s look at the underlying protocols…. Client-Server Model. Client. File Server. Printer Server. Kernel. Kernel. Kernel. What are protocols?.
E N D
CMPE 155 Week 3 Winter 2002
Project 3: Basic Servers • Telnet • Rlogin • FTP • Web In this context, let’s look at the underlying protocols… Winter 2002
Client-Server Model Client File Server Printer Server Kernel Kernel Kernel Winter 2002
What are protocols? • Set of rules governing communication between network elements (applications, hosts, routers). • Protocols define: • Format and order of messages. • Actions taken on receipt of a message. • Protocols are hard to design • We need design guidelines! Winter 2002
Protocol stack Teleconferencing User A User B Peers Application Transport Network Link Host Host Layering: technique to simplify complex systems Winter 2002
Layering Characteristics • Each layer relies on services from layer below and exports services to layer above. • Interface defines interaction, • Hides implementation - layers can change without disturbing other layers (black box). Winter 2002
Encapsulation Winter 2002
OSI Model: 7 Protocol Layers • Physical: how to transmit bits • Data link: how to transmit frames • Network: how to route packets hop2hop • Transport: how to send packets end2end • Session: how to tie flows together • Presentation: byte ordering, security • Application: everything else! Winter 2002
Layering Functionality • Reliability • Flow control • Fragmentation • Multiplexing • Connection setup (handshaking) • Addressing/naming (locating peers) Winter 2002
Example: Transport layer • First end-to-end layer. • End-to-end state. • May provide reliability, flow and congestion control. Winter 2002
Example: Network Layer • Point-to-point communication. • Network and host addressing. • Routing. Winter 2002
The Internet Protocol Host Host Application Transport Router Router IP IP IP IP Network Network Winter 2002
IP • Glues Internet together. • Common network-layer protocol spoken by all Internet participating networks. • Best effort datagram service: • No reliability guarantees. • No ordering guarantees. Winter 2002
Remote login protocols • Telnet and rlogin. • Allow interactive use of remote machines. • Use reliable transport protocols, e.g., TCP. What’s TCP? Winter 2002
The Internet Transport Protocols: TCP and UDP • UDP: user datagram protocol (RFC 768). • Connection-less protocol. • TCP: transmission control protocol (RFCs 793, 1122, 1323). • Connection-oriented protocol. Winter 2002
UDP • Provides connection-less, unreliable service. • No delivery guarantees. • No ordering guarantees. • No duplicate detection. • Low overhead. • No connection establishment/teardown. • Suitable for short-lived connections. • Example: client-server applications. Winter 2002
TCP • Reliable end-to-end communication. • TCP transport entity: • Runs on machine that supports TCP. • Interfaces to the IP layer. • Manages TCP streams. • Accepts user data, breaks it down and sends it as separate IP datagrams. • At receiver, reconstructs original byte stream from IP datagrams. Winter 2002
TCP Reliability • Reliable delivery. • ACKs. • Timeouts and retransmissions. • Ordered delivery. Winter 2002
TCP Service Model 1 • Obtained by creating TCP end points. • Example: UNIX sockets. • Socket number or address: IP address + 16-bit port number (TSAP). • Multiple connections can terminate at same socket. • Connections identified by socket ids at both ends. • Port numbers below 1024: well-known ports reserved for standard services. • List of well-known ports in RFC 1700. Winter 2002
TCP Service Model 2 • TCP connections are full-duplex and point-to-point. • Byte stream (not message stream). • Message boundaries are not preserved e2e. A B C D A B C D 2048 bytes of data delivered to application in single READ 4 512-byte segments sent as separate IP datagrams Winter 2002
TCP Byte Stream • When application passes data to TCP, it may send it immediately or buffer it. • Sometimes application wants to send data immediately. • Example: interactive applications. • Use PUSH flag to force transmission. • TCP could still bundle PUSH data together (e.g., if it cannot transmit it right away). • URGENT flag. • Also forces TCP to transmit at once. Winter 2002
TCP Protocol Overview 1 • TCP’s TPDU: segment. • 20-byte header + options. • Data. • TCP entity decides the size of segment. • 2 limits: 64KByte IP payload and MTU. • Segments that are too large are fragmented. • More overhead by addition of IP header. Winter 2002
TCP Protocol Overview 2 • Sequence numbers. • Reliability, ordering, and flow control. • Assigned to every byte. • 32-bit sequence numbers. Winter 2002
TCP Connection Setup • 3-way handshake. Host 2 Host 1 SYN (SEQ=x) SYN(SEQ=y,ACK=x+1) (SEQ=x+1, ACK=y+1) Winter 2002
TCP Connection Release 1 • Abrupt release: • Send RESET. • May cause data loss. Winter 2002
TCP Connection Release 2 • Graceful release: • Each side of the connection released independently. • Either side send TCP segment with FIN=1. • When FIN acknowledged, that direction is shut down for data. • Connection released when both sides shut down. • 4 segments: 1 FIN and 1 ACK for each direction; 1st. ACK+2nd. FIN combined. Winter 2002
TCP Connection Release 3 • Timers to avoid 2-army problem. • If response to FIN not received within 2*MSL (maximum segment lifetime), FIN sender releases connection. • After connection released, TCP waits for 2*MSL (e.g., 120 sec) to ensure all old segments have aged. Winter 2002
TCP Transmission 1 • Sender process initiates connection. • Once connection established, TCP can start sending data. • Sender writes bytes to TCP stream. • TCP sender breaks byte stream into segments. • Each byte assigned sequence number. • Segment sent and timer started. Winter 2002
TCP Transmission 2 • If timer expires, retransmit segment. • After retransmitting segment for maximum number of times, assumes connection is dead and closes it. • If user aborts connection, sending TCP flushes its buffers and sends RESET segment. • Receiving TCP decides when to pass received data to upper layer. Winter 2002
TCP Flow Control • Sliding window. • Receiver’s advertised window. • Size of advertised window related to receiver’s buffer space. • Sender can send data up to receiver’s advertised window. Winter 2002
TCP Flow Control: Example App. writes 2K of data 4K 2K;SEQ=0 2K ACK=2048; WIN=2048 App. does 3K write 2K; SEQ=2048 0 Sender blocked App. reads 2K of data ACK=4096; WIN=0 ACK=4096; WIN=2048 2K 1K; SEQ=4096 Sender may send up to 2K 1K Winter 2002
TCP Flow Control: Observations • TCP sender not required to transmit data as soon as it comes in from application. • Example: when first 2KB of data comes in, could wait for more data since window is 4KB. • Receiver not required to send ACKs as soon as possible. • Wait for data so ACK is piggybacked. Winter 2002
Congestion Control • Why do it at the transport layer? • Real fix to congestion is to slow down sender. • Use law of “conservation of packets”. • Keep number of packets in the network constant. • Don’t inject new packet until old one leaves. • Congestion indicator: packet loss. Winter 2002
TCP Congestion Control 1 • Like, flow control, also window based. • Sender keeps congestion window (cwin). • Each sender keeps 2 windows: receiver’s advertised window and congestion window. • Number of bytes that may be sent is min(advertised window, cwin). Winter 2002
TCP Congestion Control 2 • Slow start [Jacobson 1988]: • Connection’s congestion window starts at 1 segment. • If segment ACKed before time out, cwin=cwin+1. • As ACKs come in, current cwin is increased by 1. • Exponential increase. Winter 2002
TCP Congestion Control 3 • Congestion Avoidance: • Third parameter: threshold. • Initially set to 64KB. • If timeout, threshold=cwin/2 and cwin=1. • Re-enters slow-start until cwin=threshold. • Then, cwin grows linearly until it reaches receiver’s advertised window. Winter 2002
TCP Congestion Control: Example cwin timeout threshold threshold time Winter 2002
TCP Retransmission Timer • When segment sent, retransmission timer starts. • If segment ACKed, timer stops. • If time out, segment retransmitted and timer starts again. Winter 2002
How to set timer? • Based on round-trip time: time between a segment is sent and ACK comes back. • If timer is too short, unnecessary retransmissions. • If timer is too long, long retransmission delay. Winter 2002
Jacobson’s Algorithm 1 • Determining the round-trip time: • TCP keeps RTT variable. • When segment sent, TCP measures how long it takes to get ACK back (M). • RTT = alpha*RTT + (1-alpha)M. • alpha: smoothing factor; determines weight given to previous estimate. • Typically, alpha=7/8. Winter 2002
Jacobson’s Algorithm 2 • Determining timeout value: • Measure RTT variation, or |RTT-M|. • Keeps smoothed value of cumulative variation D=alpha*D+(1-alpha)|RTT-M|. • Alpha may or may not be the same as value used to smooth RTT. • Timeout = RTT+4*D. Winter 2002
Keepalive Timer • Goes off when a connection is idle for a long time. • Causes one side to check whether the other side is still alive. • If no answer, connection terminated. Winter 2002
TIME_WAIT • 2*MSL. • Makes sure all segments die after connection is closed. Winter 2002
Back to remote login… Winter 2002
Telnet User’s machine Telnet client Telnet server OS OS TCP connection over Internet Winter 2002
Telnet basic operation • When user invokes telnet, telnet client on user machine establishes TCP connection to specified server. • TCP connection established; user’s keystrokes sent to remote machine. • Telnet server sends back response, echoed on user’s terminal. • Telnet server can accept multiple concurrent connections. Winter 2002
Handling heterogeneity • Telnet protocol specifies standard data exchange: network virtual terminal (NVT). • Telnet client and server make translation. Winter 2002
Rlogin • Remote login between Unix hosts. • Simpler than telnet. Winter 2002
More details… • Stevens, TCP/IP Illustrated, Vol. 1 • Comer, Internetworking with TCP/IP, Vol. 1, 4th. edition. • RFC 854 (Telnet). Winter 2002
File Transfer • Sharing remote files: “on-line” access versus “file transfer”. • “On-line” access transparent access to shared files, e.g., distributed file system. • Sharing through file transfer: user copies file then operates on it. Winter 2002