1 Introduction: Network Applications

advertisement
1
Introduction: Network Applications
Some Network Apps
• E-mail
• Web
• Instant messaging
• Remote login
• P2P file sharing
• Multi-user network games
• Streaming stored video clips
• Internet telephone
• Real-time video conference
• Massive parallel computing
Network App Concept
Processes Communicating
A process sends/receives messages to/from its socket
Processes Communicating
• For a process to receive messages, it must have an identifier
• A host has a unique 32-bit IP address
• Identifier includes both the IP address and port numbers (16-bit) associated with the process on the host
• e.g. http://128.39.140.38:80
• or telnet 128.39.140.38 80
About App Layer Protocols
• App Layer Protocols define:
– Types of messages exchanged, eg, request & response messages
– Syntax of message types: what fields in messages & how fields are
delineated
– Semantics of the fields, ie, meaning of information in fields
– Rules for when and how processes send & respond to messages
• Public-domain protocols (e.g. HTTP, SMTP,... , RFCs)
• Proprietary protocols (e.g. KaZaA)
Net App Requirements
2
2
Web: HTTP
HyperText Transfer Protocol
• Web page consists of objects
• Object can be HTML file, JPEG image, Java applet, audio file, ...
• Web page consists of base HTML-file which includes several referenced
objects
• Each object is addressable by a URL
• e.g. http://www.hig.no/imt/index.php
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
• HTTP 1.0 (1996): http://www.faqs.org/rfcs/rfc1945.html
• HTTP 1.1 (1997): http://www.faqs.org/rfcs/rfc2068.html
• Client initiates TCP connection (creates socket) to server, port 80
• HTTP messages (application-layer protocol messages) exchanged between
browser (HTTP client) and Web server (HTTP server)
• HTTP is stateless
HTTP Request/Response
3
HTTP connections
• Nonpersistent HTTP
– At most one object is sent over a TCP connection
– HTTP/1.0 uses nonpersistent HTTP
• Persistent HTTP
– Multiple objects can be sent over single TCP connection between
client and server
– HTTP/1.1 uses persistent connections in default mode
RTT: Round Trip Time
Persistency and Pipelining
• Nonpersistent
– requires 2 RTTs per object
– OS must work and allocate host resources for each TCP connection
(browsers often open parallel TCP connections to fetch referenced
objects)
• Persistent
– server leaves connection open after sending response
– subsequent HTTP messages between same client/server are sent over
connection
• Persistent without pipelining
4
– client issues new request only when previous response has been received
– 1 RTT for each referenced object
• Persistent with pipelining (default in HTTP/1.1)
– client sends requests as soon as it encounters a referenced object
– as little as 1 RTT for all the referenced objects
Request Message
• GET, POST, HEAD, PUT, DELETE
Response Message
• 200, 301, 400, 404, 505, ...
User-server state: cookies
• Four components
1. cookie header line in the HTTP response message
2. cookie header line in HTTP request message
3. cookie file kept on user’s host and managed by user’s browser
5
4. back-end database at Web site
• What cookies can bring
–
–
–
–
authorization
shopping carts
recommendations
user session state (Web e-mail)
• Cookies and privacy
–
–
–
–
cookies permit sites to learn a lot about you
you may supply name and e-mail to sites
search engines use redirection & cookies to learn yet more
advertising companies obtain info across sites
User-server state: cookies
Web Cache (Proxy)
• User sets browser: Web accesses via cache
• Browser sends all HTTP requests to cache
– object in cache: cache returns object
– else cache requests object from origin server, then returns object to
client
• Cache acts as both client and server
• Typically cache is installed by ISP (university, company, residential ISP)
6
Web Cache (Proxy)
3
File Transfer: FTP
FTP: File Transfer Protocol
FTP: File Transfer Protocol
• Transfer file to/from remote host
• Client/server model
• http://www.faqs.org/rfcs/rfc959.html (1985)
• Active FTP
– Client contacts server port 21 from client port N (>1023)
– Server contacts client port N+1 from port 20
• Passive FTP
– Client contacts server port 21 from client port N (>1023)
– Server starts listening to port M (>1023) and tells client about it
– Client contact server port M from client port N+1
• e.g. http://slacksite.com/other/ftp.html
7
FTP: File Transfer Protocol
• FTP uses TCP for all connections, non-persistant, only one file transfer
per connection
• Control connection: “out of band”
• FTP server maintains ”state”: current directory, earlier authentication
• Commands: USER, PASS, LIST, RETR, STOR, ...
• Return codes (similar to HTTP)
– 331 Username OK, password required
– 425 Can’t open data connection
– 452 Error writing file
4
Mail: SMTP & POP/IMAP
Mail Protocols
SMTP: Simple Mail Transfer Protocol
• http://www.faqs.org/rfcs/rfc2821.html
• TCP to server port 25
• Three phases of transfer
– greeting (handshake)
– transfer of messages
– closure
• Commands: HELO/EHLO, MAIL FROM, RCPT TO, DATA, QUIT
• Return codes: 220, 250, 354, 221, ...
• Messages must be 7-bit ASCII
• Persistant connections
8
Mail Message Format
• http://www.faqs.org/rfcs/rfc822.html (1982)
• MIME: Multimedia Mail Extension http://www.faqs.org/rfcs/rfc2045.
html
• Additional lines in msg header declare MIME content type
– MIME-version: 1.0
– Content-Transfer-Encoding: e.g. base64
– Content-Type: e.g. image/jpeg
POP: Post Office Protocol
• http://www.faqs.org/rfcs/rfc1939.html (POP3, 1996)
• Commands: USER, PASS, LIST, RETR, DELE, QUIT
• Return codes: +OK, -ERR
• POP3 is stateless across sessions
IMAP: Internet Mail Access Protocol
• http://www.faqs.org/rfcs/rfc2060.html (IMAP4rev1, 1996)
• More powerful than POP
– allows user to organize messages in folders
– can retrieve parts of messages
• IMAP keeps user state across sessions
– names of folders and mappings between message IDs and folder name
5
Name Resolution: DNS
DNS: Domain Name System
• Distributed database implemented in hierarchy of many name servers
• Core Internet function, implemented as application-layer protocol
• Provides
– Hostname to IP address translation
– IP address to hostname translation
– Host aliasing
9
– Mail server aliasing
– Load distribution
– (Authorative information about your network!)
– (new uses appear, e.g. RBL, SPF)
• UDP to server port 53 (switch to TCP same port if reply > 512 bytes)
Interaction of DNS servers
• Authorative and Local/Caching servers
• Recursive and Iterative Queries
DNS: Resource Records
• RRs: (Name, Value, Type, TTL)
SOA Start Of Authority
NS Name Server
A Address, define the canonical name of an IP address
CNAME “Canonical NAME”, define alias to canonical name
PTR PoinTer Record, reverse mapping
DNS: Message Format
10
6
Next Week
Next Week
• Transport Layer - Chapter three
• remember: talk app protocols over tcp with telnet!
11
Download