Nixu Oy PL 21
Application Level
Protocols
Contents
• Client-Server
• Store and Forward
• Push
• Pull
• Poll
• Connection
• Connectionless
Application Level Protocols
• Applications handle different kinds of content
— eg. e-mail, web pages, voice
• Different types of content require different kinds of protocols
• Applications level protocols
— Transfer the application’s content
— Transfer information about the capabilities of the participants
— Use lower layer protocols to avoid doing unnecessary work
• OSI model’s session, presentation and application layers are combined to one
layer in the TCP/IP model
Network relations
• The network entities use different behavioral models on all protocol layers
— Client-Server
— Store and Forward
— Push
— Pull
— Poll
— Master-Slave
— Connection
— Connectionless
Client-Server
• Examples:
— A WWW client connects to a WWW server and requests a document
— Xeyes program requests the X server for information about mouse cursor position
• Client is the active participant
• Sessions are initiated by the client
• Server is passive and waits for contact
• Client-server model is usually used to distribute data or CPU
Store and Forward
• Example:
— SMTP e-mail server recieves a message and stores it to disk, after the message is stored, server tries to contact next server and transmit the message forward to it
> An SMTP server acts both as a server and as a client
• Store and forward makes data loss in transit less likely, at a cost
Push
• Example:
— A news server contacts a second news server and asks if it has a certain article (identi- fied by message-ID). If not, it pushes the article to the second server
— A e-mail message is sent from one server to another using the SMTP protocol
• Push is used to update information at another server
• The pushing sender has responsibility of transmitting new information
Pull
• Examples:
— A news server contacts a second news server and asks what articles it has (identified by message-ID). Then it retrieves those articles it does not already have
— An e-mail client program contacts a POP or IMAP server and asks for new e-mail for an user-ID
• Pull is used to retrieve information when it suits the client
• The pulling client has responsibility of receiving the information it needs, this
usually requires periodic checks
Poll
• Example:
— An SNMP network management station asks each router in a network for a count of trans- mitted packets at each interface
• The polling entity requests information, polled entities do not (usually) send anything by themselves
• Polled entities require minimal configuration, polling entity can decide when to poll (manage load)
• Often used in situations requiring hard real time to ensure that the controlling
program has time to loop through all the code
Master-Slave
• Example:
— An Ethernet network is used for hard real time by having one station which initiates all communications, other stations can only reply
• Master dominates slaves completely
Connection
• Examples:
— An user connects to a Unix server from a PC using Telnet protocol
— A WWW client program connects to a WWW server using HTTP/1.1 protocol over a TCP protocol and stays connected until all the elements of a WWW page are received
> Two connections at different levels
• In a connection both ends share a state
— IP network is not aware of a connection
• A connection can be broken by network fault
Connectionless data transfer
• Examples:
— A DNS resolver sends a DNS server an UDP packet, containing a DNS query
— A network management station queries routers using SNMP packets in UDP packets, if no reply is received after retries, an alarm is generated
• In connectionless data transfer the entities transferring information are responsible of knowing the status of communication
— A DNS server does not care
— The DNS resolver must retry if the query or reply are lost (UDP is defined as unreliable) or if server is down
• Avoids the setup cost of a connection
What Protocols Do?
• Protocols are the language different network entities use to talk to each other
— Windows Netscape can send e-mail to a Sendmail program running on Unix operating sys- tem, because they talk same language
• Internet protocols provide layers of abstraction and rely on other protocols to
operate together
Internet Protocol Model
SNMP, NFS DNS FTP, HTTP, SMTP, Telnet, SSH etc..
UDP TCP
Internet Protocol (IP)
Data Link protocols (Ethernet, PPP, ATM, Frame Relay...)
ICMP Ping
Physical media
SMTP mail transfer
• Simple Mail Transfer Protocol
• SMTP e-mail server recieves a message and stores it to disk
— After the message is stored, server tries to contact next server and transmit the message forward to it
— An SMTP server acts both as a server and as a client
POP and IMAP mail read
• Post Office Protocol
• Internet Message Access Protocol
• An e-mail client program contacts a POP or IMAP server and asks for new e-
mail for an user-ID
How the mail travels
Sender Sender’s Reciever’s
Server forwards Host sends
e-mail using SMTP
mail using SMTP
Client retrieves mail using POP or IMAP
Reciever local server local server
A SMTP Protocol Sample
220 tcm.hut.fi SMTP/smap Ready.
helo jalopeno.nixu.fi
250 (jalopeno.nixu.fi) pleased to meet you.
mail from: kiravuo@jalopeno.nixu.fi
250 kiravuo@jalopeno.nixu.fi... Sender Ok rcpt to: kiravuo@hut.fi
250 kiravuo@hut.fi OK data
354 Enter mail, end with "." on a line by itself From: kiravuo@jalopeno.nixu.fi
To: kiravuo@iki.fi Subject: Greetings Hi, dude!
.
250 Mail accepted
Telnet
• Network Terminal Protocol
— Remote login over the network to a host of any operating system
> Usually multi-user operating system, like Unix or VMS
• Offered by TCP/IP protocol suite
— Application layer protocol, at the top of TCP/IP protocol architecture
— A very common service
> Typically Telnet client is included with the operating system (Windows, Unix)
> The server is also included in most multiuser operating systems (Unix)
• Client always initiates the connection
Network Virtual Terminal
• Defines the way how data and commands are sent accross the network
• Client software translates keystrokes and command sequences from the user’s terminal into NVT format
• Server software translates incoming data and commands from NVT format into the format remote system requires
• At startup 7-bit US ASCII representation
— 95 printable characters
— 33 control codes
… Network Virtual Terminal
• In addition NVT defines control characters
— for example ENTER/RETURN -> mapped into CR-LF transmission
• Control functions are encoded using escape sequences
— Reserved octet IAC (Interpret as command)
Telnet commands
Command Decimal
encoding Meaning
IAC 255 Interpret next octet as command
DON’T 254 Denial of request to perform specified option DO 253 Approval to allow specified option
WON’T 252 Refusal to perform specified option WILL 251 Agreement to perform specified option
IP 244 Interrupt Process (terminate running program) BRK 243 Break (break key or attention signal)
… Telnet commands
• Request for server interrupt:
IAC IP = 255 244
• IAC as data:
IAC IAC = 255 255
• Forcing the server to read control function
— Needed when buffers are filled or
— Remote process is in endless loop
• Telnet uses an out of band signal
— TCP URGENT DATA bit is set
— Urgent data bypasses flow control and reaches the server immediately
Option negotiation
• Request WILL X
— Will you let me use option X?
• Response DO X or DON’T X
— I agree to let you use option X
— I don’t agree to let you use option X
• Request DO X
— Use option X
• Response WILL X or WON’T X
— I will start using option X
… Option negotiation
• Request WON’T X or DON’T X
— I want to disable option X
— I want you to disable option X
• Responce DON’T X or WON’T X
• Options that are not understood are simply declined
• Options are not part of the Telnet standard, but defined independetly
— Plenty of options available: echo, 8-bit transmission, status, terminal type, window size, terminal speed, X-display location...
Telnet connections
Client connects Server Another server
Client has two
A connection may be to a server
connections to two servers
formed from one server to another one
HTTP Overview
• Application-level protocol for distributed, collaborative,hypermedia information systems.
• Used by Web browsers to communicate with WWW servers.
• Generic, stateless, object-oriented
• Since 1990 HTTP/1.0 (later version 1.1)
• Based on a request/response paradigm.
• On HTTP/1.0 connection is closed after each request/response change while on
HTTP/1.1 connection may be used for more than one request/response change.
HTTP Communication (client)
• Client (browser) opens a TCP connection to an HTTP server (e.g. Apache) by default to port 80.
• Client observes the URL:
http://www.nixu.fi/:8080
> "http": use HTTP protocol
> "//": absolute URL
> "www.nixu.fi": WWW server
> ":8080": use port 8080
• Client sends a request line, some optional request headers and a blank line to
server.
HTTP Communication (server)
• Server sends a response line, some response headers, a blank line and a document and closes the connection (on HTTP/1.1 connection is not closed)
• Every object on a page is requested separately.
> HTML page with 3 pictures: with HTTP/1.0 four separate requests and connections.
• Server responce may be HTML, graphics, audio, VRML or Java...
HTTP Client request
• HTTP/1.0 supports 3 commands: GET, HEAD and POST
• Format of a simple request is following:
Request-Method Document-Address HTTP/Version (e.g. "GET /index.html HTTP/1.0")
• After request line there can be zero to n request headers which consists of Request-Header:Value pairs.
• Request is ended by a blank line. (In POST command additional data can be sent
after blank line.)
HTTP Server Response
• Format of response line is following:
HTTP/Version Status-Code Message (e.g. HTTP/1.1 200 OK)
• Unspecified amount of response headers might follow (header:value pairs). At least Content-Type header should be send (identifies the type of data that follows).
• Blank line after final response header. Response Document (or nothing when
HEAD command is used).
Example
1 bash-2.03$ telnet www.nixu.fi 80 2 Trying...
3 Connected to jalopeno.nixu.fi.
4 Escape character is ’^]’.
5 HEAD / HTTP/1.0 6
7 HTTP/1.1 200 OK
8 Date: Mon, 12 Apr 1999 10:26:06 GMT 9 Server: Apache/1.2.6
10 Last-Modified: Fri, 26 Feb 1999 15:28:20 GMT 11 Connection: close
12 Content-Type: text/html 13
14 Connection closed.
15 bash-2.03$
HTTP Methods
Command Explanation
GET Normal method to request documents HEAD Method to request document headers POST Method to send data to server
PUT Method to send a document to server and request server to store it at specified URI
DELETE Client requests server to remove a specified URI
OPTIONS Method to query available options for server in general or for specified URI
TRACE Requests the server to return the attached document unchanged. Used for
HTTP Request Headers
Header Explanation
Accept Usually username:password encoded in base64
Connection If Keep-Alive used connection is not closed after each request on HTTP/1.0 (default behaviour for HTTP/1.1)
Content-Length On POST method length of data area
Cookie Returns information supplied via a Set-Cookie header (in previous connection)
From E-mail address of person responsible for the request. Used mostly by Web indexing programs (robots)
Host Host and port as listed in the original URL
Pragma No-cache server should send a fresh copy of document (not cached) Cache-Control No-cache Identical to Pragma except used on HTTP/1.1
Referer Specifies URL of the page that contained the cross-reference User-Agent Specifies type of browser
Header Explanation
HTTP Response Status Line
HTTP/Version Status-Code Reason-Phrase
Status-Code categories
• 1xx: Informational - Not used, reserved for future use
• 2xx: Success - Action was successfully received, understood, and accepted.
• 3xx: Redirection - Further action must be taken in order to complete the request
• 4xx: Client Error - Request contains bad syntax or cannot be fulfilled
• 5xx: Server Error - Server failed to fulfill an apparently valid request
Predefined status codes (HTTP/1.1)
• "200" ; OK
• "201" ; Created
• "202" ; Accepted
• "203" ; Non-Authoritative Information
• "301" ; Moved Permanently
• "400" ; Bad Request
• "404" ; Not Found
HTTP Response Headers
Most of the headers are optional but Content-Type header should be included in all responses.
Allow Lists the set of request methods permitted for the specified resource
Content-Encoding Describes the decoding mechanism that must be used to obtain the MIME media type specified in the Content-Type header
Content-Length Number of bytes in the file Content-Type MIME type and subtype
Expires Time and date when document expires
Location New location of the requested document Server Information about the HTTP server
Set-Cookie name/value pair to be stored by browser. This pair will be
transmitted in the Cookie header in future requests to the same URL
WWW-Authenticate Gives authorization type and realm that the client has to supply in an Authorization header