CN Combined Merged
CN Combined Merged
CN Combined Merged
Pilani Campus
AUGS/AGSR Division
In addition to Part-I (General handout for all courses appended to the timetable) this portion gives
further specific details regarding the course:
TEXT BOOK
[T1] James F. Kurose, and Keith W. Ross: Computer Networking: A Top-Down Approach Featuring the
Internet, Sixth Edition, Pearson Education, India, 2017. (Fifth Edition is also fine)
[T2] L. Peterson and B. Davie, Computer Networks: A Systems Approach, Fifth Edition, Elsevier, 2012
REFERENCE BOOKS
[R1] Andrew S. Tanenbaum & David J. Wetherall: Computer Networks, 5th Edition, Pearson, New Delhi,
2014.
[R2] Douglas E. Comer: Hands-on Networking, Pearson, New Delhi, 2015.
[R3] W. R. Stevens, UNIX Network Programming, Vol I, Networking APIs: Sockets and XTI, Pearson
Education, 3rd Edition.
Access Networks & LANs (Link Layer): To understand how data moves from one
Hop by Hop data transmission using link layer hop to another hop between two end points.
frames, Multiple access links and protocols: To learn about local area network design
M5 Point-to-Point and Broadcast link (LANs), and performance issues
Node addressing in switched LANs To understand different channel access
(Ethernet), Link Virtualization (MPLS) protocols
Wireless and Mobile Networks: Wireless To understand the challenges faced by IP
links and network characteristics, Wi-Fi network due to mobile communicating
M6 (802.11) networks, Node mobility nodes
management in wireless networks (Mobile IP) To understand wireless network access in
IP networks.
PLAN OF STUDY
Lect. Topics References
No.
M1: Internet Architecture and Computer Network Primitives
1-3 Internet Architecture, Network Hardware: The Network Edge, The Network Core, T1: 1.1 – 1.5
ISPs and Internet Backbones, Delay, Loss and Throughput in Packet Switched
Networks, Protocol Layers and their Service Models (TCP/IP)
CSMA/CD
32-34 Local Area Networks, Link Layer addressing: MAC addresses, Address T1: 5.4
Resolution Protocol (ARP), Domain Host Control Protocol (DHCP), Ethernet,
Link Layer switches, Virtual Local Area Networks (VLANs)
35 Link Virtualization: Multi-Protocol Label Switching (MPLS) T1: 5.5
36-37 The theoretical basis for data communication (Bandwidth Limited Signals, R1: 2.1,
Maximum Data Rate of a Channel), Guided physical media. Line coding Class Notes
Schemes: NRZ, RZ, Manchester, Differential Manchester.
M6: Wireless and Mobile Networks
38-40 Wireless Links and Network Characteristics, Wi-Fi: 802.11 Wireless LAN T1: 6.2 – 6.6
Architecture and Protocol, Mobility management: addressing and routing, Mobile
IP
EVALUATION SCHEME
Notices: All course notices will be displayed on the NALANDA LMS/Microsoft Teams
Make-up Policy: Only in genuine cases, on a case-by-case basis, make-ups shall be allowed. Prior
permission from I/C is must.
Chamber Consultation Hour: Monday, Wednesday @ 5:00 PM – 6:00 PM
Instructor-In-Charge
CS F303
• Course Overview
• Course Administration
• What is network?
• What is Internet?
• Network Structure
– Edge, Access Network (Physical Media), Network Core
• Circuit Switching and Packet Switching
2
Computer Networks CS F303 BITS Pilani, Pilani Campus
Course Objective
4
Computer Networks CS F303 BITS Pilani, Pilani Campus
Course Administration
• Instruction delivery
– Lecture classes
• 12:00 – 12:50 pm [Tue, Th] and 5:00 – 5:50 PM [Fri]
– Lab classes
• Start from the first week of Feb (detail will be posted on MS Teams)
• Course page Information
– Lectures and course material will be available at MS Teams
– For assessments NALANDA will be used (https://nalanda-aws.bits-pilani.ac.in)
• Evaluation Plan
– Mid Semester Test @25%
– Quiz (Two) @20% [10% each]
– Lab Assessment @20%
– Comprehensive exam @35% 5
Computer Networks CS F303 BITS Pilani, Pilani Campus
Text Book
6
Computer Networks CS F303 BITS Pilani, Pilani Campus
What is a Network?
9
Computer Networks CS F303 BITS Pilani, Pilani Campus
Network Structure
10
Computer Networks CS F303 BITS Pilani, Pilani Campus
Physical Media-Guided
• Twisted pair
– Two insulated copper wires
– Transmission rates supported are 100 Mbps, 1 Gbps, 10 Gbps
• Coaxial Cable
– Two concentric copper conductors
– Multiple channels on cable
• Fiber Optic Cable
– Glass fiber carrying light pulses, each pulse a bit
– High speed operation (10 Gbps to 100 Gbps)
– Low error rate
11
Computer Networks CS F303 BITS Pilani, Pilani Campus
Physical Media-Unguided
13
Computer Networks CS F303 BITS Pilani, Pilani Campus
Internet structure: network of networks
access access
net net
access
net
access
net
access
net
access
net
access access
net access net
net
14
Computer Networks CS F303 BITS Pilani, Pilani Campus
Internet structure: network of networks
Option: connect each access ISP to every other access ISP?
access access
net net
access
net
access
access net
net
access
access net
net
access
net
access
net
access
net
access
net
access access
net access net
net
15
Computer Networks CS F303 BITS Pilani, Pilani Campus
Internet structure: network of networks
Option: connect each access ISP to a global transit ISP? Customer
and provider ISPs have economic agreement.
access access
net net
access
net
access
access net
net
access
access net
net
global
access
net
ISP access
net
access
net
access
net
access
net
access
net
access access
net access net
net
16
Computer Networks CS F303 BITS Pilani, Pilani Campus
Internet structure: network of networks
Single global ISP does not scale, there are multiple global ISPs ….
access access
net net
access
net
access
access net
net
access
access net
net
ISP A
access access
net ISP B net
access
ISP C
net
access
net
access
net
access
net
access access
net access net
net
17
Computer Networks CS F303 BITS Pilani, Pilani Campus
Internet structure: network of networks
Multiple global ISPs must be interconnected
access access
Internet exchange point
net net
access
net
access
access net
net
access
IXP access
net
net
ISP A
access
ISP C
net
access
net
access
IXP access
net
net
ISP A
access
ISP C
net
access
net
access
net regional net
access
net
access access
net access net
net
19
Computer Networks CS F303 BITS Pilani, Pilani Campus
Internet structure: network of networks
… and content provider networks (e.g., Google, Microsoft, Akamai ) may run
their own network, to bring services, content close to end users
access access
net net
access
net
access
access net
net
access
IXP access
net
net
ISP A
Content provider network
access IXP access
net ISP B net
access
ISP B
net
access
net
access
net regional net
access
net
access access
net access net
net
20
Computer Networks CS F303 BITS Pilani, Pilani Campus
Internet structure: network of networks
POP: point-of-presence
to/from backbone
peering
… …
…
…
…
to/from customers
23
Computer Networks CS F303 BITS Pilani, Pilani Campus
Network Core: Circuit Switching
24
Computer Networks CS F303 BITS Pilani, Pilani Campus
Circuit Switching: FDM and TDM
Example:
FDM
4 users
frequency
time
TDM
frequency
time 25
Computer Networks CS F303 BITS Pilani, Pilani Campus
Circuit Switch: Numerical example
• How long does it take to send a file of 640,000 bits from host A to host B
over a circuit-switched network?
– All links are 1.536 Mbps
– Each link uses TDM with 24 slots/sec
– 500 msec to establish end-to-end circuit
26
Computer Networks CS F303 BITS Pilani, Pilani Campus
Network Core: Packet Switching
transmission
A C
propagation
B D
nodal
processing queueing
28
Computer Networks CS F303 BITS Pilani, Pilani Campus
Caravan Analogy [.1]
100 km 100 km
ten-car toll toll
caravan booth booth
• Cars “propagate” at 100 km/hr
• Toll booth takes 12 sec to service a car (car transmission time)
• Car is analogous to bit; caravan is analogous to packet
• Question:
– How long until caravan is lined up before 2nd toll booth?
29
Computer Networks CS F303 BITS Pilani, Pilani Campus
Caravan analogy [..2]
100 km 100 km
ten-car toll toll
caravan booth booth
30
Computer Networks CS F303 BITS Pilani, Pilani Campus
Queuing Delay
• R=link bandwidth (bps)
• L=packet length (bits)
• a=average packet arrival rate
La/R > 1: more “work” arriving than can be serviced, average delay infinite!
La/R <= 1: delays become large
La/R ~ 0: average queueing delay small
31
Computer Networks CS F303 BITS Pilani, Pilani Campus
“Real” Internet delays and routes
• http://traceroute.org
3 probes 3 probes
3 probes
32
Computer Networks CS F303 BITS Pilani, Pilani Campus
Packet switching versus circuit switching
• Circuit-switching:
– How many users are supported?
• Packet switching:
– with 35 users, probability > 10 active at Exercise: How did we get value 0.0004?
same time is less than .0004 *
• Packet Loss
• Throughput
– Amount of bits transferred in a unit time
• Instantaneous throughput
– e.g., P2P file sharing applications displays instantaneous throughput during downloads
• Average throughput
34
Computer Networks CS F303 BITS Pilani, Pilani Campus
Exercise
35
Computer Networks CS F303 BITS Pilani, Pilani Campus
Layered (Modular) Network Model (OSI)
36
Computer Networks CS F303 BITS Pilani, Pilani Campus
Layering of Airline Functionality
airplane routing airplane routing airplane routing airplane routing airplane routing
TCP UDP…
Applications
38
Computer Networks CS F303 BITS Pilani, Pilani Campus
source
message
segment
M application Layer Encapsulation
Ht M transport
datagram Hn Ht M network
frame Hl Hn Ht M link
physical
link
physical
switch
destination Hn Ht M network
M application H l Hn Ht M link Hn Ht M
Ht M transport physical
Hn H t M network
Hl Hn Ht M link router
physical
39
Computer Networks CS F303 BITS Pilani, Pilani Campus
Summary
40
Computer Networks CS F303 BITS Pilani, Pilani Campus
Thank You!
41
TCP UDP…
Applications
2
Computer Networks CS F303 BITS Pilani, Pilani Campus
What is a Network Application?
3
Computer Networks (CS F303) BITS Pilani, Pilani Campus
Application architectures
• Client-server
• Peer-to-Peer (P2P)
• Hybrid of client-server and P2P
4
Computer Networks (CS F303) BITS Pilani, Pilani Campus
Client-Server Architecture
Server:
– “always-on” host
– Permanent IP address
– For scaling, data center is used to create
large powerful virtual server
Clients:
– Communicate with server
– May be intermittently connected
– May have dynamic IP addresses
– Clients do not communicate directly
with each other
5
Computer Networks (CS F303) BITS Pilani, Pilani Campus
Pure P2P Architecture
• No “always-on” server
• Arbitrary end systems directly
communicate
• Peers are connected and change IP
addresses
– example: Freenet and BitTorrent (File Sharing
Apps)
6
Computer Networks (CS F303) BITS Pilani, Pilani Campus
Hybrid of client-server and P2P
Skype
– Internet telephony application
– Finding address of remote party: centralized server(s)
– Client-client connection is direct (not through server)
Instant messaging
– Chatting between two users is P2P
– Presence detection/location centralized:
• User registers its IP address with central server when it comes online
• User contacts central server to find IP addresses of buddies
7
Computer Networks (CS F303) BITS Pilani, Pilani Campus
How Network Applications
Communicate?
• Process sends/receives messages host or host or
server server
to/from its Socket
– Socket is the interface between the controlled by
application layer and the transport layer app developer
process process
within the host
socket socket
TCP with TCP with
• Within same host, two processes buffers, Internet buffers,
variables variables
communicate using inter-process
communication
controlled
by OS
• Processes in different hosts
communicate by exchanging
messages
8
Computer Networks (CS F303) BITS Pilani, Pilani Campus
How to identify a process running on a
machine?
• To receive messages, process must have
host or
identifier host or
server server
• Data loss
– Some apps (e.g., audio, video) can tolerate some loss
– Other apps (e.g., file transfer, telnet) require 100% reliable data transfer
• Bandwidth
– Some apps (e.g., multimedia) require minimum amount of bandwidth to be
“effective”
– Other apps (“elastic apps”) make use of whatever bandwidth they get
– ex. E-mail, File Transfer
• Timing
– Some apps (e.g., Internet telephony, interactive games) require low delay to be
“effective”
10
Computer Networks (CS F303) BITS Pilani, Pilani Campus
Web and HTTP [1994]
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 URLs:
https://www.bits-pilani.ac.in/pilani/computerscience/ProgrammesOffered
https://www.bits-pilani.ac.in/pilani/computerscience/Faculty
11
Computer Networks (CS F303) BITS Pilani, Pilani Campus
HTTP Overview [.1]
12
Computer Networks (CS F303) BITS Pilani, Pilani Campus
HTTP Overview [..2]
Uses TCP:
• Client initiates TCP connection (creates
socket) to server at port 80
initiate TCP
• Server accepts TCP connection from client connection
RTT
request
• HTTP messages exchanged between file
browser (HTTP client) and Web server RTT
time to
transmit
(HTTP server) file
file
received
• TCP connection closed
time time
13
Computer Networks (CS F303) BITS Pilani, Pilani Campus
HTTP Request Message
data, e.g.,
requested
HTML file
15
Computer Networks (CS F303) BITS Pilani, Pilani Campus
HTTP Response status Codes
200 OK
– request succeeded, requested object later in this msg
301 Moved Permanently
– requested object moved, new location specified later in this msg (Location:)
400 Bad Request
– request msg not understood by server
404 Not Found
– requested document not found on this server
505 HTTP Version Not Supported
– the HTTP version used in the request is not supported by the server.
16
Computer Networks (CS F303) BITS Pilani, Pilani Campus
How a Webpage transfers?
• Let’s assume a web page consists of a base HTML file and 5 JPEG images.
– https://www.bits-pilani.ac.in/Pilani/SustainableEnvironment
17
Computer Networks (CS F303) BITS Pilani, Pilani Campus
HTTP Connections
Non-persistent HTTP
• At most one object is sent over a TCP connection
• HTTP/1.0 uses non-persistent HTTP
Persistent HTTP
• Multiple objects can be sent over single TCP
connection between client and server.
• Persistent with Pipeline vs. Persistent without
Pipeline
• HTTP/1.1 uses persistent connections in default
mode
18
Computer Networks (CS F303) BITS Pilani, Pilani Campus
HTTP Method Types
HTTP/1.0: HTTP/1.1:
• GET • GET, POST, HEAD
• POST • PUT
• HEAD – uploads file in entity body
– asks server to leave to path specified in URL
requested object out of field
response • DELETE
– deletes file specified in the
URL field
19
Computer Networks (CS F303) BITS Pilani, Pilani Campus
State in HTTP using “Cookies”
client server
ebay 8734
usual http request msg Amazon server
cookie file creates ID
usual http response
1678 for user create backend
ebay 8734
set-cookie: 1678 entry database
amazon 1678
usual http request msg
cookie: 1678 cookie- access
specific
usual http response msg action
origin
server
Proxy
server
client
client
origin
server
21
Computer Networks (CS F303) BITS Pilani, Pilani Campus
Conditional GET
client server
• Goal: don’t send object if cache
has up-to-date cached version HTTP request msg
If-modified-since: <date> object
not
• cache: specify date of cached modified
HTTP response
before
copy in HTTP request HTTP/1.0
304 Not Modified
<date>
If-modified-since: <date>
Assumptions:
avg object size: 1000 K bits origin
avg request rate from browsers to origin servers
public
servers: 15 req/sec Internet
avg data rate to browsers: 1Mbps
RTT from institutional router to any origin
server: 2 sec
access link rate: 15 Mbps 15 Mbps
access link
institutional
network
100 Mbps LAN
23
Computer Networks (CS F303) BITS Pilani, Pilani Campus
HTTP/2 [Proposed in 2015]
• Limitations of HTTP/1.1
– It processes only one outstanding request per TCP connection
– Forcing browsers to use multiple TCP connections to process multiple requests
simultaneously
– HTTP1.x used to process text commands which makes it slower
• Motivation
– To improve internet user experience and effectiveness
– Webpages comprise resource-intensive multimedia content
– To make it more secure, reliable with improved performance
• What is stream?
– Bi-directional sequence of text format frames
sent over the HTTP/2 protocol exchanged
between the server and client
26
Computer Networks (CS F303) BITS Pilani, Pilani Campus
HTTP/2.0 Connection
• Stream: A bidirectional flow of bytes
within an established connection, which
may carry one or more messages.
• Message: A complete sequence of
frames that map to a logical request or
response message.
• Frame: The smallest unit of
communication in HTTP/2, each
containing a frame header, which at a
minimum identifies the stream to which
the frame belongs.
27
Computer Networks (CS F303) BITS Pilani, Pilani Campus
Domain Name System (DNS)
• The domain name system maps the name people use to locate a website to
the IP address that a computer uses to locate a website.
28
Computer Networks CS F303 BITS Pilani, Pilani Campus
DNS Structure – Distributed Hierarchical
Database
Root DNS Servers
… …
30
Computer Networks CS F303 BITS Pilani, Pilani Campus
DNS Services
• Load distribution
– Replicated Web servers: many IP addresses correspond to one name
31
Computer Networks CS F303 BITS Pilani, Pilani Campus
DNS Query Processing - Recursive root DNS server
2 3
7
6
TLD DNS
server
1 8
gaia.cs.umass.edu
32
Computer Networks CS F303 BITS Pilani, Pilani Campus
DNS Query Processing - Iterative root DNS server
2
• TLD server may know only of an 3
intermediate DNS server for the TLD DNS server
4
hostname, which in turn knows the
authoritative DNS server for the 5
hostname. local DNS server
dns.poly.edu
7 6
1 8
• DNS responses are usually cached to
improve the delay performance and to authoritative DNS server
reduce the number of DNS messages dns.cs.umass.edu
requesting host
– e.g., Local DNS server caches the TLD server cis.poly.edu
information
gaia.cs.umass.edu
33
Computer Networks CS F303 BITS Pilani, Pilani Campus
DNS Records
DNS: distributed database for storing resource records (RR)
RR format: (name, value, type, ttl)
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 associated
server for this domain with name (host name, i.e.,
mailserver alias)
34
Computer Networks CS F303 BITS Pilani, Pilani Campus
DNS Messages
• Query and reply messages, both with same message format
• Explore DNS protocol in Lab Session #2
2 bytes 2 bytes
36
Computer Networks CS F303 BITS Pilani, Pilani Campus
FTP: File Transfer Protocol
file transfer
FTP FTP FTP
user client server
interface
user
at host remote file
local file system
system
37
Computer Networks CS F303 BITS Pilani, Pilani Campus
FTP: Connections
TCP control connection,
• Control connection server port 21
– Authorization, directory listing
etc. TCP data connection,
FTP server port 20 FTP
client server
• When server receives file
transfer command,
– Server opens 2nd TCP data
connection (for file) to client
38
Computer Networks CS F303 BITS Pilani, Pilani Campus
FTP Commands and Responses
39
Computer Networks CS F303 BITS Pilani, Pilani Campus
eMail
outgoing
user message queue
Three major components: agent
user mailbox
• User agents mail user
server
– e.g., Outlook, Thunderbird agent
40
Computer Networks CS F303 BITS Pilani, Pilani Campus
SMTP [RFC 5321, Original RFC 821]
• Uses TCP to reliably transfer email message from client to server, port 25
• Direct transfer: sender’s mail server to receiver’s mail server
• Three phases of transfer
– Handshaking (greeting)Transfer of messagesConnection Closure
• Command/response interaction (like HTTP, FTP)
– Commands: ASCII text
– Response: status code and phrase
• Messages must be in 7-bit ASCII
– Painful for multimedia data
41
Computer Networks CS F303 BITS Pilani, Pilani Campus
Mail Transfer Process
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 42
Computer Networks CS F303 BITS Pilani, Pilani Campus
Mail Access Protocols
45
Computer Networks (CS F303) BITS Pilani, Pilani Campus
Thank You!
46
Computer Networks (CS F303) BITS Pilani, Pilani Campus
Computer Networks (CS F303)
BITS Pilani Virendra Singh Shekhawat
Department of Computer Science and Information Systems
Pilani Campus
Today’s Agenda
2
Computer Networks (CS F303) BITS Pilani, Pilani Campus
Peer to Peer (P2P) Architecture
• No always-on server
• Arbitrary end systems directly communicate
• Peers are intermittently connected
• Examples
– File distribution (BitTorrent)
– Streaming (KanKan)
– VoIP (Skype)
3
Computer Networks CS F303 BITS Pilani, Pilani Campus
File Distribution: P2P vs CS
How much time required to distribute file (size F) from one server to N peers?
– peer upload/download capacity is limited resource
4
Computer Networks CS F303 BITS Pilani, Pilani Campus
File Distribution Time – Client Server
• Server transmission: must F
sequentially send (upload) N us
file copies: di
network
– Time to send N copies: NF/us ui
time to distribute F
to N clients using
client-server approach Dc-s > max{NF/us,,F/dmin}
5
Computer Networks CS F303 BITS Pilani, Pilani Campus
File Distribution Time - Peer to Peer
• Server transmission: must upload at least one copy
F
– time to send one copy: F/us us
di
Client: each client must download file copy network
Slowest client download time: F/dmin ui
Time to distribute F
to N clients using
P2P approach
DP2P > max{F/us,,F/dmin,,NF/(us + Sui)}
6
Computer Networks CS F303 BITS Pilani, Pilani Campus
Exercise
7
Computer Networks (CS F303) BITS Pilani, Pilani Campus
CS vs P2P: Example
1.5
0.5
0
0 5 10 15 20 25 30 35
N
8
Computer Networks CS F303 BITS Pilani, Pilani Campus
P2P File Distribution: BitTorrent
9
Computer Networks CS F303 BITS Pilani, Pilani Campus
The lookup problem
N2 N3
N1
Internet
Key = “data item”
Value = video lecture ?
Client
Publisher
N4 N6 Lookup(“data item”)
N5
Decentralized network with several peers (servers/clients)
How to find specific peer that hosts desired data within this network?
10
Computer Networks CS F303 BITS Pilani, Pilani Campus
P2P Protocols
Napster
Gnutella
Kazaa (Skype is based on Kazaa)
11
Computer Networks CS F303 BITS Pilani, Pilani Campus
Distributed Hash Table (DHT)
• Each Peer hold a small subset of the total (key, value) pairs
• Any Peer can query the distributed database with a particular key
– Distributed DB locate the Peers that have the corresponding (key, value)
pairs and return to the querying Peer
– Each peer only knows about a small number of other peers
– Any Peer can insert new (key, value) pairs into the DB
– Robust to peers coming and going (churn)
12
Computer Networks CS F303 BITS Pilani, Pilani Campus
DHT Implementation [.1]
• Randomly scatter the (key, value) pairs across all the peers
• The peers containing the (key, value) pairs that match the key can respond
with matching pairs
• Hash function assigns each “node” and “key” an m-bit identifier using a
base hash function such as SHA-1
– Node_ID = hash(IP, Port)
N63
– Key_ID = hash(original key) N60 N2
k7
ID Space: 0 to 2m-1 k58
N10
Here: m = 6 k11
N50 k16
Range = 64
k46 N20
Assign (key-value) pair to the peer that has N40 k39 k25
16
Computer Networks CS F303 BITS Pilani, Pilani Campus
The Chord algorithm –
Scalable node localization
• Search in finger table for the node
which is
most immediatly precedes key
19
Computer Networks (CS F303) BITS Pilani, Pilani Campus
Computer Networks (CS F303)
BITS Pilani Virendra Singh Shekhawat
Department of Computer Science and Information Systems
Pilani Campus
Next…
• Clients and servers communicate with each other by reading from and writing to socket
descriptors.
application application
socket controlled by
process process app developer
transport transport
network network controlled
link by OS
link Internet
physical physical
3
Computer Networks (CS F303) BITS Pilani, Pilani Campus
Socket Programming [..2]
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.
4
Computer Networks (CS F303) BITS Pilani, Pilani Campus
Socket Programming with UDP
5
Computer Networks (CS F303) BITS Pilani, Pilani Campus
Socket Programming with TCP
Application viewpoint:
TCP provides reliable, in-order byte-stream transfer (“pipe”)
between client and server.
6
Computer Networks (CS F303) BITS Pilani, Pilani Campus
Socket Structure [.1]
struct sockaddr
{
unsigned short int sa_family; // address family, AF_xxx
char sa_data[14] ; // 14 bytes of protocol address
}
7
Computer Networks (CS F303) BITS Pilani, Pilani Campus
Socket Structure [..2]
• Parallel structure to sockaddr
struct sockaddr_in
{
short int sin_family; // Address family (e.g., AF_INET)
unsigned short int sin_port; // Port number (e.g., htons (2240)
struct in_addr sin_addr; // Internet address
unsigned char sin_zero[8]; // same size as sockaddr
}
struct in_addr
{ unsigned long s_addr;
}
• sin_zero is used to pad the structure to the length of a structure sockaddr and hence is set to all zeros with
the function memset()
• Important – you can cast sockaddr_in to a pointer of type struct sockaddr and vice versa
• sin_family corresponds to sa_family and should be set to “AF_INET”.
• sin_port and sin_addr must be in NBO
8
Computer Networks (CS F303) BITS Pilani, Pilani Campus
NBO & HBO Conversion Functions
• Very Important: Even if your machine is Big-Endian m/c, but you put your bytes in NBO before putting
them on to the network for portability
9
Computer Networks (CS F303) BITS Pilani, Pilani Campus
Primary Socket System Calls
10
Computer Networks (CS F303) BITS Pilani, Pilani Campus
Socket System Calls:
Connectionless (e.g., UDP)
11
Computer Networks (CS F303) BITS Pilani, Pilani Campus
Socket System Calls: Connection-
Oriented (e.g., TCP)
12
Computer Networks (CS F303) BITS Pilani, Pilani Campus
Socket System Calls [.1]
13
Computer Networks (CS F303) BITS Pilani, Pilani Campus
Socket System Calls [..2]
14
Computer Networks (CS F303) BITS Pilani, Pilani Campus
Socket System Calls […3]
• SEND: int send(int sockfd, const void *msg, int len, int flags);
– msg: message you want to send
– len: length of the message
– flags := 0
– returned: the number of bytes actually sent
• RECEIVE: int recv(int sockfd, void *buf, int len, unsigned int flags);
– buf: buffer to receive the message
– len: length of the buffer (“don’t give me more!”)
– flags := 0
– returned: the number of bytes received
15
Computer Networks (CS F303) BITS Pilani, Pilani Campus
Socket System Calls [….4]
• SEND (DGRAM-style): int sendto(int sockfd, const void *msg, int len, int flags, const struct sockaddr *to, int
tolen);
– msg: message you want to send
– len: length of the message
– flags := 0
– to: socket address of the remote process
– tolen: = sizeof(struct sockaddr)
– returned: the number of bytes actually sent
• RECEIVE (DGRAM-style): int recvfrom(int sockfd, void *buf, int len, unsigned int flags, struct sockaddr
*from, int *fromlen);
– buf: buffer to receive the message
– len: length of the buffer (“don’t give me more!”)
– from: socket address of the process that sent the data
– fromlen:= sizeof(struct sockaddr)
– flags := 0
– returned: the number of bytes received
#include <sys/types.h>
#include <netinet/in.h>
18
Computer Networks (CS F303) BITS Pilani, Pilani Campus
Simple TCP Client
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#define SERVER_PORT 5888
int main()
{ int sockfd, clifd,len;
char buf[256];
struct sockaddr_in servaddr;
sockfd = socket( AF_INET, SOCK_STREAM, 0);
if (sockid < 0) { printf(“ Server socket error"); exit(1); }
servaddr.sin_family = AF_INET;
servaddr.sin_port = htons(SERVER_PORT);
servaddr.sin_addr.s_addr = inet_addr(“172.24.2.4”);
read(sockfd,buf,256);
printf(“Client Received%s\n",buf);
Close(sockfd);
}
19
Computer Networks (CS F303) BITS Pilani, Pilani Campus
Simple UDP Server
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#define SERVER_PORT 9988
int main()
{ int sockfd, clilen;
char buf[256];
struct sockaddr_in servaddr, cliaddr;
sockfd = socket( AF_INET, SOCK_DGRAM, 0);
servaddr.sin_family = AF_INET;
servaddr.sin_port = htons(SERVER_PORT);
servaddr.sin_addr.s_addr =htonl(INADDR_ANY);
if (bind(sockfd,(struct sockaddr*)&servaddr,sizeof(servaddr)) <0 )
{ printf(“Server Bind Error”); exit(1); }
for(; ; )
{ clilen= sizeof(cliaddr);
recvfrom(sockfd,buf,256,0,(struct sockaddr*)&cliaddr,&clilen);
printf(“Server Received:%s\n”,buf);
servaddr.sin_family = AF_INET;
servaddr.sin_port = htons(SERVER_PORT);
servaddr.sin_addr.s_addr = inet_addr(SERVER_IPADDR);
cliaddr.sin_family = AF_INET;
cliaddr.sin_port = htons(0);
cliaddr.sin_addr.s_addr =htonl(INADDR_ANY);
bind(sockfd,(struct sockaddr*)&cliaddr,sizeof(cliaddr));
recvfrom(sockfd,buf,256,0,NULL,NULL);
printf(“Clinet Received: %s \n”,buf);
close(sockfd);
} 21
Computer Networks (CS F303) BITS Pilani, Pilani Campus
Thank You!
22
Computer Networks (CS F303) BITS Pilani, Pilani Campus
Computer Networks (CS F303)
BITS Pilani Virendra Singh Shekhawat
Department of Computer Science and Information Systems
Pilani Campus
Topics
• Transport Layer
– Transport Layer Services
• Multiplexing/Demultiplexing
– Connectionless and Connection Oriented
» TCP and UDP
• Reliable data transfer (Protocol design)
• Flow control
• Congestion control
2
Computer Networks (CS F303) BITS Pilani, Pilani Campus
Transport Layer Services and Protocols
3
Computer Networks (CS F303) BITS Pilani, Pilani Campus
TP Layer vs. Network Layer
• Network layer: logical communication between hosts
• But certain services can be offered by the TP layer even when the network
layer doesn’t offer
– e.g., Reliable data transfer
4
Computer Networks (CS F303) BITS Pilani, Pilani Campus
Transport Layer Services
5
Computer Networks (CS F303) BITS Pilani, Pilani Campus
Process-to-Process Delivery Service
Multiplexing at sendening time:
Demux at receiving time:
handle data from multiple use header info to deliver
sockets, add transport header received segments to correct
socket
application
6
Computer Networks (CS F303) BITS Pilani, Pilani Campus
Demultiplexing at Receiver
7
3-7
Computer Networks (CS F303) BITS Pilani, Pilani Campus
Connectionless (UDP) Demultiplexing
• Recall: when creating datagram to send into UDP socket, must specify
• Destination IP address
• Destination port #
8
Computer Networks (CS F303) BITS Pilani, Pilani Campus
Example: Connectionless Demultiplexing
DatagramSocket serverSocket
DatagramSocket = new DatagramSocket DatagramSocket
mySocket2 = new mySocket1 = new
(6428);
DatagramSocket DatagramSocket
(9157); application
(5775);
application application
P1
P3 P4
transport
transport transport
network
network link network
link physical link
physical physical
10
Computer Networks (CS F303) BITS Pilani, Pilani Campus
Example: Connection Oriented Demux
application
application P4 P5 P6 application
P1 P2 P3
transport
transport transport
network
network link network
link physical link
physical server: IP physical
address B
13
Computer Networks (CS F303) BITS Pilani, Pilani Campus
UDP Segment Header
length, in bytes of
32 bits UDP segment,
source port # dest port # including header
length checksum
Why is there a UDP?
• No connection establishment
application
(which can add delay)
data
(payload) • simple: no connection state
at sender, receiver
• small header size
UDP segment format • no congestion control: UDP
can blast away as fast as
desired
14
Computer Networks (CS F303) BITS Pilani, Pilani Campus
UDP Checksum
15
Computer Networks (CS F303) BITS Pilani, Pilani Campus
Principles of Reliable Data Transfer
16
Computer Networks (CS F303) BITS Pilani, Pilani Campus
Principles of Reliable Data Transfer
17
Computer Networks (CS F303) BITS Pilani, Pilani Campus
Principles of Reliable Data Transfer
send receive
side side
We will:
• Incrementally develop sender, receiver sides of reliable data
transfer protocol (rdt)
• Consider only unidirectional data transfer
– But control info will flow on both directions!
• Use finite state machines (FSM) to specify sender, receiver
event causing state transition
actions taken on state transition
State: when in this “state”
next state uniquely state state
1 event
determined by next 2
event actions
20
Computer Networks (CS F303) BITS Pilani, Pilani Campus
rdt1.0: reliable transfer over a reliable channel
sender receiver
21
Computer Networks (CS F303) BITS Pilani, Pilani Campus
rdt2.0: channel with bit errors
• Underlying channel may flip bits in packet
– Don’t worry… Checksum is there to detect bit errors
22
Computer Networks (CS F303) BITS Pilani, Pilani Campus
rdt2.0: FSM Specification
rdt_send(data)
sndpkt = make_pkt(data, checksum) receiver
udt_send(sndpkt)
rdt_rcv(rcvpkt) &&
isNAK(rcvpkt)
Wait for rdt_rcv(rcvpkt) &&
Wait for call
ACK or udt_send(sndpkt) corrupt(rcvpkt)
from above
NAK
udt_send(NAK)
rdt_rcv(rcvpkt) &&
notcorrupt(rcvpkt)
extract(rcvpkt,data)
deliver_data(data)
udt_send(ACK)
24
Computer Networks (CS F303) BITS Pilani, Pilani Campus
rdt2.0: Error Scenario
rdt_send(data)
sndpkt = make_pkt(data, checksum)
udt_send(sndpkt)
rdt_rcv(rcvpkt) &&
isNAK(rcvpkt)
Wait for call Wait for rdt_rcv(rcvpkt) &&
from above ACK or udt_send(sndpkt) corrupt(rcvpkt)
NAK
udt_send(NAK)
rdt_rcv(rcvpkt) &&
notcorrupt(rcvpkt)
extract(rcvpkt,data)
deliver_data(data)
udt_send(ACK)
25
Computer Networks (CS F303) BITS Pilani, Pilani Campus
rdt2.0 Has a fatal flaw!
26
Computer Networks (CS F303) BITS Pilani, Pilani Campus
rdt2.1: Sender, handles garbled ACK/NAKs
rdt_send(data)
sndpkt = make_pkt(0, data, checksum)
udt_send(sndpkt) rdt_rcv(rcvpkt) &&
( corrupt(rcvpkt) ||
Wait for call Wait for
ACK or NAK
isNAK(rcvpkt) )
0 from
0 udt_send(sndpkt)
above
rdt_rcv(rcvpkt)
&& notcorrupt(rcvpkt) rdt_rcv(rcvpkt)
&& isACK(rcvpkt) && notcorrupt(rcvpkt)
&& isACK(rcvpkt)
L
L
Wait for Wait for
ACK or NAK call 1 from
rdt_rcv(rcvpkt) && 1 above
( corrupt(rcvpkt) ||
isNAK(rcvpkt) ) rdt_send(data)
27
Computer Networks (CS F303) BITS Pilani, Pilani Campus
rdt2.1: Receiver, handles garbled ACK/NAKs
extract(rcvpkt,data)
deliver_data(data)
sndpkt = make_pkt(ACK, chksum)
udt_send(sndpkt)
28
Computer Networks (CS F303) BITS Pilani, Pilani Campus
rdt2.1: Discussion
Sender:
• Seq # added to pkt
• Two seq. #’s (0,1) will suffice. Why?
• Must check if received ACK/NAK corrupted
• Twice as many states
– State must “remember” whether “current” pkt has 0 or 1 seq. #
Receiver:
• Must check if received packet is duplicate
– State indicates whether 0 or 1 is expected pkt seq #
– For an out of order received packet, it sends ACK for it
• Note: Receiver can not know if its last ACK/NAK received OK at sender
29
Computer Networks (CS F303) BITS Pilani, Pilani Campus
rdt2.2: NAK Free Protocol
• New assumption: Underlying channel can also lose packets (data or ACKs)
– Checksum, seq. #, ACKs, retransmissions will be of help, but not enough
31
Computer Networks (CS F303) BITS Pilani, Pilani Campus
rdt 3.0 Sender and Receiver FSM
32
Computer Networks (CS F303) BITS Pilani, Pilani Campus
Thank You!
33
Computer Networks (CS F303) BITS Pilani, Pilani Campus
Computer Networks (CS F303)
BITS Pilani Virendra Singh Shekhawat
Department of Computer Science and Information Systems
Pilani Campus
Topics
• Transport Layer
• Reliable data transfer (Protocol design)
– Stop and Wait vs. Pipelining (Sliding Window)
– Go Back N and Selective Repeat Protocols
• Flow control
• Congestion control
2
Computer Networks (CS F303) BITS Pilani, Pilani Campus
rdt3.0: Channels with errors and loss
• New assumption: Underlying channel can also lose packets (data or ACKs)
– Checksum, seq. #, ACKs, retransmissions will be of help, but not enough
3
Computer Networks (CS F303) BITS Pilani, Pilani Campus
rdt 3.0 Sender and Receiver FSM
4
Computer Networks (CS F303) BITS Pilani, Pilani Campus
rdt3.0 in action
5
Computer Networks (CS F303) BITS Pilani, Pilani Campus
rdt3.0 (Lost ACK and Premature Timeout)
6
Computer Networks (CS F303) BITS Pilani, Pilani Campus
rdt3.0: Performance
sender receiver
first packet bit transmitted, t = 0
last packet bit transmitted, t = L / R
U L/R .008
= = = 0.00027
sender 30.008
RTT + L / R microsec
7
onds
Computer Networks (CS F303) BITS Pilani, Pilani Campus
Pipelining: Increased Utilization
sender receiver
first packet bit transmitted, t = 0
last bit transmitted, t = L / R
Increase utilization
by a factor of 3!
U 3*L/R .024
= = = 0.0008
sender 30.008
RTT + L / R microsecon
ds
8
Computer Networks (CS F303) BITS Pilani, Pilani Campus
Pipelined Protocols
9
Computer Networks (CS F303) BITS Pilani, Pilani Campus
Pipelining Protocols Requirements
10
Computer Networks (CS F303) BITS Pilani, Pilani Campus
GBN Protocol
Sender window (N=4) Sender Receiver
012345678 send pkt0
012345678 send pkt1
012345678 send pkt2 receive pkt0, send ack0
012345678 send pkt3 Xloss receive pkt1, send ack1
(wait)
receive pkt3, discard,
012345678 rcv ack0, send pkt4 (re)send ack1
012345678 rcv ack1, send pkt5 receive pkt4, discard,
(re)send ack1
ignore duplicate ACK receive pkt5, discard,
(re)send ack1
pkt 2 timeout
012345678 send pkt2
012345678 send pkt3
012345678 send pkt4 rcv pkt2, deliver, send ack2
012345678 send pkt5 rcv pkt3, deliver, send ack3
rcv pkt4, deliver, send ack4
rcv pkt5, deliver, send ack5
11
Computer Networks (CS F303) BITS Pilani, Pilani Campus
GBN Sender
12
Computer Networks (CS F303) BITS Pilani, Pilani Campus
GBN Sender FSM
rdt_send(data)
if (nextseqnum < base+N) {/*If we are allowed to send packets*/
sndpkt[nextseqnum] = make_pkt(nextseqnum,data,chksum)
udt_send(sndpkt[nextseqnum])
if (base == nextseqnum) /*If there are no packets in flight*/
start_timer
nextseqnum++
}
L else
refuse_data(data)
base=0
nextseqnum=0
timeout
start_timer
Wait
udt_send(sndpkt[base])
rdt_rcv(rcvpkt) udt_send(sndpkt[base+1])
&& corrupt(rcvpkt) …
udt_send(sndpkt[nextseqnum-1])
L
rdt_rcv(rcvpkt) &&
notcorrupt(rcvpkt)
base = getacknum(rcvpkt)+1 /*Increase left size of the window*/
If (base == nextseqnum)
stop_timer
else
start_timer 13
Computer Networks (CS F303) BITS Pilani, Pilani Campus
GBN Receiver FSM
• Always send ACK for correctly-received pkt with highest in-order seq #
– Need only to remember “expectedseqnum”
• If out-of-order pkt arrived
– Discard it
– Re-ACK pkt with the highest in-order seq #
default
udt_send(sndpkt) rdt_rcv(rcvpkt)
&& notcurrupt(rcvpkt)
L && hasseqnum(rcvpkt,expectedseqnum)
expectedseqnum=0 Wait extract(rcvpkt,data)
sndpkt = deliver_data(data)
make_pkt(expectedseqnum,ACK,chksum) sndpkt = make_pkt(expectedseqnum,ACK,chksum)
udt_send(sndpkt)
expectedseqnum++
14
Computer Networks (CS F303) BITS Pilani, Pilani Campus
Selective Repeat Protocol
sender window (N=4) sender receiver
012345678 send pkt0
012345678 send pkt1
012345678 send pkt2 receive pkt0, send ack0
012345678 send pkt3 Xloss receive pkt1, send ack1
(wait)
receive pkt3, buffer,
012345678 rcv ack0, send pkt4 send ack3
012345678 rcv ack1, send pkt5 receive pkt4, buffer,
send ack4
record ack3 arrived receive pkt5, buffer,
send ack5
pkt 2 timeout
012345678 send pkt2
012345678 record ack4 arrived
012345678 rcv pkt2; deliver pkt2,
record ack5 arrived
012345678 pkt3, pkt4, pkt5; send ack2
16
Computer Networks (CS F303) BITS Pilani, Pilani Campus
SR Protocol: Windows
Events at Sender
Data from above
Timeout
ACK(n) in [sendbase,sendbase+N-1]
Events at Receiver
Pkt n in [rcvbase, rcvbase+N-1]
Pkt n in [rcvbase-N,rcvbase-1]
Otherwise
17
Computer Networks (CS F303) BITS Pilani, Pilani Campus
Selective Repeat Dilemma
0123012 pkt0
0123012 pkt1 0123012
0123012 pkt2 0123012
X 0123012
X
timeout
retransmit pkt0 X
0123012 pkt0
will accept packet
with seq number 0
18
Computer Networks (CS F303) BITS Pilani, Pilani Campus
Relation between Window Size and
Sequence Number
• Sequence numbers range for K bits
– 0 to 2K-1
• What should be the window size N for
– Selective Repeat
– Go Back N
19
Computer Networks (CS F303) BITS Pilani, Pilani Campus
Thank You!
20
Computer Networks (CS F303) BITS Pilani, Pilani Campus
Computer Networks (CS F303)
BITS Pilani Virendra Singh Shekhawat
Department of Computer Science and Information Systems
Pilani Campus
Topics
• Transport Layer
• TCP Protocol
– Connection Establishment
– TCP Segment Structure
– Reliable data transfer
– Flow control
– Congestion control
2
Computer Networks (CS F303) BITS Pilani, Pilani Campus
TCP [RFCs: 793,1122,1223,2018,2581]
4
Computer Networks (CS F303) BITS Pilani, Pilani Campus
TCP: Wireshark Capture
5
Computer Networks (CS F303) BITS Pilani, Pilani Campus
TCP Sequence Numbers and ACKs
TCP views data as stream of bytes
outgoing segment from sender Sequence number reflects stream of transmitted bytes not segments
source port #
Sequence number of a segment – Byte stream number of the first byte in the
dest port #
segment
sequence number window size
acknowledgement number N
rwnd
checksum urg pointer
sender sequence number space
application application
network network
choose x
req_conn(x)
ESTAB
acc_conn(x)
ESTAB
8
Computer Networks (CS F303) BITS Pilani, Pilani Campus
TCP 3-way Handshake
9
Computer Networks (CS F303) BITS Pilani, Pilani Campus
Lost ACK Scenario
10
Computer Networks (CS F303) BITS Pilani, Pilani Campus
Premature Timeout
11
Computer Networks (CS F303) BITS Pilani, Pilani Campus
Cumulative ACK
12
Computer Networks (CS F303) BITS Pilani, Pilani Campus
Is TCP GBN or SR…?
13
Computer Networks (CS F303) BITS Pilani, Pilani Campus
TCP Connection Close
LAST_ACK
FINbit=1, seq=y
TIMED_WAIT can no longer
send data
ACKbit=1; ACKnum=y+1
timed wait
for 2*max CLOSED
segment lifetime
CLOSED
14
Computer Networks (CS F303) BITS Pilani, Pilani Campus
TCP Connection States-Client and Server
15
Computer Networks (CS F303) BITS Pilani, Pilani Campus
TCP Flow Control
16
Computer Networks (CS F303) BITS Pilani, Pilani Campus
TCP Timeout
17
Computer Networks (CS F303) BITS Pilani, Pilani Campus
RTT Estimation
EstimatedRTT = (1-)*EstimatedRTT + *SampleRTT
– Influence of past sample decreases exponentially fast
– Typical value of = 0.125
RTT: gaia.cs.umass.edu to fantasia.eurecom.fr
350
300
250
RTT (milliseconds)
200
150
100
1 8 15 22 29 36 43 50 57 64 71 78 85 92 99 106
time (seconnds)
18
Computer Networks (CS F303) BITS Pilani, Pilani Campus
Timeout Interval
• Timeout Interval
– Estimated RTT + “Safety margin”
– Large variation in Estimated RTT large safety margin
DevRTT = (1-)*DevRTT +
*|SampleRTT-EstimatedRTT|
(typically, = 0.25)
19
Computer Networks (CS F303) BITS Pilani, Pilani Campus
Example: Timeout Interval
• Consider three RTT samples (in ms): 150, 200 and 210 in that order. Assume
initial estimated RTT= 200 ms, initial DevRTT = 50 ms, β = 0.25 and α = 0.125
20
Computer Networks (CS F303) BITS Pilani, Pilani Campus
Next…
• Transport Layer
• TCP Protocol
– Connection Establishment
– TCP Segment Structure
– Reliable data transfer
– Flow control
– Timeout Estimation
– Congestion control
21
Computer Networks (CS F303) BITS Pilani, Pilani Campus
Network Congestion…?
10 Mbps
1.5 Mbps
100 Mbps
• Why is it a problem?
– Different sources compete for resources inside
network
– Sources are unaware of current state of resource
– Sources are unaware of each other
– In many situations will result in < 1.5 Mbps of
throughput (congestion collapse)
22
Computer Networks (CS F303) BITS Pilani, Pilani Campus
Congestion Control
• What is congestion
– Too many sources sending too much data too fast for network to handle
• Congestion results in
– Packet losses
– Packet delays
– Throughput reduction
23
Computer Networks (CS F303) BITS Pilani, Pilani Campus
Causes/Cost of Congestion [.1]
delay
R/2
lout
lin R/2
lin R/2
24
Computer Networks (CS F303) BITS Pilani, Pilani Campus
Causes/Cost of Congestion [..2]
25
Computer Networks (CS F303) BITS Pilani, Pilani Campus
Causes/Cost of Congestion […3]
• Cost of congestion
– Retransmission for dropped packets
26
Computer Networks (CS F303) BITS Pilani, Pilani Campus
Causes/Cost of Congestion [….4]
27
Computer Networks (CS F303) BITS Pilani, Pilani Campus
Causes/Cost of Congestion […..5]
29
Computer Networks (CS F303) BITS Pilani, Pilani Campus
TCP Congestion Control
• Approach
– Sending rate is a function of perceived congestion
30
Computer Networks (CS F303) BITS Pilani, Pilani Campus
TCP Congestion Control
32
Computer Networks (CS F303) BITS Pilani, Pilani Campus
FSM Description of TCP Congestion Control
33
Computer Networks (CS F303) BITS Pilani, Pilani Campus
Example: TCP Congestion Control
a) Identify the intervals of time when TCP slow start is
operating.
b) Identify the intervals of time when TCP congestion
avoidance is operating.
c) What is the ssthresh value between transmission round 7-
10?
d) What is the congestion window value at transmission round
11?
e) How many segments have been sent till transmission round
11? (including 11th transmission round)
f) Identify the intervals of time when TCP fast retransmission
and fast recovery is used?
34
Computer Networks (CS F303) BITS Pilani, Pilani Campus
TCP Sawtooth Behavior
Congestion
Window Timeouts
may still
occur
35
Computer Networks (CS F303) BITS Pilani, Pilani Campus
Congestion Control Objectives
36
Computer Networks (CS F303) BITS Pilani, Pilani Campus
Linear Control
• Many different possibilities for reaction to congestion and
probing
– Examine simple linear controls
– W(t + 1) = a + b*W(t)
– Different ai/bi for increase and ad/bd for decrease
Fairness Line
Overload
User 2’s
Allocation
x2 Optimal point
Underutilization
Efficiency Line
38
Computer Networks (CS F303) BITS Pilani, Pilani Campus
Additive Increase/Decrease
• Both X1 and X2 increase/decrease by the same amount over time
– The additive increase/decrease policy of increasing both users’ allocations by
aI corresponds to moving along a 450 line
Fairness Line
T1
User 2’s
Allocation T0
x2
Efficiency Line
Fairness Line
T1
User 2’s
Allocation
x2 T0
Efficiency Line
40
Computer Networks (CS F303) BITS Pilani, Pilani Campus
What is the Right Choice?
Fairness Line
x1
x0
User 2’s
Allocation
x2 x2
Efficiency Line
• Given the congestion control behavior of TCP can we predict what type
of performance we should get?
• Important factors which affect the performance:-
– Loss rate
• Affects how often window is reduced
– RTT
• Affects increase rate and relates BW to window
– RTO
• Affects performance during loss recovery
– MSS
• Affects increase rate
42
Computer Networks (CS F303) BITS Pilani, Pilani Campus
Simple TCP Model
• Some assumptions
– Fixed RTT
– No delayed ACKs
43
Computer Networks (CS F303) BITS Pilani, Pilani Campus
TCP Performance
TCP connection 1
bottleneck
router
capacity R
TCP connection 2
45
Computer Networks (CS F303) BITS Pilani, Pilani Campus
Fairness and UDP
46
Computer Networks (CS F303) BITS Pilani, Pilani Campus
Fairness and Parallel TCP Connections
47
Computer Networks (CS F303) BITS Pilani, Pilani Campus
TCP Fairness with different RTT
48
Computer Networks (CS F303) BITS Pilani, Pilani Campus
Goals for TCP Fairness and Throughput
49
Computer Networks (CS F303) BITS Pilani, Pilani Campus
Compound TCP Implementation
• Default TCP implementation in Windows 2008 TCP Stack
– Good for connections with large “bandwidth-delay” products
– Make congestion decisions that reduces the transmission rate based on RTT variations
• Key idea: split cwnd into two separate windows
• swnd = min(cwnd + dwnd, awnd)
– Cwnd (congestion window) is controlled by AIMD
– dwnd (delay window) is the delay window
• Rules for adjusting dwnd:
– If RTT is increasing, decrease dwnd (dwnd >= 0)
– If RTT is decreasing, increase dwnd
– Increase/decrease are proportional to the rate of change
50
Computer Networks (CS F303) BITS Pilani, Pilani Campus
Compound TCP Example
Faster
High Low
cwnd
RTT RTT
Slower growth
Timeout cwnd Timeout
growth
cwnd
Slow Start
Time
• Aggressiveness corresponds to changes in RTT
• +ive: fast ramp up, more fair to flows with different RTTs
• -ive: must estimate precise value of RTT, which is challenging 51
52
Computer Networks (CS F303) BITS Pilani, Pilani Campus
TCP CUBIC Example
Slowly accelerate to
CUBIC Function probe for bandwidth
Timeout cwndmax
cwnd
Stable
Slow Start Region
Fast ramp
up
Time
• Less wasted bandwidth due to fast ramp up
• Stable region and slow acceleration help maintain fairness
– Fast ramp up is more aggressive than additive increase
– To be fair to Tahoe/Reno, CUBIC needs to be less aggressive
53
Computer Networks (CS F303) BITS Pilani, Pilani Campus
TCP Congestion Control
54
Advanced Computer Networks CS G525 BITS Pilani, Pilani Campus
BBR Congestion Control
56
Advanced Computer Networks CS G525 BITS Pilani, Pilani Campus
Thank You
57
Computer Networks (CS F303) BITS Pilani, Pilani Campus
What’s Next…
• Network Layer
– Network layer service models (Internet and ATM)
– Forwarding versus Routing
– How a router works?
– IPv4 Datagram and Fragmentation
– IPv4 Addressing
• Hierarchical Addressing
• NAT, Sub Netting, IPv4 to IPv6 translation, ICMP
– Routing Algorithms and Protocols
• Inter-domain Routing and Intra-domain routing
– Multicast Routing
58
Computer Networks (CS F303) BITS Pilani, Pilani Campus
Silly Window Syndrome[.1]
59
Computer Networks (CS F303) BITS Pilani, Pilani Campus
Silly Window Syndrome[..2]
60
Computer Networks (CS F303) BITS Pilani, Pilani Campus
Nagle’s Algorithm
61
Computer Networks (CS F303) BITS Pilani, Pilani Campus
Computer Networks (CS F303)
BITS Pilani Virendra Singh Shekhawat
Department of Computer Science and Information Systems
Pilani Campus
What’s Next…
• Network Layer
– Network layer service models (Datagram, MPLS and ATM)
– Forwarding versus Routing
– How a router works?
– IPv4 Datagram and Fragmentation
– IPv4 Addressing
• Hierarchical Addressing
• NAT, Sub Netting, IPv4 to IPv6 translation, ICMP
– Routing Algorithms and Protocols
• Inter-domain Routing and Intra-domain routing
– Multicast Routing
2
Computer Networks (CS F303) BITS Pilani, Pilani Campus
Network layer
3
Computer Networks (CS F303) BITS Pilani, Pilani Campus
Network Layer Connection and Connection-less
Service
• Datagram network
– Network-layer connectionless service
• VC Network
– Network-layer connection service
application
application
transport
transport
network
data link 1. Send data 2. Receive data network
data link
physical
physical
5
Computer Networks (CS F303) BITS Pilani, Pilani Campus
IP Datagram Format
IP protocol version
number 32 bits total datagram
header length length (bytes)
ver head type of length
(bytes) len service for
“type” of data fragment fragmentation/
16-bit identifier flgs
offset reassembly
max number time to upper header
remaining hops live layer checksum Detect bit errors
(decremented at
32 bit source IP address In Datagram headers
each router)
32 bit destination IP address
upper layer protocol
to deliver payload to options (if any) e.g. timestamp,
record route
how much overhead? data taken, specify
(variable length, list of routers
20 bytes of TCP
typically a TCP to visit.
20 bytes of IP
or UDP segment)
= 40 bytes + app
layer overhead
6
Computer Networks (CS F303) BITS Pilani, Pilani Campus
IPv4 Addressing
7
Computer Networks (CS F303) BITS Pilani, Pilani Campus
Datagram Forwarding Table
routing algorithm 4 billion IP addresses, so
rather than list individual
destination address
local forwarding table list range of addresses
dest address output link (aggregate table entries)
address-range 1 3
address-range 2 2
address-range 3 2
address-range 4 1
IP destination address in
arriving packet’s header
1
3 2
8
Computer Networks (CS F303) BITS Pilani, Pilani Campus
Forwarding Table
otherwise 3
9
Computer Networks (CS F303) BITS Pilani, Pilani Campus
Longest prefix matching
10
Computer Networks (CS F303) BITS Pilani, Pilani Campus
IP Addressing [.1]
223.1.1.1 = 11011111 00000001 00000001 00000001
223.1.1.1
Q: How are interfaces actually
223.1.2.1
connected?
223.1.1.2
223.1.1.4 223.1.2.9
223.1.3.27
223.1.1.3
223.1.2.2
12
Computer Networks (CS F303) BITS Pilani, Pilani Campus
Subnets: Subnet Mask
223.1.1.0/24
223.1.2.0/24
223.1.1.1
223.1.1.2 223.1.2.1
223.1.1.4 223.1.2.9
223.1.2.2
223.1.1.3 223.1.3.27
subnet
223.1.3.1 223.1.3.2
223.1.3.0/24
13
223.1.1.1 223.1.1.4
223.1.1.3
223.1.9.2 223.1.7.0
223.1.9.1 223.1.7.1
223.1.8.1 223.1.8.0
223.1.2.6 223.1.3.27
14
Computer Networks (CS F303) BITS Pilani, Pilani Campus
Example: Subnetting
ISP's block 11001000 00010111 00010000 00000000 200.23.16.0/20
15
Computer Networks (CS F303) BITS Pilani, Pilani Campus
Hierarchical Addressing: Route Aggregation
Organization 0
200.23.16.0/23
Organization 1
“Send me anything
200.23.18.0/23 with addresses
Organization 2 beginning
200.23.20.0/23 . Fly-By-Night-ISP 200.23.16.0/20”
.
. . Internet
.
Organization 7 .
200.23.30.0/23
“Send me anything
ISPs-R-Us
with addresses
beginning
199.31.0.0/16”
16
Computer Networks (CS F303) BITS Pilani, Pilani Campus
Hierarchical Addressing: More Specific Routes
Organization 0
200.23.16.0/23
“Send me anything
with addresses
Organization 2 beginning
200.23.20.0/23 . Fly-By-Night-ISP 200.23.16.0/20”
.
. . Internet
.
Organization 7 .
200.23.30.0/23
“Send me anything
ISPs-R-Us
with addresses
Organization 1 beginning 199.31.0.0/16
or 200.23.18.0/23”
200.23.18.0/23
17
Computer Networks (CS F303) BITS Pilani, Pilani Campus
Exercise
18
Computer Networks (CS F303) BITS Pilani, Pilani Campus
Example: Different Size Subnets
19
Computer Networks (CS F303) BITS Pilani, Pilani Campus
Class full Addressing
20
Computer Networks (CS F303) BITS Pilani, Pilani Campus
What is Inside a Router?
• Forwarding/Switching a datagram
– The actual transfer of datagram from a router’s incoming links to the
appropriate outgoing links at the router
21
Computer Networks (CS F303) BITS Pilani, Pilani Campus
Router architecture overview
forwarding data
plane (hardware)
high-seed
switching
fabric
Physical layer:
bit-level reception
Decentralized switching:
Data link layer:
• Given datagram dest., lookup output port using
e.g., Ethernet forwarding table in input port memory
• Goal: complete input port processing at ‘line speed’
23
Computer Networks (CS F303) BITS Pilani, Pilani Campus
Router Architecture Overview
24
Computer Networks (CS F303) BITS Pilani, Pilani Campus
Switching Fabric [.1]
• Switching rate: rate at which packets can be transferred from
inputs to outputs
• N inputs: switching rate N times line rate is desirable
25
Computer Networks (CS F303) BITS Pilani, Pilani Campus
Switching Fabric [..2]
26
Computer Networks (CS F303) BITS Pilani, Pilani Campus
Input Ports
switch
switch
fabric
fabric
28
Computer Networks (CS F303) BITS Pilani, Pilani Campus
Output Ports
30
Computer Networks (CS F303) BITS Pilani, Pilani Campus
Computer Networks (CS F303)
BITS Pilani Virendra Singh Shekhawat
Department of Computer Science and Information Systems
Pilani Campus
What’s Next…
• Network Layer
– Network layer service models (Datagram, Virtual Circuit)
– Forwarding versus Routing
– How a router works?
– IPv4 Datagram and Fragmentation
– IPv4 Addressing
• Sub netting, Hierarchical Addressing
– NAT, IPv4 to IPv6 translation, ICMP
– Routing Algorithms and Protocols
• Inter-domain Routing and Intra-domain routing
– Multicast Routing
– Virtual Circuit Networks
• MPLS, ATM
2
Computer Networks (CS F303) BITS Pilani, Pilani Campus
What is Inside a Router?
• Forwarding/Switching a datagram
– The actual transfer of datagram from a router’s incoming links to the
appropriate outgoing links at the router
3
Computer Networks (CS F303) BITS Pilani, Pilani Campus
Router architecture overview
forwarding data
plane (hardware)
high-seed
switching
fabric
Physical layer:
bit-level reception
Decentralized switching:
Data link layer:
• Given datagram dest., lookup output port using
e.g., Ethernet forwarding table in input port memory
• Goal: complete input port processing at ‘line speed’
5
Computer Networks (CS F303) BITS Pilani, Pilani Campus
Router Architecture Overview
6
Computer Networks (CS F303) BITS Pilani, Pilani Campus
Switching Fabric [.1]
• Switching rate: rate at which packets can be transferred from
inputs to outputs
• N inputs: switching rate N times line rate is desirable
7
Computer Networks (CS F303) BITS Pilani, Pilani Campus
Switching Fabric [..2]
8
Computer Networks (CS F303) BITS Pilani, Pilani Campus
Input Ports
switch
switch
fabric
fabric
10
Computer Networks (CS F303) BITS Pilani, Pilani Campus
Output Ports
10.0.0.4
10.0.0.2
138.76.29.7
10.0.0.3
14
Computer Networks (CS F303) BITS Pilani, Pilani Campus
Facts about NAT
• NAT is controversial:
– Routers should only process up to layer 3
– Violates end-to-end argument
– Address shortage should instead be solved by IPv6
15
Computer Networks (CS F303) BITS Pilani, Pilani Campus
NAT Traversal Problem
16
Computer Networks (CS F303) BITS Pilani, Pilani Campus
Solutions [.1]
• Universal Plug and Play (UPnP) Internet Gateway Device (IGD) Protocol.
Allows NATed host to:
– Learn public IP address (138.76.29.7)
– e.g., BitTorrent application in the host asks NAT to create a hole that maps
(10.0.0.1,3345) to (138.76.29.7,5001)
– Add/remove port mappings (with lease times)
17
Computer Networks (CS F303) BITS Pilani, Pilani Campus
Solutions [..2]
18
Computer Networks (CS F303) BITS Pilani, Pilani Campus
IP Datagram Format
IP protocol version 32 bits
number total datagram
header length length (bytes)
ver head. type of length
(bytes) len service for
“type” of data fragment fragmentation/
16-bit identifier flgs
offset reassembly
max number time to upper header
remaining hops live layer checksum Detect bit errors
(decremented at
32 bit source IP address In Datagram headers
each router)
32 bit destination IP address
upper layer protocol
to deliver payload to options (if any) e.g. timestamp,
record route
how much overhead? data taken, specify
(variable length, list of routers
20 bytes of TCP
typically a TCP to visit.
20 bytes of IP
or UDP segment)
= 40 bytes + app
layer overhead
19
Computer Networks (CS F303) BITS Pilani, Pilani Campus
IP Fragmentation & Reassembly [.1]
fragmentation:
…
in: one large datagram
out: 3 smaller datagrams
reassembly
…
Computer Networks (CS F303)
20
BITS Pilani, Pilani Campus
IP Fragmentation & Reassembly [..2]
21
Computer Networks (CS F303) BITS Pilani, Pilani Campus
The Internet network layer
host, router network layer functions:
link layer
physical layer
22
Computer Networks (CS F303) BITS Pilani, Pilani Campus
How does a host get IP address?
Goal: allow host to dynamically obtain its IP address from network server when it joins
network
– Can renew its lease on address in use
– Allows reuse of addresses (only hold address while connected/“on”)
– Support for mobile users who want to join network (more shortly)
DHCP overview:
– Host broadcasts “DHCP discover” msg
– DHCP server responds with “DHCP offer” msg
– Host requests IP address: “DHCP request” msg
– DHCP server sends address: “DHCP ack” msg
24
Computer Networks (CS F303) BITS Pilani, Pilani Campus
DHCP Client-Server Scenario
DHCP
223.1.1.0/24
server
223.1.1.1 223.1.2.1
223.1.2.0/24
223.1.3.1 223.1.3.2
223.1.3.0/24
25
Computer Networks (CS F303) BITS Pilani, Pilani Campus
DHCP
DHCP server: 223.1.2.5 DHCP discover arriving
client
src : 0.0.0.0, 68
dest.: 255.255.255.255,67
yiaddr: 0.0.0.0
transaction ID: 654
DHCP offer
src: 223.1.2.5, 67
dest: 255.255.255.255, 68
yiaddrr: 223.1.2.4
transaction ID: 654
lifetime: 3600 secs
DHCP request
src: 0.0.0.0, 68
dest:: 255.255.255.255, 67
yiaddrr: 223.1.2.4
transaction ID: 655
lifetime: 3600 secs
DHCP ACK
src: 223.1.2.5, 67
dest: 255.255.255.255, 68
yiaddrr: 223.1.2.4
transaction ID: 655
lifetime: 3600 secs 26
Computer Networks (CS F303) BITS Pilani, Pilani Campus
IPv6 Motivation
27
Computer Networks (CS F303) BITS Pilani, Pilani Campus
IPv4 vs IPv6
Source: www.cisco.com 28
Computer Networks (CS F303) BITS Pilani, Pilani Campus
Transition from IPv4 to IPv6
IPv6 datagram
IPv4 datagram 29
Computer Networks (CS F303) BITS Pilani, Pilani Campus
Tunneling [.1]
A B IPv4 tunnel E F
connecting IPv6 routers
logical view:
IPv6 IPv6 IPv6 IPv6
A B C D E F
physical view:
IPv6 IPv6 IPv4 IPv4 IPv6 IPv6
30
Computer Networks (CS F303) BITS Pilani, Pilani Campus
Tunneling [..2]
A B IPv4 tunnel E F
connecting IPv6 routers
logical view:
IPv6 IPv6 IPv6 IPv6
A B C D E F
physical view:
IPv6 IPv6 IPv4 IPv4 IPv6 IPv6
data data
A-to-B: E-to-F:
IPv6 B-to-C: B-to-C: IPv6
IPv6 inside IPv6 inside 31
IPv4
Computer Networks (CS F303) IPv4 BITS Pilani, Pilani Campus
Dual Stack Approach
32
Computer Networks (CS F303) BITS Pilani, Pilani Campus
ICMP Protocol
• The Internet Control Message Protocol (ICMP) is a helper protocol that supports
IP with facility for
– Error reporting and Simple queries
– Used by hosts and routers to communicate network layer information to each other
• ICMP lies just above IP
– ICMP messages are encapsulated as IP datagrams bit # 0 7 8 15 16 23 24 31
33
Computer Networks (CS F303) BITS Pilani, Pilani Campus
ICMP Message Types
34
Computer Networks (CS F303) BITS Pilani, Pilani Campus
Traceroute and ICMP
Source sends series of UDP segments to dest When ICMP messages arrives,
first set has TTL =1 source records RTTs
second set has TTL=2, etc.
unlikely port number
Stopping criteria:
When nth set of datagrams arrives to nth UDP segment eventually arrives at
router: destination host
router discards datagrams Destination returns ICMP “port
unreachable” message (type 3, code 3)
and sends source ICMP messages (type 11, code 0)
Source stops
ICMP messages includes name of router & IP
address
3 probes 3 probes
3 probes 35
Computer Networks (CS F303) BITS Pilani, Pilani Campus
Routing
36
Computer Networks (CS F303) BITS Pilani, Pilani Campus
Routing Algorithm Taxonomy [.1]
38
Computer Networks (CS F303) BITS Pilani, Pilani Campus
Routing Abstraction
5
v 3 w
2 5
u 2 1 z
3
1 2
x 1
y
Graph: G = (N,E)
N = set of routers = { u, v, w, x, y, z }
E = set of links ={ (u,v), (u,x), (v,x), (v,w), (x,w), (x,y), (w,y), (w,z), (y,z) }
39
Computer Networks (CS F303) BITS Pilani, Pilani Campus
Dijsktra’s Algorithm
5
1 Initialization:
2 N' = {u} 3
3 for all nodes p v w
2 5
4 if p adjacent to u
5 then D(p) = c(u,p) u 2 1 z
3
6 else D(p) = ∞ 1
2
x y
7 Loop 1
8 find q not in N' such that D(q) is a minimum
9 add q to N'
10 update D(p) for all p adjacent to q and not in N' :
11 D(p) = min( D(p), D(q) + c(q,p) )
12 /* new cost to p is either old cost to p or known
shortest path cost to q plus cost from q to p */
13 until all nodes in N'
40
Computer Networks (CS F303) BITS Pilani, Pilani Campus
Link State Routing: Example
3
v w
2 5
u 2 1 z
3
1
2
x y
1
41
Computer Networks (CS F303) BITS Pilani, Pilani Campus
Route Oscillations
1
A 1+e A A A
2+e 0 0 2+e 2+e 0
D 0 0 B D 1+e 1 B D B D 1+e 1 B
0 0
0 e 0 0
1
C C 0 1
C 1+e C 0
1
e
given these costs, given these costs, given these costs,
initially find new routing…. find new routing…. find new routing….
resulting in new costs resulting in new costs resulting in new costs
42
Computer Networks (CS F303) BITS Pilani, Pilani Campus
OSPF Protocol
• “open”: publicly available
• Uses link state algorithm
– LS packet dissemination
– Topology map at each node
– Route computation using Dijkstra’s algorithm
• OSPF advertisement carries one entry per neighbor
• Advertisements flooded to entire AS
– Carried in OSPF messages directly over IP (rather than TCP or UDP)
– Link state broadcast and reliable message transfer must be implemented in the
OSPF itself
– Broadcasts LSA whenever there is a change in link’s state and also send
Periodic updates (after every 30 mints)
43
Computer Networks (CS F303) BITS Pilani, Pilani Campus
Hierarchical OSPF Routing
An AS can be configured hierarchically into areas. boundary router
Each area runs its own OSPF link state routing algorithm.
backbone router
backbone
area
border
routers
area 3
internal
routers
area 1
area 2
44
Computer Networks (CS F303) BITS Pilani, Pilani Campus
OSPF Messages
• HELLO
– To check whether links are operational or not
• Database Description
– contain descriptions of the topology of the AS or area
• Link State Request
– used by one router to request updated information about a portion of the Link
State Database Description (LSDB) from another router
• Link State Update
– contain information about an updated portion of the LSDB. These messages
are sent in response of a Link State Request message
• Link State Acknowledgement
– acknowledges a Link State Update message
45
Computer Networks (CS F303) BITS Pilani, Pilani Campus
Thank You!
46
Computer Networks (CS F303) BITS Pilani, Pilani Campus
Computer Networks (CS F303)
BITS Pilani Virendra Singh Shekhawat
Department of Computer Science and Information Systems
Pilani Campus
What’s Next…
• Network Layer
– Network layer service models (Datagram, Virtual Circuit)
– Forwarding versus Routing
– How a router works?
– IPv4 Datagram and Fragmentation
– IPv4 Addressing
• Sub netting, Hierarchical Addressing
– NAT, IPv4 to IPv6 translation, ICMP
– Routing Algorithms and Protocols
• Inter-domain Routing and Intra-domain routing
– Multicast Routing
– Virtual Circuit Networks
• MPLS, ATM
2
Computer Networks (CS F303) BITS Pilani, Pilani Campus
Routing
3
Computer Networks (CS F303) BITS Pilani, Pilani Campus
Routing Algorithm Taxonomy [.1]
5
Computer Networks (CS F303) BITS Pilani, Pilani Campus
Routing Abstraction
5
v 3 w
2 5
u 2 1 z
3
1 2
x 1
y
Graph: G = (N,E)
N = set of routers = { u, v, w, x, y, z }
E = set of links ={ (u,v), (u,x), (v,x), (v,w), (x,w), (x,y), (w,y), (w,z), (y,z) }
6
Computer Networks (CS F303) BITS Pilani, Pilani Campus
Dijsktra’s Algorithm
5
1 Initialization:
2 N' = {u} 3
3 for all nodes r v w
2 5
4 if r adjacent to u
5 then D(r) = c(u,r) u 2 1 z
3
6 else D(r) = ∞ 1
2
x y
7 Loop 1
8 find s not in N' such that D(s) is a minimum
9 add s to N'
10 update D(r) for all r adjacent to s and not in N' :
11 D(r) = min( D(r), D(s) + c(s,r) )
12 /* new cost to r is either old cost to r or known
least path cost to s plus cost from s to r */
13 until all nodes in N'
7
Computer Networks (CS F303) BITS Pilani, Pilani Campus
Link State Routing: Example
3
v w
2 5
u 2 1 z
3
1
2
x y
1
8
Computer Networks (CS F303) BITS Pilani, Pilani Campus
Route Oscillations
1
A 1+e A A A
2+e 0 0 2+e 2+e 0
D 0 0 B D 1+e 1 B D B D 1+e 1 B
0 0
0 e 0 0
1
C C 0 1
C 1+e C 0
1
e
given these costs, given these costs, given these costs,
initially find new routing…. find new routing…. find new routing….
resulting in new costs resulting in new costs resulting in new costs
9
Computer Networks (CS F303) BITS Pilani, Pilani Campus
OSPF Protocol
• “open”: publicly available
• Uses link state algorithm
– LS packet dissemination
– Topology map at each node
– Route computation using Dijkstra’s algorithm
• OSPF advertisement carries one entry per neighbor
• Advertisements flooded to entire AS
– Carried in OSPF messages directly over IP (rather than TCP or UDP)
– Link state broadcast and reliable message transfer must be implemented in the
OSPF itself
– Broadcasts LSA whenever there is a change in link’s state and also send
Periodic updates (after every 30 mints)
10
Computer Networks (CS F303) BITS Pilani, Pilani Campus
OSPF: Advanced Features
11
Computer Networks (CS F303) BITS Pilani, Pilani Campus
Hierarchical OSPF Routing
An AS can be configured hierarchically into areas. boundary router
Each area runs its own OSPF link state routing algorithm.
backbone router
backbone
area
border
routers
area 3
internal
routers
area 1
area 2
12
Computer Networks (CS F303) BITS Pilani, Pilani Campus
OSPF Messages
• HELLO
– To check whether links are operational or not
• Database Description
– contain descriptions of the topology of the AS or area
• Link State Request
– used by one router to request updated information about a portion of the Link
State Database Description (LSDB) from another router
• Link State Update
– contain information about an updated portion of the LSDB. These messages
are sent in response of a Link State Request message
• Link State Acknowledgement
– acknowledges a Link State Update message
13
Computer Networks (CS F303) BITS Pilani, Pilani Campus
OSPF Packet Format
14
Computer Networks (CS F303) BITS Pilani, Pilani Campus
Distance Vector (DV) Routing
• Distributed
– Node receives some information from
its one or more neighbors wait for (change in local link
cost or msg from neighbor)
• Iterative
– Process continues until no more
info is exchanged recompute estimates
• Asynchronous
if DV to any dest has
– Does not require nodes to operate
changed, notify neighbors
in lockstep manner
• Self terminating!
15
Computer Networks (CS F303) BITS Pilani, Pilani Campus
Distance Vector Routing Algorithm
5
3
dv(z) = 5, dx(z) = 3, dw(z) = 3
v w 5
2
u 2 1 z Cost of least cost path from u to z
3
1 2 du(z) = ???
x 1
y
17
Computer Networks (CS F303) BITS Pilani, Pilani Campus
Dx(y) = min{c(x,y) + Dy(y), c(x,z) + Dz(y)}
= min{2+0 , 7+1} = 2
from
from y ∞∞ ∞ y 2 0 1
z ∞∞ ∞ z 7 1 0
node y cost to
table x y z y
2 1
x ∞ ∞ ∞
x z
from
y 2 0 1 7
z ∞∞ ∞
node z cost to
table x y z
x ∞∞ ∞
from
y ∞∞ ∞
z 7 1 0
18
time
Computer Networks (CS F303) BITS Pilani, Pilani Campus
Dx(y) = min{c(x,y) + Dy(y), c(x,z) + Dz(y)}
= min{2+0 , 7+1} = 2
from
y ∞∞ ∞ y 2 0 1 = min{2+1 , 7+0} = 3
from
y 2 0 1
from
z ∞∞ ∞ z 7 1 0 z 3 1 0
node y cost to cost to cost to
table x y z x y z x y z y
2 1
x ∞ ∞ ∞ x 0 2 7 x 0 2 3 x z
from
y 2 0 1 from
y 2 0 1 y 2 0 1 7
from
z ∞∞ ∞ z 7 1 0 z 3 1 0
from
y 2 0 1 y 2 0 1
from
y ∞∞ ∞
z 7 1 0 z 3 1 0 z 3 1 0
19
time
Computer Networks (CS F303) BITS Pilani, Pilani Campus
Distance Vector: Link Cost Changes [.1]
Link cost changes: 1
Y
Node detects local link cost change 4 1
Updates the distance table X Z
If cost change in least cost path, notify neighbors 50
20
Computer Networks (CS F303) BITS Pilani, Pilani Campus
Distance Vector: Link Cost Changes [..2]
Link cost changes:
Bad news travels slow - “count to 60
infinity” problem! Y
4 1
X Z
50
21
Computer Networks (CS F303) BITS Pilani, Pilani Campus
Poisson Reverse and Split Horizon
• Split Horizon rule states that a route can't be advertised out of the
interface if the next hop for the advertised route is found on that
interface.
• Poison Reverse rule states that routes received via one interface
have to be advertised back out from that interface with an
unreachable metric
22
Computer Networks (CS F303) BITS Pilani, Pilani Campus
Split Horizon with Poisson Reverse
23
Computer Networks (CS F303) BITS Pilani, Pilani Campus
RIP ( Routing Information Protocol)
24
Computer Networks (CS F303) BITS Pilani, Pilani Campus
RIP Table processing
routed routed
Transprt Transprt
(UDP) (UDP)
network forwarding forwarding network
(IP) table table (IP)
link link
physical physical
25
Computer Networks (CS F303) BITS Pilani, Pilani Campus
RIP: Example
z
w x y
A D B
C
Destination Network Next Router Num. of hops to dest.
w A 2
y B 2
z B 7
x -- 1
…. …. ....
Routing table in D
26
Computer Networks (CS F303) BITS Pilani, Pilani Campus
RIP: Example
Dest Next hops
w - - Advertisement
x - - from A to D
z C 4
…. … ... z
w x y
A D B
C
Destination Network Next Router Num. of hops to dest.
w A 2
y B 2
z BA 75
x -- 1
…. …. ....
Routing table in D 27
Computer Networks (CS F303) BITS Pilani, Pilani Campus
RIP: Link Failure and Recovery
28
Computer Networks (CS F303) BITS Pilani, Pilani Campus
Weaknesses of RIP
• INFINITY defined as 15
– thus RIP cannot be used in networks where routes are more than 15 hops
29
Computer Networks (CS F303) BITS Pilani, Pilani Campus
Internet Routing System:
Two Tier
• Inter-domain routing: Between ASes
– Routing policies are based on business relationships
– No common metrics, and limited cooperation
– BGP: policy-based, path-vector routing protocol
• Intra-domain routing: Within an AS
– Shortest-path routing based on link metrics
– Routers are managed by a single institution
– OSPF and IS-IS: link-state routing protocol
– RIP and EIGRP: distance-vector routing protocol
30
Computer Networks (CS F303) BITS Pilani, Pilani Campus
Next…
• BGP
– ASes, Policies
– BGP Attributes
– BGP Path Selection
– I-BGP vs. E-GBP
31
Computer Networks (CS F303) BITS Pilani, Pilani Campus
The BIG Picture
32
Computer Networks (CS F303) BITS Pilani, Pilani Campus
Autonomous Systems (ASes)
• Autonomous system
– AS is an actual entity that participates in routing
– Has an unique 16 bit ASN (now 32 bit [RFC 4893 @ 2007]) assigned to it and
typically participates in inter-domain routing
• Examples:
– MIT: 3, CMU: 9
– AT&T: 7018, 6341, 5074, …
– UUNET: 701, 702, 284, 12199, …
– Sprint: 1239, 1240, 6211, 6242, …
33
Computer Networks (CS F303) BITS Pilani, Pilani Campus
Let’s Find out…
34
Computer Networks (CS F303) BITS Pilani, Pilani Campus
Interconnected ASes
3c
3a 2c
3b 2a
AS3 2b
1c AS2
1a 1b AS1
1d
Intra-AS Inter-AS
Routing Routing
algorithm algorithm
Forwarding
table
35
Computer Networks (CS F303) BITS Pilani, Pilani Campus
AS Categories [Stub/Multi-homed/Transit]
Traffic NEVER
flows from AS 2
through AS 1 to AS 3
AS 3
AS 2
AS 1
Traffic
AS 1 carries ONLY
flows from AS 2
local traffic
through AS 1 to AS 3
36
Computer Networks (CS F303) BITS Pilani, Pilani Campus
Inter-domain Routing in the Internet
37
Computer Networks (CS F303) BITS Pilani, Pilani Campus
Solution: Distance Vector with Path
38
Computer Networks (CS F303) BITS Pilani, Pilani Campus
BGP-4
• BGP = Border Gateway Protocol
• Is a Policy-Based routing protocol
• It is the EGP of today’s global Internet
• Relatively simple protocol, but configuration is complex
or withdrawing previously
announced routes.
AS2
41
Computer Networks (CS F303) BITS Pilani, Pilani Campus
Policy Decisions
• BGP provides capability for enforcing various policies
• Import policy
– What to do with routes learned from neighbors?
• Export policy
– What routes to be announced to neighbors?
42
Computer Networks (CS F303) BITS Pilani, Pilani Campus
Distributing Path Information
3c
3a
3b
AS3 2c other
1c 2a networks
other 1a 2b
networks 1b AS2
AS1 1d
43
Computer Networks (CS F303) BITS Pilani, Pilani Campus
Export Policy
44
Computer Networks (CS F303) BITS Pilani, Pilani Campus
How to implement export policies?
• BGP Attributes
– Local Preference
– AS-Path Length
– MED (Multi Exit Discriminator)
– NEXT-HOP
45
Computer Networks (CS F303) BITS Pilani, Pilani Campus
Local Preference
Local-pref = 100
Tier-2
Tier-3 Yale
46
Computer Networks (CS F303) BITS Pilani, Pilani Campus
NEXT-HOP
The next hop IP address that is going to be used to reach a certain destination.
3c
3a
3b
AS3 2c other
1c 2a networks
other 1a 2b
networks 1b AS2
AS1 1d
49
Computer Networks (CS F303) BITS Pilani, Pilani Campus
Internal BGP vs. External BGP
R1 E-BGP
AS1 AS2
R3 R4
R2
Subnet-2
50
Computer Networks (CS F303) BITS Pilani, Pilani Campus
Route Selection Process
51
Computer Networks (CS F303) BITS Pilani, Pilani Campus
Thank You!
52
Computer Networks (CS F303) BITS Pilani, Pilani Campus
Computer Networks
CS F303
Ashutosh Bhatia
Department of Computer Science and Information Systems
BITS Pilani Birla Institute of Technology and Science
Pilani|Dubai|Goa|Hyderabad Pilani Campus, Pilani
Data-Link Layer
• Frame-by-Frame next-hop delivery
– Frame: Block of data exchanged at link layer
• Uses services of PHY layer (which delivers bits) to
deliver frames
• Repetition code
– 0 -> 000; 1 -> 111
– m=1, k=2; n=3
– Hamming distance is 3, code rate is 1/3
• Can detect up to 2 errors and correct up to 1 error
• Error Detection
• Reliable Transfer (retransmissions)
• Error Correction
–E.g. Reed-Solomon codes, Convolution codes,
–Turbo codes
• T: 11001011000
?
BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956
Outline
• How to interconnect nodes? Network Topology
• How to mediate access among the nodes? Media Access
Control (MAC)
– Categorize and discuss some popular MAC protocols
• Overview, merits and demerits
• Specify:
– How to detect collisions?
– How to recover from collisions?
• Disadvantages:
– High load leads to too many collisions and wastage of
resources
• Throughput S = G * Ps
– Ps: probability that a frame is successful i.e. did not suffer
collision
• Determine Ps
– Under what conditions will a frame not suffer collision?
• Which of the following protocols does better in terms of channel utilization at high loads?
– Slotted aloha
– 1 persistent
– Non persistent
– 0.5 persistent
Ans. 25
• The propogation delay is 2 * 10^3/2*10^8 = 10us. RTT = 20us.
Bits that can be sent during 20us = 200 bits = 25 bytes.
Hence we need a frame size of at least 25 bytes.
Obtaining IP Addresses
Ashutosh Bhatia
Department of Computer Science and Information Systems
BITS Pilani Birla Institute of Technology and Science
Pilani|Dubai|Goa|Hyderabad Pilani Campus, Pilani
Problem Statement
• A feature of ARP
– Host H has an entry in its ARP cache for IP address X
– It receives an ARP request from IP address X for some
address Y
– Even though H does not reply to the ARP request, it updates
its ARP cache with X’s hardware address (contained in the
ARP Req)
– “Latest” hardware address is maintained
• After detecting that the primary server has failed, the backup
server
– Issues a gratuitous ARP request, with the primary server’s IP address and
its own hardware address
– Causes all machines to update their ARP cache entries, so that the
backup’s hardware address is noted