csci5211: Computer Networks and Data Communications
Download
Report
Transcript csci5211: Computer Networks and Data Communications
Internet Engineering Course
Application Layer Protocols
Applications and application-layer protocols
Application: communicating, distributed
processes
◦ running in network hosts in “user
space”
◦ exchange messages
◦ e.g., email, file transfer, the Web
Application-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
application
transport
network
data link
physical
application
transport
network
data link
physical
application
transport
network
data link
physical
2
Client-server paradigm
Typical network app has two
pieces: client and server
Client:
r initiates contact with server
(“speaks first”)
r typically requests service from
server,
r for Web, client is implemented
in browser; for e-mail, in mail
reader
Server:
r provides requested service to
client
r e.g., Web server sends
requested Web page, mail
server delivers e-mail
application
transport
network
data link
physical
request
reply
application
transport
network
data link
physical
3
Auxiliary terms ++
Q: how does a process
socket: Internet application
“identify” the other
programming interface
process with which it
◦ 2 processes communicate by
wants to communicate?
sending data into socket,
reading data out of socket
(like sending out, receiving in
via doors)
◦ IP address of host running
other process
◦ “port number” - allows
receiving host to determine
to which local process the
message should be delivered
4
Properties of transport service of interest to 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
r
r
r
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
5
Transport service requirements of common apps
Application
file transfer
e-mail
Web documents
real-time audio/
video
stored audio/video
interactive games
financial apps
Data loss
Bandwidth
Time Sensitive
no loss
no loss
No-loss
loss-tolerant
elastic
elastic
elastic
audio: 5Kb-1Mb
video:10Kb-5Mb
same as above
few Kbps up
elastic
no
no
no
yes, 100’s msec
loss-tolerant
loss-tolerant
no loss
yes, few secs
yes, 100’s msec
yes and no
6
Internet apps: their protocols
Application
e-mail
remote terminal access
Web
file transfer
streaming multimedia
remote file server
Internet telephony
nslookup and many
others
Application
layer protocol
Underlying
transport protocol
» smtp [RFC 821]
» telnet [RFC 854]
» http [RFC 2068]
» ftp [RFC 959]
proprietary
(e.g. RealNetworks)
NSF
SIP, RTP, proprietary
(e.g., Skype)
» DNS
TCP
TCP
TCP
TCP
TCP or UDP
TCP or UDP
typically UDP, TCP
also possible
UDP
[RFC 882, 883,1034,1035]
7
The TELNET Protocol
TCP connection
data and control over the same
connection.
Network Virtual Terminal
negotiated options
8
Network Virtual Terminal
intermediate representation of a generic
terminal.
provides a standard language for
communication of terminal control
functions.
9
Network Virtual Terminal
Server
Process
NVT
NVT
TCP
TCP
10
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).
11
Option examples
Line mode vs. character mode
echo modes
character set (EBCDIC vs. ASCII)
12
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.
13
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.
14
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.
15
Command Structure
All 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.
16
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.
17
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).
18
Some TCP Servers you can play
with
Many Unix systems have these servers
running (by default):
◦
◦
◦
◦
echo
discard
daytime
chargen
port 7
port 9
port 13
port 19
19
telnet hostname port
> telnet rcs.rpi.edu 7
Trying 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.
20
ftp: the file transfer protocol
user
at host
file transfer
FTP
FTP
user
client
interface
local file
system
FTP
server
remote file
system
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
21
ftp: separate control, data connections
ftp client contacts ftp server at
port 21, specifying TCP as
transport protocol
two parallel TCP connections
opened:
◦ control: exchange commands,
FTP
responses between client,
client
server.
◦ data: file data to/from server
ftp server maintains “state”:
current directory, earlier
authentication
TCP control connection
port 21
TCP data connection
port 20
FTP
server
22
ftp commands, responses
Sample commands:
Sample return codes
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
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
23
Sockets as means for inter-process communication (IPC)
application layer
application layer
Process
Internet
Socket
transport
layer (TCP/UDP)
OS network
network layer (IP)
stack
Socket
Internet
transport
(TCP/UDP)
OS layer
network
network layer (IP)
stack
link layer (e.g. ethernet)
link layer (e.g. ethernet)
physical layer
Process
Internet
physical layer
24
Addressing server
Address the machine on the network
◦ By IP address (127.0.0.1 – localhost)
Address the process
◦ By the “port”-number
The pair of IP-address + port – makes up a “socketaddress”
Host#1
Process#1
Port#1
…
Host#n
Process#m
Process#1
Port#m
Port#1
OS network
stack
…
IP-address#1
…
Process#k
Port#k
OS network
stack
IP-address#n
Network
25
Socket types
Datagram socket – using UDP
◦
◦
◦
◦
Stream socket – using TCP
◦
◦
◦
◦
Not sequenced
Not reliable
Not unduplicated
Connectionless
Sequenced
Reliable
Unduplicated
Connection-oriented
Raw and others
(extracurricular)
26
Usage of port-numbers
Standard applications use predefined port-numbers
◦
◦
◦
◦
◦
21 - ftp
23 - telnet
80 - http
110 - pop3 (email)
…
Other applications should choose between 1024 and
65535
◦ 4662 – eMule
◦ …
27
Socket primitives
SOCKET
BIND
LISTEN
ACCEPT
CONNECT
SEND
RECEIVE
CLOSE
create a new socket
attach a local address to a socket
announce a willingness to accept
connections
Accept an incoming connection, Create a
socket and a child process for the client
actively attempt to establish a connection
send some data over the connection
receive some data from the connection
release the connection (the port)
28
Client+server: connectionless
CREATE
BIND
SEND
RECEIVE
SEND
CLOSE
29
Client+server: connection-oriented
BIND
SOCKET
LISTEN
CONNECT
ACCEPT
TCP three-way
handshake
SEND
RECEIVE
SEND
RECEIVE
CLOSE
30
Application Layer: Summary
application service
requirements:
◦ reliability, bandwidth,
delay
client-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
31