Download as pdf or txt
Download as pdf or txt
You are on page 1of 21

CS F303

(Computer Networks)
Vishal Gupta
Department of Computer Science and Information Systems
BITS Pilani Birla Institute of Technology and Science
Pilani|Dubai|Goa|Hyderabad
Pilani Campus, Pilani
DNS review
• What is the difference between Recursive Query and Iterative Query ?

COMPUTER NETWORKS 2 BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956
DNS name root DNS server
resolution example
2
• host at cis.poly.edu 3
TLD DNS server
wants IP address for 4
gaia.cs.umass.edu 5

iterated query: local DNS server


dns.poly.edu
 contacted server 7 6
1 8
replies with name of
server to contact
authoritative DNS server
 “I don’t know this dns.cs.umass.edu
name, but ask this requesting host
server” cis.poly.edu

gaia.cs.umass.edu

Application Layer 2-3


DNS name root DNS server
resolution example
2 3
recursive query: 7
6
 puts burden of name TLD DNS
server
resolution on
contacted name local DNS server
server dns.poly.edu 5 4

 heavy load at upper 1 8


levels of hierarchy?
authoritative DNS server
dns.cs.umass.edu
requesting host
cis.poly.edu

gaia.cs.umass.edu

Application Layer 2-4


BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956
DNS review
Suppose within your web browser you click on a link to obtain a web page. The IP
address of the associated URL is not cached in your local host, so a DNS look up is
necessary to obtain the IP address. Suppose that n DNS servers are visited before
your host receives the IP address from DNS; the successive visits incur an RTT of
RTT1 …. RTTn. Further suppose that the web page associated with the link contains
exactly one object, consisting of a small amount of HTML text. Let RTT0 denote the
RTT between the local host and the server containing the object. Assuming zero
transmission time of the object,
a) how much time elapses from when the client clicks on the link until the client
receives the object ?
suppose the HTML file references three very small objects on the same server.
Neglecting transmission times, how much time elapses with:
1) Non persistent HTTP with no parallel TCP connections ?
2) Non persistent HTTP with three parallel TCP connections ?
3) Persistent HTTP with pipelining ?

COMPUTER NETWORKS 5 BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956
Problem
Consider the scenario shown in
which a server is connected to a
router by a 100Mbps link with a
50ms propagation delay. Initially this
router is also connected to two
routers, each over a 25Mbps link
with a 200ms propagation delay. A
1Gbps link connects a host and a
cache (if present) to each of these
routers and we assume that this link
has 0 propagation delay. All packets
in the network are 20,000 bits long.

VISHAL GUPTA, PhD 6 BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956
Problem
What is the end-‐to-‐end delay from
when a packet is transmitted by the
server to when it is received by the
client? In this case, we assume there
are no caches, there’s no queuing
delay at the routers, and the packet
processing delays at routers and
nodes are all 0.

VISHAL GUPTA, PhD 7 BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956
Problem
Here we assume that client hosts
send requests for files directly to the
server (caches are not used or off in
this case). What is the maximum
rate at which the server can deliver
data to a single client if we assume
no other clients are making
requests?

VISHAL GUPTA, PhD 8 BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956
Problem
Again we assume only one active
client but in this case the caches are
on and behave like HTTP caches. A
client’s HTTP GET is always first
directed to its local cache. 60% of
the requests can be satisfied by the
local cache. What is the average rate
at which the client can receive data
in this case?

VISHAL GUPTA, PhD 9 BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956
Problem
What is the average end-‐to-‐end
delay for the case that 60% of the
requests can be satisfied by the
local cache?

VISHAL GUPTA, PhD 10 BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956
Socket programming
goal: learn how to build client/server applications that
communicate using sockets
socket: door between application process and end-end-
transport protocol

application application
socket controlled by
process process app developer

transport transport
network network controlled
link by OS
link Internet
physical physical

Application Layer 2-11 BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956
Socket programming
Two socket types for two transport services:
– UDP: unreliable datagram

– TCP: reliable, byte stream-oriented

Application Example:
1. Client reads a line of characters (data) from its
keyboard and sends the data to the server.
2. The server receives the data and converts
characters to uppercase.
3. The server sends the modified data to the client.
4. The client receives the modified data and displays
the line on its screen.
Application Layer 2-12 BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956
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
• rcvr 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

Application Layer 2-13


Client/server socket interaction: UDP

server (running on serverIP) client


create socket:
create socket, port= x: clientSocket =
serverSocket = socket(AF_INET,SOCK_DGRAM)
socket(AF_INET,SOCK_DGRAM)
Create datagram with server IP and
port=x; send datagram via
read datagram from clientSocket
serverSocket

write reply to
serverSocket read datagram from
specifying clientSocket
client address,
port number close
clientSocket

Application
BITS Pilani, Deemed to be University under Section 3 of UGC Act,2-14
1956
Example app: UDP client
Python UDPClient
include Python’s socket
library
from socket import *
serverName = ‘hostname’
serverPort = 12000
create UDP socket for clientSocket = socket(socket.AF_INET,
server

get user keyboard


socket.SOCK_DGRAM)
input message = raw_input(’Input lowercase sentence:’)
Attach server name, port to
message; send into socket clientSocket.sendto(message,(serverName, serverPort))
read reply characters from modifiedMessage, serverAddress =
socket into string
clientSocket.recvfrom(2048)
print out received string print modifiedMessage
and close socket
clientSocket.close()
Application Layer 2-15
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 1:
Read from UDP socket into message, clientAddress = serverSocket.recvfrom(2048)
message, getting client’s
address (client IP and port) modifiedMessage = message.upper()
send upper case string serverSocket.sendto(modifiedMessage, clientAddress)
back to this client

Application Layer 2-16


Socket programming with TCP
client must contact server • when contacted by client, server
• server process must first be TCP creates new socket for server
running process to communicate with
• server must have created that particular client
socket (door) that welcomes – allows server to talk with
client’s contact multiple clients
– source port numbers used to
client contacts server by: distinguish clients (more in
• Creating TCP socket, Chap 3)
specifying IP address, port
number of server process application viewpoint:
• when client creates socket: TCP provides reliable, in-order
client TCP establishes byte-stream transfer (“pipe”)
connection to server TCP between client and server

Application Layer 2-17


Client/server socket interaction: TCP
server (running on hostid) client
create socket,
port=x, for incoming
request:
serverSocket = socket()

wait for incoming create socket,


connection request
TCP connect to hostid, port=x
connectionSocket = connection setup clientSocket = socket()
serverSocket.accept()

send request using


read request from clientSocket
connectionSocket

write reply to
connectionSocket read reply from
clientSocket
close
connectionSocket close
clientSocket

Application Layer 2-18


BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956
Example app: TCP client
Python TCPClient
from socket import *
serverName = ’servername’
create TCP socket for
serverPort = 12000
server, remote port 12000
clientSocket = socket(AF_INET, SOCK_STREAM)
clientSocket.connect((serverName,serverPort))
sentence = raw_input(‘Input lowercase sentence:’)
No need to attach server clientSocket.send(sentence)
name, port
modifiedSentence = clientSocket.recv(1024)
print ‘From Server:’, modifiedSentence
clientSocket.close()

Application Layer 2-19


Example app: TCP server
Python TCPServer
from socket import *
create TCP welcoming serverPort = 12000
socket serverSocket = socket(AF_INET,SOCK_STREAM)
serverSocket.bind((‘’,serverPort))
server begins listening for
incoming TCP requests serverSocket.listen(1)
print ‘The server is ready to receive’
loop forever
while 1:
server waits on accept()
for incoming requests, new
connectionSocket, addr = serverSocket.accept()
socket created on return

sentence = connectionSocket.recv(1024)
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) connectionSocket.close()
Application Layer 2-20
BITS Pilani
Pilani|Dubai|Goa|Hyderabad

You might also like