Winter CMPE 155 Week 3
Winter Project 3: Basic Servers Telnet Rlogin FTP Web In this context, let’s look at the underlying protocols…
Winter Client-Server Model Client Kernel File Server Kernel Printer Server Kernel
Winter 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 Protocol stack Host Application Transport Network Link User A User B Teleconferencing Layering: technique to simplify complex systems Peers
Winter 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 Encapsulation
Winter 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 Layering Functionality Reliability Flow control Fragmentation Multiplexing Connection setup (handshaking) Addressing/naming (locating peers)
Winter Example: Transport layer First end-to-end layer. End-to-end state. May provide reliability, flow and congestion control.
Winter Example: Network Layer Point-to-point communication. Network and host addressing. Routing.
Winter The Internet Protocol Router Host Application Transport Network IP Network
Winter 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 Remote login protocols Telnet and rlogin. Allow interactive use of remote machines. Use reliable transport protocols, e.g., TCP. What’s TCP?
Winter 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 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 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 TCP Reliability Reliable delivery. – ACKs. – Timeouts and retransmissions. Ordered delivery.
Winter 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 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 byte segments sent as separate IP datagrams A B C D 2048 bytes of data delivered to application in single READ
Winter 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 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 TCP Protocol Overview 2 Sequence numbers. – Reliability, ordering, and flow control. – Assigned to every byte. – 32-bit sequence numbers.
Winter TCP Connection Setup 3-way handshake. Host 1 Host 2 SYN (SEQ=x) SYN(SEQ=y,ACK=x+1) (SEQ=x+1, ACK=y+1)
Winter TCP Connection Release 1 Abrupt release: –Send RESET. –May cause data loss.
Winter 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 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 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 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 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 TCP Flow Control: Example 2K;SEQ=0 ACK=2048; WIN=2048 2K; SEQ=2048 ACK=4096; WIN=0 ACK=4096; WIN=2048 1K; SEQ=4096 App. writes 2K of data 4K 2K 0 App. reads 2K of data 2K 1K App. does 3K write Sender blocked Sender may send up to 2K
Winter 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 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 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 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 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 TCP Congestion Control: Example threshold timeout threshold cwin time
Winter TCP Retransmission Timer When segment sent, retransmission timer starts. –If segment ACKed, timer stops. –If time out, segment retransmitted and timer starts again.
Winter 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 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 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 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 TIME_WAIT 2*MSL. Makes sure all segments die after connection is closed.
Winter Back to remote login…
Winter Telnet User’s machine Telnet client OS TCP connection over Internet Telnet server OS
Winter 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 Handling heterogeneity Telnet protocol specifies standard data exchange: network virtual terminal (NVT). Telnet client and server make translation.
Winter Rlogin Remote login between Unix hosts. Simpler than telnet.
Winter More details… Stevens, TCP/IP Illustrated, Vol. 1 Comer, Internetworking with TCP/IP, Vol. 1, 4 th. edition. RFC 854 (Telnet).
Winter 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 FTP File transfer accounted for most of the Internet traffic until the Web exploded! Also uses TCP. Allows interactive access; format specification (e.g., binary); authentication (clients required to authenticate themselves).
Winter FTP Operation Client Server OS DataControl OS DataControl TCP connection
Winter Port Assignment FTP server listens on well-known port (21); data transfer uses port 20. On client side, uses any unused port; client control process communicates that port number to server. Server process initiates data transfer connection.
Winter Anonymous FTP