You are on page 1of 172

Data Communication

Components

Data Representation

Direction of Data Flow


Five components of data communication
Simplex
Half-duplex
Full-duplex
Networks

Distributed Processing

Network Criteria

Physical Structures

Categories of Networks
Point-to-point connection
Multipoint connection
Categories of topology
Figure 1.8 Fully connected mesh topology (for five devices)
Mesh.
• A network that uses a mesh topology provides a direct connection
between each pair of computers. The chief disadvantage of a mesh
arises from the cost: a mesh network connecting n computers
requires :

• The important point is that the number of connections needed for a


mesh network grows faster than the number of computers. Because
connections are expensive, few LANs employ a mesh topology.
Mesh Topology
• Every Link carries its own • Large amount of cabling.
data avoids traffic • No. of I/O ports requird
problems. are more (N-1).
• Robust as alternative • Installation and
path is available Reconnection are difficult
• Privacy & Security as (scalability).
dedicated link is there • Expensive.
only desired user can see • In a limited application or
the message very good for to be used
• Troubleshooting is easy as backbone.
Star topology

A network uses a star topology when all computers attach to a central point.
Because a star-shaped network resembles the spokes of a wheel, the
center of a star network is often called a hub. A typical hub consists of an
electronic device that accepts data from a sending computer and delivers it
to the appropriate destination. In practice, star networks seldom have a
symmetric shape in which the hub is located an equal distance from all
computers. Instead, a hub often resides in a location separate from the
computers attached to it. For example, computers can reside in individual
offices, while the hub resides in a location accessible to an organization’s
networking staff.
Star Topology
• Less Expensive one link • Works effectively as long
and one I/O port only per as hub works.
device. • More cabling as
• Easy installation , compared to ring or bus.
reconfiguration, addition
and deletion of nodes.
Less cabling
• Robust- only affected link
is inactive.
• Easy troubleshooting.
Bus topology

A network that uses a bus topology usually consists of a


single cable to which computers attach†. Any computer
attached to a bus can send a signal down the cable, and all
computers receive the signal. Because all computers attach
directly to the cable, any computer can send data to any
other computer. Of course, the computers attached to a bus
network must coordinate to ensure that only one computer
sends a signal at any time.
Bus Topology
• Ease of installation. • Due to tap signal becomes
• Less cabling efficient weaker and weaker as it
backbone. travels farther & farther.
Hence limitation of distance
and no. of nodes.
• Includes difficult
reconnection (splicing).
• Difficult Troubleshooting.
• Addition, Deletion is difficult.
Signal reflection at tap
degrades quality may
involve backbone cable
replacement.
• A fault or break in cable
causes reflection noise and
interruption in transmission.
Ring topology

A network that uses a ring topology arranges for computers to be connected


in a closed loop — a cable connects the first computer to a second computer,
another cable connects the second computer to a third, and so on, until a
cable connects the final computer back to the first. Some technologies that
use a ring topology require a computer to connect to a small device that
forms the ring. The advantage of using a separate device lies in the ability of
the ring to continue operation even if some of the computers are
disconnected. The name ring arises because one can imagine the computers
and the cables connecting them arranged in a circle as Figure 13.7 illustrates.
In practice, the cables in a ring network do not form a circle. Instead, they run
along hallways or rise vertically from one floor of a building to another.
Ring Topology
• Easier installation , • Media and Traffic
reconfiguration. consideration constraints.
• Addition and Deletion is • Maximum ring length may
easier. take time to reach signal
• Fault isolation is easier. to destination. The
requisite node can raise
an alarm.
• A break in ring disrupts
entire network , solved by
using dual ring.
Reason for Multiple Topologies
• Each topology has advantages and disadvantages. A
ring topology makes it easy for computers to coordinate
access and to detect whether the network is operating
correctly. However, an entire ring network is disabled if
one of the cables is cut. A star topology helps protect the
network from damage to a single cable because each
cable connects only one machine. A bus requires fewer
wires than a star, but has the same disadvantage as a
ring: a network is disabled if someone accidentally cuts
the main cable. Later chapters that describe specific
network technologies provide additional details about
differences. For now, it is sufficient to understand:
• Networks are classified into broad categories according
to their general shape. Although a mesh topology is
possible, the primary topologies used with LANs are star,
ring, and bus; each has advantages and disadvantages.
Exercise

• Draw a hybrid topology with a Star with


two Buses each with 3 Rings of 4 devices
each
Exercise
• For n devices in a network the number of
cable links required for Mesh, Ring , Bus
and Star topology is…
• Mesh: n (n – 1) / 2
• Star: n
• Ring: n – 1
• Bus: one backbone and n drop lines
Exercise
• Mesh: easy installation
• Bus: easy fault isolation
• Star: secure
• Ring: robust

• Mesh: secure
• Bus: easy installation
• Star: robust
• Ring: easy fault isolation
Categories of networks
Network Types
LAN
LAN (Continued)
Figure 1.14 MAN
WAN
Network: Links & switches
• Circuit consists of dedicated resources in
sequence of links & switches across network
• Circuit switch connects input links to output links
zSwitch
zNetwork
Control

Link Switch
1 1
2 2
User n 3 Connection 3
of inputs
User n – 1 …
to outputs


User 1

N N
Switching Methods
• Circuit Switching.
• Packet Switching.
Circuit Switching.
• The term circuit switching refers to a
communication mechanism that establishes a
path between a sender and receiver with
guaranteed isolation from paths used by other
pairs of senders and receivers. Circuit switching
is usually associated with telephone technology
because a telephone system provides a
dedicated connection between two telephones.
In fact, the term originated with early dialup
telephone networks that used electromechanical
switching devices to form a physical circuit.
Circuit Switching
Circuit Switching
• Currently, circuit switching networks use electronic
devices to establish circuits. Furthermore, instead of
having each circuit correspond to a physical path,
multiple circuits are multiplexed over shared media,
and the result is known as a virtual circuit. Thus, the
distinction between circuit switching and other forms
of networking does not arise from the existence of
separate physical paths. Instead, three general
properties define a circuit switched paradigm:
• Point-to-point communication
• Separate steps for circuit creation, use, and
termination
• Performance equivalent to an isolated physical path
Circuit Switching
• The first property means that a circuit is formed
between exactly two endpoints, and the second
property distinguishes circuits that are switched
(i.e., established when needed) from circuits that
are permanent (i.e., always remain in place
ready for use). Switched circuits use a three-
step process analogous to placing a phone call.
In the first step, a circuit is established. In the
second, the two parties use the circuit to
communicate, and in the third, the two parties
terminate use.
Circuit Switching
• The third property provides a crucial distinction
between circuit switched networks and other
types. Circuit switching means that the
communication between two parties is not
affected in any way by communication among
other parties, even if all communication is
multiplexed over a common medium. In
particular, circuit switching must provide the
illusion of an isolated path for each pair of
communicating entities. Thus, techniques such
as frequency division multiplexing or
synchronous time division multiplexing must be
used to multiplex circuits over a shared medium.
Conclusion
• Circuit switching provides the illusion of an
isolated physical path between a pair of
communicating entities; a path is created
when needed, and discontinued after use.
Packet Switching
• The main alternative to circuit switching, packet
switching, forms the basis for the Internet. A packet
switching system uses statistical multiplexing in which
communication from multiple sources competes for the
use of shared media. The chief difference between
packet switching and other forms of statistical
multiplexing arises because a packet switching system
requires a sender to divide each message into blocks of
data that are known as packets. The size of a packet
varies; each packet switching technology defines a
maximum packet size.
Packet Switching
• Arbitrary, asynchronous communication
• No set-up required before communication begins
• Performance varies due to statistical multiplexing among
packets
• The first property means that packet switching can allow
a sender to communicate with one recipient or multiple
recipients, and a given recipient can receive messages
from one sender or multiple senders. Furthermore,
communication can occur at any time, and a sender can
delay arbitrarily long between successive
communications. The second property means that,
unlike a circuit switched system, a packet switched
system remains ready to deliver a packet to any
destination at any time. Thus, a sender does not need to
perform initialization before communicating, and does
not need to notify the underlying system when
communication terminates.
Packet Switching
• The third property means that multiplexing
occurs among packets rather than among bits or
bytes. That is, once a sender gains access to
the underlying channel, the sender transmits an
entire packet, and then allows other senders to
transmit a packet. When no other senders are
ready to transmit a packet, a single sender can
transmit repeatedly. However, if N senders each
have a packet to send, a given sender will
transmit approximately 1/N of all packets.
Packet Switching
• One of the chief advantages of packet
switching is the lower cost that arises from
sharing. To provide communication among
N computers, a circuit-switched network
must have a connection for each computer
plus at least N/ 2 independent paths. With
packet switching, a network must have a
connection for each computer, but only
requires one path that is shared.
Conclusion
• Packet switching, which forms the basis of
the Internet, is a form of statistical
multiplexing that permits many-to-many
communication. A sender must divide a
message into a set of packets; after
transmitting a packet, a sender allows
other senders to transmit before
transmitting a successive packet.
Comparison
Comparison
• Propagation delay. The time it takes a signal to
propagate from one node to the next. This time
is generally negligible. The speed of
electromagnetic signals through a wire medium,
for example, is typically 2 X lo8 mts.
• Transmission time. The time it takes for a
transmitter to send out a block of data. For
example, it takes 1 s to transmit a 10,000-bit
block of data onto a 10-kbps line.
• Node delay. The time it takes for a node to
perform the necessary processing as it switches
data.
Circuit Switch Types
• Space-Division switches
– Provide separate physical connection
between inputs and outputs
– Crossbar switches
– Multistage switches
• Time-Division switches
– Time-slot interchange technique
– Time-space-time switches
• Hybrids combine Time & Space switching
Space Division Switching
Crossbar Space Switch
• N x N array of
crosspoints 1
• Connect an input 2
to an output by


closing a
crosspoint N
• Nonblocking: Any …
input can connect 1 2 N –1 N

to idle output
• Complexity: N2
crosspoints
Multistage Space Switch
• Large switch built from multiple stages of small switches
• The n inputs to a first-stage switch share k paths through
intermediate crossbar switches
• Larger k (more intermediate switches) means more paths to
output
• In 1950s, Clos asked, “How many intermediate switches
required to make switch nonblocking?”
2(N/n)nk + k (N/n)2 crosspoints

n×k N/n × N/n k×n


1 1
1
n×k k×n
N 2
N/n × N/n
2 N
inputs n×k 2 k×n outputs
3 3



n×k k×n
N/n N/n
N/n × N/n
k
Clos Non-Blocking Condition: k=2n-1
• Request connection from last input to input switch j to last output in output
switch m
• Worst Case: All other inputs have seized top n-1 middle switches AND all
other outputs have seized next n-1 middle switches
• If k=2n-1, there is another path left to connect desired input to desired output

nxk N/n x N/n kxn


1 1
1


n-1
busy N/n x N/n
Desired nxk n-1 kxn Desired
j
input m output
n-1
N/n x N/n
n+1 busy


# internal links =
N/n x N/n 2x # external links
2n-2
nxk kxn
N/n
Free path N/n2n-1
x N/n Free path N/n
Minimum Complexity Clos Switch
C(n) = number of crosspoints in Clos switch

= 2Nk + k( N )2 = 2N(2n – 1)+(2n – 1)( N )2


n n
Differentiate with respect to n:

δC
==> n ≈ √ 2
2N2 2N2 2N2 N
0= = 4N – + ≈ 4N –
δn n2 n3 n2

The minimized number of crosspoints is then:

C* = (2N + N2 )(2( N )1/2 – 1) ≈ 4N √ 2N = 4 √ 2N1.5


N/2 2
This is lower than N2 for large N
Example: Clos Switch Design
• Circa 2002, Mindspeed offered a Crossbar
chip with the following specs:
– 144 inputs x 144 outputs, 3.125
Gbps/line 8x16 144×144 16x8
1 1
– Aggregate Crossbar chip throughput: 1

1152 outputs
450 Gbps 8x16 16x8

1152 inputs
2 2
144x144
• Clos Nonblocking Design for 1152x1152 8x16 2 16x8
switch 3 3




– N=1152, n=8, k=16
– N/n=144 8x16 switches in first stage
8x16 16x8
– 16 144x144 in centre stage 144 N/n
– 144 16x8 in third stage 144x144
16
– Aggregate Throughput: 3.6 Tbps!

– Note: the 144x144 crossbar can be


partitioned into multiple smaller switches
Time Division Switching

Hybrid
Space
Switch
Time
Switch

•Time Division switches are cost effective as


compared to space switches.
Time Division Space Switching
•Each inlet & outlet is a 1 1
single subscriber line . .
•Sampling rate is 8 Khz. . .
hence T= 125 µs. N N
•Simultaneous conversations
or switching capacity = 125
µs/ ts , where ts is time
required for transfer of one Decoder Counter
value. 2N – N-
•A single switching element
and a bus is time shared
and a physical connection is
established between one
inlet & outlet for time ts ¾Non blocking
hence is TD Space switch
¾No full availability :- i.e. any inlet can
not be connected to any outlet.
• Thus to achieve full availability
following types of TDS switches can
be used,
¾Input controlled TDS switch.
¾Output controlled TDS switch.
¾Memory controlled TDS switch
Input Controlled TDS Switch
1 1
. .
. .
N N

Decoder Counter
2N – N-

MAR
5
Time-Slot Interchange (TSI)
Switching
• Write bytes from arriving TDM stream into memory
• Read bytes in permuted order into outgoing TDM
stream
• Max # slots = 125 µsec / (2 x memory cycle time)
1 a
Read slots
2 b
according to
3 connection
d c … b a zzz permutation b a … d c
24 23 2 1 24 23 2 1
Write
22
slots in
order of 23 c
zIncoming arrival zOutgoing
TDM 24 d TDM
stream stream

Time-slot interchange
Time-Space-Time Hybrid Switch
• Use TSI in first & third stage; Use crossbar in middle
• Replace n input x k output space switch by TSI switch that takes n-
slot input frame and switches it to k-slot output frame

nxk N/n x N/n kxn


1 1
1

nxk
N 2
Input TDM Output TDM
inputs
nxk frame with frame with k
n slots 1
3 slots
2

zzz

n … 2 1 k … 2 1

nxk n
N/n

Time-slot interchange
Flow of time slots between
switches
First slot First slot
n×k N/n × N/n k×n
1 1 1

n×k k×n
2
2 N/n × N/n
2



n×k k×n
N/n
N/n N/n × N/n
kth slot k kth slot

• Only one space switch active in each time slot


Time-Share the Crossbar Switch
TSI stage Space stage TSI stage

TDM nxk TDM TDM kxn


n slots 1 k slots k slots 1

n slots nxk kxn


N 2 N/n x N/n 2 N
inputs Time-shared outputs
n slots nxk space switch kxn
3 3


n slots nxk kxn
N/n N/n

• Interconnection pattern of space switch is


reconfigured every time slot
• Very compact design: fewer lines because of
TDM & less space because of time-shared
crossbar
Example: A→3, B→4, C→1, D→3
(a)
A C
B
A
z3-stage
Space
Switch
C D
D B

(b)
B2 A2 B1 A1 B1 A1 C1 A1 A1 C1
2x3 3x2
1 1
zEquivalent
TST Switch

D1 B1 B1 D1
D2 C2 D1 C1
2x3
D1 C1 3x2
2 2
Example: T-S-T Switch Design
For N = 960
• Single stage space switch ~ 1 million
crosspoints
• T-S-T
– Let n = 120 N/n = 8 TSIs
– k = 2n – 1 = 239 for non-blocking
– Pick k = 240 time slots
– Need 8x8 time-multiplexed space switch

For N = 96,000
• T-S-T
– Let n = 120 k = 239
– N / n = 800
– Need 800x800 space switch
Available TSI Chips circa 2002
• OC-192 SONET Framer Chips
– Decompose 192 STS1s and perform
(restricted) TSI

• Single-chip TST
– 64 inputs x 64 outputs
– Each line @ STS-12 (622 Mbps)
– Equivalent to 768x768 STS-1 switch
Pure Optical Switching
• Pure Optical switching: light-in, light-out, without
optical-to-electronic conversion
• Space switching theory can be used to design
optical switches
– Multistage designs using small optical switches
– Typically 2x2 or 4x4
– MEMs and Electro-optic switching devices
• Wavelength switches
– Very interesting designs when space switching is
combined with wavelength conversion devices
Exercise
• Construct A three stage switch with N = 16,
n = 4, k = 2.
• Repeat all questions for k=4 and k=10.
• What is the maximum number of connections that can be
supported at any given time?
– Thus, the second stage is the bottleneck, and blocking can occur in
the first stage. Thus, eight connections can be supported at a time. If
k = 4, then blocking will occur if we are not allowed to rearrange
connections. It can be shown that in this case blocking can be
avoided if we are allowed to rearrange the connection pattern every
time a new connection request is made. If k = 10, then there are ten
4 x 4 switches in the second stage. Since there are only 16 inputs
and 16 outputs, the switch can accommodate any set of connections
without blocking.
• For a given set of input-output pairs, is there more than
one way to arrange the connections over the multistage
switch?
– As shown in the picture in part (a), it is clear that each input-output
pair can be connected through any one of the k second-stage
switches. Thus, here are k ways to arrange the connections over a
multi-stage switch.
Exercise
• What is the delay incurred in traversing a TSI
switch?
– The arriving frame is written onto the switch
register and after the frame is completely
written in, it needs to be read out in permuted
order.
Protocols
• A protocol is a set of rules that governs
how two or more communicating entities in
a layer are to interact
• Messages that can be sent and received
• Actions that are to be taken when a certain
event occurs, e.g. sending or receiving
messages, expiry of timers
• The purpose of a protocol is to provide
a service to the layer above
Layers
• A set of related communication functions that
can be managed and grouped together
• Application Layer: communications functions
that are used by application programs
– HTTP, DNS, SMTP (email)
• Transport Layer: end-to-end communications
between two processes in two machines
– TCP, User Datagram Protocol (UDP)
• Network Layer: node-to-node communications
between two machines
– Internet Protocol (IP)
Summary
• Layers: related communications functions
– Application Layer: HTTP, DNS
– Transport Layer: TCP, UDP
– Network Layer: IP
• Services: a protocol provides a communications
service to the layer above
– TCP provides connection-oriented reliable byte transfer
service
– UDP provides best-effort datagram service
• Each layer builds on services of lower layers
– HTTP builds on top of TCP
– DNS builds on top of UDP
– TCP and UDP build on top of IP
Applications and Layered
Architectures
OSI Reference Model
Why Layering?
• Layering simplifies design, implementation, and
testing by partitioning overall communications
process into parts
• Protocol in each layer can be designed
separately from those in other layers
• Protocol makes “calls” for services from layer
below
• Layering provides flexibility for modifying and
evolving protocols and services without having
to change layers below
• Monolithic non-layered architectures are costly,
inflexible, and soon obsolete
Open Systems Interconnection
• Network architecture:
– Definition of all the layers
– Design of protocols for every layer
• By the 1970s every computer vendor had
developed its own proprietary layered network
architecture
• Problem: computers from different vendors
could not be networked together
• Open Systems Interconnection (OSI) was an
international effort by the International
Organization for Standardization (ISO) to enable
multivendor computer interconnection
OSI Reference Model
• Describes a seven-layer abstract reference
model for a network architecture
• Purpose of the reference model was to provide a
framework for the development of protocols
• OSI also provided a unified view of layers,
protocols, and services which is still in use in the
development of new protocols
• Detailed standards were developed for each
layer, but most of these are not in use
• TCP/IP protocols preempted deployment of OSI
protocols
7-Layer OSI Reference Model
Application Application
End-to-End Protocols
Application Application
Layer Layer
Presentation Presentation
Layer Layer
Session Session
Layer Layer
Transport Transport
Layer Layer
Network Network Network Network
Layer Layer Layer Layer
Data Link Data Link Data Link Data Link
Layer Layer Layer Layer
Physical Physical Physical Physical
Layer Layer Layer Layer

Communicating End Systems


One or More Network Nodes
Physical Layer
• Transfers bits across link
• Definition & specification of the physical
aspects of a communications link
– Mechanical: cable, plugs, pins...
– Electrical/optical: modulation, signal strength, voltage
levels, bit times, …
– functional/procedural: how to activate, maintain, and
deactivate physical links…
• Ethernet, DSL, cable modem, telephone
modems…
• Twisted-pair cable, coaxial cable optical fiber,
radio, infrared, …
Data Link Layer
• Transfers frames across direct connections
• Groups bits into frames
• Detection of bit errors; Retransmission of frames
• Activation, maintenance, & deactivation of data link
connections
• Medium access control for local area networks
• Flow control
frames
Data Link Data Link
Layer Layer

Physical bits Physical


Layer Layer
Network Layer
• Transfers packets across multiple links and/or
multiple networks
• Addressing must scale to large networks
• Nodes jointly execute routing algorithm to
determine paths across the network
• Forwarding transfers packet across a node
• Congestion control to deal with traffic surges
• Connection setup, maintenance, and teardown
when connection-based
Internetworking
Ethernet LAN

• Internetworking
z z z z z z is part of network layer and

provides transfer of packets across


ATM multiple
Network
possibly dissimilar networks
ATM
Switch

• Gateways (routers) direct packets ATM


HSwitch
across Switch
ATM

networks
ATM
H Switch
Net
Net 33
G
Net
Net 11 G
G
G
Net55
Net
H Net 2 G Net 4 G
H
G = gateway
H = host
Transport Layer
• Transfers data end-to-end from process in a
machine to process in another machine
• Reliable stream transfer or quick-and-simple
single-block transfer
• Port numbers enable multiplexing
• Message segmentation and reassembly
• Connection setup, maintenance, and release
Transport Transport
Layer Layer

Network Network Network Network


Layer Layer Layer Layer

Communication Network
Application & Upper Layers
• Application Layer: Provides
services that are frequently Application
required by applications: Application
DNS, web acess, file transfer, Application
Layer
email… Application
Layer
Presentation
• Presentation Layer: machine- Transport
Layer
independent representation of Layer
Session
data… Layer

• Session Layer: dialog Transport


Layer
management, recovery from
Incorporated into
errors, …Application Layer
Headers & Trailers
• Each protocol uses a header that carries addresses,
sequence numbers, flag bits, length indicators, etc…
• CRC check bits may be appended for error detection

Application APP DATA Application

Application Application
AH APP DATA
Layer Layer
Transport Transport
Layer TH AH APP DATA Layer

Network Network
Layer NH TH AH APP DATA Layer

Data Link Data Link


Layer DH NH TH AH APP DATA CRC Layer

Physical Physical
Layer bits Layer
OSI Unified View: Protocols
• Layer n in one machine interacts with layer n in
another machine to provide a service to layer n
+1
• The entities comprising the corresponding layers
on different machines are called peer processes.
• The machines use a set of rules and
conventions called the layer-n protocol.
• Layer-n peer processes
n-PDUscommunicate by
exchanging Protocol Data Units (PDUs)
n n
Entity Entity

Layer n peer protocol


OSI Unified View: Services
• Communication between peer processes is virtual
and actually indirect
• Layer n+1 transfers information by invoking the
services provided by layer n
• Services are available at Service Access Points
(SAP’s)
• Each layer passes data & control information to the
layer below it until the physical layer is reached and
transfer occurs
• The data passed to the layer below is called a
Service Data Unit (SDU)
• SDU’s are encapsulated in PDU’s
Layers, Services & Protocols

n+1 n+1
entity entity

n-SDU n-SDU
n-SAP n-SAP

n-SDU H
n entity n entity
H n-SDU
n-PDU
Interlayer Interaction
layer

N+1 user N provider N provider N+1 user

Request
Indication

on se
Re sp

o n firm
C

System A System B
Connectionless & Connection-
Oriented Services
• Connection-Oriented • Connectionless
– Three-phases: – Immediate SDU
1. Connection setup
transfer
between two SAPs – No connection setup
to initialize state – E.g. UDP, IP
information • Layered services
2. SDU transfer need not be of same
3. Connection release type
– E.g. TCP, ATM – TCP operates over IP
– IP operates over ATM
Segmentation & Reassembly
• A layer may impose a (a) Segmentation
limit on the size of a data
n-SDU
block that it can transfer
for implementation or
other reasons
n-PDU n-PDU n-PDU
• Thus a layer-n SDU may
be too large to be
handled as a single unit Reassembly
(b)
by layer-(n-1)
• Sender side: SDU is n-SDU
segmented into multiple
PDUs
n-PDU n-PDU n-PDU
• Receiver side: SDU is
reassembled from
sequence of PDUs
Multiplexing
• Sharing of layer n service by multiple layer n+1 users
• Multiplexing tag or ID required in each PDU to determine
which users an SDU belongs to
n+1 n+1
entity entity
n+1 n+1
entity entity

n-SDU n-SDU
n-SDU H
n entity n entity
H n-SDU
n-PDU
Summary
• Layers: related communications functions
– Application Layer: HTTP, DNS
– Transport Layer: TCP, UDP
– Network Layer: IP
• Services: a protocol provides a communications
service to the layer above
– TCP provides connection-oriented reliable byte transfer
service
– UDP provides best-effort datagram service
• Each layer builds on services of lower layers
– HTTP builds on top of TCP
– DNS builds on top of UDP
– TCP and UDP build on top of IP
Summary of duties
Applications and Layered
Architectures
TCP/IP Architecture
How the Layers Work Together
Why Internetworking?
• To build a “network of networks” or internet
– operating over multiple, coexisting, different network
technologies
– providing ubiquitous connectivity through IP packet
transfer
– achieving huge economies ofH scale

H
Net53
Net
Net51
Net G
G
G
G
Net55
Net
H G G
Net52
Net Net54
Net
H
Why Internetworking?
• To provide universal communication services
– independent of underlying network technologies
– providing common interface to user applications

H
Reliable Stream Service
H
Net53
Net
Net51
Net G
G
G
G
Net55
Net
H G G
Net52
Net Net54
Net
H
User Datagram Service
Why Internetworking?
• To provide distributed applications
– Any application designed to operate based on Internet
communication services immediately operates across
the entire Internet
– Rapid deployment of new applications
• Email, WWW, Peer-to-peer
– Applications independent of network technology
• New networks can be introduced below
• Old network technologies can be retired
Internet Protocol Approach
z IP packets transfer information across Internet
Host A IP → router→ router…→ router→ Host B IP
z IP layer in each router determines next hop (router)
z Network interfaces transfer IP packets across networks
Host A Router Host B
Router
Transport Internet Transport
Layer Layer Internet Layer
Layer
Internet Network Internet
Interface
Net51
Net Network
Layer Layer
Interface
Router Network
Network
Interface Internet Interface
Layer
Net54
Net Network Net53
Net52
Net Net
Interface
TCP/IP Protocol Suite
HTTP SMTP DNS RTP
Distributed
applications User
Reliable
TCP UDP
stream datagram
service service

Best-effort (ICMP, ARP)


IP
connectionless
packet transfer

Network Network Network


interface 1 interface 2 interface 3

Diverse network technologies


Internet Names & Addresses
Internet Names Internet Addresses
• Each host a a unique name • Each host has globally unique
– Independent of physical logical 32 bit IP address
location
– Facilitate memorization by• Separate address for each
humans physical connection to a
– Domain Name network
– Organization under single
administrative unit • Routing decision is done
• Host Name based on destination IP
– Name given to host computer address
• User Name • IP address has two parts:
– Name assigned to user
– netid and hostid
leongarcia@comm.utoronto.ca – netid unique
– netid facilitates routing
• Dotted Decimal Notation:
DNS resolves IP name to IP address
int1.int2.int3.int4
(intj = jth octet)
Physical Addresses
• LANs (and other networks) assign physical
addresses to the physical attachment to the
network
• The network uses its own address to transfer
packets or frames to the appropriate destination
• IP address needs to be resolved to physical
address at each IP network interface
• Example: Ethernet uses 48-bit addresses
– Each Ethernet network interface card (NIC) has
globally unique Medium Access Control (MAC) or
physical address
– First 24 bits identify NIC manufacturer; second 24 bits
Intel
are serial number
Example internet
Server PC
Router
(2,1)
(1,1) s
PPP
(1,3) r (2,2)
Netid=2
w
Ethernet *PPP does not use addresses
(netid=1) Workstation

(1,2)

Physical
netid hostid
address
server 1 1 s
workstation 1 2 w
router 1 3 r
router 2 1 -
PC 2 2 -
Encapsulation

IP
header IP Payload

Ethernet IP
IP Payload FCS
header header

z Ethernet header contains:


z source and destination physical addresses
z network protocol type (e.g. IP)
IP packet from workstation to
server
Server PC
Router
(2,1)
(1,1) PPP
s (1,3) r (2,2)
w
Ethernet w, s (1,2), (1,1)

Workstation
(1,2)

1. IP packet has (1,2) IP address for source and (1,1) IP address for
destination
2. IP table at workstation indicates (1,1) connected to same network, so IP
packet is encapsulated in Ethernet frame with addresses w and s
3. Ethernet frame is broadcast by workstation NIC and captured by server
NIC
4. NIC examines protocol type field and then delivers packet to its IP layer
IP packet from server to PC
Server PC
Router
(2,1) (1,1), (2,2)
(1,1) s (1,3) r (2,2)
w
s, r (1,1), (2,2)

Workstation
(1,2)
1. IP packet has (1,1) and (2,2) as IP source and destination addresses
2. IP table at server indicates packet should be sent to router, so IP packet
is encapsulated in Ethernet frame with addresses s and r
3. Ethernet frame is broadcast by server NIC and captured by router NIC
4. NIC examines protocol type field and then delivers packet to its IP layer
5. IP layer examines IP packet destination address and determines IP
packet should be routed to (2,2)
6. Router’s table indicates (2,2) is directly connected via PPP link
7. IP packet is encapsulated in PPP frame and delivered to PC
8. PPP at PC examines protocol type field and delivers packet to PC IP
How the layers work together
(a) Server PC
Router
(2,1)
(1,1) s (1,3) r PPP
(2,2)
Ethernet
HTTP uses process-to-process
Reliable byte stream transfer of
TCP connection:
Server Server socket: (IP Address, 80)
(b) PC
PC socket (IP Address, Eph. #)
HTTP TCP uses node-to-node HTTP
Unreliable packet transfer of IP
TCP Server IP address & PC IP address TCP
IP IP IP
Network interface Network interface Network interface
Internet
Router
Ethernet PPP
Encapsulation
TCP Header contains
source & destination HTTP Request
port numbers

IP Header contains
source and destination TCP
IP addresses; header HTTP Request
transport protocol type

Ethernet Header contains


source & destination MAC IP TCP
header header HTTP Request
addresses;
network protocol type

Ethernet IP TCP
HTTP Request FCS
header header header
How the layers work together:
Network Analyzer Example

Internet

• User clicks on http://www.nytimes.com/


• Ethereal network analyzer captures all frames
observed by its Ethernet NIC
• Sequence of frames and contents of frame can
be examined in detail down to individual bytes
Top Pane Middle Pane
Ethereal windows
shows shows
frame/packet encapsulation for
sequence a given frame

Bottom Pane shows hex & text


Top pane: frame
TCP
sequence
DNS Connection
HTTP
Query Setup
Request &
Response
Middle pane: Encapsulation
Ethernet Frame

Ethernet
Protocol Type Destination and
Source
Addresses
Middle pane:
And a lot of
Encapsulation
other stuff!
IP Packet

IP Source and
Destination
Addresses

Protocol Type
Middle pane: Encapsulation

TCP Segment

Source and
Destination Port
Numbers

GET

HTTP
Request
Summary
• Encapsulation is key to layering
• IP provides for transfer of packets across
diverse networks
• TCP and UDP provide universal
communications services across the Internet
• Distributed applications that use TCP and UDP
can operate over the entire Internet
• Internet names, IP addresses, port numbers,
sockets, connections, physical addresses
Applications and Layered
Architectures
Sockets
Socket API
• API (Application Programming Interface)
– Provides a standard set of functions that can be called
by applications
• Berkeley UNIX Sockets API
– Abstraction for applications to send & receive data
– Applications create sockets that “plug into” network
– Applications write/read to/from sockets
– Implemented in the kernel
– Facilitates development of network applications
– Hides details of underlying protocols & mechanisms
• Also in Windows, Linux, and other OS’s
Communications through Socket
Interface
Client Server
Socket Socket
Application 1 Application 2
interface interface

User User
descriptor descriptor
Kernel Kernel
Socket Socket
• Application references a
socket through a descriptor
port number • Socket bound to a port number port number

Underlying Underlying
communication communication
protocols protocols

Communications
network
Stream mode of service
Connection-oriented • Connectionless
• First, setup connection • Immediate transfer of one
between two peer block of information
application processes (boundaries preserved)
• Then, reliable • No setup overhead &
bidirectional in-sequence delay
transfer of byte stream • Destination address with
(boundaries not each block
preserved in transfer) • Send/receive to/from
• Multiple write/read multiple peer processes
between peer processes • Best-effort service only
• Finally, connection – Possible out-of-order
release
– Possible loss
• Uses TCP • Uses UDP
Client & Server Differences
• Server
– Specifies well-known port # when creating socket
– May have multiple IP addresses (net interfaces)
– Waits passively for client requests
• Client
– Assigned ephemeral port #
– Initiates communications with server
– Needs to know server’s IP address & port #
• DNS for URL & server well-known port #
– Server learns client’s address & port #
Socket Calls for Connection-
Oriented Mode
Server does Passive Open
Server z socket creates socket to listen for connection

socket()
requests
z Server specifies type: TCP (stream)
bind() z socket call returns: non-negative integer descriptor;
or -1 if unsuccessful
listen()
Client
accept()
socket()
Blocks Connect
negotiation connect()

Data write()
read()

write() Data
read()

close()
close()
Socket Calls for Connection-
Oriented Mode
Server does Passive Open
Server z bind assigns local address & port # to socket with

socket()
specified descriptor
z Can wildcard IP address for multiple net interfaces
bind() z bind call returns: 0 (success); or -1 (failure)
z Failure if port # already in use or if reuse option not
listen() set Client
accept()
socket()
Blocks Connect
negotiation connect()

Data write()
read()

write() Data
read()

close()
close()
Socket Calls for Connection-
Oriented Mode
Server does Passive Open
Server z listen indicates to TCP readiness to receive

socket()
connection requests for socket with given descriptor
z Parameter specifies max number of requests that may
bind() be queued while waiting for server to accept them
z listen call returns: 0 (success); or -1 (failure)
listen()
Client
accept()
socket()
Blocks Connect
negotiation connect()

Data write()
read()

write() Data
read()

close()
close()
Socket Calls for Connection-
Oriented Mode
Server does Passive Open
Server z Server calls accept to accept incoming requests

socket() z accept blocks if queue is empty

bind()

listen()
Client
accept()
socket()
Blocks Connect
negotiation connect()

Data write()
read()

write() Data
read()

close()
close()
Socket Calls for Connection-
Oriented Mode
Client does Active Open
Server z socket creates socket to connect to server

socket() z Client specifies type: TCP (stream)


z socket call returns: non-negative integer descriptor;
bind() or -1 if unsuccessful

listen()
Client
accept()
socket()
Blocks Connect
negotiation connect()

Data write()
read()

write() Data
read()

close()
close()
Socket Calls for Connection-
Oriented Mode
Client does Active Open
Server z connect establishes a connection on the local socket

socket()
with the specified descriptor to the specified remote
address and port #
bind() z connect returns 0 if successful; -1 if unsuccessful

listen()
Client
accept()
socket()
Note: connect
Blocks Connect initiates TCP three-way
negotiation connect()
handshake
Data write()
read()

write() Data
read()

close()
close()
Socket Calls for Connection-
Oriented Mode
z accept wakes with incoming connection request
Server z accept fills client address & port # into address structure
socket() z accept call returns: descriptor of new connection socket
(success); or -1 (failure)
bind() z Client & server use new socket for data transfer
z Original socket continues to listen for new requests
listen()
Client
accept()
socket()
Blocks Connect
negotiation connect()

Data write()
read()

write() Data
read()

close()
close()
Socket Calls for Connection-
Oriented Mode
Data Transfer
Server z Client or server call write to transmit data into a
connected socket
socket()
z write specifies: socket descriptor; pointer to a buffer;

bind() amount of data; flags to control transmission behavior


z write call returns: # bytes transferred (success); or -1
listen() (failure); blocks until all data transferred
Client
accept()
socket()
Blocks Connect
negotiation connect()

Data write()
read()

write() Data
read()

close()
close()
Socket Calls for Connection-
Oriented Mode
Data Transfer
Server z Client or server call read to receive data from a
connected socket
socket()
z read specifies: socket descriptor; pointer to a buffer;

bind() amount of data


z read call returns: # bytes read (success); or -1 (failure);
listen() blocks if no data arrives
Client
accept()
socket()
Note: write and read
Blocks Connect can be called multiple
negotiation connect()
times to transfer byte
Data streams in both
read() write() directions

write() Data
read()

close()
close()
Socket Calls for Connection-
Oriented Mode
Connection Termination
Server z Client or server call close when socket is no longer
needed
socket()
z close specifies the socket descriptor

bind() z close call returns: 0 (success); or -1 (failure)

listen()
Client
accept()
socket()
Note: close initiates
Blocks Connect TCP graceful close
negotiation connect()
sequence
Data write()
read()

write() Data
read()

close()
close()
Example: TCP Echo Server
/* A simple echo server using TCP */ /* Bind an address to the socket */
#include <stdio.h> bzero((char *)&server, sizeof(struct sockaddr_in));
#include <sys/types.h> server.sin_family = AF_INET;
#include <sys/socket.h> server.sin_port = htons(port);
#include <netinet/in.h> server.sin_addr.s_addr = htonl(INADDR_ANY);
if (bind(sd, (struct sockaddr *)&server,
#define SERVER_TCP_PORT 3000 sizeof(server)) == -1) {
#define BUFLEN 256 fprintf(stderr, "Can't bind name to socket\n");
exit(1);
int main(int argc, char **argv) }
{
int n, bytes_to_read; /* queue up to 5 connect requests */
int sd, new_sd, client_len, port; listen(sd, 5);
struct sockaddr_in server, client;
char *bp, buf[BUFLEN]; while (1) {
client_len = sizeof(client);
switch(argc) { if ((new_sd = accept(sd, (struct sockaddr *)&client,
case 1: &client_len)) == -1) {
port = SERVER_TCP_PORT; fprintf(stderr, "Can't accept client\n");
break; exit(1);
case 2: }
port = atoi(argv[1]);
break; bp = buf;
default: bytes_to_read = BUFLEN;
fprintf(stderr, "Usage: %s [port]\n", argv[0]); while ((n = read(new_sd, bp, bytes_to_read)) > 0) {
exit(1); bp += n;
} bytes_to_read -= n;
}
/* Create a stream socket */ printf("Rec'd: %s\n", buf);
if ((sd = socket(AF_INET, SOCK_STREAM, 0)) == -1) {
fprintf(stderr, "Can't create a socket\n"); write(new_sd, buf, BUFLEN);
exit(1); printf("Sent: %s\n", buf);
} close(new_sd);
}
close(sd);
return(0);
}
Example: TCP Echo Client
/* A simple TCP client */ bzero((char *)&server, sizeof(struct sockaddr_in));
#include <stdio.h> server.sin_family = AF_INET;
#include <netdb.h> server.sin_port = htons(port);
#include <sys/types.h> if ((hp = gethostbyname(host)) == NULL) {
#include <sys/socket.h> fprintf(stderr, "Can't get server's address\n");
#include <netinet/in.h> exit(1);
}
#define SERVER_TCP_PORT 3000 bcopy(hp->h_addr, (char *)&server.sin_addr, hp->h_length);
#define BUFLEN 256
/* Connecting to the server */
int main(int argc, char **argv) if (connect(sd, (struct sockaddr *)&server,
{ sizeof(server)) == -1) {
int n, bytes_to_read; fprintf(stderr, "Can't connect\n");
int sd, port; exit(1);
struct hostent *hp; }
struct sockaddr_in server; printf("Connected: server's address is %s\n", hp->h_name);
char *host, *bp, rbuf[BUFLEN], sbuf[BUFLEN];
printf("Transmit:\n");
switch(argc) { gets(sbuf);
case 2: write(sd, sbuf, BUFLEN);
host = argv[1];
port = SERVER_TCP_PORT; printf("Receive:\n");
break; bp = rbuf;
case 3: bytes_to_read = BUFLEN;
host = argv[1]; while ((n = read(sd, bp, bytes_to_read)) > 0) {
port = atoi(argv[2]); bp += n;
break; bytes_to_read -= n;
default: }
fprintf(stderr, "Usage: %s host [port]\n", argv[0]); printf("%s\n", rbuf);
exit(1);
} close(sd);
return(0);
/* Create a stream socket */ }
if ((sd = socket(AF_INET, SOCK_STREAM, 0)) == -1) {
fprintf(stderr, "Can't create a socket\n");
exit(1);
}
Socket Calls for Connection-Less
Mode
Server started
Server z socket creates socket of type UDP (datagram)
z socket call returns: descriptor; or -1 if unsuccessful
socket()
z bind assigns local address & port # to socket with
specified descriptor; Can wildcard IP address
bind()
Client
recvfrom() socket()

Data
Blocks until server
receives data from sendto()
client
sendto() Data
recvfrom()

close()
close()
Socket Calls for Connection-Less
Mode
z recvfrom copies bytes received in specified socket
Server into a specified location
z recvfrom blocks until data arrives
socket()

bind()
Client
recvfrom() socket()

Data
Blocks until server
receives data from sendto()
client
sendto() Data
recvfrom()

close()
close()
Socket Calls for Connection-Less
Mode
Client started
Server z socket creates socket of type UDP (datagram)
z socket call returns: descriptor; or -1 if unsuccessful
socket()

bind()
Client
recvfrom() socket()

Data
Blocks until server
receives data from sendto()
client
sendto() Data
recvfrom()

close()
close()
Socket Calls for Connection-Less
Mode
Client started
Server z sendto transfer bytes in buffer to specified socket
z sendto specifies: socket descriptor; pointer to a
socket() buffer; amount of data; flags to control transmission
behavior; destination address & port #; length of
destination address structure
bind()
z sendto returns: # bytes sent; or -1 if unsuccessful
Client
recvfrom() socket()

Data
Blocks until server
receives data from sendto()
client
sendto() Data
recvfrom()

close()
close()
Socket Calls for Connection-Less
Mode
z recvfrom wakes when data arrives
Server z recvfrom specifies: socket descriptor; pointer to a
buffer to put data; max # bytes to put in buffer; control
socket() flags; copies: sender address & port #; length of
sender address structure
z recvfrom returns # bytes received or -1 (failure)
bind()
Client
recvfrom() socket()
Note: receivefrom
Data
Blocks until server returns data from at
receives data from sendto()
most one send, i.e.
client
from one datagram
sendto() Data
recvfrom()

close()
close()
Socket Calls for Connection-Less
Mode
Socket Close
Server z Client or server call close when socket is no longer
needed
socket() z close specifies the socket descriptor
z close call returns: 0 (success); or -1 (failure)

bind()
Client
recvfrom() socket()

Data
Blocks until server
receives data from sendto()
client
sendto() Data
recvfrom()

close()
close()
Example: UDP Echo Server
/* Echo server using UDP */ /* Bind an address to the socket */
#include <stdio.h> bzero((char *)&server, sizeof(server));
#include <sys/types.h> server.sin_family = AF_INET;
#include <sys/socket.h> server.sin_port = htons(port);
#include <netinet/in.h> server.sin_addr.s_addr = htonl(INADDR_ANY);
if (bind(sd, (struct sockaddr *)&server,
#define SERVER_UDP_PORT 5000 sizeof(server)) == -1) {
#define MAXLEN 4096 fprintf(stderr, "Can't bind name to socket\n");
exit(1);
int main(int argc, char **argv) }
{
int sd, client_len, port, n; while (1) {
char buf[MAXLEN]; client_len = sizeof(client);
struct sockaddr_in server, client; if ((n = recvfrom(sd, buf, MAXLEN, 0,
(struct sockaddr *)&client, &client_len)) < 0) {
switch(argc) { fprintf(stderr, "Can't receive datagram\n");
case 1: exit(1);
port = SERVER_UDP_PORT; }
break;
case 2: if (sendto(sd, buf, n, 0,
port = atoi(argv[1]); (struct sockaddr *)&client, client_len) != n) {
break; fprintf(stderr, "Can't send datagram\n");
default: exit(1);
fprintf(stderr, "Usage: %s [port]\n", argv[0]); }
exit(1); }
} close(sd);
return(0);
/* Create a datagram socket */ }
if ((sd = socket(AF_INET, SOCK_DGRAM, 0)) == -1) {
fprintf(stderr, "Can't create a socket\n");
exit(1);
}
Example: UDP Echo Client
#include <stdio.h>
#include <string.h>
#include <sys/time.h> else {
#include <netdb.h> fprintf(stderr,
#include <sys/types.h> "Usage: %s [-s data_size] host [port]\n", pname);
#include <sys/socket.h> exit(1);
#include <netinet/in.h> }
#define SERVER_UDP_PORT 5000
#define MAXLEN 4096 if ((sd = socket(AF_INET, SOCK_DGRAM, 0)) == -1) {
#define DEFLEN 64 fprintf(stderr, "Can't create a socket\n");
exit(1);
long delay(struct timeval t1, struct timeval t2) }
{ bzero((char *)&server, sizeof(server));
long d; server.sin_family = AF_INET;
d = (t2.tv_sec - t1.tv_sec) * 1000; server.sin_port = htons(port);
d += ((t2.tv_usec - t1.tv_usec + 500) / 1000); if ((hp = gethostbyname(host)) == NULL) {
return(d); fprintf(stderr, "Can't get server's IP address\n");
} exit(1);
int main(int argc, char **argv) }
{ bcopy(hp->h_addr, (char *) &server.sin_addr, hp->h_length);
int data_size = DEFLEN, port = SERVER_UDP_PORT;
int i, j, sd, server_len; if (data_size > MAXLEN) {
char *pname, *host, rbuf[MAXLEN], sbuf[MAXLEN]; fprintf(stderr, "Data is too big\n");
struct hostent *hp; exit(1);
struct sockaddr_in server; }
struct timeval start, end; for (i = 0; i < data_size; i++) {
unsigned long address; j = (i < 26) ? i : i % 26;
sbuf[i] = 'a' + j;
pname = argv[0]; }
argc--; gettimeofday(&start, NULL); /* start delay measurement */
argv++; server_len = sizeof(server);
if (argc > 0 && (strcmp(*argv, "-s") == 0)) { if (sendto(sd, sbuf, data_size, 0, (struct sockaddr *)
if (--argc > 0 && (data_size = atoi(*++argv))) { &server, server_len) == -1) {
argc--; fprintf(stderr, "sendto error\n");
argv++; exit(1);
} }
else { if (recvfrom(sd, rbuf, MAXLEN, 0, (struct sockaddr *)
fprintf(stderr, &server, &server_len) < 0) {
"Usage: %s [-s data_size] host [port]\n", pname); fprintf(stderr, "recvfrom error\n");
exit(1); exit(1);
} }
} gettimeofday(&end, NULL); /* end delay measurement */
if (argc > 0) { if (strncmp(sbuf, rbuf, data_size) != 0)
host = *argv; printf("Data is corrupted\n");
if (--argc > 0) close(sd);
port = atoi(*++argv); return(0);
} }
Applications and Layered
Architectures
Application Layer Protocols &
IP Utilities
Telnet (RFC 854)
• Provides general bi-directional byte-oriented
TCP-based communications facility (Network
Virtual Terminal)
• Initiating machine treated as local to the remote
host
• Used to connect to port # of other servers and to
interact with
Serverthem using command line
process

NVT NVT
Network Virtual Terminal
• Network Virtual Terminal
• Lowest common denominator terminal
• Each machine maps characteristics to NVT
• Negotiate options for changes to the NVT
• Data input sent to server & echoed back
• Server control functions : interrupt, abort output,
are-you-there, erase character, erase line
• Default requires login & password
telnet
• A program that uses the Telnet protocol
• Establishes TCP socket
• Sends typed characters to server
• Prints whatever characters arrive
• Try it to retrieve a web page (HTTP) or to
send an email (SMTP)
File Transfer Protocol (RFC 959)
• Provides for transfer of file from one machine to
another machine
• Designed to hide variations in file storage
• FTP parameter commands specify file info
– File Type: ASCII, EBCDIC, image, local.
– Data Structure: file, record, or page
– Transmission Mode: stream, block, compressed
• Other FTP commands
– Access Control: USER, PASS, CWD, QUIT, …
– Service: RETR, STOR, PWD, LIST, …
FTP File Transfer

User
interface

Control
Server PI User PI
connection

Data
Server DTP User DTP
connection

Server FTP User FTP

PI = Protocol interface
DTP = Data transfer process
Two TCP Connections
Control connection Data connection
– Set up using Telnet – To perform file transfer,
protocol on well-known port obtain lists of files,
21 directories
– FTP commands & replies – Each transfer requires
between protocol new data connection
interpreters
– Passive open by user PI
– PIs control the data transfer with ephemeral port #
process
– Port # sent over control
– User requests close of connection
control connection; server
performs the close – Active open by server
using port 20
FTP Replies
Reply Meaning

1yz Positive preliminary reply (action has begun, but wait for another reply before
sending a new command).
2yz Positive completion reply (action completed successfully; new command may be
sent).
3yz Positive intermediary reply (command accepted, but action cannot be performed
without additional information; user should send a command with the
necessary information).
4yz Transient negative completion reply (action currently cannot be performed;
resend command later).
5zy Permanent negative completion reply (action cannot be performed; do not
resend it).
x0z Syntax errors.
x1z Information (replies to requests for status or help).
x2z Connections (replies referring to the control and data connections).
x3z Authentication and accounting (replies for the login process and accounting
procedures).
x4z Unspecified.
x5z File system status.
FTP Client (192.168.1.132: 1421) establishes
Control Connection to FTP Server
(128.100.132.23: 21)
User types ls to list files in directory (frame 31 on
control)
FTP Server (128.100.132.23: 20) establishes Data
Connection to FTP Client (192.168.1.132: 1422)
User types get index.html to request file transfer
in control connection (frame 47 request); File
transfer on new data connection (port 1423, fr.
48, 49, 51)
Hypertext Transfer Protocol
• RFC 1945 (HTTP 1.0), RFC 2616 (HTTP 1.1)
• HTTP provides communications between web
browsers & web servers
• Web: framework for accessing documents &
resources through the Internet
• Hypertext documents: text, graphics, images,
hyperlinks
• Documents prepared using Hypertext Markup
Language (HTML)
HTTP Protocol
• HTTP servers use well-known port 80
• Client request / Server reply
• Stateless: server does not keep any
information about client
• HTTP 1.0 new TCP connection per
request/reply (non-persistent)
• HTTP 1.1 persistent operation is default
HTTP Typical Exchange
HTTP Message Formats
• HTTP messages written in ASCII text
• Request Message Format
– Request Line (Each line ends with carriage return)
• Method URL HTTP-Version \r\n
• Method specifies action to apply to object
• URL specifies object
– Header Lines (Ea. line ends with carriage return)
• Attribute Name: Attribute Value
• E.g. type of client, content, identity of requester, …
• Last header line has extra carriage return)
– Entity Body (Content)
• Additional information to server
HTTP Request Methods
Request Meaning
method
GET Retrieve information (object) identified by the URL.
HEAD Retrieve meta-information about the object, but do not
transfer the object; Can be used to find out if a document
has changed.
POST Send information to a URL (using the entity body) and retrieve
result; used when a user fills out a form in a browser.
PUT Store information in location named by URL
DELETE Remove object identified by URL
TRACE Trace HTTP forwarding through proxies, tunnels, etc.
OPTIONS Used to determine the capabilities of the server, or
characteristics of a named resource.
Universal Resource Locator
• Absolute URL
– scheme://hostname[:port]/path
– http://www.nytimes.com/

• Relative URL
– /path
–/
HTTP Request Message
HTTP Response Message
• Response Message Format
– Status Line
• HTTP-Version Status-Code Message
• Status Code: 3-digit code indicating result
• E.g. HTTP/1.0 200 OK
– Headers Section
• Information about object transferred to client
• E.g. server type, content length, content type, …
– Content
• Object (document)
HTTP Response Message
HTTP Proxy Server & Caching
• Web users generate large traffic volumes
• Traffic causes congestion & delay
• Can improve delay performance and reduce
traffic in Internet by moving content to servers
closer to the user
• Web proxy servers cache web information
– Deployed by ISPs
– Customer browsers configured to first access ISPs
proxy servers
– Proxy replies immediately when it has requested
object or retrieves the object if it does not
Cookies and Web Sessions
• Cookies are data exchanged by clients &
servers as header lines
• Since HTTP stateless, cookies can provide
context for HTTP interaction
• Set cookie header line in reply message from
server + unique ID number for client
• If client accepts cookie, cookie added to client’s
cookie file (must include expiration date)
• Henceforth client requests include ID
• Server site can track client interactions, store
these in a separate database, and access
database to prepare appropriate responses
Cookie Header Line;
ID is 24 hexadecimal numeral
PING
• Application to determine if host is reachable
• Based on Internet Control Message Protocol
– ICMP informs source host about errors encountered in
IP packet processing by routers or by destination host
– ICMP Echo message requests reply from destination
host
• PING sends echo message & sequence #
• Determines reachability & round-trip delay
• Sometimes disabled for security reasons
PING from NAL host
Microsoft(R) Windows DOS
(c)Copyright Microsoft Corp 1990-2001.
C:\DOCUME~1\1>ping nal.toronto.edu
Pinging nal.toronto.edu [128.100.244.3] with 32 bytes of data:
Reply from 128.100.244.3: bytes=32 time=84ms TTL=240
Reply from 128.100.244.3: bytes=32 time=110ms TTL=240
Reply from 128.100.244.3: bytes=32 time=81ms TTL=240
Reply from 128.100.244.3: bytes=32 time=79ms TTL=240
Ping statistics for 128.100.244.3:
Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
Minimum = 79ms, Maximum = 110ms, Average = 88ms
C:\DOCUME~1\1>
Traceroute
• Find route from local host to a remote host
• Time-to-Live (TTL)
– IP packets have TTL field that specifies maximum #
hops traversed before packet discarded
– Each router decrements TTL by 1
– When TTL reaches 0 packet is discarded
• Traceroute
– Send UDP to remote host with TTL=1
– First router will reply ICMP Time Exceeded Msg
– Send UDP to remote host with TTL=2, …
– Each step reveals next router in path to remote host
Traceroute from home PC to
university host
Tracing route to www.comm.utoronto.ca [128.100.11.60]
over a maximum of 30 hops:

1 1 ms <10 ms <10 ms 192.168.2.1 Home Network


2 3 ms 3 ms 3 ms 10.202.128.1
3 4 ms 3 ms 3 ms gw04.ym.phub.net.cable.rogers.com [66.185.83.142]
4 * * * Request timed out.
5 47 ms 59 ms 66 ms gw01.bloor.phub.net.cable.rogers.com [66.185.80.230]
6 3 ms 3 ms 38 ms gw02.bloor.phub.net.cable.rogers.com [66.185.80.242]
7 8 ms 3 ms 5 ms gw01.wlfdle.phub.net.cable.rogers.com [66.185.80.2] Rogers Cable
8 8 ms 7 ms 7 ms gw02.wlfdle.phub.net.cable.rogers.com [66.185.80.142] ISP
9 4 ms 10 ms 4 ms gw01.front.phub.net.cable.rogers.com [66.185.81.18]
10 6 ms 4 ms 5 ms ra1sh-ge3-4.mt.bigpipeinc.com [66.244.223.237] Shaw Net
11 16 ms 17 ms 13 ms rx0sh-hydro-one-telecom.mt.bigpipeinc.com [66.244.223.246] Hydro One
12 7 ms 14 ms 8 ms 142.46.4.2
13 10 ms 7 ms 6 ms utorgw.onet.on.ca [206.248.221.6] Ontario Net
14 7 ms 6 ms 11 ms mcl-gateway.gw.utoronto.ca [128.100.96.101]
15 7 ms 5 ms 8 ms sf-gpb.gw.utoronto.ca [128.100.96.17] University of
16 7 ms 7 ms 10 ms bi15000.ece.utoronto.ca [128.100.96.236] Toronto
17 7 ms 9 ms 9 ms www.comm.utoronto.ca [128.100.11.60]

Trace complete.
ipconfig
• Utility in Microsoft® Windows to display
TCP/IP information about a host
• Many options
– Simplest: IP address, subnet mask, default
gateway for the host
– Information about each IP interface of a host
• DNS hostname, IP addresses of DNS servers,
physical address of network card, IP address, …
– Renew IP address from DHCP server
netstat
• Queries a host about TCP/IP network
status
• Status of network drivers & their interface
cards
– #packets in, #packets out, errored packets, …
• State of routing table in host
• TCP/IP active server processes
• TCP active connections
netstat protocol statistics
IPv4 Statistics ICMPv4 Statistics

Packets Received = 71271 Received Sent


Received Header Errors = 0 Messages 10 6
Received Address Errors = 9 Errors 0 0
Datagrams Forwarded = 0 Destination Unreachable 8 1
Unknown Protocols Received = 0 Time Exceeded 0 0
Received Packets Discarded = 0 Parameter Problems 0 0
Received Packets Delivered = 71271 Source Quenches 0 0
Output Requests = 70138 Redirects 0 0
Routing Discards = 0 Echos 0 2
Discarded Output Packets = 0 Echo Replies 2 0
Output Packet No Route = 0 Timestamps 0 0
Reassembly Required = 0 Timestamp Replies 0 0
Reassembly Successful = 0 Address Masks 0 0
Reassembly Failures = 0 Address Mask Replies 0 0
Datagrams Successfully Fragmented = 0
Datagrams Failing Fragmentation = 0 TCP Statistics for IPv4
Fragments Created = 0
Active Opens = 798
UDP Statistics for IPv4 Passive Opens = 17
Failed Connection Attempts = 13
Datagrams Received = 6810 Reset Connections = 467
No Ports = 15 Current Connections = 0
Receive Errors = 0 Segments Received = 64443
Datagrams Sent = 6309 Segments Sent = 63724
Segments Retransmitted = 80
tcpdump and Network Protocol
Analyzers
• tcpdump program captures IP packets on a
network interface (usually Ethernet NIC)
• Filtering used to select packets of interest
• Packets & higher-layer messages can be
displayed and analyzed
• tcpdump basis for many network protocol
analyzers for troubleshooting networks
• We use the open source Ethereal analyzer to
generate examples
– www.ethereal.com
Standards
• New technologies very costly and risky
• Standards allow players to share risk and
benefits of a new market
– Reduced cost of entry
– Interoperability and network effect
– Compete on innovation
– Completing the value chain
• Chips, systems, equipment vendors, service providers
• Example
– 802.11 wireless LAN products
Standards Bodies
• Internet Engineering Task Force
– Internet standards development
– Request for Comments (RFCs): www.ietf.org
• International Telecommunications Union
– International telecom standards
• IEEE 802 Committee
– Local area and metropolitan area network standards
• Industry Organizations
– MPLS Forum, WiFi Alliance, World Wide Web
Consortium
A humorous illustration of a
protocol stack as depicted by
various
standards organizations.

You might also like