Chapter - 2 CN
Chapter - 2 CN
Application
Layer
•FTP (File Transfer Protocol): Facilitates the transfer of files between a client and server, allowing users
to upload or download files securely across networks.
•SMTP (Simple Mail Transfer Protocol): Responsible for sending emails from client to
server and between
email servers, ensuring email delivery across different networks.
•DNS (Domain Name System): Translates domain names into IP addresses, allowing users
to access websites by name rather than IP, simplifying internet navigation.
communicate
peers request service from other
peers, provide service in return to
other peers local or
regional ISP
• self scalability – new peers bring new
service capacity, and new service demands home network content
peers are intermittently connected provider
network datacenter
network
and change IP addresses
• complex management
examples: P2P file sharing (BitTorrent), enterprise
network
streaming (KanKan), VoIP (Skype)
Application Layer: 2-28
File distribution: client-server vs P2P
Q: how much time to distribute file (size F) from one server to
N peers?
• peer upload/download capacity is limited resource
us: server upload
capacity
di: peer i download
file, size F u1 d1 u2 capacity
us d2
server
di
uN network (with abundant
bandwidth) ui
dN
ui: peer i upload
capacity
Introduction: 1-29
File distribution time: client-server
server transmission: must sequentially
send (upload) N file copies:
F
• time to send one copy: F/us us
time to distribute F
to N clients using
P2P approach
DP2P > max{F/us,,F/dmin,,NF/(us + Sui)}
increases linearly in N …
… but so does this, as each peer brings service capacity Application Layer: 2-31
Client-server vs. P2P: example
client upload rate = u, F/u = 1 hour, us = 10u, dmin ≥ us
3.5
P2P
1.5
0.5
0
0 5 10 15 20 25 30 35
N
Application Layer: 2-32
P2P file distribution: BitTorrent
file divided into 256Kb chunks
peers in torrent send/receive file chunks
tracker: tracks peers torrent: group of peers
participating in torrent exchanging chunks of a file
Alice arrives …
… obtains list
of peers from tracker
… and begins exchanging
file chunks with peers in torrent
Internet
video server
client
(stored video)
Main challenges:
server-to-client bandwidth will vary over time, with changing network
congestion levels (in house, access network, network core, video server)
packet loss, delay due to congestion will delay playout, or result in poor
video quality
Application Layer: 2-41
Streaming stored video
Cumulative data
2. video
sent
1. video 3. video received, played out at client
recorded (30 frames/sec)
(e.g., 30 time
network delay
frames/sec) (fixed in this
example)
streaming: at this time, client playing out
early part of video, while server still sending
later part of video
Application Layer: 2-42
Streaming stored video: challenges
continuous playout constraint: during client
video playout, playout timing must match
original timing
• … but network delays are variable (jitter), so will
need client-side buffer to match continuous playout
constraint
other challenges:
• client interactivity: pause, fast-forward, rewind,
jump through video
• video packets may be lost, retransmitted
Application Layer: 2-43
Streaming stored video: playout buffering
constant bit
Cumulative data rate video client video constant bit
transmission reception rate video
playout at client
variable
network
buffered
video
delay
client:
periodically estimates server-to-client bandwidth
consulting manifest, requests one chunk at a time
• chooses maximum coding rate sustainable given current bandwidth
• can choose different coding rates at different points in time (depending
on available bandwidth at time), and from different servers
Application Layer: 2-45
Streaming multimedia: DASH
“intelligence” at client: client
determines ...
• when to request chunk (so that buffer ...
Source: https://networkingchannel.eu/living-on-the-edge-for-a-quarter-century-an-akamai-retrospective-downloads/
… …
…
manifest file
…
where’s Madmen?
… …
Application Layer: 2-50
Content distribution networks (CDNs)
… …
Internet host-host communication as a service
…
…
transport transport
network network controlled
link
by OS
link Internet
physical physical
write reply to
serverSocket read datagram from
specifying clientSocket
client address,
port number close
clientSocket
Application Layer: 2-56
Example app: UDP client
Python UDPClient
include Python’s socket library from socket import *
serverName = 'hostname'
serverPort = 12000
create UDP socket clientSocket = socket(AF_INET,
SOCK_DGRAM)
get user keyboard input message = input('Input lowercase sentence:')
attach server name, port to message; send into socket clientSocket.sendto(message.encode(),
(serverName, serverPort))
read reply data (bytes) from socket modifiedMessage, serverAddress =
clientSocket.recvfrom(2048)
print out received string and close socket print(modifiedMessage.decode())
clientSocket.close()
write reply to
connectionSocket read reply from
clientSocket
close
connectionSocket close
clientSocket
Application Layer: 2-60
Example app: TCP client
Python TCPClient
from socket import *
serverName = 'servername'
serverPort = 12000
create TCP socket for server, clientSocket = socket(AF_INET, SOCK_STREAM)
remote port 12000
clientSocket.connect((serverName,serverPort))
sentence = input('Input lowercase sentence:')
clientSocket.send(sentence.encode())
No need to attach server name, port modifiedSentence = clientSocket.recv(1024)
print ('From Server:', modifiedSentence.decode())
clientSocket.close()
sometimes a program must wait for one of several events to happen, e.g.,:
wait for either (i) a reply from another end of the socket, or (ii) timeout: timer
wait for replies from several different open sockets: select(), multithreading
timeouts are used extensively in networking
using timeouts with Python socket:
receive a message
socket() connect() send() settimeout() recv() …
timeout
handle
timeout
…
Application Layer: 2-66
How Python socket.settimeout() works?
netcinema’s
authoratative DNS KingCDN.com KingCDN
authoritative DNS
Application Layer: 2-71
Case study: Netflix
Amazon cloud upload copies of
multiple versions of
video to CDN servers
CDN
server
Netflix registration,
accounting servers
Bob browses
Netflix video CDN
2 Manifest file, server
requested
1 3 returned for
Bob manages specific video
Netflix account
CDN
4 server
DASH server
selected, contacted,
streaming begins
Application Layer: 2-72