【正文】
on ? cache: specify date of cached copy in HTTP request Ifmodifiedsince: date ? server: response contains no object if cached copy is uptodate: HTTP/ 304 Not Modified cache server HTTP request msg Ifmodifiedsince: date HTTP response HTTP/ 304 Not Modified object not modified HTTP request msg Ifmodifiedsince: date HTTP response HTTP/ 200 OK data object modified 2: Application Layer 44 Chapter 2: Application layer ? Principles of work applications ? Web and HTTP ? FTP ? Electronic Mail ? SMTP, POP3, IMAP ? DNS ? P2P file sharing ? Socket programming with TCP ? Socket programming with UDP ? Building a Web server 2: Application Layer 45 FTP: the file transfer protocol ? transfer file to/from remote host ? client/server model ? client: side that initiates transfer (either to/from remote) ? server: remote host ? ftp: RFC 959 ? ftp server: port 21 file transfer FTP server FTP user interface FTP client local file system remote file system user at host 2: Application Layer 46 FTP: separate control, data connections ? 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 mands over control connection. ? When server receives a mand for a file transfer, the server opens a TCP data connection to client ? After transferring one file, server closes connection. FTP client FTP server TCP control connection port 21 TCP data connection port 20 ? Server opens a second TCP data connection to transfer another file. ? Control connection: “out of band” ? FTP server maintains “state”: current directory, earlier authentication 2: Application Layer 47 FTP mands, responses Sample mands: ? sent as ASCII text over control channel ? USER username ? PASS password ? LIST return list of file in current directory ? RETR filename retrieves (gets) file ? STOR filename stores (puts) file onto remote host Sample return codes ? status code and phrase (as in HTTP) ? 331 Username OK, password required ? 125 data connection already open。 how fields are delineated ? Semantics of the fields, ie, meaning of information in fields ? Rules for when and how processes send amp。 (2) ability to fix a few parameters (lots more on this later) 2: Application Layer 13 Addressing processes ? For a process to receive messages, it must have an identifier ? A host has a unique32bit IP address ? Q: does the IP address of the host on which the process runs suffice for identifying the process? ? Answer: No, many processes can be running on same host ? Identifier includes both the IP address and port numbers associated with the process on the host. ? Example port numbers: ? HTTP server: 80 ? Mail server: 25 ? More on this later 2: Application Layer 14 Applayer protocol defines ? Types of messages exchanged, eg, request amp。2: Application Layer 1 Chapter 2 Application Layer 2: Application Layer 2 Chapter 2: Application layer ? Principles of work applications ? Web and HTTP ? FTP ? Electronic Mail ? SMTP, POP3, IMAP ? DNS ? P2P file sharing ? Socket programming with TCP ? Socket programming with UDP ? Building a Web server 2: Application Layer 3 Chapter 2: Application Layer Our goals: ? conceptual, implementation aspects of work application protocols ? transportlayer service models ? clientserver paradigm ? peertopeer paradigm ? learn about protocols by examining popular applicationlevel protocols ? HTTP ? FTP ? SMTP / POP3 / IMAP ? DNS ? programming work applications ? socket API 2: Application Layer 4 Some work apps ? Email ? Web ? Instant messaging ? Remote login ? P2P file sharing ? Multiuser work games ? Streaming stored video clips ? Inter telephone ? Realtime video conference ? Massive parallel puting 2: Application Layer 5 Creating a work app Write programs that ? run on different end systems and ? municate over a work. ? ., Web: Web server software municates with browser software No software written for devices in work core ? Network core devices do not function at app layer ? This design allows for rapid app development application transport work data link physical application transport work data link physical application transport work data link physical 2: Application Layer 6 Chapter 2: Application layer ? Principles of work applications ? Web and HTTP ? FTP ? Electronic Mail ? SMTP, POP3, IMAP ? DNS ? P2P file sharing ? Socket programming with TCP ? Socket programming with UDP ? Building a Web server 2: Application Layer 7 Application architectures ? Clientserver ? Peertopeer (P2P) ? Hybrid of clientserver and P2P 2: Application Layer 8 Clientserver archicture server: ? alwayson host ? permanent IP address ? server farms for scaling clients: ? municate with server ? may be intermittently connected ? may have dynamic IP addresses ? do not municate directly with each other 2: Application Layer 9 Pure P2P architecture ? no always on server ? arbitrary end systems directly municate ? peers are intermittently connected and change IP addresses ? example: Gnutella Highly scalable But difficult to manage 2: Application Layer 10 Hybrid of clientserver and P2P Napster ? File transfer P2P ? File search centralized: ? Peers register content at central server ? Peers query same central server to locate content I