Unit 1: Application Layer Prof. Nalini Mhetre. Unit 1:Application layer… syllabus (04 Hrs) OSI...

98
Unit 1: Application Layer Prof. Nalini Mhetre

Transcript of Unit 1: Application Layer Prof. Nalini Mhetre. Unit 1:Application layer… syllabus (04 Hrs) OSI...

Page 1: Unit 1: Application Layer Prof. Nalini Mhetre. Unit 1:Application layer… syllabus (04 Hrs) OSI Model Block Diagram Application layer protocols: Functionality.

Unit 1: Application Layer

Prof. Nalini Mhetre

Page 2: Unit 1: Application Layer Prof. Nalini Mhetre. Unit 1:Application layer… syllabus (04 Hrs) OSI Model Block Diagram Application layer protocols: Functionality.

CN UNIT 1 2

Unit 1:Application layer… syllabus (04 Hrs)• OSI Model Block Diagram• Application layer protocols: Functionality and header formats,

• HTTP• FTP• DNS• SMTP• TELNET• DHCP

Page 3: Unit 1: Application Layer Prof. Nalini Mhetre. Unit 1:Application layer… syllabus (04 Hrs) OSI Model Block Diagram Application layer protocols: Functionality.

CN UNIT 1 3

OSI Model: Block Diagram

Page 4: Unit 1: Application Layer Prof. Nalini Mhetre. Unit 1:Application layer… syllabus (04 Hrs) OSI Model Block Diagram Application layer protocols: Functionality.

CN UNIT 1 4

OSI ModelLayers

Page 5: Unit 1: Application Layer Prof. Nalini Mhetre. Unit 1:Application layer… syllabus (04 Hrs) OSI Model Block Diagram Application layer protocols: Functionality.

CN UNIT 1 5

Why layered architecture?

• Designing of protocol between two different entities.

• Levels of details required may be different.

• Transmitting data to its most fundamental form.

• Identified functions are grouped which serves as a layer

Page 6: Unit 1: Application Layer Prof. Nalini Mhetre. Unit 1:Application layer… syllabus (04 Hrs) OSI Model Block Diagram Application layer protocols: Functionality.

CN UNIT 1 6

Protocol

• A protocol is a set of rules that governs data communication. A protocol defines :

a. What is communicated ? {syntax}b. How it is communicated ? {semantics}c. When it is communicated ?{timings}

Page 7: Unit 1: Application Layer Prof. Nalini Mhetre. Unit 1:Application layer… syllabus (04 Hrs) OSI Model Block Diagram Application layer protocols: Functionality.

CN UNIT 1 7

OSI layers

Page 8: Unit 1: Application Layer Prof. Nalini Mhetre. Unit 1:Application layer… syllabus (04 Hrs) OSI Model Block Diagram Application layer protocols: Functionality.

CN UNIT 1 8

Note to remember:

• Headers are added to the data at layers 6, 5, 4, 3, and 2. • Trailers are usually added only at layer 2.

Page 9: Unit 1: Application Layer Prof. Nalini Mhetre. Unit 1:Application layer… syllabus (04 Hrs) OSI Model Block Diagram Application layer protocols: Functionality.

CN UNIT 1 9

Summary of layers

Page 10: Unit 1: Application Layer Prof. Nalini Mhetre. Unit 1:Application layer… syllabus (04 Hrs) OSI Model Block Diagram Application layer protocols: Functionality.

CN UNIT 1 10

Internet protocol stack• application: supporting network

applications• FTP, SMTP, HTTP

• transport: process-process data transfer• TCP, UDP

• network: routing of datagrams from source to destination

• IP, routing protocols

• link: data transfer between neighboring network elements

• PPP, Ethernet

• physical: bits “on the wire”

application

transport

network

link

physical

Page 11: Unit 1: Application Layer Prof. Nalini Mhetre. Unit 1:Application layer… syllabus (04 Hrs) OSI Model Block Diagram Application layer protocols: Functionality.

CN UNIT 1 11

ISO/OSI reference model• presentation: allow applications to

interpret meaning of data, e.g., encryption, compression, machine-specific conventions

• session: synchronization, checkpointing, recovery of data exchange

• Internet stack “missing” these layers!• these services, if needed, must be

implemented in application• needed?

application

presentation

session

transport

network

link

physical

Page 12: Unit 1: Application Layer Prof. Nalini Mhetre. Unit 1:Application layer… syllabus (04 Hrs) OSI Model Block Diagram Application layer protocols: Functionality.

CN UNIT 1 12

sourceapplicatio

ntransportnetwork

linkphysical

HtHn M

segment Ht

datagram

destination

application

transportnetwork

linkphysical

HtHnHl M

HtHn M

Ht M

M

networklink

physical

linkphysical

HtHnHl M

HtHn M

HtHn M

HtHnHl M

router

switch

Encapsulationmessage M

Ht M

Hn

frame

Page 13: Unit 1: Application Layer Prof. Nalini Mhetre. Unit 1:Application layer… syllabus (04 Hrs) OSI Model Block Diagram Application layer protocols: Functionality.

CN UNIT 1 13

TCP/IP and OSI model

SCTP

Page 14: Unit 1: Application Layer Prof. Nalini Mhetre. Unit 1:Application layer… syllabus (04 Hrs) OSI Model Block Diagram Application layer protocols: Functionality.

CN UNIT 1 14

Creating a network app

write programs that:• run on (different) end systems• communicate over network• e.g., web server software communicates

with browser software

no need to write software for network-core devices

• network-core devices do not run user applications

• applications on end systems allows for rapid app development, propagation

applicationtransportnetworkdata linkphysical

applicationtransportnetworkdata linkphysical

applicationtransportnetworkdata linkphysical

Page 15: Unit 1: Application Layer Prof. Nalini Mhetre. Unit 1:Application layer… syllabus (04 Hrs) OSI Model Block Diagram Application layer protocols: Functionality.

15CN UNIT 1

Application architectures

possible structure of applications:• client-server• peer-to-peer (P2P)

Page 16: Unit 1: Application Layer Prof. Nalini Mhetre. Unit 1:Application layer… syllabus (04 Hrs) OSI Model Block Diagram Application layer protocols: Functionality.

CN UNIT 1

Client-server architecture

server: • always-on host• permanent IP address• data centers for scaling

clients:• communicate with server• may be intermittently

connected• may have dynamic IP addresses• do not communicate directly

with each other

client/server

2-16

Page 17: Unit 1: Application Layer Prof. Nalini Mhetre. Unit 1:Application layer… syllabus (04 Hrs) OSI Model Block Diagram Application layer protocols: Functionality.

CN UNIT 1

P2P architecture• no always-on server• arbitrary end systems

directly communicate• peers request service from

other peers, provide service in return to other peers

• self scalability – new peers bring new service capacity, as well as new service demands

• peers are intermittently connected and change IP addresses

• complex management

peer-peer

2-17

Page 18: Unit 1: Application Layer Prof. Nalini Mhetre. Unit 1:Application layer… syllabus (04 Hrs) OSI Model Block Diagram Application layer protocols: Functionality.

18CN UNIT 1

Processes communicating

process: program running within a host

• within same host, two processes communicate using inter-process communication (defined by OS)

• processes in different hosts communicate by exchanging messages

client process: process that initiates communication

server process: process that waits to be contacted

note: applications with P2P architectures have client processes & server processes

clients, servers

Page 19: Unit 1: Application Layer Prof. Nalini Mhetre. Unit 1:Application layer… syllabus (04 Hrs) OSI Model Block Diagram Application layer protocols: Functionality.

CN UNIT 1

Sockets• process sends/receives messages to/from its socket• socket analogous to door

• sending process shoves message out door• sending process relies on transport infrastructure on other

side of door to deliver message to socket at receiving process

Internet

controlledby OS

controlled byapp developer

transport

application

physical

link

network

process

transport

application

physical

link

network

processsocket

2-19

Page 20: Unit 1: Application Layer Prof. Nalini Mhetre. Unit 1:Application layer… syllabus (04 Hrs) OSI Model Block Diagram Application layer protocols: Functionality.

20CN UNIT 1

Addressing processes

• to receive messages, process must have identifier

• host device has unique 32-bit IP address (version 4)

• Q: does IP address of host on which process runs suffice for identifying the process?

• identifier includes both IP address and port numbers associated with process on host.

• example port numbers:• HTTP server: 80• mail server: 25

• to send HTTP message to gaia.cs.umass.edu web server:

• IP address: 128.119.245.12• port number: 80

• more shortly…

A: no, many processes can be running on same host

Page 21: Unit 1: Application Layer Prof. Nalini Mhetre. Unit 1:Application layer… syllabus (04 Hrs) OSI Model Block Diagram Application layer protocols: Functionality.

21CN UNIT 1

App-layer protocol defines

• types of messages exchanged,

• e.g., request, response • message syntax:

• what fields in messages & how fields are defined

• message semantics • meaning of information

in fields• rules for when and how

processes send & respond to messages

open protocols:• defined in RFCs• allows for interoperability• e.g., HTTP, SMTPproprietary protocols:• e.g., Skype

Page 22: Unit 1: Application Layer Prof. Nalini Mhetre. Unit 1:Application layer… syllabus (04 Hrs) OSI Model Block Diagram Application layer protocols: Functionality.

23CN UNIT 1

Web and HTTP

First, a review…• 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.,

www.someschool.edu/someDept/pic.gif

host name path name

Page 23: Unit 1: Application Layer Prof. Nalini Mhetre. Unit 1:Application layer… syllabus (04 Hrs) OSI Model Block Diagram Application layer protocols: Functionality.

24CN UNIT 1

HTTP overview

HTTP: hypertext transfer protocol

• Web’s application layer protocol

• client/server model• client: browser that

requests, receives, (using HTTP protocol) and “displays” Web objects

• server: Web server sends (using HTTP protocol) objects in response to requests

PC runningFirefox browser

server running

Apache Webserver

iphone runningSafari browser

HTTP requestHTTP response

HTTP request

HTTP response

Page 24: Unit 1: Application Layer Prof. Nalini Mhetre. Unit 1:Application layer… syllabus (04 Hrs) OSI Model Block Diagram Application layer protocols: Functionality.

25CN UNIT 1

HTTP overview (continued)

uses TCP:• client initiates TCP

connection (creates socket) to server, port 80

• server accepts TCP connection from client

• HTTP messages (application-layer protocol messages) exchanged between browser (HTTP client) and Web server (HTTP server)

• TCP connection closed

HTTP is “stateless”• server maintains no

information about past client requests

Page 25: Unit 1: Application Layer Prof. Nalini Mhetre. Unit 1:Application layer… syllabus (04 Hrs) OSI Model Block Diagram Application layer protocols: Functionality.

26CN UNIT 1

HTTP connections

non-persistent HTTP• at most one object sent over TCP connection

• connection then closed• downloading multiple objects required multiple connections

persistent HTTP• multiple objects can be

sent over single TCP connection between client, server

Page 26: Unit 1: Application Layer Prof. Nalini Mhetre. Unit 1:Application layer… syllabus (04 Hrs) OSI Model Block Diagram Application layer protocols: Functionality.

27CN UNIT 1

Non-persistent HTTPsuppose user enters URL:

1a. HTTP client initiates TCP connection to HTTP server (process) at www.someSchool.edu on port 80

2. HTTP client sends HTTP request message (containing URL) into TCP connection socket. Message indicates that client wants object someDepartment/home.index

1b. HTTP server at host www.someSchool.edu waiting for TCP connection at port 80. “accepts” connection, notifying client

3. HTTP server receives request message, forms response message containing requested object, and sends message into its sockettime

(contains text, references to 10

jpeg images)www.someSchool.edu/someDepartment/home.index

Page 27: Unit 1: Application Layer Prof. Nalini Mhetre. Unit 1:Application layer… syllabus (04 Hrs) OSI Model Block Diagram Application layer protocols: Functionality.

28CN UNIT 1

Non-persistent HTTP (cont.)

5. HTTP client receives response message containing html file, displays html. Parsing html file, finds 10 referenced jpeg objects

6. Steps 1-5 repeated for each of 10 jpeg objects

4. HTTP server closes TCP connection.

time

Page 28: Unit 1: Application Layer Prof. Nalini Mhetre. Unit 1:Application layer… syllabus (04 Hrs) OSI Model Block Diagram Application layer protocols: Functionality.

CN UNIT 1

Non-persistent HTTP: response time

RTT (definition): time for a small packet to travel from client to server and back

HTTP response time:• one RTT to initiate TCP

connection• one RTT for HTTP request and

first few bytes of HTTP response to return

• file transmission time• non-persistent HTTP response

time = 2RTT+ file transmission time

time to transmit file

initiate TCPconnection

RTT

requestfile

RTT

filereceived

time time

2-29

Page 29: Unit 1: Application Layer Prof. Nalini Mhetre. Unit 1:Application layer… syllabus (04 Hrs) OSI Model Block Diagram Application layer protocols: Functionality.

30CN UNIT 1

Persistent HTTP

non-persistent HTTP issues:

• requires 2 RTTs per object• OS overhead for each TCP

connection• browsers often open

parallel TCP connections to fetch referenced objects

persistent HTTP:• server leaves connection

open after sending response

• subsequent HTTP messages between same client/server sent over open connection

• client sends requests as soon as it encounters a referenced object

• as little as one RTT for all the referenced objects

Page 30: Unit 1: Application Layer Prof. Nalini Mhetre. Unit 1:Application layer… syllabus (04 Hrs) OSI Model Block Diagram Application layer protocols: Functionality.

31CN UNIT 1

HTTP request message

• two types of HTTP messages: request, response• HTTP request message:

• ASCII (human-readable format)

request line(GET, POST, HEAD commands)

header lines

carriage return, line feed at startof line indicatesend of header lines

GET /index.html HTTP/1.1\r\nHost: www-net.cs.umass.edu\r\nUser-Agent: Firefox/3.6.10\r\nAccept: text/html,application/xhtml+xml\r\nAccept-Language: en-us,en;q=0.5\r\nAccept-Encoding: gzip,deflate\r\nAccept-Charset: ISO-8859-1,utf-8;q=0.7\r\nKeep-Alive: 115\r\nConnection: keep-alive\r\n\r\n

carriage return character

line-feed character

Page 31: Unit 1: Application Layer Prof. Nalini Mhetre. Unit 1:Application layer… syllabus (04 Hrs) OSI Model Block Diagram Application layer protocols: Functionality.

32CN UNIT 1

HTTP request message: general format

requestline

headerlines

body

method sp sp cr lfversionURL

cr lfvalueheader field name

cr lfvalueheader field name

~~ ~~

cr lf

entity body~~ ~~

Page 32: Unit 1: Application Layer Prof. Nalini Mhetre. Unit 1:Application layer… syllabus (04 Hrs) OSI Model Block Diagram Application layer protocols: Functionality.

33CN UNIT 1

Uploading form input

POST method:• web page often includes form input• input is uploaded to server in entity body

URL method:• uses GET method • input is uploaded in URL field of request line:

www.somesite.com/animalsearch?monkeys&banana

Page 33: Unit 1: Application Layer Prof. Nalini Mhetre. Unit 1:Application layer… syllabus (04 Hrs) OSI Model Block Diagram Application layer protocols: Functionality.

34CN UNIT 1

Method typesHTTP/1.0:• GET• POST• HEAD

• asks server to leave requested object out of response

HTTP/1.1:• GET, POST, HEAD• PUT

• uploads file in entity body to path specified in URL field

• DELETE• deletes file specified in

the URL field

Page 34: Unit 1: Application Layer Prof. Nalini Mhetre. Unit 1:Application layer… syllabus (04 Hrs) OSI Model Block Diagram Application layer protocols: Functionality.

35CN UNIT 1

HTTP request message: general format

requestline

headerlines

body

method sp sp cr lfversionURL

cr lfvalueheader field name

cr lfvalueheader field name

~~ ~~

cr lf

entity body~~ ~~

Page 35: Unit 1: Application Layer Prof. Nalini Mhetre. Unit 1:Application layer… syllabus (04 Hrs) OSI Model Block Diagram Application layer protocols: Functionality.

36CN UNIT 1

HTTP response message

status line(protocolstatus codestatus phrase)

header lines

data, e.g., requestedHTML file

HTTP/1.1 200 OK\r\nDate: Sun, 26 Sep 2010 20:09:20 GMT\r\nServer: Apache/2.0.52 (CentOS)\r\nLast-Modified: Tue, 30 Oct 2007 17:00:02

GMT\r\nETag: "17dc6-a5c-bf716880"\r\nAccept-Ranges: bytes\r\nContent-Length: 2652\r\nKeep-Alive: timeout=10, max=100\r\nConnection: Keep-Alive\r\nContent-Type: text/html; charset=ISO-8859-1\

r\n\r\ndata data data data data ...

Page 36: Unit 1: Application Layer Prof. Nalini Mhetre. Unit 1:Application layer… syllabus (04 Hrs) OSI Model Block Diagram Application layer protocols: Functionality.

37

HTTP response message: general format

CN UNIT 1

Page 37: Unit 1: Application Layer Prof. Nalini Mhetre. Unit 1:Application layer… syllabus (04 Hrs) OSI Model Block Diagram Application layer protocols: Functionality.

38CN UNIT 1

HTTP response status codes

200 OK• request succeeded, requested object later in this msg

301 Moved Permanently• requested object moved, new location specified later in this msg

(Location:)400 Bad Request

• request msg not understood by server404 Not Found

• requested document not found on this server505 HTTP Version Not Supported

status code appears in 1st line in server-to-client response message.

some sample codes:

Page 38: Unit 1: Application Layer Prof. Nalini Mhetre. Unit 1:Application layer… syllabus (04 Hrs) OSI Model Block Diagram Application layer protocols: Functionality.

39CN UNIT 1

FTP: the file transfer protocolfile transfer

FTPserver

FTPuser

interface

FTPclient

local filesystem

remote filesystem

user at host

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

Page 39: Unit 1: Application Layer Prof. Nalini Mhetre. Unit 1:Application layer… syllabus (04 Hrs) OSI Model Block Diagram Application layer protocols: Functionality.

40CN UNIT 1

FTP: separate control, data connections

• FTP client contacts FTP server at port 21, using TCP

• client authorized over control connection

• client browses remote directory, sends commands over control connection

• when server receives file transfer command, server opens 2nd TCP data connection (for file) to client

• after transferring one file, server closes data connection

FTPclient

FTPserver

TCP control connection,server port 21

TCP data connection,server port 20

server opens another TCP data connection to transfer another file

control connection: “out of band”FTP server maintains “state”:

current directory, earlier authentication

Page 40: Unit 1: Application Layer Prof. Nalini Mhetre. Unit 1:Application layer… syllabus (04 Hrs) OSI Model Block Diagram Application layer protocols: Functionality.

CN UNIT 1 41

Commands ,which are sent from FTP client control process ,are in the form of ASCII uppercase. Commands can be divided in to six categories:

• access commands

• file management commands

• data formatting commands

• defining commands

• file transferring commands

• miscellaneous commands

Page 41: Unit 1: Application Layer Prof. Nalini Mhetre. Unit 1:Application layer… syllabus (04 Hrs) OSI Model Block Diagram Application layer protocols: Functionality.

CN UNIT 1 42

1.Access commands:

USER-user Information, PASS-password, ACCT-account information, REIN-reinitialize, QUIT-log out, ABOR-abort previous command

2. File Mgmt commands:

CWD-change to another directory, CDUP-change to parent directory, LIST-list subdirectories or files, MKD-create new directory, PWD, DELE, RNFR-identify the file to be renamed, RNTO-rename the file, SMNT-mount the file system

3. Data formatting commands:

TYPE-file type, STRU-structure, MODE-transmission mode.

Page 42: Unit 1: Application Layer Prof. Nalini Mhetre. Unit 1:Application layer… syllabus (04 Hrs) OSI Model Block Diagram Application layer protocols: Functionality.

CN UNIT 1 43

4. Port defining commands :

PORT-client chooses a port, PASV-server chooses a port

5. File transfer commands:

RETR-retrieve remote file, STOR-store to remote server, APPE-append mode, STOU-store uniquely

6.Miscellaneous commands:

HELP, NOOP-check if server is alive, SYST-OS of server

Page 43: Unit 1: Application Layer Prof. Nalini Mhetre. Unit 1:Application layer… syllabus (04 Hrs) OSI Model Block Diagram Application layer protocols: Functionality.

CN UNIT 1 44

Response: Every FTP command generates at least one response. A response has two parts. 1.a three digit no. followed by text. We represent numeric part as xyz. The meaning of each will be as follows.First Digit:

1yz:positive preliminary reply – Action has started. Server sends another reply before accepting 2nd command.

2yz:Positive completion reply – Action completed

3yz:Positive intermediate reply – Command accepted but further information required.

4yz: transient negative completion reply - Action did not take place but the error is temporary.

5yz: Permanent negative reply- command can not be completed.

Page 44: Unit 1: Application Layer Prof. Nalini Mhetre. Unit 1:Application layer… syllabus (04 Hrs) OSI Model Block Diagram Application layer protocols: Functionality.

CN UNIT 1 45

Second digit:

x0z: (syntax) ,

x1z:(information) ,

x2z: (connection) ,

x3z: (authentication & accounting),

x5z: (file system)

Third digit: Provides additional information.

Page 45: Unit 1: Application Layer Prof. Nalini Mhetre. Unit 1:Application layer… syllabus (04 Hrs) OSI Model Block Diagram Application layer protocols: Functionality.

46CN UNIT 1

FTP commands, responses

sample commands: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 codesstatus 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

Page 46: Unit 1: Application Layer Prof. Nalini Mhetre. Unit 1:Application layer… syllabus (04 Hrs) OSI Model Block Diagram Application layer protocols: Functionality.

CN UNIT 1 47

DNS

Page 47: Unit 1: Application Layer Prof. Nalini Mhetre. Unit 1:Application layer… syllabus (04 Hrs) OSI Model Block Diagram Application layer protocols: Functionality.

48CN UNIT 1

DNS: domain name system

people: many identifiers:• SSN, name, passport #

Internet hosts, routers:• IP address (32 bit) -

used for addressing datagrams

• “name”, e.g., www.yahoo.com - used by humans

Q: how to map between IP address and name, and vice versa ?

Domain Name System:• distributed database

implemented in hierarchy of many name servers

• application-layer protocol: hosts, name servers communicate to resolve names (address/name translation)

• note: core Internet function, implemented as application-layer protocol

• complexity at network’s “edge”

Page 48: Unit 1: Application Layer Prof. Nalini Mhetre. Unit 1:Application layer… syllabus (04 Hrs) OSI Model Block Diagram Application layer protocols: Functionality.

49

DNS: services, structure

DNS services• hostname to IP address

translation• host aliasing

• canonical, alias names

• mail server aliasing• load distribution

• replicated Web servers: many IP addresses correspond to one name

why not centralize DNS?• single point of failure• traffic volume• distant centralized database• maintenance

CN UNIT 1

A: doesn’t scale!

Page 49: Unit 1: Application Layer Prof. Nalini Mhetre. Unit 1:Application layer… syllabus (04 Hrs) OSI Model Block Diagram Application layer protocols: Functionality.

2-50

DNS: a distributed, hierarchical database

client wants IP for www.amazon.com; 1st approx:• client queries root server to find com DNS server• client queries .com DNS server to get amazon.com DNS server• client queries amazon.com DNS server to get IP address for

www.amazon.com

CN UNIT 1

Root DNS Servers

com DNS servers org DNS servers edu DNS servers

poly.eduDNS servers

umass.eduDNS servers

yahoo.comDNS servers

amazon.comDNS servers

pbs.orgDNS servers

… …

Page 50: Unit 1: Application Layer Prof. Nalini Mhetre. Unit 1:Application layer… syllabus (04 Hrs) OSI Model Block Diagram Application layer protocols: Functionality.

51

TLD, authoritative, local DNS servers

top-level domain (TLD) servers:• responsible for com, org, net, edu, aero, jobs, museums, and all top-level

country domains, e.g.: uk, fr, ca, jp• Network Solutions maintains servers for .com TLD• Educause for .edu TLD

authoritative DNS servers: • organization’s own DNS server(s), providing authoritative hostname to IP

mappings for organization’s named hosts • can be maintained by organization or service provider

CN UNIT 1

Page 51: Unit 1: Application Layer Prof. Nalini Mhetre. Unit 1:Application layer… syllabus (04 Hrs) OSI Model Block Diagram Application layer protocols: Functionality.

52

Local DNS name server• does not strictly belong to hierarchy• each ISP (residential ISP, company, university) has one

• also called “default name server”

• when host makes DNS query, query is sent to its local DNS server• has local cache of recent name-to-address translation pairs (but may be out of

date!)• acts as proxy, forwards query into hierarchy

CN UNIT 1

Page 52: Unit 1: Application Layer Prof. Nalini Mhetre. Unit 1:Application layer… syllabus (04 Hrs) OSI Model Block Diagram Application layer protocols: Functionality.

53

DNS name resolution example

• host at cis.poly.edu wants IP address for gaia.cs.umass.edu

CN UNIT 1

requesting hostcis.poly.edu

gaia.cs.umass.edu

root DNS server

local DNS serverdns.poly.edu

1

23

4

5

6

authoritative DNS serverdns.cs.umass.edu

78

TLD DNS server

iterated query: contacted server

replies with name of server to contact

“I don’t know this name, but ask this server”

Page 53: Unit 1: Application Layer Prof. Nalini Mhetre. Unit 1:Application layer… syllabus (04 Hrs) OSI Model Block Diagram Application layer protocols: Functionality.

54CN UNIT 1

45

6

3

recursive query: puts burden of name

resolution on contacted name server

heavy load at upper levels of hierarchy?

requesting hostcis.poly.edu

gaia.cs.umass.edu

root DNS server

local DNS serverdns.poly.edu

1

27

authoritative DNS serverdns.cs.umass.edu

8

DNS name resolution example

TLD DNS server

Page 54: Unit 1: Application Layer Prof. Nalini Mhetre. Unit 1:Application layer… syllabus (04 Hrs) OSI Model Block Diagram Application layer protocols: Functionality.

58

DNS protocol, messages

• query and reply messages, both with same message format

CN UNIT 1

msg header identification: 16 bit # for

query, reply to query uses same #

flags: query or reply recursion desired recursion available reply is authoritative

identification flags

# questions

questions (variable # of questions)

# additional RRs# authority RRs

# answer RRs

answers (variable # of RRs)

authority (variable # of RRs)

additional info (variable # of RRs)

2 bytes 2 bytes

Page 55: Unit 1: Application Layer Prof. Nalini Mhetre. Unit 1:Application layer… syllabus (04 Hrs) OSI Model Block Diagram Application layer protocols: Functionality.

59CN UNIT 1

name, type fields for a query

RRs in responseto query

records forauthoritative servers

additional “helpful”info that may be used

identification flags

# questions

questions (variable # of questions)

# additional RRs# authority RRs

# answer RRs

answers (variable # of RRs)

authority (variable # of RRs)

additional info (variable # of RRs)

DNS protocol, messages

2 bytes 2 bytes

Page 56: Unit 1: Application Layer Prof. Nalini Mhetre. Unit 1:Application layer… syllabus (04 Hrs) OSI Model Block Diagram Application layer protocols: Functionality.

CN UNIT 1 62

Electronic Mail

• SMTP• POP3• IMAP

Page 57: Unit 1: Application Layer Prof. Nalini Mhetre. Unit 1:Application layer… syllabus (04 Hrs) OSI Model Block Diagram Application layer protocols: Functionality.

63CN UNIT 1

Electronic Mail

Three major components:

• user agents

• mail servers

• simple mail transfer protocol: SMTP

1. User Agent

• a.k.a. “mail reader”

• composing, editing, reading mail messages

• e.g., Eudora, Outlook, elm, Mozilla Thunderbird

• outgoing, incoming messages stored on server

user mailbox

outgoing message queue

mailserver

useragent

useragent

useragent

mailserver

useragent

useragent

mailserver

useragent

SMTP

SMTP

SMTP

Page 58: Unit 1: Application Layer Prof. Nalini Mhetre. Unit 1:Application layer… syllabus (04 Hrs) OSI Model Block Diagram Application layer protocols: Functionality.

64CN UNIT 1

Electronic Mail: mail servers

2.Mail Servers

• mailbox contains incoming messages for user

• message queue of outgoing (to be sent) mail messages

3. SMTP protocol between mail servers to transmit email messages

• “Client”: sending mail server• “server”: receiving mail server

mailserver

useragent

useragent

useragent

mailserver

useragent

useragent

mailserver

useragent

SMTP

SMTP

SMTP

Page 59: Unit 1: Application Layer Prof. Nalini Mhetre. Unit 1:Application layer… syllabus (04 Hrs) OSI Model Block Diagram Application layer protocols: Functionality.

65CN UNIT 1

Scenario: Alice sends message to Bob1) Alice uses UA to compose message and

“to” [email protected]

2) Alice’s UA sends message to her mail server; message placed in message queue

3) Client side of SMTP opens TCP connection with Bob’s mail server

4) SMTP client sends Alice’s message over the TCP connection

5) Bob’s mail server places the message in Bob’s mailbox

6) Bob invokes his user agent to read message

useragent

mailserver

mailserver user

agent

1

2 3 4 56

Page 60: Unit 1: Application Layer Prof. Nalini Mhetre. Unit 1:Application layer… syllabus (04 Hrs) OSI Model Block Diagram Application layer protocols: Functionality.

66CN UNIT 1

Electronic Mail: SMTP [RFC 2821]

• uses TCP to reliably transfer email message from client to server, 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

Page 61: Unit 1: Application Layer Prof. Nalini Mhetre. Unit 1:Application layer… syllabus (04 Hrs) OSI Model Block Diagram Application layer protocols: Functionality.

69CN UNIT 1

SMTP: final words

• SMTP uses persistent connections

• SMTP requires message (header & body) to be in 7-bit ASCII

• SMTP server uses CRLF.CRLF to determine end of message

Comparison with HTTP:• HTTP: pull

• SMTP: push

• both have ASCII command/response interaction, status codes

• HTTP: each object encapsulated in its own response msg

• SMTP: multiple objects sent in multipart msg

Page 62: Unit 1: Application Layer Prof. Nalini Mhetre. Unit 1:Application layer… syllabus (04 Hrs) OSI Model Block Diagram Application layer protocols: Functionality.

70CN UNIT 1

Mail message format

SMTP: protocol for exchanging email msgs

RFC 822: std for text message format:

• header lines, e.g.,• To:• From:• Subject:different from SMTP commands!

• body• the “message”, ASCII characters only

header

body

blankline

Page 63: Unit 1: Application Layer Prof. Nalini Mhetre. Unit 1:Application layer… syllabus (04 Hrs) OSI Model Block Diagram Application layer protocols: Functionality.

71CN UNIT 1

Mail access protocols

• SMTP: transfer/storage to receiver’s server

• Mail access protocol: retrieval from server• POP: Post Office Protocol [RFC 1939]

• authorization (agent <-->server) and download • IMAP: Internet Mail Access Protocol [RFC 1730]

• more features (more complex)• manipulation of stored msgs on server

• HTTP: gmail, Hotmail, Yahoo! Mail, etc.

useragent

sender’s mail server

useragent

SMTP SMTP accessprotocol

receiver’s mail server

Page 64: Unit 1: Application Layer Prof. Nalini Mhetre. Unit 1:Application layer… syllabus (04 Hrs) OSI Model Block Diagram Application layer protocols: Functionality.

72CN UNIT 1

POP3 protocolauthorization phase• client commands:

• user: declare username• pass: password

• server responses• +OK• -ERR

transaction phase, client:

• 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> S: . C: dele 1 C: retr 2 S: <message 2 contents> S: . C: dele 2 C: quit S: +OK POP3 server signing off

S: +OK POP3 server ready C: user bob S: +OK C: pass hungry S: +OK user successfully logged on

Page 65: Unit 1: Application Layer Prof. Nalini Mhetre. Unit 1:Application layer… syllabus (04 Hrs) OSI Model Block Diagram Application layer protocols: Functionality.

73CN UNIT 1

POP3 (more) and IMAPMore about POP3• Previous example uses

“download and delete” mode.

• Bob cannot re-read e-mail if he changes client

• “Download-and-keep”: copies of messages on different clients

• POP3 is stateless across sessions

IMAP• Keep all messages in one

place: the server• Allows user to organize

messages in folders• IMAP keeps user state

across sessions:• names of folders and

mappings between message IDs and folder name

Page 66: Unit 1: Application Layer Prof. Nalini Mhetre. Unit 1:Application layer… syllabus (04 Hrs) OSI Model Block Diagram Application layer protocols: Functionality.

74

Dynamic Host Configuration Protocol (DHCP) • Module about dynamic assignment of IP addresses with DHCP.

CN UNIT 1

Page 67: Unit 1: Application Layer Prof. Nalini Mhetre. Unit 1:Application layer… syllabus (04 Hrs) OSI Model Block Diagram Application layer protocols: Functionality.

75

Dynamic Assignment of IP addresses• Dynamic assignment of IP addresses is desirable for several reasons:

• IP addresses are assigned on-demand• Avoid manual IP configuration• Support mobility of laptops

• Three Protocols:• RARP (until 1985, no longer used)• BOOTP (1985-1993)• DHCP (since 1993)

• Only DHCP is widely used today.

CN UNIT 1

Page 68: Unit 1: Application Layer Prof. Nalini Mhetre. Unit 1:Application layer… syllabus (04 Hrs) OSI Model Block Diagram Application layer protocols: Functionality.

Solutions for dynamic assignment of IP addresses

• Reverse Address Resolution Protocol (RARP)• RARP is no longer used• Works similar to ARP• Broadcast a request for the IP address associated with a

given MAC address• RARP server responds with an IP address• Only assigns IP address (not the default router and subnet

mask)

RARP

Ethernet MACaddress(48 bit)

ARPIP address(32 bit)

CN UNIT 1 2-76

Page 69: Unit 1: Application Layer Prof. Nalini Mhetre. Unit 1:Application layer… syllabus (04 Hrs) OSI Model Block Diagram Application layer protocols: Functionality.

77

BOOTP(BOOTstrap Protocol ) Not only assigns IP address, but also default router, network mask,

etc. • Host can configure its IP parameters at boot time. • 3 services.

• IP address assignment. • Detection of the IP address for a serving machine. • The name of a file to be loaded and executed by the client machine (boot file

name)

• Sent as UDP messages (UDP Port 67 (server) and 68 (host))• Use limited broadcast address (255.255.255.255):

• These addresses are never forwarded

CN UNIT 1

Page 70: Unit 1: Application Layer Prof. Nalini Mhetre. Unit 1:Application layer… syllabus (04 Hrs) OSI Model Block Diagram Application layer protocols: Functionality.

78

BOOTP Interaction

• BOOTP can be used for downloading memory image for diskless workstations

• Assignment of IP addresses to hosts is static

Argon00:a0:24:71:e4:44 BOOTP Server

BOOTP Request00:a0:24:71:e4:44Sent to 255.255.255.255

Argon128.143.137.144

00:a0:24:71:e4:44 DHCP ServerBOOTP Response:IP address: 128.143.137.144Server IP address: 128.143.137.100Boot file name: filename

(a)(b)

Argon128.143.137.14400:a0:24:71:e4:44 DHCP Server

128.143.137.100

TFTP“filename”

(c)

CN UNIT 1

Page 71: Unit 1: Application Layer Prof. Nalini Mhetre. Unit 1:Application layer… syllabus (04 Hrs) OSI Model Block Diagram Application layer protocols: Functionality.

79

DHCP• Dynamic Host Configuration Protocol (DHCP)

• Designed in 1993• An extension of BOOTP (Many similarities to BOOTP)• Same port numbers as BOOTP • Extensions:

• Supports temporary allocation (“leases”) of IP addresses• DHCP client can acquire all IP configuration parameters

• DHCP is the preferred mechanism for dynamic assignment of IP addresses• DHCP can interoperate with BOOTP clients.

CN UNIT 1

Page 72: Unit 1: Application Layer Prof. Nalini Mhetre. Unit 1:Application layer… syllabus (04 Hrs) OSI Model Block Diagram Application layer protocols: Functionality.

80

DHCP Interaction (simplified)Argon

00:a0:24:71:e4:44 DHCP Server

DHCP Request00:a0:24:71:e4:44Sent to 255.255.255.255

Argon128.143.137.14400:a0:24:71:e4:44 DHCP Server

DHCP Response:IP address: 128.143.137.144Default gateway: 128.143.137.1Netmask: 255.255.0.0

CN UNIT 1

Page 73: Unit 1: Application Layer Prof. Nalini Mhetre. Unit 1:Application layer… syllabus (04 Hrs) OSI Model Block Diagram Application layer protocols: Functionality.

81

BOOTP/DHCP Message Format

Number of Seconds

OpCode Hardware Type

Your IP address

Unused (in BOOTP)Flags (in DHCP)

Gateway IP address

Client IP address

Server IP address

Hardware AddressLength

Hop Count

Server host name (64 bytes)

Client hardware address (16 bytes)

Boot file name (128 bytes)

Transaction ID

Options

(There are >100 different options)CN UNIT 1

Page 74: Unit 1: Application Layer Prof. Nalini Mhetre. Unit 1:Application layer… syllabus (04 Hrs) OSI Model Block Diagram Application layer protocols: Functionality.

82

BOOTP/DHCP• OpCode: 1 (Request), 2(Reply) Note: DHCP message type is sent in an option

• Hardware Type: 1 (for Ethernet)

• Hardware address length: 6 (for Ethernet)

• Hop count: set to 0 by client

• Transaction ID: Integer (used to match reply to response)

• Seconds: number of seconds since the client started to boot

• Client IP address, Your IP address, server IP address, Gateway IP address, client hardware address, server host name, boot file name: client fills in the information that it has, leaves rest blank

CN UNIT 1

Page 75: Unit 1: Application Layer Prof. Nalini Mhetre. Unit 1:Application layer… syllabus (04 Hrs) OSI Model Block Diagram Application layer protocols: Functionality.

DHCP Message Type

• Message type is sent as an option. Value Message Type

1 DHCPDISCOVER

2 DHCPOFFER

3 DHCPREQUEST

4 DHCPDECLINE

5 DHCPACK

6 DHCPNAK

7 DHCPRELEASE

8 DHCPINFORM

CN UNIT 1 2-83

Page 76: Unit 1: Application Layer Prof. Nalini Mhetre. Unit 1:Application layer… syllabus (04 Hrs) OSI Model Block Diagram Application layer protocols: Functionality.

84

Other options (selection)

• Other DHCP information that is sent as an option:Subnet Mask, Name Server, Hostname, Domain Name, Forward On/Off, Default IP TTL, Broadcast Address, Static Route, Ethernet Encapsulation, X Window Manager, X Window Font, DHCP Msg Type, DHCP Renewal Time, DHCP Rebinding, Time SMTP-Server, SMTP-Server, Client FQDN, Printer Name, …

CN UNIT 1

Page 77: Unit 1: Application Layer Prof. Nalini Mhetre. Unit 1:Application layer… syllabus (04 Hrs) OSI Model Block Diagram Application layer protocols: Functionality.

85

DHCP Operation

• DCHP DISCOVER

DHCP Client00:a0:24:71:e4:44 DHCP Server

DHCPDISCOVERSent to 255.255.255.255

DHCP Server

DHCP Client00:a0:24:71:e4:44 DHCP Server

DHCP Server

DHCPOFFER

DHCPOFFER

DCHP OFFER

CN UNIT 1

Page 78: Unit 1: Application Layer Prof. Nalini Mhetre. Unit 1:Application layer… syllabus (04 Hrs) OSI Model Block Diagram Application layer protocols: Functionality.

86

DHCP OperationDHCP Client

00:a0:24:71:e4:44 DHCP Server

DHCP Server

DHCPREQUEST

DHCPACKDCHPREQUEST

At this time, the DHCP client can start to use the IP address

DHCP Client00:a0:24:71:e4:44 DHCP Server

DHCP Server

DHCPREQUEST

DHCPACK

Renewing a Lease(sent when 50% of lease has

expired)If DHCP server sends DHCPNACK, then address is released.

CN UNIT 1

Page 79: Unit 1: Application Layer Prof. Nalini Mhetre. Unit 1:Application layer… syllabus (04 Hrs) OSI Model Block Diagram Application layer protocols: Functionality.

87

DHCP OperationDHCP Client

00:a0:24:71:e4:44 DHCP Server

DHCP Server

DHCPRELEASE

DCHP RELEASE

At this time, the DHCP client has released the IP address

CN UNIT 1

Page 80: Unit 1: Application Layer Prof. Nalini Mhetre. Unit 1:Application layer… syllabus (04 Hrs) OSI Model Block Diagram Application layer protocols: Functionality.

The TELNET ProtocolReference: RFC 854

Page 81: Unit 1: Application Layer Prof. Nalini Mhetre. Unit 1:Application layer… syllabus (04 Hrs) OSI Model Block Diagram Application layer protocols: Functionality.

89

TELNET vs. telnet• TELNET is a protocol that provides “a general, bi-

directional, eight-bit byte oriented

communications facility”.

• telnet is a program that supports the TELNET

protocol over TCP.

• Many application protocols are built upon the

TELNET protocol.

CN UNIT 1

Page 82: Unit 1: Application Layer Prof. Nalini Mhetre. Unit 1:Application layer… syllabus (04 Hrs) OSI Model Block Diagram Application layer protocols: Functionality.

90

The TELNET Protocol• TCP connection• data and control over the same connection.• Network Virtual Terminal [NVT]• Negotiated options• One computer can connect to another to use its

services• Connecting Privileges:

guest - usually logins are not requiredfull - requires username and password.

CN UNIT 1

Page 83: Unit 1: Application Layer Prof. Nalini Mhetre. Unit 1:Application layer… syllabus (04 Hrs) OSI Model Block Diagram Application layer protocols: Functionality.

91

Network Virtual Terminal

CN UNIT 1

NVT NVT

ServerProcess

TCP TCP

Page 84: Unit 1: Application Layer Prof. Nalini Mhetre. Unit 1:Application layer… syllabus (04 Hrs) OSI Model Block Diagram Application layer protocols: Functionality.

92

Network Virtual Terminal

• Intermediate representation of a generic terminal.

• Provides a standard language for communication of terminal control functions.

CN UNIT 1

Page 85: Unit 1: Application Layer Prof. Nalini Mhetre. Unit 1:Application layer… syllabus (04 Hrs) OSI Model Block Diagram Application layer protocols: Functionality.

93

Negotiated Options

• All NVTs support a minimal set of capabilities.• Some terminals have more capabilities than the minimal set.• The 2 endpoints negotiate a set of mutually acceptable options

(character set, echo mode, etc).

CN UNIT 1

Page 86: Unit 1: Application Layer Prof. Nalini Mhetre. Unit 1:Application layer… syllabus (04 Hrs) OSI Model Block Diagram Application layer protocols: Functionality.

94

Negotiated Options [Cntd.]

• The set of options is not part of the TELNET protocol, so that new terminal features can be incorporated without changing the TELNET protocol.

• The protocol for requesting optional features is well defined and includes rules for eliminating possible negotiation “loops”.

CN UNIT 1

Page 87: Unit 1: Application Layer Prof. Nalini Mhetre. Unit 1:Application layer… syllabus (04 Hrs) OSI Model Block Diagram Application layer protocols: Functionality.

95

Option examples

• Line mode vs. character mode

• echo modes

• character set (EBCDIC vs. ASCII)

CN UNIT 1

Page 88: Unit 1: Application Layer Prof. Nalini Mhetre. Unit 1:Application layer… syllabus (04 Hrs) OSI Model Block Diagram Application layer protocols: Functionality.

96

Control Functions

• TELNET includes support for a series of control functions commonly supported by servers.

• This provides a uniform mechanism for communication of (the supported) control functions.

CN UNIT 1

Page 89: Unit 1: Application Layer Prof. Nalini Mhetre. Unit 1:Application layer… syllabus (04 Hrs) OSI Model Block Diagram Application layer protocols: Functionality.

97

Control Functions

• Interrupt Process (IP)• suspend/abort process.

• Abort Output (AO)• process can complete, but send no more output to user’s terminal.

• Are You There (AYT)• check to see if system is still running.

CN UNIT 1

Page 90: Unit 1: Application Layer Prof. Nalini Mhetre. Unit 1:Application layer… syllabus (04 Hrs) OSI Model Block Diagram Application layer protocols: Functionality.

98

More Control Functions

• Erase Character (EC)• delete last character sent• typically used to edit keyboard input.

• Erase Line (EL)• delete all input in current line.

CN UNIT 1

Page 91: Unit 1: Application Layer Prof. Nalini Mhetre. Unit 1:Application layer… syllabus (04 Hrs) OSI Model Block Diagram Application layer protocols: Functionality.

99

Command Structure

• All TELNET commands and data flow through the same TCP connection.

• Commands start with a special character called the Interpret as Command (IAC) escape character

• The IAC code is 255.• If a 255 is sent as data - it must be followed by another 255.

CN UNIT 1

Page 92: Unit 1: Application Layer Prof. Nalini Mhetre. Unit 1:Application layer… syllabus (04 Hrs) OSI Model Block Diagram Application layer protocols: Functionality.

100

Looking for Commands

• Each receiver must look at each byte that arrives and look for IAC.• If IAC is found and the next byte is IAC - a single byte is presented to

the application/terminal (a 255).• If IAC is followed by any other code - the TELNET layer interprets this

as a command.

CN UNIT 1

Page 93: Unit 1: Application Layer Prof. Nalini Mhetre. Unit 1:Application layer… syllabus (04 Hrs) OSI Model Block Diagram Application layer protocols: Functionality.

101

Command Codes• IP 243• AO 244• AYT 245• EC 246• EL 247• WILL 251• WON’T 252• DO 253• DON’T 254• IAC 255

CN UNIT 1

Page 94: Unit 1: Application Layer Prof. Nalini Mhetre. Unit 1:Application layer… syllabus (04 Hrs) OSI Model Block Diagram Application layer protocols: Functionality.

102

Playing with TELNET

• You can use the telnet program to play with the TELNET protocol.• telnet is a generic TCP client.

• Sends whatever you type to the TCP socket.• Prints whatever comes back through the TCP socket.• Useful for testing TCP servers (ASCII based protocols).

CN UNIT 1

Page 95: Unit 1: Application Layer Prof. Nalini Mhetre. Unit 1:Application layer… syllabus (04 Hrs) OSI Model Block Diagram Application layer protocols: Functionality.

103

Some TCP Servers you can play with

• Many Unix systems have these servers running (by default):• echo port 7• discard port 9• daytime port 13• chargen port 19

CN UNIT 1

Page 96: Unit 1: Application Layer Prof. Nalini Mhetre. Unit 1:Application layer… syllabus (04 Hrs) OSI Model Block Diagram Application layer protocols: Functionality.

104

telnet hostname port> telnet rcs.rpi.edu 7Trying 128.113.113.33...

Connected to cortez.sss.rpi.edu (128.113.113.33).

Escape character is '^]'.

Hi dave

Hi dave

stop it

stop it

^]

telnet> quit

Connection closed.CN UNIT 1

Page 97: Unit 1: Application Layer Prof. Nalini Mhetre. Unit 1:Application layer… syllabus (04 Hrs) OSI Model Block Diagram Application layer protocols: Functionality.

105

telnet vs. TCP

• Not all TCP servers talk TELNET (most don't)

• You can use the telnet program to play with these servers, but the fancy commands won't do anything.

• type ^], then "help" for a list of fancy TELNET stuff you can do in telnet.

CN UNIT 1

Page 98: Unit 1: Application Layer Prof. Nalini Mhetre. Unit 1:Application layer… syllabus (04 Hrs) OSI Model Block Diagram Application layer protocols: Functionality.

106

END

CN UNIT 1