Application Level Protocols
2 Application Level Protocols Applications handle different kinds of content e.g.. e-mail, web pages, voice Different types of content require different kinds of protocols Application level protocols Transfer the application s content (application specific behavior) 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
3 Network relations The network entities use different behavioral models on all protocol layers Client-Server Store and Forward Push Pull Poll Master-Slave Connections Connectionless communication
4 Client-Server communications model 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
5 Thin and Fat Clients These terms do not refer to the communications logic, but instead to the software architecture The client can be a simple user interface manager E.g. WWW-client The applications logic is in the server Or an application specific program capable of complex data processing operations The applications logic is mostly in the client and the server is usually mostly a database server The difference in communications is between I/O (display) information and between raw data The current trend is towards thin clients and servers that provide the application logic and data
6 Middleware Middleware is a term, which meaning depends on context In the client-server model middleware means usually software that implements the business logic Middleware is connected to the user s thin client at one end and to a database at the other end Typically different protocols are used E.g. HTTP for the client and SQL*Net for the database Middleware can also mean a layer between the actual application and the communications layer (TCP & IP) Provides e.g. AAA services, database access The interaction models between various parties are usually of client-server type The user initiates actions from the web client, which the middleware translates to database queries and data processing However actual business applications may break this pure model E.g. the server sends a notification to the client
7 Store and Forward A message is stored until it can be forwarded Example: SMTP e-mail server receives 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 An IP router stores an IP packet in its memory, until the next link is available for transmission Store and forward makes packet networks efficient and allow discarding the requirement for reserving bandwidth
8 Push Example: A news server contacts a second news server and asks if it has a certain article (identified 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
9 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
10 Poll Example: An SNMP network management station asks each router in a network for a count of transmitted 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
11 Master-Slave Example: An Ethernet network is used for hard real time by having one station which initiates all communications, other stations are allowed only to reply Master dominates slaves completely
12 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 protocol levels, TCP and HTTP In a connection both ends share a state IP network is not aware of a connection A connection can be broken by network fault
13 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
14 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 system, because they talk same language Internet protocols provide layers of abstraction and rely on other protocols to operate together
15 Internet Protocol Model SNMP, NFS, NTP... DNS FTP, HTTP, SMTP, SSH... Ping UDP TCP ICMP Internet Protocol (IP) Data Link protocols (Ethernet, PPP, ATM, Frame Relay...) Physical media (twisted pair, glass fiber)
16 SMTP mail transfer Simple Mail Transfer Protocol SMTP e-mail server receives 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
17 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
18 How the mail travels Host sends e-mail using SMTP Server forwards mail using SMTP Client retrieves mail using POP or IMAP Sender Sender's local server Receiver's local server Receiver
19 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 Server waits for connections from the client
20 Network Virtual Terminal Defines the way how data and commands are sent across 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
21 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)
22 Telnet commands Command IAC DON T DO WON T WILL IP BRK NOP... Decimal encoding 255 254 253 252 251 244 243 241... Meaning Interpret next octet as command Denial of request to perform specified option Approval to allow specified option Refusal to perform specified option Agreement to perform specified option Interrupt Process (terminate running program) Break (break key or attention signal) No operation...
23 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
24 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 I won t start using option X
25 Option negotiation Request WON T X or DON T X I want to disable option X I want you to disable option X Response 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 independently Plenty of options available: echo, 8-bit transmission, status, terminal type, window size, terminal speed, X- display location... Leaving the options open for future additions enables the protocol to be adapted to future requirements
26 Telnet connections A connection is made from one server to another Client Client connects to a server Server Another server Client has two simultaneous connections Another client
27 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/1.0 specified in RFC 1945 HTTP/1.1 in RFC 2068
28 HTTP Communication (client) Client (browser) opens a TCP connection to an HTTP server (e.g. Apache) by default to port 80. Client decodes 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.
29 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 response may be HTML, graphics, audio, VRML or Java...
30 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.)
31 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).
32 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$
33 HTTP Methods Command GET HEAD POST PUT DELETE OPTIONS TRACE Explanation Normal method to request documents Method to request document headers Method to send data to server Method to send a document to server and request server to store it at specified URI Client requests server to remove a specified URI Method to query available options for server in general or for specified URI Requests the server to return the attached document unchanged. Used for debugging
34 HTTP Request Headers Header Accept Connection Content-Length Cookie From Host Explanation Usually username:password encoded in base64 If Keep-Alive used connection is not closed after each request on HTTP/1.0 (default behavior for HTTP/1.1) On POST method length of data area Returns information supplied via a Set- Cookie header (in previous connection) E-mail address of person responsible for the request. Used mostly by Web indexing programs (robots) Host and port as listed in the original URL
35...HTTP Request Headers Header If-Modified-Since Pragma Cache-Control Referer User-Agent Explanation Conditional GET No-cache server should send a fresh copy of document (not cached) No-cache Identical to Pragma except used on HTTP/1.1 Specifies URL of the page that contained the cross-reference Specifies type of browser
36 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
37 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 "500" ; Internal Server Error "505" ; HTTP Version not supported
38 HTTP Response Headers Most of the headers are optional but Content-Type header should be included in all responses. Allow Content- Encoding Content-Length Content-Type Expires Last-Modified Location Server Set-Cookie WWW- Authenticate Lists the set of request methods permitted for the specified resource Describes the decoding mechanism that must be used to obtain the MIME media type specified in the Content-Type header Number of bytes in the file MIME type and subtype Time and date when document expires Time and date when document was changed last time New location of the requested document Information about the HTTP server name/value pair to be stored by browser. This pair will be transmitted in the Cookie header in future requests to the same URL Gives authorization type and realm that the client has to supply in an Authorization header