Internet Engineering Internet Engineering CourseCourse
Application Layer Protocols
2
Applications and application-layer protocolsApplications and application-layer protocols
Application: communicating, distributed processes◦ running in network hosts in
“user space”◦ exchange messages◦ e.g., email, file transfer, the
WebApplication-layer protocols
◦ one “piece” of an application -others are e.g. user agents. Web:browser E-mail: mail reader streaming audio/video: media
player
◦ define messages exchanged by apps and actions taken
◦ use services provided by lower layer protocols
applicationtransportnetworkdata linkphysical
applicationtransportnetworkdata linkphysical
applicationtransportnetworkdata linkphysical
3
Client-server paradigmClient-server paradigm
Typical network app has two pieces: client and server
applicationtransportnetworkdata linkphysical
applicationtransportnetworkdata linkphysical
Client: initiates contact with server
(“speaks first”) typically requests service
from server, for Web, client is
implemented in browser; for e-mail, in mail reader
Server: provides requested service
to client e.g., Web server sends
requested Web page, mail server delivers e-mail
request
reply
4
Auxiliary terms ++Auxiliary terms ++
socket: Internet application programming interface◦ 2 processes
communicate by sending data into socket, reading data out of socket (like sending out, receiving in via doors)
Q: how does a process “identify” the other process with which it wants to communicate?◦ IP address of host
running other process◦ “port number” - allows
receiving host to determine to which local process the message should be delivered
5
Properties of transport service of interest Properties of transport service of interest
to the appto the app Data loss some apps (e.g., audio)
can tolerate some loss other apps (e.g., file
transfer, telnet) require 100% reliable data transfer
Connection-oriented vs connectionless services
Bandwidth, Timing some apps (e.g.,
multimedia) require at least a minimum amount of bandwidth
some apps (e.g., Internet telephony, interactive games) require low delay and/or low jitter
other apps (elastic apps, e.g. file transfer) make use of whatever bandwidth, timing they get
6
Transport service requirements of Transport service requirements of common appscommon apps
Application
file transfere-mail
Web documentsreal-time audio/
videostored audio/videointeractive games
financial apps
Data loss
no lossno lossNo-lossloss-tolerant
loss-tolerantloss-tolerantno loss
Bandwidth
elasticelasticelasticaudio: 5Kb-1Mbvideo:10Kb-5Mbsame as above few Kbps upelastic
Time Sensitive
nononoyes, 100’s msec
yes, few secsyes, 100’s msecyes and no
7
Internet apps: their protocolsInternet apps: their protocols
Application
e-mail remote terminal access Web file transferstreaming multimedia
remote file serverInternet telephony
nslookup and many others
Applicationlayer protocol
» smtp [RFC 821]» telnet [RFC 854]» http [RFC 2068]» ftp [RFC 959]proprietary(e.g. RealNetworks)NSFSIP, RTP, proprietary (e.g., Skype)» DNS [RFC 882, 883,1034,1035]
Underlyingtransport protocol
TCPTCPTCPTCPTCP or UDP
TCP or UDPtypically UDP, TCP also possibleUDP
8
The TELNET ProtocolThe TELNET ProtocolTCP connectiondata and control over the same
connection.Network Virtual Terminalnegotiated options
9
Network Virtual TerminalNetwork Virtual Terminalintermediate representation of a
generic terminal.provides a standard language for
communication of terminal control functions.
10
Network Virtual TerminalNetwork Virtual Terminal
NVTNVT NVTNVT
ServerServerProcessProcess
TCPTCP TCPTCP
11
Negotiated OptionsNegotiated OptionsAll 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).
12
Option examplesOption examples
Line mode vs. character mode
echo modes
character set (EBCDIC vs. ASCII)
13
Control FunctionsControl FunctionsTELNET includes support for a
series of control functions commonly supported by servers.
This provides a uniform mechanism for communication of (the supported) control functions.
14
Control FunctionsControl FunctionsInterrupt 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.
15
More Control FunctionsMore Control FunctionsErase Character (EC)
◦delete last character sent◦typically used to edit keyboard input.
Erase Line (EL)◦delete all input in current line.
16
Command StructureCommand StructureAll TELNET commands and data
flow through the same TCP connection.
Commands start with a special character called the Interpret as Command escape character (IAC).
The IAC code is 255.If a 255 is sent as data - it must
be followed by another 255.
17
Looking for CommandsLooking for CommandsEach 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.
18
Playing with TELNETPlaying with TELNETYou 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).
19
Some TCP Servers you can Some TCP Servers you can play withplay withMany Unix systems have these
servers running (by default):◦echo port 7◦discard port 9◦daytime port 13◦chargen port 19
20
telnet hostname porttelnet 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 daveHi davestop itstop it^]telnet> quitConnection closed.
21
ftp: the file transfer protocolftp: the file transfer protocol
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
file transfer FTPserver
FTPuser
interface
FTPclient
local filesystem
remote filesystem
user at host
22
ftp: separate control, data ftp: separate control, data connectionsconnections
ftp client contacts ftp server at port 21, specifying TCP as transport protocol
two parallel TCP connections opened:◦ control: exchange
commands, responses between client, server.
◦ data: file data to/from server
ftp server maintains “state”: current directory, earlier authentication
FTPclient
FTPserver
TCP control connectionport 21
TCP data connectionport 20
23
ftp commands, responsesftp 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 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
24
application layer
transport layer (TCP/UDP)
network layer (IP)
link layer (e.g. ethernet)
physical layer
application layer
transport layer (TCP/UDP)
network layer (IP)
link layer (e.g. ethernet)
physical layer
OS network
stack
Sockets as means for inter-process Sockets as means for inter-process communication (IPC)communication (IPC)
Process ProcessSocket
OS network
stack
Socket
Internet
Internet
Internet
25
Addressing serverAddressing serverAddress the machine on the network
◦ By IP address (127.0.0.1 – localhost)Address the process
◦ By the “port”-numberThe pair of IP-address + port – makes up
a “socket-address”
OS network
stack
Process#m
Port#m
Process#1
Port#1…
Host#1
OS network
stack
Process#k
Port#k
Process#1
Port#1…
Host#n
…
NetworkIP-address#1 IP-address#n
26
Socket typesSocket types Datagram socket – using
UDP◦ Not sequenced◦ Not reliable◦ Not unduplicated◦ Connectionless
Stream socket – using TCP◦ Sequenced◦ Reliable◦ Unduplicated◦ Connection-oriented
Raw and others (extracurricular)
27
Usage of port-numbersUsage of port-numbersStandard applications use predefined port-
numbers◦ 21 - ftp◦ 23 - telnet◦ 80 - http◦ 110 - pop3 (email)◦ …
Other applications should choose between 1024 and 65535◦ 4662 – eMule◦ …
28
Socket primitivesSocket primitives SOCKET create a new socket BIND attach a local address to a socket LISTEN announce a willingness to accept
connections ACCEPT Accept an incoming connection,
Create a socket and a child process for the client
CONNECT actively attempt to establish a connection
SEND send some data over the connection RECEIVE receive some data from the
connection CLOSE release the connection (the port)
29
Client+server: Client+server: connectionlessconnectionless
CREATE
BIND
SEND
SEND
CLOSE
RECEIVE
30
Client+server: connection-Client+server: connection-orientedoriented
SOCKETBIND
LISTEN
CONNECT
ACCEPT
RECEIVE
RECEIVE
SEND
SEND
CLOSE
TCP three-way handshake
31
Application Layer: SummaryApplication Layer: Summary
application service requirements:◦ reliability,
bandwidth, delayclient-server paradigm Internet transport
service model◦ connection-oriented,
reliable: TCP◦ unreliable,
datagrams: UDP
• specific protocols:– http– ftp– smtp, pop3– Dns– …
• sockets– client/server
implementation– using tcp, udp sockets