Infraestructura de Comunicaciones
Infraestructura de Comunicaciones
Infraestructura de Comunicaciones
Chapter 2
Application Layer
2: Application Layer 3
Chapter 2: Application Layer
Our goals: learn about protocols
conceptual, by examining popular
implementation application-level
aspects of network protocols
application protocols HTTP
transport-layer FTP
service models SMTP / POP3 / IMAP
DNS
client-server
paradigm programming network
peer-to-peer applications
paradigm socket API
2: Application Layer 4
Some network apps
e-mail voice over IP
web real-time video
instant messaging conferencing
remote login grid computing
P2P file sharing
multi-user network
games
streaming stored video
clips
2: Application Layer 5
Creating a network app application
transport
network
data link
2: Application Layer 7
Application architectures
Client-server
Peer-to-peer (P2P)
Hybrid of client-server and P2P
2: Application Layer 8
Client-server architecture
server:
always-on host
permanent IP address
server farms for
scaling
clients:
client/server communicate with server
may be intermittently
connected
may have dynamic IP
addresses
do not communicate
directly with each other
2: Application Layer 9
Pure P2P architecture
no always-on server
arbitrary end systems
directly communicate peer-peer
peers are intermittently
connected and change IP
addresses
2: Application Layer 10
Hybrid of client-server and P2P
Skype
voice-over-IP P2P application
centralized server: finding address of remote
party:
client-client connection: direct (not through
server)
Instant messaging
chatting between two users is P2P
centralized service: client presence
detection/location
• user registers its IP address with central
server when it comes online
• user contacts central server to find IP
addresses of buddies
2: Application Layer 11
Processes communicating
Process: program running Client process: process
within a host. that initiates
within same host, two communication
processes communicate Server process: process
using inter-process that waits to be
communication (defined contacted
by OS).
processes in different Note: applications with
hosts communicate by P2P architectures have
exchanging messages client processes &
server processes
2: Application Layer 12
Sockets
process sends/receives
host or host or
server server
messages to/from its
socket controlled by
app developer
socket analogous to door process process
2: Application Layer 14
Addressing processes
to receive messages, identifier includes both
process must have IP address and port
identifier numbers associated with
host device has unique process on host.
32-bit IP address Example port numbers:
Q: does IP address of HTTP server: 80
host on which process Mail server: 25
runs suffice for to send HTTP message
identifying the to gaia.cs.umass.edu web
process? server:
A: No, many IP address: 128.119.245.12
processes can be Port number: 80
running on same host more shortly…
2: Application Layer 15
App-layer protocol defines
Types of messages Public-domain protocols:
exchanged, defined in RFCs
e.g., request, response allows for
Message syntax: interoperability
what fields in messages & e.g., HTTP, SMTP
how fields are delineated
Proprietary protocols:
Message semantics
meaning of information in e.g., Skype
fields
Rules for when and how
processes send &
respond to messages
2: Application Layer 16
What transport service does an app need?
Data loss Throughput
some apps (e.g., audio) can some apps (e.g.,
tolerate some loss multimedia) require
other apps (e.g., file minimum amount of
transfer, telnet) require throughput to be
100% reliable data “effective”
transfer
other apps (“elastic apps”)
Timing make use of whatever
some apps (e.g., throughput they get
Internet telephony,
interactive games) Security
require low delay to be Encryption, data
“effective” integrity, …
2: Application Layer 17
Transport service requirements of common apps
2: Application Layer 18
Internet transport protocols services
Application Underlying
Application layer protocol transport protocol
2: Application Layer 20
TCP Traffic
2: Application Layer 21
UDP Traffic
2: Application Layer 22
Security Problems in TCP/UDP
Application
Application
SSL sublayer
TCP
SSL
TCP
TCP socket
IP IP
socket
TCP API TCP enhanced with SSL
2: Application Layer 24
Security Problems in TCP/UDP
2: Application Layer 25
Security Problems in TCP/UDP
Handshake:
client server
Connection
request
Connection
granted
ACK
time time
2: Application Layer 26
Security Problems in TCP/UDP
1. Handshake:
Bob establishes TCP
connection to Alice
authenticates Alice
via CA signed
certificate
creates, encrypts
(using Alice’s public
key), sends master create
secret key to Alice Master
nonce exchange not Secret decrypt using KA-
shown (MS) to get MS
2: Application Layer 27
Security Problems in TCP/UDP
2. Key Derivation:
Alice, Bob use shared secret (MS) to generate 4
keys:
EB: Bob->Alice data encryption key
EA: Alice->Bob data encryption key
MB: Bob->Alice MAC key
MA: Alice->Bob MAC key
encryption and MAC algorithms negotiable between
Bob, Alice
2: Application Layer 28
Security Problems in TCP/UDP
3. Data transfer
TCP byte stream b1b2b3 … bn
d H(d)
EB
.
H( ) SSL
encrypt d,
MAC, SSL
seq. #
seq. #
d H(d)
SSL record
format Type Ver Len d H(d)
2: Application Layer 29
Security Problems in TCP/UDP
2: Application Layer 30
Chapter 2: Application layer
2.1 Principles of 2.6 P2P applications
network applications Convergencia de
app architectures Servicios
app requirements
Caracterización del
2.2 Web and HTTP Tráfico de una Red
2.4 Electronic Mail 2.7 Socket programming
SMTP, POP3, IMAP with TCP
2.5 DNS 2.8 Socket programming
with UDP
2: Application Layer 31
Web and HTTP
First some jargon
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
Example URL:
www.someschool.edu/someDept/pic.gif
2: Application Layer 32
HTTP overview
HTTP: hypertext
transfer protocol
Web’s application layer PC running
protocol Explorer
client/server model
client: browser that
requests, receives, Server
“displays” Web objects running
Apache Web
server: Web server server
sends objects in
response to requests
Mac running
Navigator
2: Application Layer 33
HTTP overview (continued)
Uses TCP: HTTP is “stateless”
client initiates TCP server maintains no
connection (creates socket) information about
to server, port 80 past client requests
server accepts TCP
connection from client aside
Protocols that maintain
HTTP messages (application- “state” are complex!
layer protocol messages) past history (state) must
exchanged between browser be maintained
(HTTP client) and Web
if server/client crashes,
server (HTTP server)
their views of “state” may
TCP connection closed be inconsistent, must be
reconciled
2: Application Layer 34
HTTP connections
Nonpersistent HTTP Persistent HTTP
At most one object is Multiple objects can
sent over a TCP be sent over single
connection. TCP connection
between client and
server.
2: Application Layer 35
Nonpersistent HTTP
(contains text,
Suppose user enters URL references to 10
www.someSchool.edu/someDepartment/home.index jpeg images)
time
2: Application Layer 36
Nonpersistent HTTP (cont.)
2: Application Layer 37
Non-Persistent HTTP: Response time
Definition of RTT: time for
a small packet to travel
from client to server
and back. initiate TCP
connection
Response time: RTT
one RTT to initiate TCP request
file
connection time to
RTT
transmit
one RTT for HTTP file
request and first few file
received
bytes of HTTP response
to return time time
file transmission time
total = 2RTT+transmit time
2: Application Layer 38
Persistent HTTP
2: Application Layer 39
Persistent HTTP
HTTP request message
request line
(GET, POST, GET /somedir/page.html HTTP/1.1
HEAD commands) Host: www.someschool.edu
User-agent: Mozilla/4.0
header Connection: close
lines Accept-language:fr
Carriage return,
line feed (extra carriage return, line feed)
indicates end
of message
2: Application Layer 41
HTTP request message: general format
2: Application Layer 42
HTTP request message: general format
Uploading form input
Post method:
Web page often
includes form input URL method:
Input is uploaded to Uses GET method
server in entity body Input is uploaded in
URL field of request
line:
www.somesite.com/animalsearch?monkeys&banana
2: Application Layer 44
Method types
HTTP/1.0 HTTP/1.1
GET GET, POST, HEAD
POST PUT
HEAD uploads file in entity
body to path specified
asks server to leave
in URL field
requested object out of
response DELETE
deletes file specified in
the URL field
2: Application Layer 45
HTTP response message
status line
(protocol
status code HTTP/1.1 200 OK
status phrase) Connection close
Date: Thu, 06 Aug 1998 12:00:15 GMT
Server: Apache/1.3.0 (Unix)
header
Last-Modified: Mon, 22 Jun 1998 …...
lines
Content-Length: 6821
Content-Type: text/html
2: Application Layer 46
HTTP response status codes
In first line in server->client response message.
A few sample codes:
200 OK
request succeeded, requested object later in this message
301 Moved Permanently
requested object moved, new location specified later in
this message (Location:)
400 Bad Request
request message not understood by server
404 Not Found
requested document not found on this server
505 HTTP Version Not Supported
2: Application Layer 47
Trying out HTTP (client side) for yourself
2: Application Layer 48
User-server state: cookies
Example:
Many major Web sites
use cookies Susan always access
Four components: Internet always from PC
1) cookie header line of visits specific e-
HTTP response message commerce site for first
2) cookie header line in time
HTTP request message
3) cookie file kept on when initial HTTP
user’s host, managed by requests arrives at site,
user’s browser
site creates:
4) back-end database at
Web site unique ID
entry in backend
database for ID
2: Application Layer 49
Cookies: keeping “state” (cont.)
client server
ebay 8734
usual http request msg
Amazon server
cookie file usual http response creates ID
Set-cookie: 1678 1678 for user create
ebay 8734 entry
amazon 1678
usual http request msg
cookie: 1678 cookie- access
specific
one week later: usual http response msg action backend
database
access
ebay 8734 usual http request msg
amazon 1678 cookie: 1678 cookie-
spectific
usual http response msg action
2: Application Layer 50
Cookies (continued)
aside
What cookies can bring: Cookies and privacy:
authorization cookies permit sites to
shopping carts learn a lot about you
recommendations you may supply name
and e-mail to sites
user session state
(Web e-mail)
How to keep “state”:
protocol endpoints: maintain state
at sender/receiver over multiple
transactions
cookies: http messages carry state
2: Application Layer 51
Cookies (continued)
Web caches (proxy server)
Goal: satisfy client request without involving origin server
institutional
cache
2: Application Layer 56
Caching example (cont)
origin
possible solution: install servers
cache public
suppose hit rate is 0.4 Internet
consequence
40% requests will be
satisfied almost immediately
1.5 Mbps
60% requests satisfied by access link
origin server
utilization of access link institutional
reduced to 60%, resulting in network
10 Mbps LAN
negligible delays (say 10
msec)
total avg delay = Internet
delay + access delay + LAN institutional
delay = .6*(2.01) secs +
.4*milliseconds < 1.4 secs cache
2: Application Layer 57
Conditional GET
Total
6,920
2: Application Layer 59
Capacity Planning in Web Traffic
Relative Network Interface Speed
2: Application Layer 73
FTP: the file transfer protocol
2: Application Layer 76
Capacity Planning in FTP Traffic
2: Application Layer 77
Security Problems in FTP Traffic
2: Application Layer 78
Security Problems in FTP Traffic
Security Problems in FTP Traffic
Application
SSL sublayer
SSL
TCP
IP
socket
TCP enhanced with SSL
Chapter 2: Application layer
2.1 Principles of 2.6 P2P applications
network applications Convergencia de
2.2 Web and HTTP Servicios
2.3 FTP Caracterización del
2.4 Electronic Mail Tráfico de una Red
SMTP, POP3, IMAP 2.7 Socket programming
2.5 DNS with TCP
2.8 Socket programming
with UDP
2: Application Layer 81
Electronic Mail outgoing
message queue
user mailbox
user
Three major components: agent
user agents mail
user
server
mail servers agent
simple mail transfer SMTP mail
protocol: SMTP server user
SMTP agent
User Agent
“mail reader” SMTP
mail user
composing, editing, reading agent
server
mail messages
e.g., Eudora, Outlook, elm, user
Mozilla Thunderbird agent
user
outgoing, incoming messages agent
stored on server
2: Application Layer 82
Electronic Mail: mail servers
user
Mail Servers agent
mailbox contains incoming mail
user
messages for user server
agent
message queue of outgoing
SMTP
(to be sent) mail messages mail
server user
SMTP protocol between mail
servers to send email SMTP agent
messages SMTP
client: sending mail mail user
agent
server server
“server”: receiving mail
user
server agent
user
agent
2: Application Layer 83
Electronic Mail: SMTP [RFC 2821]
2: Application Layer 84
Scenario: Alice sends message to Bob
1) Alice uses UA to compose 4) SMTP client sends Alice’s
message and “to” message over the TCP
[email protected] connection
2) Alice’s UA sends message 5) Bob’s mail server places the
to her mail server; message message in Bob’s mailbox
placed in message queue 6) Bob invokes his user agent
3) Client side of SMTP opens to read message
TCP connection with Bob’s
mail server
1 mail
mail
server user
user server
2 agent
agent 3 6
4 5
2: Application Layer 85
Sample SMTP interaction
S: 220 hamburger.edu
C: HELO crepes.fr
S: 250 Hello crepes.fr, pleased to meet you
C: MAIL FROM: <[email protected]>
S: 250 [email protected]... Sender ok
C: RCPT TO: <[email protected]>
S: 250 [email protected] ... Recipient ok
C: DATA
S: 354 Enter mail, end with "." on a line by itself
C: Do you like ketchup?
C: How about pickles?
C: .
S: 250 Message accepted for delivery
C: QUIT
S: 221 hamburger.edu closing connection
2: Application Layer 86
Try SMTP interaction for yourself:
telnet servername 25
see 220 reply from server
enter HELO, MAIL FROM, RCPT TO, DATA, QUIT
commands
above lets you send email without using email client
(reader)
2: Application Layer 87
SMTP: final words
SMTP uses persistent Comparison with HTTP:
connections
HTTP: pull
SMTP requires message
(header & body) to be in 7- SMTP: push
bit ASCII both have ASCII
SMTP server uses command/response
CRLF.CRLF to determine interaction, status codes
end of message
HTTP: each object
encapsulated in its own
response msg
SMTP: multiple objects
sent in multipart msg
2: Application Layer 88
Mail message format
2: Application Layer 89
Mail access protocols
SMTP SMTP access user
user
agent protocol agent
2: Application Layer 92
Capacity Planning in email
2: Application Layer 93
Security in email
2: Application Layer 94
Security in email
2: Application Layer 95
Security in email
2: Application Layer 96
Security in email
2: Application Layer 97
Security in email
• Alice wants to provide secrecy, sender authentication,
message integrity.
-
KA
m .
H( )
-
KA( ). -
KA(H(m))
KS
+ KS( ).
m + Internet
KS
+ .
K B( ) +
KB(KS )
+
KB
2: Application Layer 99
DNS: Domain Name System
13 root name
servers worldwide
b USC-ISI Marina del Rey, CA
l ICANN Los Angeles, CA
resolution example
2
Host at cis.poly.edu 3
TLD DNS server
wants IP address for 4
gaia.cs.umass.edu 5
gaia.cs.umass.edu
recursive query: 2 3
puts burden of name 6
7
resolution on
TLD DNS server
contacted name
server
heavy load? local DNS server
dns.poly.edu 5 4
1 8
gaia.cs.umass.edu
Type=A Type=CNAME
name is hostname name is alias name for some
value is IP address “canonical” (the real) name
www.ibm.com is really
Type=NS
servereast.backup2.ibm.com
name is domain (e.g.
value is canonical name
foo.com)
value is hostname of Type=MX
authoritative name
value is name of mailserver
server for this domain
associated with name
msg header
identification: 16 bit #
for query, reply to query
uses same #
flags:
query or reply
recursion desired
recursion available
reply is authoritative
RRs in response
to query
records for
authoritative servers
additional “helpful”
info that may be used
Three topics:
File distribution
Searching for information
Case Study: Skype
Time to distribute F
to N clients using = dcs = max { NF/us, F/min(di) }
i
client/server approach
increases linearly in N
(for large N) 2: Application Layer 120
File distribution time: P2P
Server
server must send one F u1 d1 u2
copy: F/us time us d2
downloaded (aggregate)
fastest possible upload rate: us + Sui
3.5
P2P
Minimum Distribution Time
3
Client-Server
2.5
1.5
0.5
0
0 5 10 15 20 25 30 35
N
2: Application Layer 122
File distribution: BitTorrent
P2P file distribution
tracker: tracks peers torrent: group of
participating in torrent peers exchanging
chunks of a file
obtain list
of peers
trading
chunks
peer
SGSN Intranet
GGSN
Convergencia de Servicios
GSM
Convergencia de Servicios
UMTS
Convergencia de Servicios
Convergencia de Servicios
Convergencia de Servicios
Convergencia de Servicios
Arquitectura NGN/NGMN
Convergencia de Servicios
Arquitectura NGN/NGMN
Convergencia de Servicios
Convergencia de Servicios
Convergencia de Servicios
VoIP
Convergencia de Servicios
Convergencia de Servicios
IPTV
Convergencia de Servicios
IPTV
Convergencia de Servicios
EPC
Chapter 2: Application layer
2.1 Principles of 2.6 P2P applications
network applications Convergencia de
2.2 Web and HTTP Servicios
2.3 FTP Caracterización del
2.4 Electronic Mail Tráfico de una Red
SMTP, POP3, IMAP 2.7 Socket programming
2.5 DNS with TCP
2.8 Socket programming
with UDP
Destino 1 Destino 2
Origen 1
Origen 2
controlled by
controlled by process application
application process
developer
developer socket socket
TCP with TCP with controlled by
controlled by
buffers, operating
operating buffers, internet system
system variables variables
host or host or
server server
write reply to
connectionSocket read reply from
clientSocket
close
connectionSocket close
clientSocket
2: Application Layer 169
Stream jargon
keyboard monitor
A stream is a sequence of
characters that flow into
inFromUser
or out of a process. input
stream
inFromServer
outToServer
source, e.g., monitor or
output input
stream stream
socket.
client TCP
clientSocket
socket TCP
socket
sentence = inFromUser.readLine();
Send line
to server outToServer.writeBytes(sentence + '\n');
clientSocket.close();
}
}
2: Application Layer 173
Example: Java server (TCP)
import java.io.*;
import java.net.*;
class TCPServer {
Create output
stream, attached DataOutputStream outToClient =
to socket new DataOutputStream(connectionSocket.getOutputStream());
Read in line
from socket clientSentence = inFromClient.readLine();
write reply to
serverSocket
specifying read datagram from
client address, clientSocket
port number close
clientSocket
inFromUser
input
stream
Client
Process
Input: receives
process
packet (recall
Output: sends thatTCP received
packet (recall “byte stream”)
receivePacket
sendPacket
that TCP sent UDP
packet
UDP
packet
“byte stream”)
client UDP
clientSocket
socket UDP
socket
class UDPClient {
public static void main(String args[]) throws Exception
{
Create
input stream BufferedReader inFromUser =
new BufferedReader(new InputStreamReader(System.in));
Create
client socket DatagramSocket clientSocket = new DatagramSocket();
Translate
InetAddress IPAddress = InetAddress.getByName("hostname");
hostname to IP
address using DNS byte[] sendData = new byte[1024];
byte[] receiveData = new byte[1024];
class UDPServer {
public static void main(String args[]) throws Exception
Create {
datagram socket
DatagramSocket serverSocket = new DatagramSocket(9876);
at port 9876
byte[] receiveData = new byte[1024];
byte[] sendData = new byte[1024];
while(true)
{
Create space for
DatagramPacket receivePacket =
received datagram
new DatagramPacket(receiveData, receiveData.length);
Receive serverSocket.receive(receivePacket);
datagram
2: Application Layer 182
Example: Java server (UDP), cont
String sentence = new String(receivePacket.getData());
Get IP addr
InetAddress IPAddress = receivePacket.getAddress();
port #, of
sender int port = receivePacket.getPort();
sendData = capitalizedSentence.getBytes();
Create datagram
DatagramPacket sendPacket =
to send to client new DatagramPacket(sendData, sendData.length, IPAddress,
port);
Write out
datagram serverSocket.send(sendPacket);
to socket }
}
} End of while loop,
loop back and wait for
another datagram
2: Application Layer 183
Chapter 2: Summary
our study of network apps now complete!
application architectures specific protocols:
client-server HTTP
P2P FTP
hybrid SMTP, POP, IMAP
DNS
application service
P2P: BitTorrent, Skype
requirements:
reliability, bandwidth, socket programming
delay
Internet transport
service model
connection-oriented,
reliable: TCP
unreliable, datagrams: UDP
2: Application Layer 184