Application Layer: Computer Networking: A Top Down Approach
Application Layer: Computer Networking: A Top Down Approach
Application Layer
Computer
They obviously represent a lot of work on our part. In return for use, we only
ask the following:
§ If you use these slides (e.g., in a class) that you mention their source
(after all, we’d like people to use our book!) Networking: A Top
§ If you post any slides on a www site, that you note that they are adapted
from (or perhaps identical to) our slides, and note our copyright of this Down Approach
material.
7th edition
Thanks and enjoy! JFK/KWR Jim Kurose, Keith Ross
Pearson/Addison Wesley
All material copyright 1996-2016
April 2016
J.F Kurose and K.W. Ross, All Rights Reserved
Application Layer 2-1
Chapter 2: outline
2.1 principles of network 2.5 P2P applications
applications 2.6 video streaming and
2.2 Web and HTTP content distribution
2.3 electronic mail networks
• SMTP, POP3, IMAP 2.7 socket programming
2.4 DNS with UDP and TCP
… …
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
type=NS § www.ibm.com is really
• name is domain (e.g., servereast.backup2.ibm.com
foo.com) § value is canonical name
• value is hostname of
authoritative name type=MX
server for this domain § value is name of mailserver
associated with name
2 bytes 2 bytes
identification flags
time to distribute F
to N clients using Dc-s > max{NF/us,,F/dmin}
client-server approach
increases linearly in N
Application Layer 2-20
File distribution time: P2P
§ server transmission: must
upload at least one copy F
us
• time to send one copy: F/us
di
§ client: each client must network
download file copy ui
• min client download time: F/dmin
§ clients: as aggregate must download NF bits
• max upload rate (limiting max download rate) is us + Sui
time to distribute F
to N clients using DP2P > max{F/us,,F/dmin,,NF/(us + Sui)}
P2P approach
increases linearly in N …
… but so does this, as each peer brings service capacity
Application Layer 2-21
Client-server vs. P2P: example
client upload rate = u, F/u = 1 hour, us = 10u, dmin ≥ us
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
Application Layer 2-22
Chapter 2: outline
2.1 principles of network 2.5 P2P applications
applications 2.6 video streaming and
2.2 Web and HTTP content distribution
2.3 electronic mail networks
• SMTP, POP3, IMAP 2.7 socket programming
2.4 DNS with UDP and TCP
application application
socket controlled by
process process app developer
transport transport
network network controlled
link by OS
link Internet
physical physical
Application Example:
1. client reads a line of characters (data) from its
keyboard and sends data to server
2. server receives the data and converts characters
to uppercase
3. server sends modified data to client
4. client receives modified data and displays line on
its screen
Application Layer 2-25
Socket programming with UDP
UDP: no “connection” between client & server
§ no handshaking before sending data
§ sender explicitly attaches IP destination address and
port # to each packet
§ receiver extracts sender IP address and port# from
received packet
UDP: transmitted data may be lost or received
out-of-order
Application viewpoint:
§ UDP provides unreliable transfer of groups of bytes
(“datagrams”) between client and server
write reply to
serverSocket read datagram from
specifying clientSocket
client address,
port number close
clientSocket
Application 2-27
Example app: UDP client
Python UDPClient
include Python’s socket
library
from socket import *
serverName = ‘hostname’
serverPort = 12000
create UDP socket for clientSocket = socket(AF_INET,
server
SOCK_DGRAM)
get user keyboard
input message = raw_input(’Input lowercase sentence:’)
Attach server name, port to clientSocket.sendto(message.encode(),
message; send into socket
(serverName, serverPort))
read reply characters from modifiedMessage, serverAddress =
socket into string
clientSocket.recvfrom(2048)
print out received string print modifiedMessage.decode()
and close socket
clientSocket.close()
Application Layer 2-28
Example app: UDP server
Python UDPServer
from socket import *
serverPort = 12000
create UDP socket serverSocket = socket(AF_INET, SOCK_DGRAM)
bind socket to local port
number 12000
serverSocket.bind(('', serverPort))
print (“The server is ready to receive”)
loop forever while True:
Read from UDP socket into message, clientAddress = serverSocket.recvfrom(2048)
message, getting client’s
address (client IP and port) modifiedMessage = message.decode().upper()
send upper case string serverSocket.sendto(modifiedMessage.encode(),
back to this client
clientAddress)
write reply to
connectionSocket read reply from
clientSocket
close
connectionSocket close
clientSocket
sentence = connectionSocket.recv(1024).decode()
read bytes from socket (but
not address as in UDP) capitalizedSentence = sentence.upper()
close connection to this connectionSocket.send(capitalizedSentence.
client (but not welcoming
socket) encode())
connectionSocket.close()
Application Layer 2-33
Chapter 2: summary
our study of network apps now complete!
§ application architectures § specific protocols:
• client-server • HTTP
• P2P • SMTP, POP, IMAP
§ application service
requirements: • DNS
• reliability, bandwidth, delay • P2P: BitTorrent
§ Internet transport service § video streaming, CDNs
model § socket programming:
• connection-oriented,
TCP, UDP sockets
reliable: TCP
• unreliable, datagrams: UDP