Different Layers Lecture 21 10/17/2003 Jian Ren 1
The Transport Layer 10/17/2003 Jian Ren 2
Transport Services and Protocols Provide logical communication between app processes running on different hosts Transport protocols run in end systems Example protocols TCP UDP 10/17/2003 Jian Ren 3
Transport vs. network layer Network layer Logical communication between hosts Transport layer Logical communication between processes Relies on, and enhances network layer services 10/17/2003 Jian Ren 4
Transport Layer Protocols Reliable, in-order delivery: TCP Flow control Congestion control Connection setup Unreliable, unordered delivery: UDP Services not available: Delay guarantees Bandwidth guarantees 10/17/2003 Jian Ren 5
UDP: User Datagram Protocol UDP segments may be: Lost Delivered out of order to app Connectionless: No handshaking between UDP sender, receiver Each UDP segment handled independently of others Why is there a UDP? No connection establishment (which can add delay) Simple: no connection state at sender, receiver Small segment header No congestion control: UDP can blast away as fast as desired 10/17/2003 Jian Ren 6
UDP Often used for streaming multimedia apps Loss tolerant Rate sensitive Other UDP uses DNS SNMP Reliable transfer over UDP: add reliability at application layer Application-specific error recovery! 10/17/2003 Jian Ren 7
TCP: Overview Point-to-point: One sender, one receiver Reliable, in-order byte steam Full duplex data: Bi-directional data flow in same connection Connection-oriented: Handshaking (exchange of control msgs) init s sender, receiver state before data exchange Flow controlled: Sender will not overwhelm receiver socket door application writes data TCP send buffer application reads data TCP receive buffer socket door segment 10/17/2003 Jian Ren 8
TCP seq. # s and ACKs Seq. # s: Byte stream number of first byte in segment s data ACKs: Seq # of next byte expected from other side Cumulative ACK User types C host ACKs receipt of echoed C Host A Host B Seq=42, ACK=79, data = C Seq=79, ACK=43, data = C Seq=43, ACK=80 host ACKs receipt of C, echoes back C simple telnet scenario time 10/17/2003 Jian Ren 9
TCP Reliable Data Transfer TCP creates reliable data transfer service on top of IP s unreliable service TCP uses single retransmission timer Retransmissions are triggered by: Timeout events Duplicate acks 10/17/2003 Jian Ren 10
TCP Flow Control Receiver side of TCP connection has a receive buffer Flow control Sender won t overflow receiver s buffer by transmitting too much, too fast Speed-matching service Matching the send rate to the receiving app s drain rate 10/17/2003 Jian Ren 11
TCP Fairness Goal: if K TCP sessions share same bottleneck link of bandwidth R, each should have average rate of R/K TCP connection 1 TCP connection 2 bottleneck router capacity R 10/17/2003 Jian Ren 12
The Application Layer 10/17/2003 Jian Ren 13
Applications and Application- Layer Protocols Application: communicating, distributed processes e.g., e-mail, Web, P2P file sharing, instant messaging running in end systems (hosts) exchange messages to implement application Application-layer protocols one piece of an app define messages exchanged by apps and actions taken use communication services provided by lower layer protocols (TCP, UDP) 10/17/2003 Jian Ren 14
Application-Layer Protocol Defines Types of messages exchanged Syntax of message types Semantics of the fields Rules for when and how processes send & respond to messages 10/17/2003 Jian Ren 15
HTTP overview HTTP: hypertext transfer protocol Web s application layer protocol client/server model client: browser that requests, receives, displays Web objects server: Web server sends objects in response to requests PC running Explorer Mac running Navigator HTTP request HTTP response HTTP request HTTP response Server running Apache Web server 10/17/2003 Jian Ren 16
HTTP Overview Uses TCP Client initiates TCP connection (creates socket) to server, port 80 Server accepts TCP connection from client HTTP messages exchanged between browser and Web server HTTP is stateless Server maintains no information about past client requests 10/17/2003 Jian Ren 17
FTP Protocol user at host FTP user interface FTP client local file system file transfer FTP server remote file system Transfer file to/from remote host Client/Server model client: initiates transfer (either to/from remote) Server: remote host Ftp server: port 21 10/17/2003 Jian Ren 18
FTP FTP client contacts FTP server at port 21, specifying TCP as transport protocol Client obtains authorization over control connection Client browses remote directory by sending commands over control connection. When server receives a command for a file transfer, the server opens a TCP data connection to client After transferring one file, server closes connection. FTP client TCP control connection port 21 TCP data connection port 20 FTP server Server opens a second TCP data connection to transfer another file. Control connection: out of band FTP server maintains state : current directory, earlier authentication 10/17/2003 Jian Ren 19
Electronic Mail Major components: User agents Mail servers Simple mail transfer protocol: SMTP User Agent A.k.a. mail reader Composing, editing, reading mail messages E.g., Eudora, Outlook, Netscape Messenger Outgoing, incoming messages stored on server 10/17/2003 Jian Ren 20
Electronic Mail: Mail Servers Mail Servers mailbox contains incoming messages for user message queue of outgoing (to be sent) mail messages SMTP protocol between mail servers to send email messages client: sending mail server server : receiving mail server 10/17/2003 Jian Ren 21
Electronic Mail: SMTP Uses TCP to reliably transfer email message from client to server, port 25 Direct transfer: sending server to receiving server Three phases of transfer Handshaking (greeting) Transfer of messages Closure 10/17/2003 Jian Ren 22
Mail Access Protocols user agent SMTP SMTP access protocol user agent sender s mail server receiver s mail server SMTP: delivery/storage to receiver s server Mail access protocol: retrieval from server POP: Post Office Protocol Authorization (agent <-->server) and download IMAP: Internet Mail Access Protocol More features (more complex) Manipulation of stored msgs on server HTTP: Hotmail, Yahoo! Mail, etc. 10/17/2003 Jian Ren 23
DNS: Domain Name System Distributed database implemented in hierarchy of many name servers Application-layer protocol: name servers to communicate to resolve names (address/name translation) Internet hosts, routers: IP address (32 bit) - used for addressing datagrams name, e.g., egr.msu.edu - used by humans 10/17/2003 Jian Ren 24
DNS Name Servers Why not centralize DNS? Single point of failure Traffic volume Distant centralized database Maintenance No server has all name-to-ip address mappings 10/17/2003 Jian Ren 25