Presentation is loading. Please wait.

Presentation is loading. Please wait.

Computer Networks 364 Protocols

Similar presentations


Presentation on theme: "Computer Networks 364 Protocols"— Presentation transcript:

1 Computer Networks 364 Protocols
John Morris Computer Science/Electrical Engineering University of Auckland URL:

2 Protocols - HTTP HyperText Transfer Protocol (HTTP)
WWW application layer protocol Client: browser (Netscape, Opera, that other one, … ) Server: a web server (source of Web pages - Apache, … ) Defines the language used by clients to request web pages RFC 2616 (HTTP/1.1) [ RFC 1945 (HTTP/1.0) ] Default port is 80 RFC = Request for Comment Now managed by the Internet Engineering Task Force (IETF) Over 2000 RFCs Standards for the Internet

3 Protocols - HTTP HyperText Transfer Protocol (HTTP)
Web pages consist of a number of objects Basic page Embedded images, etc Each object is fetched from the server in a single session Open TCP connection GET message from client Response from server with object Close connection HTTP is stateless Server does not keep track of state of session with client Each request/response pair is independent of any other Suitable for information serving only applications Transaction oriented applications eg database update generally require some state to be maintained HTTP makes it difficult to implement ‘safe’ transaction based systems but Cookies provide a simple mechanism for maintaining state Stateless protocols are simpler!

4 Protocols - HTTP HyperText Transfer Protocol (HTTP)
Web pages consist of a number of objects ... Each object is fetched from the server in a single session Open TCP connection GET message from client Response from server with object Close connection Obviously rather inefficient TCP connection establishment is expensive Persistent connections TCP connection is left open for subsequent requests Further efficiency from pipelining Send additional requests before first response received Allows browser to do useful work while server is fetching objects Parsing to discover embedded objects, Formatting and displaying pages, etc

5 } HTTP example GET /somedir/page.html HTTP/1.1
Method URL Version GET /somedir/page.html HTTP/1.1 Host: Connection: close User-agent: Mozilla/4.0 Accept-language:fr (extra carriage return, line feed) Request line } Header lines Methods: GET POST HEAD

6 HTTP request messages General form

7 HTTP response HTTP/1.1 200 OK Connection: close
Version Status code Status message Status line HTTP/ OK Connection: close Date: Thu, 06 Aug :00:15 GMT Server: Apache/1.3.0 (Unix) Last-Modified: Mon, 22 Jun :23:24 GMT Content-Length: 6821 Content-Type: text/html (data data data data data . . .) Header lines Entity body

8 HTTP response - general format

9 HTTP response - common status codes
* 200 OK: Request succeeded and the information is returned in the response. * 301 Moved Permanently: Requested object has been permanently moved; new URL is specified in Location: header of the response message. The client software will automatically retrieve the new URL. * 400 Bad Request: A generic error code indicating that the request could not be understood by the server. * 404 Not Found: The requested document does not exist on this server. * 505 HTTP Version Not Supported: The requested HTTP protocol version is not supported by the server.

10 Try out http (client side) for yourself
1. Telnet to your favorite Web server: telnet 80 Opens TCP connection to port 80 (default http server port) at Anything typed in sent to port 80 at 2. Type in a GET http request: By typing this in (hit carriage return twice), you send this minimal (but complete) GET request to http server GET /~ross/index.html HTTP/1.0 3. Look at response message sent by http server!

11 User-server interaction: authentication
Authentication : control access to server content authorization credentials: typically name, password stateless: client must present authorization in each request authorization: header line in each request if no authorization: header, server refuses access, sends WWW authenticate: header line in response client server usual http request msg 401: authorization req. WWW authenticate: usual http request msg + Authorization: <cred> usual http response msg usual http request msg + Authorization: <cred> time usual http response msg

12 Cookies: keeping “state”
client server Server-generated # rembered by server Later used for: authentication remembering user preferences, previous choices Server sends “cookie” to client in response msg Set-cookie: Client presents cookie in later requests cookie: usual http request msg usual http response + Set-cookie: # usual http request msg cookie: # cookie- spectific action usual http response msg usual http request msg cookie: # cookie- spectific action usual http response msg

13 Conditional GET: client-side caching
server Goal Don’t send object if client has up-to-date cached version Client Specify date of cached copy in http request If-modified-since: <date> Server Response has no object if cached copy is up-to-date: HTTP/ Not Modified http request message If-modified-since: <date> object not modified http response HTTP/ Not Modified http request message If-modified-since: <date> object modified http response HTTP/ OK <data>

14 Web Caches (proxy server)
Goal Satisfy client request without involving original server User sets browser Web accesses via web cache Client sends all http requests to web cache Object in web cache web cache returns object else web cache requests object from original server, returns object to client origin server Proxy server http request http request client http response http response http request http response client origin server

15 Why Web Caching? Assume origin Cache is “close” to client servers
eg in same network Smaller response time Cache “closer” to client Decrease traffic to distant servers Link out of local network often bottleneck Cache works on locality of reference principle Recently used objects more likely to be needed again Temporal locality Keep them ‘closer’ Processor caches use the same principle (+ spatial locality!) origin servers public Internet 1.5 Mbps access link institutional network 10 Mbps LAN institutional cache

16 FTP: File Transfer Protocol
user interface client file transfer FTP server 21 user at host local file system remote file system Transfer file(s) to/from remote host Client/Server model Client: side that initiates transfer (either to/from remote) Server: remote host RFC 959 ftp server: port 21

17 FTP: Separate Control and Data Connections
FTP client contacts server at port 21 Specifies TCP as transport protocol Two parallel TCP connections opened: Control connection Exchange commands, responses between client and server Out of band control Data connection File data to / from server FTP server maintains state Current directory Earlier authentication FTP client server TCP control connection port 21 TCP data connection port 20

18 FTP Commands and Responses
Sample commands: Sent as ASCII text over control channel USER username PASS password LIST Return list of files 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; transfer starting 425 Can’t open data connection 452 Error writing file

19 Electronic Mail SMTP Three major components: User agents Mail servers
user mailbox outgoing message queue user agent mail server SMTP Three major components: User agents Mail servers Simple Mail Transfer Protocol: SMTP User Agent Mail reader Composing, editing, reading mail messages Examples Eudora, Outlook, elm, Netscape Messenger Outgoing, incoming messages stored on server

20 eMail: Mail servers SMTP Mail Servers
user agent mail server SMTP Mail Servers Mailbox contains incoming messages (yet to be read) for user Message queue of outgoing (to be sent) mail messages SMTP protocol Used between mail servers to send messages Client: sending mail server Server: receiving mail server

21 eMail: SMTP Messages must be in 7-bit ASCII RFC 821
First published: 1982 Uses TCP to reliably transfer message Port 25 Direct transfer Sending server to receiving server Three phases of transfer Handshaking (greeting) Transfer of messages Closure Command/response interaction Commands: ASCII text Response: status code and phrase Messages must be in 7-bit ASCII Legacy of 1982 Binary data must be encoded before transfer

22 Sample SMTP interaction
S: 220 hamburger.edu C: HELO crepes.fr S: 250 Hello crepes.fr, pleased to meet you C: MAIL FROM: S: 250 Sender ok C: RCPT TO: S: Recipient ok C: DATA S: 354 Enter mail, end with "." on a line by itself C: Do you like ketchup? C: How about pickles? C: . S: 250 Message accepted for delivery C: QUIT S: 221 hamburger.edu closing connection This is why 7-bit ASCII is required!

23 Exercise: make a simple Java mail sender
Try SMTP yourself telnet servername 25 See 220 reply from server Enter HELO MAIL FROM RCPT TO DATA QUIT HELP commands You can send Using telnet to send commands yourself By writing a simple program to do it for you! Exercise: make a simple Java mail sender Able to send messages directly from programs

24 SMTP: Final Words Comparison with HTTP: Uses persistent connections
Requires message (header & body) to be in 7-bit ASCII Certain character strings not permitted in message Example CRLF.CRLF Thus message has to be encoded Usually base-64 or quoted printable Server uses CRLF.CRLF to determine end of message Comparison with HTTP: HTTP: pull push Command and response, interaction and status codes All ASCII in both HTTP Each object encapsulated in its own response message SMTP Multiple objects sent in multipart message

25 Mail message format header body blank line RFC 821
SMTP protocol for exchanging messages RFC 822 Text message format Header lines, e.g. To: From: Subject: Different from SMTP commands! Defines semantics (interpretation) also Body The “message” ASCII characters only! header blank line body

26 Message format: Multimedia extensions
RFC 822 format OK for text messages Inefficient for multimedia Multipurpose Internet Mail Extensions (MIME) RFC 2045, 2056 Additional lines in message header declare MIME content type MIME version From: To: Subject: Picture of yummy crepe MIME-Version: 1.0 Content-Transfer-Encoding: base64 Content-Type: image/jpeg base64 encoded data ..... ......base64 encoded data Method used to encode data Multimedia data type, subtype, parameters Encoded data

27 MIME types Content-Type: type/subtype; parameters
Text Subtypes: plain, html, ... Image Subtypes: jpeg, gif Audio Subtypes basic 8-bit -law encoded 32kadpcm 32 Kbps coding (RFC 1911) Video Subtypes: mpeg, quicktime Application Other data that must be processed by reader before becoming “viewable” Subtypes msword octet-stream Arbitrary binary data

28 MIME: Multipart Type Arbitrary ASCII string which defines boundaries
From: To: Subject: Picture of yummy crepe. MIME-Version: 1.0 Content-Type: multipart/mixed; boundary= Content-Transfer-Encoding: quoted-printable Content-Type: text/plain Dear Bob, Please find a picture of a crepe. Content-Transfer-Encoding: base64 Content-Type: image/jpeg base64 encoded data ..... ......base64 encoded data Arbitrary ASCII string which defines boundaries of a part

29 Mail Access Protocols SMTP SMTP POP3 or IMAP
user agent user agent sender’s mail server receiver’s mail server SMTP: delivery to and storage on receiver’s server Mail access protocol: retrieval from server POP: Post Office Protocol [RFC 1939] Simple, limited functions Authorization (agent  server) and download IMAP: Internet Mail Access Protocol [RFC 2060] More features (more complex) Manipulation of stored messages on server Set up, search folders, etc HTTP: Hotmail , Yahoo! Mail, etc

30 POP3 Protocol C: list Authorization phase Transaction phaseclient:
S: +OK POP3 server ready C: user alice S: +OK C: pass hungry S: +OK user successfully logged on Authorization phase Client commands: user: declare username pass: password Server responses +OK -ERR Transaction phaseclient: list: list message numbers retr: retrieve message by number dele: delete quit C: list S: 1 498 S: 2 912 S: . C: retr 1 S: <message 1 contents> C: dele 1 C: retr 2 C: dele 2 C: quit S: +OK POP3 server signing off

31 DNS: Domain Name System
People: Many identifiers: IRD #, name, passport # Internet hosts, routers: IP address (32 bit) Used for in datagrams “name” eg gaia.cs.umass.edu Used by humans (with some exceptions!) ? Map between IP addresses and name? Domain Name System: Distributed database Implemented in hierarchy of many name servers Application-layer protocol Host, routers, name servers to communicate to resolve names (address  name translation) Note Core Internet function, implemented as application-layer protocol Complexity at network’s “edge”

32 DNS name servers No server has all name  IP address mappings
Why not centralize DNS? Single point of failure Congestion Traffic volume on central server Distance Time to reach centralized database Maintenance Doesn’t scale! No server has all name  IP address mappings Local name servers: Each ISP, company has local (default) name server DNS query first goes to local name server Authoritative name server: For a host: stores that host’s IP address, name Can perform name/address translation for that host’s name

33 DNS: Root Name Servers Contacted by local name server that can not resolve name Root Name Server: Contacts authoritative name server if name mapping not known Gets mapping Returns mapping to local name server b USC-ISI Marina del Rey, CA l ICANN Marina del Rey, CA e NASA Mt View, CA f Internet Software C. Palo Alto, CA i NORDUnet Stockholm k RIPE London m WIDE Tokyo a NSI Herndon, VA c PSInet Herndon, VA d U Maryland College Park, MD g DISA Vienna, VA h ARL Aberdeen, MD j NSI (TBD) Herndon, VA 13 root name servers worldwide

34 authorititive name server
Simple DNS example root name server Host surf.eurecom.fr wants IP address of gaia.cs.umass.edu 1. Contacts its local DNS server, dns.eurecom.fr 2. dns.eurecom.fr contacts root name server, if necessary 3. Root name server contacts authoritative name server, dns.umass.edu, if necessary 2 4 3 5 authorititive name server dns.umass.edu local name server dns.eurecom.fr 1 6 requesting host surf.eurecom.fr gaia.cs.umass.edu

35 DNS example Root name server: root name server
May not know authoritative name server May know intermediate name server: who to contact to find authoritative name server 2 6 7 3 local name server dns.eurecom.fr intermediate name server dns.umass.edu 4 5 1 8 authoritative name server dns.cs.umass.edu requesting host surf.eurecom.fr gaia.cs.umass.edu

36 DNS: iterated queries Recursive query: Iterated query:
root name server Recursive query: Puts burden of name resolution on contacted name server Heavy load? Iterated query: Contacted server replies with name of server to contact “I don’t know this name, but ask this server” iterated query 2 3 4 7 local name server dns.eurecom.fr intermediate name server dns.umass.edu 5 6 1 8 authoritative name server dns.cs.umass.edu requesting host surf.eurecom.fr gaia.cs.umass.edu

37 DNS: Caching and updating records
Once (any) name server learns mapping, it caches mapping Cache entries timeout (disappear) after some time Update/notify mechanisms being designed by IETF RFC 2136

38 RR format: (name, value, type, ttl)
DNS records DNS: Distributed database storing resource records (RR) RR format: (name, value, type, ttl) Type=A name is hostname value is IP address Type=CNAME name is alias name for some “cannonical” (real) name is really servereast.backup2.ibm.com value is cannonical name Type=NS name is domain (eg foo.com) value is IP address of authoritative name server for this domain Type=MX value is name of mailserver associated with name

39 DNS protocol, messages DNS protocol query and reply messages
both with same message format Message header Identification 16 bit # for query, reply to query uses same # Flags query or reply recursion desired recursion available reply is authoritative

40 DNS protocol, messages Name, type fields for a query RRs in reponse
to query Records for authoritative servers Additional “helpful” info that may be used


Download ppt "Computer Networks 364 Protocols"

Similar presentations


Ads by Google