Computer Networks (2)
Computer Networks (2)
Dr. Gayathri M
Assistant professor
ECE Department
[email protected]
Syllabus
Unit 1
Introduction to the Internet - Services and Protocols, Edge and Core, Packet Switching vs. Circuit Switching - Performance Metrics Delay -
Loss – Throughput - Protocol Layers and Service Models OSI and TCP/IP models - Application Layer: Client-Server and Peer-to-Peer
architectures - Application Layer protocols - Transport Layer - Unreliable Connectionless vs. Reliable Connection-Oriented Services -
Multiplexing; Stop-and Wait - Go-Back-N and Selective-Repeat - UDP vs. TCP - Flow and Congestion Control.
Unit 2
Network Layer - Data plane forwarding vs. Control plane routing -Software Defined Networking (SDN) approach - Network Services -
Router architecture - Switching fabrics - Input and output queueing IPv4 and IPv6 addressing DHCP -NAT - IPv4 and IPv6 fragmentation -
SDN based generalized forwarding - Routing and Supporting Algorithms - Link State vs Distance Vector - RIP - OSPF – BGP – ICMP - SNMP -
SDN Control Plane.
Unit 3
Link Layer – Services - Error Detection and Correction; Multiple Access protocols Channel partitioning - Random access - Taking-Turns
protocols - Switched LANs ARP - Ethernet - Link layer switching – VLANs – MPLS - Introduction to Wireless and Mobile Networks - Link
characteristics - CDMA - 802.11 WiFi - Bluetooth and Zigbee - Cellular Networks - GSM – UMTS – LTE - Mobility management and handoff -
Mobile IP.
Text Book and References
• Text Book(s)
1. James Kurose and Keith Ross, “Computer Networking: A Top-Down Approach”, Seventh (Global) Edition, Pearson
Education Ltd., 2017.
2. Larry L. Peterson and Bruce S. Davie, “Computer Networks - A Systems Approach”, Morgan Kaufmann, Fifth Edition,
2011.
• Reference(s)
1. Brandon Rhodes, John Goerzen, “Foundations of Python Network Programming”, Third Edition, Apress, 2014.
2. Teerawat Issariyakul and Ekram Hossain, “Introduction to Network Simulator NS”2, Springer, Boston, MA, 2009.
Assessment
Component Marks
Quiz (2) 15
Assignment (1) 10
Attendance 05
Midterm Exam 30
Continuous Assessment Total 60
End Sem 40
QUIZ I - 27.01.2025
QUIZ II -10.03.2025
Assignment – [01.03.2024-07.03.2024]
1.1 what is the Internet
1.2 network edge
• end systems, access networks, links
1.3 network core
• packet switching, circuit switching, network structure
1.4 delay, loss, throughput in networks
Network
• A computer network is a collection of interconnected devices that share resources and
information. These devices can include computers, servers, printers, and other hardware.
Networks allow for the efficient exchange of data, enabling various applications such as email, file
sharing, and internet browsing.
Building blocks of CN
Basics building blocks of a Computer network are Nodes and Links
Nodes
• A node is any physical device within a LINKS
network of other tools that’s able to A link refers to The
send, receive, or forward information. transmission media connecting
A personal computer is the most two nodes, which can be
common node. It's called the computer physical (like cable wires or
node or internet node. optical fibers) or wireless
(used by WiFi)
• Nodes within a computer network
must have some form of identification,
like an IP address or MAC address, for
other network devices to recognize
them. A node without this information,
or one that's offline, no longer
functions as a node.
Basic Terminologies of Computer Networks
• Nodes: Nodes are devices that are connected to a
network. These can include computers, Servers,
Printers, Routers, Switches, and other devices.
• Protocol: A protocol is a set of rules and standards
that govern how data is transmitted over a network.
Examples of protocols include TCP/IP, HTTP, and FTP.
• Topology: Network topology refers to the physical
and logical arrangement of nodes on a network. The
common network topologies include bus, star, ring,
mesh, and tree.
• Service Provider Networks: These types of
Networks give permission to take Network Capacity
and Functionality on lease from the Provider. Service
Provider Networks include Wireless Communications,
Data Carriers, etc.
Basic Terminologies of Computer Networks
• IP Address: An IP address is a unique numerical identifier that is assigned to every device on a
network. IP addresses are used to identify devices and enable communication between them.
• DNS: The Domain Name System (DNS) is a protocol that is used to translate human-readable
domain names (such as www.google.com) into IP addresses that computers can understand.
• Firewall: A firewall is a security device that is used to monitor and control incoming and
outgoing network traffic. Firewalls are used to protect networks from unauthorized access and
other security threats.
Network Devices
• Network devices are physical devices that
allow hardware on a computer network to
communicate and interact with each other.
• NIC- Network Interface cards
• A network interface card (NIC) is a hardware
component without which a computer cannot
be connected over network. It is a circuit
board installed in a computer that provides a
dedicated network connection to the
computer
• it works on both the physical and data link
layers of the network model.
Network Devices
• Wireless Access Point •Hub
A Wireless Access Point (WAP) is a • A hub is a hardware device used at the physical
networking device that allows layer to connect multiple devices in the
connecting the devices with the network. Hubs are widely used to connect
wired network. A Wireless Access LANs. It cannot identify the destination of the
Point (WAP) is used to create the packet, So it broadcasts or sends the message
WLAN to each port.
• operates only on physical layers of the OSI
model.
Network Devices
• Switch
• Switch is a point-to-point communication
device. It operates at the data link layer and
advanced switch in network layer of OSI
model.
• It uses switching table to find out the
correct destination.
Network Devices
• Routers
• The router is a physical or virtual
internetworking device that is designed to
receive, analyze, and forward data packets
between computer networks.
• A router examines a destination IP address of a
given data packet, and it uses the headers and
forwarding tables to decide the best way to
transfer the packets.
• It shares information with other routers in
networking.
• A router works on the third layer (network
layer) of the OSI model, and it is based on the
IP address of a computer.
Difference
institutional
network
What’s a protocol?
human protocols: network protocols:
• “what’s the time?” ▪ machines rather than
humans
• “I have a question”
▪ all communication activity
• introductions
in Internet governed by
protocols
… specific messages sent
… specific actions taken when protocols define format, order of
messages received, or other messages sent and received
events among network entities, and
actions taken on message
transmission, receipt
What’s a protocol?
Network edge mobile network
global ISP
▪ network edge:
• hosts: clients and servers
home
• servers often in data centers network
regional ISP
▪ access networks, physical media:
wired, wireless communication links
▪ network core:
• interconnected routers
• network of networks institutional
• Two approach-Circuit Switching,Packet network
Switching
Access networks and physical media
Q: How to connect end systems to edge
router?
▪ residential access nets
▪ institutional access networks
(school, company)
▪ mobile access networks
keep in mind:
▪ bandwidth (bits per second)
of access network?
▪ shared or dedicated?
1-28
Network edge (End Systems)
• The computers connected to the Internet are often referred to as end systems.
• They are referred to as end systems because they sit at the edge of the Internet.
• End systems are also referred to as hosts because they host (that is, run) application programs
such as a Web browser program, a Web server program, an e-mail reader program, or an e-mail
server program.
• Hosts are sometimes further divided into two categories: clients and servers. Informally, clients
tend to be desktop and mobile PCs, PDAs, and so on, whereas servers tend to be more powerful
machines that store and distribute Web pages, stream video, relay e-mail, and so on.
• A client program is a program running on one end system that requests and receives a service
from a server program running on another end system.
• a client program typically runs on one computer and the server program runs on another
computer, client/server Internet applications are, by definition, distributed applications.
Access network: Digital Subscriber line (DSL)
A
Circuit Switching
• A dedicated path is established between sender and receiver.
• Before data transfer, At first connection will be established.
• Ex: Telephone network
frequency
time
TDM
frequency
time
Multiplexing in Circuit-Switched Networks
• FDM and TDM for a specific network link supporting up to four circuits or users.
• For FDM, the frequency domain is segmented into four bands, each of bandwidth 4 kHz.
• For TDM, the time domain is segmented into frames, with four time slots in each frame;
• Each circuit is assigned the same dedicated slot in the revolving TDM frames.
• For TDM, the transmission rate of a circuit is equal to the frame rate multiplied by the number of bits in a
slot.
• For example, if the link transmits 8,000 frames per second and each slot consists of 8 bits, then the
transmission rate of each circuit is 64 kbps
TDM
• The frame rate ensures how frequently data from each circuit is transmitted.
• The number of bits per slot determines the granularity of data transferred in each time interval.
Packet Switching
• mesh of interconnected routers
• packet-switching: hosts break application-layer
messages into packets
• forward packets from one router to the
next, across links on path from source to
destination
• each packet transmitted at full link capacity
Packet Switching - Datagram approach- Connectionless
Datagram forwarding: an example network.
R = 100 Mb/s C
A
D
R = 1.5 Mb/s
B
queue of packets E
waiting for output link
1-52
Two key network-core functions
routing: determines source-destination route taken by packets
▪ routing algorithms
forwarding: move
packets from routers
input to appropriate
router output
routing algorithm
In Packet switching, data is processed at all In-Circuit switching, data is processed at the source
intermediate nodes including the source system. system only.
The delay between data units in packet switching is The delay between data units in circuit switching is
not uniform. uniform.
In Packet Switching there is no physical path between In-Circuit Switching there is a physical path between
the source and the destination. the source and the destination.
Internet structure: network of networks
Question: given millions of access ISPs, how to connect them
together?
access access
net net
access
net
access
access net
net
access
access net
net
access access
net net
access
net
access
net
access
net
access
net
access access
net access net
net
1-57
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
1-58
Internet structure: network of networks
Option: connect each access ISP to one 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
1-59
Internet structure: network of networks
But if one global ISP is viable business, there will be competitors
….
access access
net net
access
net
access
access net
net
access
access net
net
ISP A
access
net ISP B access
net
access
net
ISP C
access
net
access
net
access
net
access access
net access net
net
1-60
Internet structure: network of networks
But if one global ISP is viable business, there will be competitors
…. which must be interconnected
access access
Internet exchange point
net net
access
net
access
access net
net
access
IXP access
net
net
ISP A
access
net
IXP ISP B access
net
access
net
ISP C
access
net
1-61
Internet structure: network of networks
… and regional networks may arise to connect access nets to
ISPs
access access
net net
access
net
access
access net
net
access
IXP access
net
net
ISP A
access
net
IXP ISP B access
net
access
net
ISP C
access
net
access
net regional net
access
net
access access
net access net
net
1-62
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
net
IXP ISP B access
net
access
net
ISP C
access
net
access
net regional net
access
net
access access
net access net
net
1-63
Internet structure: network of networks
POP: point-of-presence
to/from backbone
peering
… …
…
…
…
to/from customers
1.1 what is the Internet
1.2 network edge
• end systems, access networks, links
1.3 network core
• packet switching, circuit switching, network structure
1.4 delay, packet loss, throughput in networks
How do loss and delay occur?
packets queue in router buffers
▪ packet arrival rate to link (temporarily) exceeds output link
capacity
▪ packets queue, wait for turn
packet being transmitted (delay)
B
packets queueing (delay)
free (available) buffers: arriving packets
dropped (loss) if no free buffers
Four sources of packet delay
transmission
A propagation
B
nodal
processing queueing
B
nodal
processing queueing
100 km 100 km
1h12s
ten-car 12s
toll toll
caravan booth booth
buffer
(waiting area) packet being transmitted
A
B
packet arriving to
full buffer is lost
Throughput
• throughput: rate (bits/time unit) at which bits transferred between
sender/receiver
• instantaneous: rate at given point in time
• average: rate over longer period of time
server,
server withbits
sends linkpipe
capacity
that can carry linkpipe
capacity
that can carry
file of into
(fluid) F bitspipe Rs bits/sec
fluid at rate Rc bits/sec
fluid at rate
to send to client Rs bits/sec) Rc bits/sec)
Throughput (more)
• Rs < Rc What is average end-end throughput?
Rs bits/sec Rc bits/sec
Rs bits/sec Rc bits/sec
bottleneck link
link on end-end path that constrains end-end throughput
Throughput: Internet scenario
• per-connection end-end
throughput: min(Rc ,Rs,R/10)
Rs
• in practice: Rc or Rs is often
bottleneck Rs Rs
Throughput is the number of packets successfully transmitted
per unit time. It is controlled by available bandwidth, the
R
available signal-to-noise ratio, and hardware limitations.
Rc
• Define the model structure in the NED language. You can edit NED in a text editor or in the graphical editor of the Eclipse-
based OMNeT++ Simulation IDE.
• The active components of the model (simple modules) are programmed in C++, using the simulation kernel and class library.
C++ classes that represent protocol headers are described in MSG files which are then translated into C++ code.
• Provide a suitable omnetpp.ini file to hold OMNeT++ configuration and parameters to your model. One ini file may hold
several configurations which can build on one another, and may even contain parameter studies.
• Build the simulation program and run it. You’ll link the code with the OMNeT++ simulation kernel and one of the user
interfaces OMNeT++ provides. There are command line and interactive, graphical user interfaces.
• Simulation results are written into output vector and output scalar files. You can use the Analysis Tool powered by Pandas and
Matplotlib in the Simulation IDE to analyze and plot them. Event logs recorded from the simulation can be viewed in the
Sequence Chart Tool in the IDE. Result files are text-based, so you can also process them with R, Matlab or other tools.
Platforms
The OMNeT++ simulation kernel is standard C++, and runs basically on all platforms where a
modern C++ compiler is available. The Simulation IDE requires Windows, Linux, or macOS.
Frameworks
• INET is especially useful when designing and validating new protocols, or exploring new or exotic
scenarios.
• INET contains models for the Internet stack (TCP, UDP, IPv4, IPv6, OSPF, BGP, etc.), wired and
wireless link layer protocols (Ethernet, IEEE 802.11, etc), support for mobility, MANET protocols,
DiffServ, MPLS with LDP and RSVP-TE signalling, several application models, and many other
protocols and components.
• Several other simulation frameworks take INET as a base, and extend it into specific directions,
such as vehicular networks, overlay/peer-to-peer networks, or LTE.
• Simu5G is a simulator for 5G NewRadio and LTE/LTE-A networks for OMNeT++ and INET
frameworks.
• SimuLTE has been superseded by Simu5G, which contains support for both the LTE and 5G
protocol stack.
• Veins - Vehicles in Network Simulation
Veins is an open source Inter-Vehicular Communication (IVC) simulation framework composed of
an event-based network simulator (OMNeT++) and a road traffic simulator (SUMO), using
cosimulation. Versions before 3.0 required INET or MiXiM, later versions can be used without these
frameworks.
• Artery - V2X simulation framework for ETSI ITS-G5
• Core4INET - Real-Time Ethernet protocols for INET
• FiCo4OMNeT - Fieldbus Communication (CAN, FlexRay)
• ANSA - Automated Network Simulation and Analysis
• RSPSIM - Reliable Server Pooling (RSerPool) Simulation
• OverSim - Overlay Network Simulation Framework
Protocol “layers”
Networks are complex,
with many “pieces”:
▪ hosts
▪ routers Question:
is there any hope of organizing
▪ links of various structure of network?
media
▪ applications …. or at least our discussion of
▪ protocols networks?
▪ hardware,
software
Organization of air travel
• a series of steps
Layering of airline functionality
airplane routing airplane routing airplane routing airplane routing airplane routing
•The protocols in this layer are again link dependent and further depend on the
actual transmission medium of the link (for example, twisted-pair copper wire,
single-mode fiber optics).
Link Layers
•The Internet’s network layer routes a datagram through a series of routers between the source and
destination.
•To move a packet from one node (host or router) to the next node in the route, the network layer
relies on the services of the link layer.
•In particular, at each node, the network layer passes the datagram down to the link layer, which delivers
the datagram to the next node along the route.
•At this next node, the link layer passes the datagram up to the network layer.
•The services provided by the link layer depend on the specific link-layer protocol that is employed over
the link.
•For example, some link-layer protocols provide reliable delivery, from transmitting node, over one link, to
receiving node. Note that this reliable delivery service is different from the reliable delivery service of
TCP, which provides reliable delivery from one end system to another
•the link-layer packets as frames.
Network Layers
•The Internet’s network layer is responsible for moving network-layer packets known as datagrams from
one host to another.
•The Internet transport-layer protocol (TCP or UDP) in a source host passes a transport-layer segment and a
destination address to the network layer, just as you would give the postal service a letter with a destination
address.
•The network layer then provides the service of delivering the segment to the transport layer in the
destination host.
•The Internet’s network layer includes the IP protocol, which defines the fields in the datagram as well as
how the end systems and routers act on these fields.
•There is only one IP protocol, and all Internet components that have a network layer must run the IP
protocol.
•The Internet’s network layer also contains routing protocols that determine the routes that datagrams take
between sources and destinations.
•The Internet has many routing protocols.
Transport Layers
•The Internet’s transport layer transports application-layer messages between application endpoints.
•In the Internet there are two transport protocols, TCP and UDP, either of which can transport
application layer messages. TCP provides a connection-oriented service to its applications.
•This service includes guaranteed delivery of application-layer messages to the destination and flow
control (that is, sender/receiver speed matching).
•TCP also breaks long messages into shorter segments and provides a congestion-control mechanism,
so that a source throttles its transmission rate when the network is congested.
•The UDP protocol provides a connectionless service to its applications.
•transport-layer packet as a segment.
Application Layers
• An application-layer protocol is distributed over multiple end systems, with the application in
one end system using the protocol to exchange packets of information with the application in
another end system.
• We’ll refer to this packet of information at the application layer as a message.
• HTTP
• SMTP
• FTP
Internet protocol stack
• application: supporting network applications
• FTP, SMTP, HTTP
• transport: process-process data transfer
• TCP, UDP
• network: routing of datagrams from source to destination
• IP, routing protocols
• link: data transfer between neighboring network elements
• Ethernet, 802.111 (WiFi), PPP
• physical: bits “on the wire”
ISO/OSI reference model
• presentation: allow applications to interpret
meaning of data, e.g., encryption, compression,
machine-specific conventions application
• session: synchronization, checkpointing, presentation
recovery of data exchange
• Internet stack “missing” these layers! session
• these services, if needed, must be transport
implemented in application
network
link
physical
TCP/IP models
• The TCP/IP model is a fundamental framework
for computer networking.
• It stands for Transmission Control
Protocol/Internet Protocol, which are the core
protocols of the Internet.
• This model defines how data is transmitted over
networks, ensuring reliable communication
between devices.
• It consists of four layers: the Link Layer, the
Internet Layer, the Transport Layer, and the
Application Layer
• Each layer has specific functions that help manage
different aspects of network communication,
making it essential for understanding and working
with modern networks.
FTP- File Transfer Protocol
SMTP- Simple Mail Transfer Protocol
DNS- Domain Name System
RIP- Routing Information Protocol
SNMP- Simple Network Management Protocol
TCP- Transmission Control Protocol
UDP- User Datagram Protocol
ARP - Address Resolution Protocol
IGMP- Internet Group Management Protocol
ICMP -Internet Control Message Protocol
ATM -Asynchronous Transfer Mode
Differences between the OSI and TCP/IP model
OSI Model TCP/IP Model
It stands for Open System Interconnection. It stands for Transmission Control Protocol.
OSI model has been developed by ISO (International It was developed by ARPANET (Advanced Research
Standard Organization). Project Agency Network).
It consists of standard protocols that lead to the
It is an independent standard and generic protocol
development of an internet. It is a communication
used as a communication gateway between the
protocol that provides the connection among the
network and the end user.
hosts.
In this model, the session and presentation layer are
In this model, the session and presentation layers are
not different layers. Both layers are included in the
separated, i.e., both the layers are different.
application layer.
The network layer provides only connectionless
In this model, the network layer provides both
service.
connection-oriented and connectionless service.
It provides standardization to the devices like router, It does not provide the standardization to the devices.
motherboard, switches, and other hardware devices. It provides a connection between various computers.
Similarities between the OSI and TCP/IP model
Share common architecture
Both the models are the logical models and having similar architectures as both the models are
constructed with the layers.
Define standards
Both the layers have defined standards, and they also provide the framework used for implementing
the standards and devices.
Simplified troubleshooting process
Both models have simplified the troubleshooting process by breaking the complex function into
simpler components.
Pre-defined standards
The standards and protocols which are already pre-defined; these models do not redefine them;
they just reference or use them. For example, the Ethernet standards were already defined by the
IEEE before the development of these models; instead of recreating them, models have used these
pre-defined standards.
message M
source
application
Encapsulation
segment 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 Hl Hn Ht M link Hn Ht M
Ht M transport physical
Hn Ht M network
Hl Hn Ht M link router
physical
M -text, a file
Ht-source and destination port,sequence numbers,
numbers, and it breaks the message into smaller
segments if necessary
Hn - logical addressing information, such as IP addresses,
and is used for routing.
2-104
Creating a network app application
transport
network
data link
physical
write programs that:
• run on (different) end systems
• communicate over network
• e.g., web server software communicates
with browser software
no need to write software for network-core devices
application
applications
data link application
physical transport
network
2-105
Application architectures
possible structure of applications:
• client-server
• peer-to-peer (P2P)
2-106
Client-server architecture
server:
• always-on host
• permanent IP address
• data centers for scaling
clients:
• communicate with server
client/server • may be intermittently
connected
• may have dynamic IP
addresses
• do not communicate directly
with each other
2-108
P2P architecture
• no always-on server peer-peer
• arbitrary end systems directly
communicate
• peers request service from
other peers, provide service
in return to other peers
• self scalability – new peers bring
new service capacity, as well as
new service demands
• peers are intermittently
connected and change IP
addresses
• complex management
Processes communicating
process: program running within a host
• within same host, two processes communicate using inter-process
communication (defined by OS)
• processes in different hosts communicate by exchanging messages
clients, servers
client process: process that
initiates communication ▪ aside: applications with P2P
architectures have client processes
server process: process that
& server processes
waits to be contacted
2-110
Sockets
• process sends/receives messages to/from its socket
• socket analogous to door
• sending process shoves message out door
• sending process relies on transport infrastructure on other side of door
to deliver message to socket at receiving process
application application
socket controlled by
process process app developer
transport transport
network network controlled
link by OS
link Internet
physical physical
Multiplexing/demultiplexing-Addressing processes
multiplexing at sender:
handle data from multiple demultiplexing at receiver:
sockets, add transport header use header info to deliver
(later used for demultiplexing) received segments to correct
socket
Src=2.2.2.2 Port=55
Dst IP = 1.1.1.1 Port = 15
Addressing processes
• identifier includes both IP address and • to receive messages, process must
port numbers associated with have identifier
process on host.
• host device has unique 32-bit IP
• example port numbers: address
• HTTP server: 80
• mail server: 25
• to send HTTP message to
gaia.cs.umass.edu web server:
• IP address: 128.119.245.12
• port number: 80
• more shortly…
App-layer protocol defines
• types of messages exchanged, open protocols:
• e.g., request, response • defined in RFCs
• message syntax: • allows for interoperability
• what fields in messages & how fields are delineated
• e.g., HTTP, SMTP
• message semantics
• meaning of information in fields ex.404 proprietary protocols:
• rules for when and how processes send & • e.g., Skype
respond to messages
ex: Handshake protocol
What transport service does an app need?
data integrity throughput
▪ some apps (e.g., file transfer, ▪ some apps (e.g.,
web transactions) require 100% multimedia) require
reliable data transfer minimum amount of
▪ other apps (e.g., audio) can throughput to be
tolerate some loss “effective”
▪ other apps (“elastic apps”)
timing
make use of whatever
• some apps (e.g., Internet telephony, throughput they get
interactive games) require low
delay to be “effective” security
▪ encryption, data integrity,
…
2-115
2-116
File distribution time: client-server
• server transmission: must sequentially send (upload) N file copies:
• time to send one copy: F/us
F
• time to send N copies: NF/us us
di
network
ui
time to distribute F
to N clients using
client-server approach Dc-s > max{NF/us,,F/dmin}
increases linearly in N
2-117
• Us : Server upload bandwidth
• Ui : peer i upload bandwidth
• di: peer i download bandwidth
time to distribute F
to N clients using
P2P approach
DP2P > max{F/us,,F/dmin,,NF/(us + ui)}
increases linearly in N …
… but so does this, as each peer brings service capacity
2-119
• Us : Server upload bandwidth
• Ui : peer i upload bandwidth
• di: peer i download bandwidth
3.5
P2P
1.5
0.5
0
0 5 10 15 20 25 30 35
N
2-121
P2P file distribution: BitTorrent
▪ file divided into 256Kb chunks
▪ peers in torrent send/receive file chunks
Alice arrives …
… obtains list
of peers from tracker
… and begins exchanging
file chunks with peers in torrent
2-122
P2P file distribution: BitTorrent
• peer joining torrent:
• has no chunks, but will accumulate
them over time from other peers
• registers with tracker to get list of
peers, connects to subset of peers
(“neighbors”)
2-123
BitTorrent: requesting, sending file chunks
requesting chunks:
sending chunks: tit-for-tat
▪ at any given time, different peers ▪ Alice sends chunks to those
have different subsets of file chunks four peers currently sending her
▪ periodically, Alice asks each peer for chunks at highest rate
• other peers are choked by Alice
list of chunks that they have (do not receive chunks from her)
▪ Alice requests missing chunks from • re-evaluate top 4 every10 secs
peers, rarest first ▪ every 30 secs: randomly select
another peer, starts sending
chunks
• “optimistically unchoke” this peer
• newly chosen peer may join top 4
2-124
BitTorrent: tit-for-tat
(1) Alice “optimistically unchokes” Bob
(2) Alice becomes one of Bob’s top-four providers; Bob reciprocates
(3) Bob becomes one of Alice’s top-four providers
2-125
• Application layer protocol-HTTP,SMTP,DNS
HTTP overview
HTTP: hypertext transfer protocol
• Web’s application layer
protocol
• client/server model PC running
Firefox browser
• client: browser that requests,
receives, (using HTTP
protocol) and “displays”
Web objects
• server: Web server sends server
(using HTTP protocol) running
objects in response to Apache Web
requests server
iPhone running
Safari browser
2-127
HTTP overview (continued)
uses TCP: HTTP is “stateless”
▪ client initiates TCP • server maintains no
connection (creates socket) information about past
to server, port 80 client requests
▪ server accepts TCP
connection from client aside
protocols that maintain
▪ HTTP messages (application- “state” are complex!
layer protocol messages) ▪ past history (state) must be
exchanged between browser maintained
(HTTP client) and Web ▪ if server/client crashes, their
server (HTTP server) views of “state” may be
inconsistent, must be
▪ TCP connection closed reconciled
2-128
HTTP connections
persistent HTTP
non-persistent HTTP
• multiple objects can be sent over
• at most one object sent over TCP single TCP connection between
connection client, server
• connection then closed
• downloading multiple objects required
multiple connections
2-129
2-130
3-160
Internet transport-layer protocols
• reliable, in-order delivery (TCP) application
transport
network
• congestion control data link
physical
• flow control network
network
data link
• connection setup data link
physical
physical
network
• unreliable, unordered delivery: UDP data link
physical
3-161
Multiplexing/demultiplexing
multiplexing at sender:
handle data from multiple demultiplexing at receiver:
sockets, add transport header use header info to deliver
(later used for demultiplexing) received segments to correct
socket
application
3-162
Connectionless demultiplexing
▪ DatagramSocket mySocket1 ▪ When creating datagram to
= new send into UDP socket,
DatagramSocket(12534);
must specify
• destination IP address
• destination port #
3-163
Connectionless demux: example
DatagramSocket
DatagramSocket serverSocket = new
mySocket2 = new DatagramSocket DatagramSocket
DatagramSocket (6428); mySocket1 = new
(9157); DatagramSocket
application
(5775);
application application
P1
P3 P4
transport
transport transport
network
network link network
link physical link
physical physical
3-165
Connection-oriented demux: example-Multiplexing/demultiplexing-Addressing processes
multiplexing at sender:
handle data from multiple demultiplexing at receiver:
sockets, add transport header use header info to deliver
(later used for demultiplexing) received segments to correct
socket
Src=2.2.2.2 Port=55
Dst IP = 1.1.1.1 Port = 15
Internet transport protocols services
UDP service:
TCP service:
• reliable transport between sending ▪ unreliable data transfer
and receiving process between sending and
receiving process
• flow control: sender won’t
overwhelm receiver ▪ does not provide: reliability,
• congestion control: throttle sender flow control, congestion
when network overloaded control, timing, throughput
guarantee, security, or
• does not provide: timing, minimum
throughput guarantee, security connection setup,
• connection-oriented: setup required
between client and server
processes
2-167
Principles of reliable data transfer
▪ important in application, transport, link layers
3-168
Reliable data transfer: getting started
rdt_send(): called from above, deliver_data(): called by
(e.g., by app.). Passed data to rdt to deliver data to upper
deliver to receiver upper layer
send receive
side side
3-169
Reliable data transfer: getting started
• 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
3-170
rdt1.0: reliable transfer over a reliable channel
▪ underlying channel perfectly reliable
• no bit errors
• no loss of packets, no out of order
▪ separate FSMs for sender, receiver:
• sender sends data into underlying channel
• receiver reads data from underlying channel
sender receiver
3-171
rdt2.0: channel with bit errors
▪ underlying channel may flip bits in packet
• checksum to detect bit errors
▪ the question: how to recover from errors:
• acknowledgements (ACKs): receiver
explicitly tells sender that pkt BIT error only
received OK
• negative acknowledgements (NAKs): A checksum is a value used to verify the integrity of data
receiver explicitly tells sender that during transmission or storage. It is a mathematical summary of
pkt had errors
a set of data, calculated using an algorithm. The checksum allows
• sender retransmits pkt on receipt of
NAK the receiver to detect errors in the data caused by corruption,
transmission errors, or hardware issues.
▪ new mechanisms in rdt2.0 (beyond
rdt1.0):
• error detection
• receiver feedback: control msgs
(ACK,NAK) rcvr->sender
rdt2.0: FSM specification
rdt_send(data)
sndpkt = make_pkt(data, checksum) receiver
udt_send(sndpkt)
rdt_rcv(rcvpkt) &&
isNAK(rcvpkt)
Wait for Wait for rdt_rcv(rcvpkt) &&
call from ACK or udt_send(sndpkt) corrupt(rcvpkt)
above NAK
udt_send(NAK)
rdt_rcv(rcvpkt) &&
notcorrupt(rcvpkt)
extract(rcvpkt,data)
deliver_data(data)
udt_send(ACK)
rdt2.0: operation with no errors
rdt_send(data)
snkpkt = make_pkt(data, checksum)
udt_send(sndpkt)
rdt_rcv(rcvpkt) &&
isNAK(rcvpkt)
Wait for Wait for rdt_rcv(rcvpkt) &&
call from ACK or udt_send(sndpkt) corrupt(rcvpkt)
above NAK
udt_send(NAK)
rdt_rcv(rcvpkt) &&
notcorrupt(rcvpkt)
extract(rcvpkt,data)
deliver_data(data)
udt_send(ACK)
rdt2.0: error scenario
rdt_send(data)
snkpkt = make_pkt(data, checksum)
udt_send(sndpkt)
rdt_rcv(rcvpkt) &&
isNAK(rcvpkt)
Wait for Wait for rdt_rcv(rcvpkt) &&
call from ACK or udt_send(sndpkt) corrupt(rcvpkt)
above NAK
udt_send(NAK)
rdt_rcv(rcvpkt) &&
notcorrupt(rcvpkt)
extract(rcvpkt,data)
deliver_data(data)
udt_send(ACK)
rdt2.0 has a fatal flaw! handling duplicates:
• sender retransmits current
what happens if ACK/NAK corrupted? pkt if ACK/NAK corrupted
• sender doesn’t know what happened at receiver! • sender adds sequence
• can’t just retransmit: possible duplicate number to each pkt
• receiver discards (doesn’t
deliver up) duplicate pkt
extract(rcvpkt,data)
deliver_data(data)
sndpkt = make_pkt(ACK, chksum)
udt_send(sndpkt)
rdt2.1: discussion receiver:
▪ must check if received packet is duplicate
sender: • state indicates whether 0 or 1 is
expected pkt seq #
• seq # added to pkt
▪ note: receiver can not know if its last
• two seq. #’s (0,1) will suffice. Why? ACK/NAK received OK at sender
• must check if received ACK/NAK corrupted
• twice as many states
• state must “remember” whether “expected” pkt should have seq # of 0 or 1
rdt2.2: NAK-free protocol
▪ same functionality as rdt2.1, using ACKs only
▪ instead of NAK, receiver sends ACK for last pkt received OK
• receiver must explicitly include seq # of pkt being ACKed
▪ duplicate ACK at sender results in same action as NAK: retransmit current pkt
▪ If we send P0 and P1 (0,1)
▪ Received correctly P0,P1>>Ack0,Ack1
rdt2.2: sender, receiver fragments
rdt_send(data)
sndpkt = make_pkt(0, data, checksum)
udt_send(sndpkt)
rdt_rcv(rcvpkt) &&
( corrupt(rcvpkt) ||
Wait for Wait for
ACK isACK(rcvpkt,1) )
call 0 from
above 0 udt_send(sndpkt)
sender FSM
fragment rdt_rcv(rcvpkt)
&& notcorrupt(rcvpkt)
rdt_rcv(rcvpkt) && && isACK(rcvpkt,0)
(corrupt(rcvpkt) ||
has_seq1(rcvpkt)) Wait for receiver FSM
0 from
udt_send(sndpkt) below fragment
rdt_rcv(rcvpkt) && notcorrupt(rcvpkt)
&& has_seq1(rcvpkt)
extract(rcvpkt,data)
deliver_data(data)
sndpkt = make_pkt(ACK1, chksum)
udt_send(sndpkt)
rdt3.0: channels with errors and loss
approach: sender waits
new assumption: underlying channel can also lose “reasonable” amount of time for
packets (data, ACKs) ACK
• checksum, seq. #, ACKs, retransmissions will be
of help … but not enough • retransmits if no ACK
received in this time
• if pkt (or ACK) just delayed
(not lost):
• retransmission will be
duplicate, but seq. #’s already
handles this
• receiver must specify seq # of
pkt being ACKed
• requires countdown timer
rdt3.0 sender
rdt_send(data)
rdt_rcv(rcvpkt) &&
sndpkt = make_pkt(0, data, checksum) ( corrupt(rcvpkt) ||
udt_send(sndpkt) isACK(rcvpkt,1) )
rdt_rcv(rcvpkt) start_timer
Wait for Wait
for timeout
call 0from
ACK0 udt_send(sndpkt)
above
start_timer
rdt_rcv(rcvpkt)
&& notcorrupt(rcvpkt) rdt_rcv(rcvpkt)
&& isACK(rcvpkt,1) && notcorrupt(rcvpkt)
stop_timer && isACK(rcvpkt,0)
stop_timer
Wait Wait for
timeout for call 1 from
udt_send(sndpkt) ACK1 above
start_timer rdt_rcv(rcvpkt)
rdt_send(data)
rdt_rcv(rcvpkt) &&
( corrupt(rcvpkt) || sndpkt = make_pkt(1, data, checksum)
isACK(rcvpkt,0) ) udt_send(sndpkt)
start_timer
rdt3.0 in action
sender receiver sender receiver
send pkt0 pkt0 send pkt0 pkt0
rcv pkt0 rcv pkt0
ack0 send ack0 ack0 send ack0
rcv ack0 rcv ack0
send pkt1 pkt1 send pkt1 pkt1
rcv pkt1 X
ack1 send ack1 loss
rcv ack1
send pkt0 pkt0
rcv pkt0 timeout
ack0 send ack0 resend pkt1 pkt1
rcv pkt1
ack1 send ack1
rcv ack1
send pkt0 pkt0
(a) no loss rcv pkt0
ack0 send ack0
L 8000 bits
Dtrans = R = = 8 microsecs
109 bits/sec
U L/R .008
sender = = = 0.00027
RTT + L / R 30.008
U L/R .008
sender = = = 0.00027
RTT + L / R 30.008
Pipelined Protocol
• GO-BACK
• Selective ARQ
Pipelined protocols
pipelining: sender allows multiple, “in-flight”, yet-to-be-acknowledged pkts
• range of sequence numbers must be increased
• buffering at sender and/or receiver
U 3L / R .0024
sender = = = 0.00081
RTT + L / R 30.008
Pipelined protocols: overview
Selective Repeat:
Go-back-N:
• sender can have up to N unack’ed
• sender can have up to N unacked packets in pipeline packets in pipeline
• receiver only sends cumulative ack • rcvr sends individual ack for each
• Doesn’t ack packet if there’s a gap packet
• sender has timer for oldest unacked packet
• when timer expires, retransmit all unacked packets
• sender maintains timer for each
unacked packet
• when timer expires, retransmit
only that unacked packet
GBN in action
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
Go-Back-N: sender
• k-bit seq # in pkt header
• “window” of up to N, consecutive unack’ed pkts allowed
ACK-only: always send ACK for correctly-received pkt with highest in-order seq #
• may generate duplicate ACKs
• need only remember expectedseqnum
• out-of-order pkt:
• discard (don’t buffer): no receiver buffering!
• re-ACK pkt with highest in-order seq #
Selective repeat
• receiver individually acknowledges all correctly received pkts
• buffers pkts, as needed, for eventual in-order delivery to upper layer
• sender only resends pkts for which ACK not received
• sender timer for each unACKed pkt
• sender window
• N consecutive seq #’s
• limits seq #s of sent, unACKed pkts
Selective repeat in action
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
X
• window size=3 0123012
pkt0 will accept packet
with seq number 0
(a) no problem
▪ receiver sees no receiver can’t see sender side.
difference in two receiver behavior identical in both cases!
scenarios! something’s (very) wrong!
▪ duplicate data 0123012 pkt0
accepted as new in (b) 0123012 pkt1 0123012
0123012 pkt2 0123012
X 0123012
Q: what relationship X
between seq # size timeout
retransmit pkt0 X
and window size to 0123012 pkt0
will accept packet
avoid problem in (b)? with seq number 0
(b) oops!
Selective repeat: sender, receiver windows
Selective repeat
sender
data from above: receiver
▪ if next available seq # in window, pkt n in [rcvbase, rcvbase+N-1]
send pkt ▪ send ACK(n)
timeout(n): ▪ out-of-order: buffer
▪ in-order: deliver (also
▪ resend pkt n, restart timer deliver buffered, in-order
ACK(n) in [sendbase,sendbase+N]: pkts), advance window to
next not-yet-received pkt
▪ mark pkt n as received
▪ if n smallest unACKed pkt, advance
pkt n in [rcvbase-N,rcvbase-1]
window base to next unACKed seq ▪ ACK(n)
# otherwise:
▪ ignore
TCP Flow control
TCP flow control
application
application may process
remove data from application
TCP socket buffers ….
TCP socket OS
receiver buffers
… slower than TCP
receiver is delivering
(sender is sending) TCP
code
IP
flow control code
receiver controls sender, so
sender won’t overflow
receiver’s buffer by transmitting from sender
too much, too fast
receiver protocol stack
TCP flow control
• receiver “advertises” free buffer
space by including rwnd(Receiver-
Advertised window)value in TCP to application process
header of receiver-to-sender segments
• RcvBuffer size set via socket options
(typical default is 4096 bytes) RcvBuffer buffered data
• many operating systems autoadjust
RcvBuffer rwnd free buffer space
• sender limits amount of unacked (“in-
flight”) data to receiver’s rwnd
value TCP segment payloads
• guarantees receive buffer will not
overflow receiver-side buffering
TCP- Connection oriented protocol-Connection
Management
before exchanging data, sender/receiver “handshake”:
• agree to establish connection (each knowing the other willing to establish
connection)
• agree on connection parameters
application application
network network
Socket clientSocket = Socket connectionSocket =
newSocket("hostname","port welcomeSocket.accept();
number");
Agreeing to establish a connection
2-way handshake:
Q: will 2-way handshake always work
in network?
• variable delays
Let’s talk
ESTAB • retransmitted messages (e.g.
OK
ESTAB req_conn(x)) due to message
loss
• message reordering
• can’t “see” other side
choose x
req_conn(x)
ESTAB
acc_conn(x)
ESTAB
Agreeing to establish a connection
2-way handshake failure scenarios:
choose x choose x
req_conn(x) req_conn(x)
ESTAB ESTAB
retransmit acc_conn(x) retransmit acc_conn(x)
req_conn(x) req_conn(x)
ESTAB ESTAB
data(x+1) accept
req_conn(x)
retransmit data(x+1)
data(x+1)
connection connection
client x completes server x completes server
client
terminates forgets x terminates forgets x
req_conn(x)
accept
ESTAB ESTAB data(x+1)
data(x+1)
half open connection!
(no client!)
TCP 3-way handshake
Socket connectionSocket =
welcomeSocket.accept();
Socket clientSocket =
SYN(x) newSocket("hostname","port
number");
SYNACK(seq=y,ACKnum=x+1)
create new socket for SYN(seq=x)
communication back to client listen
SYN SYN
rcvd sent
SYNACK(seq=y,ACKnum=x+1)
ESTAB ACK(ACKnum=y+1)
ACK(ACKnum=y+1)
TCP: closing a connection
▪ client, server each close their side of connection
• send TCP segment with FIN bit = 1
▪ respond to received FIN with ACK
• on receiving FIN, ACK can be combined with own FIN
▪ simultaneous FIN exchanges can be handled
TCP: closing a connection
client state server state
ESTAB ESTAB
clientSocket.close()
FIN_WAIT_1 can no longer FINbit=1, seq=x
send but can
receive data CLOSE_WAIT
ACKbit=1; ACKnum=x+1
can still
FIN_WAIT_2 wait for server send data
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