0% found this document useful (0 votes)
28 views430 pages

Semester v - Computer Networks(Cs8591)_compressed

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
28 views430 pages

Semester v - Computer Networks(Cs8591)_compressed

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 430

CS8591 COMPUTER NETWORKS

UNIT – I
Unit - I
INTRODUCTION AND PHYSICAL LAYER

Networks – Network Types – Protocol


Layering – TCP/IP Protocol suite – OSI
Model – Physical Layer: Performance –
Transmission media – Switching –
Circuit-switched Networks – Packet
Switching.
Behrouz A. Forouzan, Data Communications and Networking, Fifth Edition
TMH, 2013
1-1 DATA COMMUNICATIONS
The term telecommunication means communication at a
distance. The word data refers to information presented in
whatever form is agreed upon by the parties creating and
using the data. Data communications are the exchange of
data between two devices via some form of transmission
medium such as a wire cable.

Topics discussed in this section:


 Components of a data communications system
 Data Flow

3
Figure 1.1 Components of a data communication system

4
Figure 1.2 Data flow (simplex, half-duplex, and full-duplex)

5
1-2 NETWORKS

A network is a set of devices (often referred to as nodes)


connected by communication links. A node can be a
computer, printer, or any other device capable of sending
and/or receiving data generated by other nodes on the
network. A link can be a cable, air, optical fiber, or any
medium which can transport a signal carrying
information.
Topics discussed in this section:
 Network Criteria
 Physical Structures
 Categories of Networks
6
Network Criteria

 Performance
 Depends on Network Elements
 Measured in terms of Delay and Throughput
 Reliability
 Failure rate of network components
 Measured in terms of availability/robustness
 Security
 Data protection against corruption/loss of data due to:
 Errors
 Malicious users

7
Physical Structures

 Type of Connection
 Point to Point - single transmitter and receiver
 Multipoint - multiple recipients of single
transmission
 Physical Topology
 Connection of devices
 Type of transmission - unicast, mulitcast,
broadcast

8
Figure 1.3 Types of connections: point-to-point and multipoint

9
Figure 1.4 Categories of topology

10
Figure 1.9 A hybrid topology: a star backbone with three bus networks

11
Categories of Networks
 Local Area Networks (LANs)
 Short distances
 Designed to provide local interconnectivity
 Wide Area Networks (WANs)
 Long distances
 Provide connectivity over large areas
 Metropolitan Area Networks (MANs)
 Provide connectivity over areas such as a city, a campus

12
1-3 THE INTERNET

The Internet has revolutionized many aspects of our daily lives. It has
affected the way we do business as well as the way we spend our
leisure time. The Internet is a communication system that has brought
a wealth of information to our fingertips and organized it for our use.

Topics discussed in this section:


Organization of the Internet
Internet Service Providers (ISPs)

13
1-4 PROTOCOLS

A protocol is synonymous with rule. It consists of a set of


rules that govern data communications. It determines
what is communicated, how it is communicated and when
it is communicated. The key elements of a protocol are
syntax, semantics and timing

Topics discussed in this section:


 Syntax
 Semantics
 Timing

14
Elements of a Protocol

 Syntax
 Structure or format of the data
 Indicates how to read the bits - field delineation
 Semantics
 Interprets the meaning of the bits
 Knows which fields define what action
 Timing
 When data should be sent and what
 Speed at which data should be sent or speed at which it is being
received.

15
Network Models

16
2-1 LAYERED TASKS
We use the concept of layers in our daily life. As
an example, let us consider two friends who
communicate through postal mail. The process of
sending a letter to a friend would be complex if
there were no services available from the post
office.

Topics discussed in this section:


Sender, Receiver, and Carrier
Hierarchy

17
Figure 2.1 Tasks involved in sending a letter

18
2-2 THE OSI MODEL
Established in 1947, the International Standards
Organization (ISO) is a multinational body
dedicated to worldwide agreement on
international standards. An ISO standard that
covers all aspects of network communications is
the Open Systems Interconnection (OSI) model. It
was first introduced in the late 1970s.

Topics discussed in this section:


Layered Architecture
Peer-to-Peer Processes
Encapsulation
19
Figure 2.2 Seven layers of the OSI model

Note

ISO is the organization.


OSI is the model.

20
Figure 2.3 The interaction between layers in the OSI model

21
Figure 2.4 An exchange using the OSI model

22
2-3 LAYERS IN THE OSI MODEL

In this section we briefly describe the functions


of each layer in the OSI model.

Topics discussed in this section:


Physical Layer
Data Link Layer
Network Layer
Transport Layer
Session Layer
Presentation Layer
Application Layer

23
Figure 2.5 Physical layer

Note

The physical layer is responsible for movements of


individual bits from one hop (node) to the next.

24
Figure 2.6 Data link layer

Note

The data link layer is responsible for moving


frames from one hop (node) to the next.

25
Figure 2.7 Hop-to-hop delivery

26
Figure 2.8 Network layer

Note

The network layer is responsible for the


delivery of individual packets from
the source host to the destination host.

27
Figure 2.9 Source-to-destination delivery

28
Figure 2.10 Transport layer

Note

The transport layer is responsible for the delivery


of a message from one process to another.

29
Figure 2.11 Reliable process-to-process delivery of a message

30
Figure 2.12 Session layer

Note

The session layer is responsible for dialog


control and synchronization.
31
Figure 2.13 Presentation layer

Note

The presentation layer is responsible for translation,


compression, and encryption.

32
Figure 2.14 Application layer

Note

The application layer is responsible for


providing services to the user.

33
Figure 2.15 Summary of layers

34
2-4 TCP/IP PROTOCOL SUITE
The layers in the TCP/IP protocol suite do not
exactly match those in the OSI model. The
original TCP/IP protocol suite was defined as
having four layers: host-to-network, internet,
transport, and application. However, when TCP/IP
is compared to OSI, we can say that the TCP/IP
protocol suite is made of five layers: physical,
data link, network, transport, and application.
Topics discussed in this section:
Physical and Data Link Layers
Network Layer
Transport Layer
Application Layer
35
Figure 2.16 TCP/IP and OSI model

36
2-5 ADDRESSING
Four levels of addresses are used in an internet
employing the TCP/IP protocols: physical, logical,
port, and specific.
Topics discussed in this section:
Physical Addresses
Logical Addresses
Port Addresses
Specific Addresses

37
Figure 2.18 Relationship of layers and addresses in TCP/IP

38
Example 2.1

In Figure 2.19 a node with physical address 10 sends a


frame to a node with physical address 87. The two nodes
are connected by a link (bus topology LAN). As the figure
shows, the computer with physical address 10 is the
sender, and the computer with physical address 87 is the
receiver.

39
Example 2.2

Most local-area networks use a 48-bit (6-byte)


physical address written as 12 hexadecimal
digits; every byte (2 hexadecimal digits) is
separated by a colon, as shown below:

07:01:02:01:2C:4B

A 6-byte (12 hexadecimal digits) physical


address.

40
Example 2.3

Figure 2.20 shows a part of an internet with two


routers connecting three LANs. Each device
(computer or router) has a pair of addresses
(logical and physical) for each connection. In this
case, each computer is connected to only one
link and therefore has only one pair of
addresses. Each router, however, is connected
to three networks (only two are shown in the
figure). So each router has three pairs of
addresses, one for each connection.

41
Figure 2.20 IP addresses

42
Example 2.4

Figure 2.21 shows two computers


communicating via the Internet. The sending
computer is running three processes at this time
with port addresses a, b, and c. The receiving
computer is running two processes at this time
with port addresses j and k. Process a in the
sending computer needs to communicate with
process j in the receiving computer. Note that
although physical addresses change from hop to
hop, logical and port addresses remain the same
from the source to destination.
43
Figure 2.21 Port addresses

44
Example 2.5

A port address is a 16-bit address represented


by one decimal number as shown.
753

A 16-bit port address represented


as one single number.

Note

The physical addresses will change from hop to hop,


but the logical addresses usually remain the same.
45
3-6 PERFORMANCE

One important issue in networking is the


performance of the network—how good is it? We
discuss quality of service, an overall
measurement of network performance, in greater
detail in Chapter 24. In this section, we introduce
terms that we need for future chapters.
Topics discussed in this section:
 Bandwidth - capacity of the system
 Throughput - no. of bits that can be pushed through
 Latency (Delay) - delay incurred by a bit from start to finish
 Bandwidth-Delay Product
46
Note
In networking, we use the term bandwidth in
two contexts.
 The first, bandwidth in hertz, refers to the
range of frequencies in a composite signal or
the range of frequencies that a channel can
pass.
 The second, bandwidth in bits per second,
refers to the speed of bit transmission in a
channel or link. Often referred to as Capacity.

47
Example 3.42

The bandwidth of a subscriber line is 4 kHz


for voice or data. The bandwidth of this
line for data transmission
can be up to 56,000 bps using a
sophisticated modem to change the digital
signal to analog.

48
Example 3.43

If the telephone company improves the


quality of the line and increases the
bandwidth to 8 kHz, we can send 112,000
bps by using the same technology as
mentioned in Example 3.42.

49
Example 3.44

A network with bandwidth of 10 Mbps can


pass only an average of 12,000 frames per
minute with each frame carrying an average
of 10,000 bits. What is the throughput of this
network?
Solution
We can calculate the throughput as

The throughput is almost one-fifth of the


bandwidth in this case.
50
Propagation & Transmission delay

 Propagation speed - speed at which a bit travels


though the medium from source to destination.
 Transmission speed - the speed at which all the bits
in a message arrive at the destination. (difference in
arrival time of first and last bit)
Propagation Delay = Distance/Propagation speed

Transmission Delay = Message size/bandwidth bps

Latency = Propagation delay + Transmission delay +


Queueing time + Processing time

51
Example 3.45

What is the propagation time if the distance


between the two points is 12,000 km? Assume the
propagation speed to be 2.4 × 108 m/s in cable.

Solution
We can calculate the propagation time as

The example shows that a bit can go over the


Atlantic Ocean in only 50 ms if there is a direct cable
between the source and the destination.
52
Example 3.46

What are the propagation time and the transmission time


for a 2.5-kbyte message (an e-mail) if the bandwidth of the
network is 1 Gbps? Assume that the distance between the
sender and the receiver is 12,000 km and that light travels at
2.4 × 108 m/s.
Solution
We can calculate the propagation and transmission time

Note that in this case, because the message is short and the bandwidth is high,
the dominant factor is the propagation time, not the transmission time. The
transmission time can be ignored.
53
Example 3.47

What are the propagation time and the transmission time


for a 5-Mbyte message (an image) if the bandwidth of the
network is 1 Mbps? Assume that the distance between
the sender and the receiver is 12,000 km and that light
travels at 2.4 × 108 m/s.
Solution
We can calculate the propagation and transmission times

Note that in this case, because the message is very long and the bandwidth is not
very high, the dominant factor is the transmission time, not the propagation time.
The propagation time can be ignored.
54
Figure 3.31 Filling the link with bits for case 1

55
Example 3.48

We can think about the link between two


points as a pipe. The cross section of the
pipe represents the bandwidth, and the
length of the pipe represents the delay. We
can say the volume of the pipe defines the
bandwidth-delay product, as shown in
Figure 3.33.

56
Figure 3.32 Filling the link with bits in case 2

57
Figure 3.33 Concept of bandwidth-delay product

Note
The bandwidth-delay product defines
the number of bits that can fill the link.

58
Transmission Media

59
Figure 7.1 Transmission medium and physical layer

60
Figure 7.2 Classes of transmission media

61
7-1 GUIDED MEDIA

Guided media, which are those that provide a conduit from one device
to another, include twisted-pair cable, coaxial cable, and fiber-optic
cable. Topics discussed in this section:

Twisted-Pair Cable

Coaxial Cable

Fiber-Optic Cable

62
Table 7.1 Categories of unshielded twisted-pair cables

63
Figure 7.5 UTP connector Figure 7.6 UTP performance

64
Figure 7.8 BNC connectors Figure 7.9 Coaxial cable performance

Table 7.2 Categories of coaxial cables

65
Figure 7.12 Propagation modes

Figure 7.10 Bending of light ray

66
Figure 7.13 Modes Figure 7.14 Fiber construction

67
Table 7.3 Fiber types
Figure 7.15 Fiber-optic cable connectors

Figure 7.16 Optical fiber performance

68
7-2 UNGUIDED MEDIA: WIRELESS

Unguided media transport electromagnetic waves without using a


physical conductor. This type of communication is often referred to as
wireless communication. Topics discussed in this section:
Radio Waves
Microwaves
Infrared

Figure 7.17 Electromagnetic spectrum for wireless communication

69
Figure 7.18 Propagation methods

70
Table 7.4 Bands

71
Figure 7.19 Wireless transmission waves

Note
Infrared signals can be used for short-range communication
in a closed area using line-of-sight propagation.

72
Figure 7.20 Omnidirectional antenna

Note

Radio waves are used for multicast


communications, such as radio and television, and
paging systems.

73
Figure 7.21 Unidirectional antennas

Note Microwaves are used for unicast communication such as cellular


telephones, satellite networks, and wireless LANs.

74
Switching

Figure 8.1 Switched network

75
8-1 CIRCUIT-SWITCHED NETWORKS

A circuit-switched network consists of a set of switches


connected by physical links. A connection between two
stations is a dedicated path made of one or more links.
However, each connection uses only one dedicated
channel on each link. Each link is normally divided
into n channels by using FDM or TDM.

Topics discussed in this section:


Three Phases
Efficiency
Delay
Circuit-Switched Technology in Telephone Networks
76
Figure 8.3 A trivial circuit-switched network

Note

A circuit-switched network is made of a set of


switches connected by physical links, in
which each link is divided into n channels.
77
Example 8.1

As a trivial example, let us use a circuit-switched network to connect eight telephones


in a small area. Communication is through 4-kHz voice channels. We assume that
each link uses FDM to connect a maximum of two voice channels. The bandwidth of
each link is then 8 kHz. Figure 8.4 shows the situation. Telephone 1 is connected to
telephone 7; 2 to 5; 3 to 8; and 4 to 6. Of course the situation may change when new
connections are made. The switch controls the connections.
Note

In circuit switching, the resources need to be reserved during


the setup phase; the resources remain dedicated for the entire
duration of data transfer until the teardown phase.

78
Example 8.2

As another example, consider a circuit-switched network that connects computers in


two remote offices of a private company. The offices are connected using a T-1 line
leased from a communication service provider. There are two 4 × 8 (4 inputs and 8
outputs) switches in this network. For each switch, four output ports are folded into
the input ports to allow communication between computers in the same office. Four
other output ports allow communication between the two offices. Figure shows the
situation.

Note
Switching at the physical layer in the traditional
telephone network uses the circuit-switching approach. 79
Figure 8.6 Delay in a circuit-switched network

80
8-2 DATAGRAM NETWORKS

In data communications, we need to send messages


from one end system to another. If the message is
going to pass through a packet-switched network, it
needs to be divided into packets of fixed or variable
size. The size of the packet is determined by the
network and the governing protocol.

Topics discussed in this section:


Routing Table
Efficiency
Delay
Datagram Networks in the Internet
81
Figure 8.7 A datagram network with four switches (routers)

Note

In a packet-switched network, there is no resource


reservation; resources are allocated on demand.

82
Figure 8.8 Routing table in a datagram network

Note

A switch in a datagram network


uses a routing table that is based
on the destination address.

Note

The destination address in the header of a packet in a


datagram network remains the same during the entire
journey of the packet.

83
Figure 8.9 Delay in a datagram network

Note

Switching in the Internet is done by using the


datagram approach to packet switching at
the network layer.
84
8-3 VIRTUAL-CIRCUIT NETWORKS

A virtual-circuit network is a cross between a circuit-


switched network and a datagram network. It has some
characteristics of both. Topics discussed in this section:

Addressing
Three Phases
Efficiency
Delay
Circuit-Switched Technology in WANs

Figure 8.11 Virtual-circuit identifier


85
Figure 8.12 Switch and tables in a virtual-circuit network

Figure 8.13 Source-to-destination data transfer in a virtual-circuit nwk

86
Figure 8.14 Setup request in a virtual-circuit network

87
Figure 8.15 Setup acknowledgment in a virtual-circuit network

Note
In virtual-circuit switching, all packets belonging to the same source
and destination travel the same path; but the packets may arrive at the
destination with different delays if resource allocation is on demand.

88
Figure 8.16 Delay in a virtual-circuit network

Note

Switching at the data link layer in a switched WAN is


normally implemented by using virtual-circuit techniques.
89
8-4 STRUCTURE OF A SWITCH

We use switches in circuit-switched and packet-switched networks. In


this section, we discuss the structures of the switches used in each type
of network. Topics discussed in this section:
Structure of Circuit Switches
Structure of Packet Switches

Figure 8.18 Multistage switch

Figure 8.17 Crossbar switch


with three inputs and four outputs 90
Example 8.3 Note

In a three-stage switch, the total number of crosspoints is


2kN + k(N/n)2 which is much smaller than the number of crosspoints
in a single-stage switch (N2).
Design a three-stage, 200 × 200 switch (N = 200) with k = 4 and n = 20.
Solution
In the first stage we have N/n or 10 crossbars, each of size 20 × 4. In the second
stage, we have 4 crossbars, each of size 10 × 10. In the third stage, we have 10
crossbars, each of size 4 × 20. The total number of crosspoints is 2kN + k(N/n)2,
or 2000 crosspoints. This is 5 percent of the number of crosspoints in a single-
stage switch (200 × 200 = 40,000).
Note

According to the Clos criterion: n = (N/2)1/2


k > 2n – 1 Crosspoints ≥ 4N [(2N)1/2 – 1]
91
Example 8.4
Redesign the previous three-stage, 200 × 200 switch, using
the Clos criteria with a minimum number of crosspoints.
Solution
We let n = (200/2)1/2, or n = 10. We calculate k = 2n − 1 = 19. In the first stage, we
have 200/10, or 20, crossbars, each with 10 × 19 crosspoints. In the second stage,
we have 19 crossbars, each with 10 × 10 crosspoints. In the third stage, we have 20
crossbars each with 19 × 10 crosspoints. The total number of crosspoints is 20(10 ×
19) + 19(10 × 10) + 20(19 ×10) = 9500.

Fig 8.19 Time-slot interchange

92
Figure 8.20 Time-space-time switch

93
Figure 8.21 Packet switch components

Figure 8.22 Input port

94
Figure 8.23 Output port

Figure 8.24 A banyan switch

95
Figure 8.25 Examples of routing in a banyan switch

96
Figure 8.26 Batcher-banyan switch

97
CS8591 COMPUTER NETWORKS

UNIT – II
Unit - II
DATA-LINK LAYER & MEDIA ACCESS

Introduction – Link-Layer Addressing –


DLC Services – Data-Link Layer
Protocols – HDLC – PPP – Media Access
Control – Wired LANs: Ethernet –
Wireless LANs – Introduction – IEEE
802.11, Bluetooth – Connecting Devices.
Behrouz A. Forouzan, Data Communications and Networking, Fifth Edition
TMH, 2013
Data Link layer Services

3
Perspectives on Connecting

An end-user’s view of the Internet

4
Link Capacity & Shannon-Hartley
Theorem
❑Gives the upper bound to the capacity of a link in
terms of bits per second (bps) as a function of
signal-to-noise ratio of the link measured in
decibels (dB).
❑C = Blog2(1+S/N)
❑Where B = 3300 – 300 = 3000Hz, S is the signal power,
N the average noise.
❑The signal to noise ratio (S/N) is measured in decibels is
related to dB = 10 x log10(S/N). If there is 30dB of
noise then S/N = 1000.
❑Now C = 3000 x log2(1001) = 30kbps.
❑How can we get 56kbps?
5
Links
❑ All practical links rely on some sort of electromagnetic
radiation propagating through a medium or, in some cases,
through free space
❑ One way to characterize links, then, is by the medium they use
❑Typically copper wire in some form (as in Digital Subscriber
Line (DSL) and coaxial cable),
❑Optical fiber (as in both commercial fiber-to-the home
services and many long-distance links in the Internet’s
backbone), or
❑Air/free space (for wireless links)
❑ Another important link characteristic is the frequency
❑Measured in hertz, with which the electromagnetic waves
oscillate
6
Links
❑ Distance between the adjacent pair of maxima or minima of a wave
measured in meters is called wavelength
❑ Speed of light divided by frequency gives the wavelength.
❑ Frequency on a copper cable range from 300Hz to 3300Hz; Wavelength for
300Hz wave through copper is speed of light on a copper / frequency
❑ 2/3 x 3 x 108 /300 = 667 x 103 meters.

Electromagnetic
spectrum

7
Links
❑Placing binary data on a signal is called encoding.
❑Modulation involves modifying the signals in terms of
their frequency, amplitude, and phase.

Common services available to connect your home

8
Encoding

Signals travel between signaling components; bits flow between adaptors

NRZ encoding of a bit stream

9
Encoding
❑Problem with NRZ
❑Baseline wander
❑The receiver keeps an average of the signals it has seen so far
❑Uses the average to distinguish between low and high signal
❑When a signal is significantly low than the average, it is 0, else it is 1
❑Too many consecutive 0’s and 1’s cause this average to change, making it
difficult to detect
❑Clock recovery
❑Frequent transition from high to low or vice versa are necessary to enable
clock recovery
❑Both the sending and decoding process is driven by a clock
❑Every clock cycle, the sender transmits a bit and the receiver recovers a bit
❑The sender and receiver have to be precisely synchronized

10
Encoding
❑NRZI
❑Non Return to Zero Inverted
❑Sender makes a transition from the current signal to encode 1
and stay at the current signal to encode 0
❑Solves for consecutive 1’s
❑Manchester encoding
❑Merging the clock with signal by transmitting Ex-OR of the
NRZ encoded data and the clock
❑Clock is an internal signal that alternates from low to high, a
low/high pair is considered as one clock cycle
❑In Manchester encoding
❑0: low→ high transition
❑1: high→ low transition 11
Encoding

Different encoding strategies

12
Encoding
❑ Problem with Manchester encoding
❑ Doubles the rate at which the signal transitions are made on the link
❑Which means the receiver has half of the time to detect each pulse of the
signal
❑ The rate at which the signal changes is called the link’s baud rate
❑ In Manchester the bit rate is half the baud rate
❑ 4B/5B encoding
❑ Insert extra bits into bit stream so as to break up the long sequence of 0’s and
1’s
❑ Every 4-bits of actual data are encoded in a 5- bit code that is transmitted to
the receiver
❑ 5-bit codes are selected in such a way that each one has no more than one
leading 0(zero) and no more than two trailing 0’s.
❑ No pair of 5-bit codes results in more than three consecutive 0’s

13
Encoding
❑4B/5B encoding

0000 → 11110 16 left


0001 → 01001 11111 – when the line is idle
0010 → 10100 00000 – when the line is dead
.. 00100 – to mean halt
..
1111 → 11101 13 left : 7 invalid, 6 for various
control signals

14
Framing
❑ We are focusing on packet-switched networks, which means that
blocks of data (called frames at this level), not bit streams, are
exchanged between nodes.
❑ It is the network adaptor that enables the nodes to exchange
frames.
❑ When node A wishes to transmit a frame to node B, it tells its
adaptor to transmit a frame from the node’s memory. This results in
a sequence of bits being sent over the link.

Bits flow between adaptors,


frames between hosts

15
Framing
❑The adaptor on node B then collects together the
sequence of bits arriving on the link and deposits the
corresponding frame in B’s memory.
❑Recognizing exactly what set of bits constitute a frame—
that is, determining where the frame begins and ends—is
the central challenge faced by the adaptor
❑Byte-oriented Protocols
❑To view each frame as a collection of bytes (characters) rather
than bits
❑BISYNC (Binary Synchronous Communication) Protocol
❑Developed by IBM (late 1960)
❑DDCMP (Digital Data Communication Protocol)
❑Used in DECNet
16
Framing
❑ BISYNC – sentinel approach
❑ Frames transmitted beginning with leftmost field
❑ Beginning of a frame is denoted by sending a special SYN (synchronize)
character
❑ Data portion of the frame is contained between special sentinel character STX
(start of text) and ETX (end of text)
❑ SOH : Start of Header DLE : Data Link Escape CRC: Cyclic Redund.Check
❑ Recent PPP which is commonly run over Internet links uses sentinel approach
❑ Special start of text character denoted as Flag
❑0 1 1 1 1 1 1 0
❑ Address, control : default numbers
❑ Protocol for demux : IP / IPX
❑ Payload : negotiated (1500 bytes)
❑ Checksum : for error detection

17
Framing
❑ Byte-counting approach
❑DDCMP
❑count : how many bytes are contained in the frame body
❑If count is corrupted
❑Framing error
❑ Bit-oriented Protocol
❑HDLC : High Level Data Link Control
❑Beginning and Ending Sequences
❑0 1 1 1 1 1 1 0
❑On the sending side, any time five consecutive 1’s have been
transmitted from the body of the message (i.e. excluding when the
sender is trying to send the distinguished 01111110 sequence)
❑The sender inserts 0 before transmitting the next bit
18
Framing
❑HDLC Protocol
❑On the receiving side
❑5 consecutive 1’s
❑Next bit 0 : Stuffed, so discard it
❑ 1 : Either End of the frame marker Or Error has been
introduced in the bitstream
❑ Look at the next bit
❑ If 0 ( 01111110 ) → End of the frame marker
❑ If 1 ( 01111111 ) → Error, discard the whole frame
❑The receiver needs to wait for next 01111110 before it can start
receiving again

19
Error Detection
❑ Bit errors are introduced into frames
❑ Because of electrical interference and thermal noises
❑ Detecting Error and Correction Error
❑ Two approaches when the recipient detects an error
❑ Notify the sender that the message was corrupted, so the sender can send
again.
❑If the error is rare, then the retransmitted message will be error-free
❑ Using some error correct detection and correction algorithm, the receiver
reconstructs the message
❑ Common technique for detecting transmission error
❑ CRC (Cyclic Redundancy Check)
❑Used in HDLC, DDCMP, CSMA/CD, Token Ring
❑ Other approaches
❑Two Dimensional Parity (BISYNC)
❑Checksum (IP) 20
Error Detection
❑ Basic Idea of Error Detection
❑To add redundant information to a frame that can be used to
determine if errors have been introduced
❑Imagine (Extreme Case)
❑Transmitting two complete copies of data
❑Identical → No error
❑Differ → Error
❑Poor Scheme ???
❑n bit message, n bit redundant information
❑Error can go undetected
❑In general, we can provide strong error detection technique
❑k redundant bits, n bits message, k << n
❑In Ethernet, a frame carrying up to 12,000 bits of data
requires only 32-bit CRC 21
Error Detection
❑ Extra bits are redundant
❑ They add no new information to the message
❑ Derived from the original message using some algorithm
❑ Both the sender and receiver know the algorithm

Sender Receiver
m r m r

❑ Receiver computes r using m


❑ If they match, no error

22
Two-dimensional parity
❑Two-dimensional parity is exactly what the name suggests
❑It is based on “simple” (one-dimensional) parity, which
usually involves adding one extra bit to a 7-bit code to
balance the number of 1s in the byte. For example,
❑Odd parity sets the eighth bit to 1 if needed to give an odd
number of 1s in the byte, and
❑Even parity sets the eighth bit to 1 if needed to give an even
number of 1s in the byte
❑Two-dimensional parity does a similar calculation
for each bit position across each of the bytes
contained in the frame
23
Two-dimensional parity
❑This results in an extra parity
byte for the entire frame, in
addition to a parity bit for each
byte
❑Two-dimensional parity catches
all 1-, 2-, and 3-bit errors and
most 4-bit errors

24
Internet Checksum Algorithm
❑Not used at the link level
❑Add up all the words that are transmitted and then transmit
the result of that sum
❑The result is called the checksum
❑The receiver performs the same calculation on the received
data and compares the result with the received checksum
❑If any transmitted data, including the checksum itself, is
corrupted, then the results will not match, so the receiver
knows that an error occurred
❑Consider the data being checksummed as a sequence of 16-
bit integers.
25
Internet Checksum Algorithm
❑Add them together using 16-bit ones complement
arithmetic (explained next slide) and then take the ones
complement of the result.
❑That 16-bit number is the checksum
❑In ones complement arithmetic, a negative integer −x is
represented as the complement of x;
❑Each bit of x is inverted.
❑When adding numbers in ones complement arithmetic, a
carryout from the most significant bit needs to be added
to the result.

26
Internet Checksum Algorithm
❑Consider, for example, the addition of −5 and −3 in
ones complement arithmetic on 4-bit integers
❑+5 is 0101, so −5 is 1010; +3 is 0011, so −3 is 1100
❑If we add 1010 and 1100 ignoring the carry, we get
0110
❑In ones complement arithmetic, the fact that this
operation caused a carry from the most significant bit
causes us to increment the result, giving 0111, which is
the ones complement representation of −8 (obtained by
inverting the bits in 1000), as we would expect

27
Cyclic Redundancy Check (CRC)
❑ Reduce the number of extra bits and maximize protection
❑ Given a bit string 110001 we can associate a polynomial on a single
variable x for it.
❑1.x5+1.x4+0.x3+0.x2+0.x1+1.x0 = x5+x4+1 and the degree is 5.
❑A k-bit frame has a maximum degree of k-1
❑ Let M(x) be a message polynomial and C(x) be a generator
polynomial.
❑ Let M(x)/C(x) leave a remainder of 0.
❑ When M(x) is sent and M’(x) is received we have M’(x) =
M(x)+E(x)
❑ The receiver computes M’(x)/C(x) and if the remainder is nonzero,
then an error has occurred.
❑ The only thing the sender and the receiver should know is C(x).
28
Cyclic Redundancy Check (CRC)
❑Polynomial Arithmetic Modulo 2
❑Any polynomial B(x) can be divided by a divisor polynomial
C(x) if B(x) is of higher degree than C(x).
❑Any polynomial B(x) can be divided once by a divisor
polynomial C(x) if B(x) is of the same degree as C(x).
❑The remainder obtained when B(x) is divided by C(x) is
obtained by subtracting C(x) from B(x).
❑To subtract C(x) from B(x), we simply perform the exclusive-
OR (XOR) operation on each pair of matching coefficients.
❑Let M(x) be a frame with m bits and let the generator
polynomial have less than m bits say equal to r.
❑Let r be the degree of C(x). Append r zero bits to the
low-order end of the frame, so it now contains m+r bits
and corresponds to the polynomial xrM(x).
29
Cyclic Redundancy Check (CRC)
❑ Divide the bit string
corresponding to xrM(x) by
the bit string corresponding to
C(x) using modulo 2 division.
❑ Subtract the remainder (which
is always r or fewer bits) from
the string corresponding to
xrM(x) using modulo 2
subtraction (addition and
subtraction are the same in
modulo 2).
❑ The result is the CRC Calculation using
checksummed frame to be Polynomial Long Division
transmitted. Call it
polynomial M’(x). 30
Cyclic Redundancy Check (CRC)
❑ Properties of Generator Polynomial
❑ Let P(x) represent what the sender sent and P(x) + E(x) is the received string.
A 1 in E(x) represents that in the corresponding position in P(x) the message
the bit is flipped.
❑ We know that P(x)/C(x) leaves a remainder of 0, but if E(x)/C(x) leaves a
remainder of 0, then either E(x) = 0 or C(x) is factor of E(x).
❑ When C(x) is a factor of E(x) we have problem; errors go unnoticed.
❑ If there is a single bit error then E(x) = xi, where i determines the bit in error.
If C(x) contains two or more terms it will never divide E(x), so all single bit
errors will be detected.
❑ In general, it is possible to prove that the following types of errors can be detected
by a C(x) with the stated properties
❑ All single-bit errors, as long as the xk and x0 terms have nonzero coefficients.
❑ All double-bit errors, as long as C(x) has a factor with at least three terms.
❑ Any odd number of errors, as long as C(x) contains the factor (x+1).
❑ Any “burst” error (i.e., sequence of consecutive error bits) for which the length
of the burst is less than k bits. (Most burst errors of larger than k bits can also
be detected.) 31
Cyclic Redundancy Check (CRC)

❑Six generator polynomials that have become


international standards are:
❑CRC-8 = x8+x2+x+1
❑CRC-10 = x10+x9+x5+x4+x+1
❑CRC-12 = x12+x11+x3+x2+x+1
❑CRC-16 = x16+x15+x2+1
❑CRC-CCITT = x16+x12+x5+1
❑CRC-32 =
x32+x26+x23+x22+x16+x12+x11+x10+x8+x7+x5+x4+x2+x+1

32
Reliable Transmission
❑ CRC is used to detect errors.
❑ Some error codes are strong enough to correct errors.
❑ The overhead is typically too high.
❑ Corrupt frames must be discarded.
❑ A link-level protocol that wants to deliver frames reliably must
recover from these discarded frames.
❑ This is accomplished using a combination of two fundamental
mechanisms
❑Acknowledgements and Timeouts
❑ An acknowledgement (ACK for short) is a small control frame that
a protocol sends back to its peer saying that it has received the
earlier frame.
❑A control frame is a frame with header only (no data).
33
Reliable Transmission
❑The receipt of an acknowledgement indicates to the
sender of the original frame that its frame was
successfully delivered.
❑If the sender does not receive an acknowledgment after a
reasonable amount of time, then it retransmits the original
frame.
❑The action of waiting a reasonable amount of time is
called a timeout.
❑The general strategy of using acknowledgements and
timeouts to implement reliable delivery is sometimes
called Automatic Repeat reQuest (ARQ).

34
Stop and Wait Protocol
❑Idea of stop-and-wait
protocol is
straightforward
❑After transmitting one
frame, the sender waits
for an acknowledgement
before transmitting the
next frame.
❑If the acknowledgement
does not arrive after a
certain period of time,
Timeline showing four different scenarios for the stop-
the sender times out and and-wait algorithm. (a) The ACK is received before the
retransmits the original timer expires; (b) the original frame is lost; (c) the
ACK is lost; (d) the timeout fires too soon
frame
35
Stop and Wait Protocol
❑ If the acknowledgment is lost or delayed
in arriving
❑ The sender times out and retransmits the
original frame, but the receiver will think
that it is the next frame since it has correctly
received and acknowledged the first frame
❑ As a result, duplicate copies of frames will
be delivered
❑ How to solve this
❑ Use 1 bit sequence number (0 or 1)
❑ When the sender retransmits frame 0, the
receiver can determine that it is seeing a
second copy of frame 0 rather than the first
copy of frame 1 and therefore can ignore it Timeline for stop-and-wait
(the receiver still acknowledges it, in case with 1-bit sequence
the first acknowledgement was lost) number
36
Stop and Wait Protocol
❑ The sender has only one outstanding frame on the link at a
time
❑ This may be far below the link’s capacity
❑ Consider a 1.5 Mbps link with a 45 ms RTT
❑ The link has a delay  bandwidth product of 67.5 Kb or approximately
8 KB
❑ Since the sender can send only one frame per RTT and assuming a
frame size of 1 KB
❑ Maximum Sending rate
❑ Bits per frame  Time per frame = 1024  8  0.045 = 182 Kbps
❑ Or about one-eighth of the link’s capacity
❑ To use the link fully, then sender should transmit up to eight frames
before having to wait for an acknowledgement

37
Sliding Window Protocol
❑ Sender assigns a sequence
number denoted as SeqNum to
each frame.
❑ Assume it can grow infinitely large
❑ Sender maintains three variables
❑ Sending Window Size (SWS)
❑ Upper bound on the number of
outstanding (unacknowledged)
frames that the sender can transmit
❑ Last Acknowledgement Received
(LAR)
❑ Sequence number of the last
acknowledgement received Timeline for Sliding Window Protocol
❑ Last Frame Sent (LFS)
❑ Sequence number of the last frame
sent
38
Sliding Window Protocol
❑ Sender also maintains the following invariant
❑ LFS – LAR ≤ SWS
Sliding Window
on Sender

❑ When an acknowledgement arrives


❑ the sender moves LAR to right, thereby allowing the sender to transmit
another frame
❑ Also the sender associates a timer with each frame it transmits
❑ It retransmits the frame if the timer expires before the ACK is received
❑ Note that the sender has to be willing to buffer up to SWS
frames
❑ WHY?

39
Sliding Window Protocol
❑ Receiver maintains three variables
❑ Receiving Window Size (RWS)
❑ Upper bound on the number of out-of-order frames that the receiver is willing to
accept
❑ Largest Acceptable Frame (LAF)
❑ Sequence number of the largest acceptable frame
❑ Last Frame Received (LFR)
❑ Sequence number of the last frame received
❑ Receiver also maintains the following invariant
LAF – LFR ≤ RWS

Sliding Window
on Receiver

40
Sliding Window Protocol
❑ When a frame with sequence number SeqNum arrives, what does the
receiver do?
❑ If SeqNum ≤ LFR or SeqNum > LAF
❑ Discard it (the frame is outside the receiver window)
❑ If LFR < SeqNum ≤ LAF
❑ Accept it
❑ Now the receiver needs to decide whether or not to send an ACK
❑ Let SeqNumToAck
❑ Denote the largest sequence number not yet acknowledged, such that all frames
with sequence number less than or equal to SeqNumToAck have been received
❑ The receiver acknowledges the receipt of SeqNumToAck even if high-
numbered packets have been received
❑ This acknowledgement is said to be cumulative.
❑ The receiver then sets
❑ LFR = SeqNumToAck and adjusts
❑ LAF = LFR + RWS 41
Sliding Window Protocol
❑ For example, suppose LFR = 5 and RWS = 4
❑ (i.e. the last ACK that the receiver sent was for seq. no. 5)
❑ LAF = 9
❑ If frames 7 and 8 arrive, they will be buffered because they are
within the receiver window
❑ But no ACK will be sent since frame 6 is yet to arrive
❑ Frames 7 and 8 are out of order
❑ Frame 6 arrives (it is late because it was lost first time and had to
be retransmitted)
❑ Now Receiver Acknowledges Frame 8
❑ and bumps LFR to 8
❑ and LAF to 12

42
Issues with Sliding Window Protocol
❑ When timeout occurs, the amount of data in transit decreases
❑ Since the sender is unable to advance its window
❑ When the packet loss occurs, this scheme is no longer keeping the
pipe full
❑ The longer it takes to notice that a packet loss has occurred, the more severe
the problem becomes
❑ How to improve this
❑ Negative Acknowledgement (NAK)
❑ Additional Acknowledgement
❑ Selective Acknowledgement
❑ Negative Acknowledgement (NAK)
❑ Receiver sends NAK for frame 6 when frame 7 arrive (in the previous example)
❑ However this is unnecessary since sender’s timeout mechanism will be sufficient to catch
the situation
❑ Additional Acknowledgement
❑ Receiver sends additional ACK for frame 5 when frame 7 arrives
❑ Sender uses duplicate ACK as a clue for frame loss
43
Issues with Sliding Window Protocol
❑ Selective Acknowledgement
❑ Receiver will acknowledge exactly those frames it has received, rather than the
highest number frames
❑Receiver will acknowledge frames 7 and 8
❑Sender knows frame 6 is lost
❑Sender can keep the pipe full (additional complexity)
❑ How to select the window size
❑ SWS is easy to compute
❑Delay  Bandwidth
❑ RWS can be anything
❑Two common setting
❑RWS = 1
❑No buffer at the receiver for frames that arrive out of order RWS = SWS
❑The receiver can buffer frames that the sender transmits
❑It does not make any sense to keep RWS > SWS
❑WHY?
44
Issues with Sliding Window Protocol
❑Finite Sequence Number
❑Frame sequence number is specified in the header field
❑Finite size
❑ 3 bit: eight possible sequence number: 0, 1, 2, 3, 4, 5, 6, 7
❑It is necessary to wrap around
❑How to distinguish between different incarnations of the
same sequence number?
❑Number of possible sequence number must be larger than the
number of outstanding frames allowed
❑Stop and Wait: One outstanding frame
❑ 2 distinct sequence number (0 and 1)
❑Let MaxSeqNum be the number of available sequence numbers
❑SWS + 1 ≤ MaxSeqNum
❑ Is this sufficient?
45
Issues with Sliding Window Protocol
❑ SWS + 1 ≤ MaxSeqNum
❑Is this sufficient?
❑Depends on RWS
❑If RWS = 1, then sufficient
❑If RWS = SWS, then not good enough
❑ For example, we have eight sequence numbers 0, 1, 2, 3, 4, 5, 6, 7
❑ RWS = SWS = 7
❑ Sender sends 0, 1, …, 6
❑ Receiver receives 0, 1, … ,6
❑ Receiver acknowledges 0, 1, …, 6
❑ ACK (0, 1, …, 6) are lost
❑ Sender retransmits 0, 1, …, 6
❑ Receiver is expecting 7, 0, …., 5

46
Issues with Sliding Window Protocol
❑To avoid this,
❑ If RWS = SWS
❑ SWS < (MaxSeqNum + 1)/2
❑Serves three different roles
❑ Reliable
❑ Preserve the order
❑Each frame has a sequence number
❑The receiver makes sure that it does not pass a frame up to the next
higher-level protocol until it has already passed up all frames with a
smaller sequence number
❑ Frame control
❑Receiver is able to throttle the sender
❑ Keeps the sender from overrunning the receiver
❑ From transmitting more data than the receiver is able to process

47
HDLC and PPP

48
The Data Link Layer in the Internet

A home personal computer acting as an internet


host.

Technology like Ethernet cannot provide “high-level” functionality


like connection management and parameter negotiation
49
Point to Point Data Link Control
❑ One sender, one receiver, one link: easier than broadcast link:
❑No Media Access Control
❑No need for explicit MAC addressing
❑E.g., dialup link, ISDN line
❑ Popular point-to-point and high-level DLC protocols:
❑PPP (point-to-point protocol)
❑HDLC: High level data link control (Data link used to be considered
“high layer” in protocol stack). HDLC is also used in multi-point links
(one station many receivers)
❑ These protocols can often be run over other data link technologies
providing best of both worlds
❑E.g., PPPoE, HDLC encapsulation by Ethernet

50
PPP Design Requirements [RFC 1557]
❑Functionality : (similar to link layer services +
extra management functions)
❑Packet framing - encapsulation of network-layer datagram in
data link frame
❑Multi-protocol - carry network layer data of any network
layer protocol (not just IP) at same time ability to demultiplex
upwards
❑Bit transparency - must carry any bit pattern in the data field
(even if underlying channel can't)
❑Error detection - not correction

51
PPP Design Requirements (cont.)
The extra stuff:
❑ Connection liveness: detect, signal link failure to
network layer
❑ Network layer address negotiation: endpoint can
learn/configure each other’s network address and other
characteristics.
❑ Authentication: who are you (or at least whose account
do I bill for your dial-in time?)
❑ This information is used by traffic management software to control
bandwidth to individual subscribers
❑ Management features: loopback detection
52
PPP non-requirements
❑No error correction/recovery
❑(modems do one layer FEC, one layer packetization +
retransmission “under the covers” anyway; other
technologies are pretty reliable)
❑No flow control
❑Out of order delivery OK

Error recovery, flow control, data re-ordering


all relegated to higher layers!

53
PPP Data Frame

❑Flag: delimiter (framing)


❑Address: ignored. (historical)
❑Control: ignored. (historical)
❑Protocol: upper layer protocol to which frame
delivered (e.g., PPP-LCP, IP, IPCP, etc)

54
PPP Data Frame

❑info: upper layer data being carried


❑check: cyclic redundancy check for error detection

55
Byte Stuffing

flag byte
pattern
in data
to send

flag byte pattern plus


stuffed byte in
transmitted data

56
PPP Data Control Protocol

Before exchanging network-layer


data, data link peers must
❑ Configure PPP link (max.
frame length, authentication)
❑ Learn/configure network
❑ layer information
❑for IP: carry IP Control
Protocol (IPCP) msgs
(protocol field: 8021) to
configure/learn IP address

57
Where does PPP get used?

❑Dial-up – PPP over async serial, over modem


❑ADSL – PPP over Ethernet
❑Backbone – Packet over SONET (POS)
❑Why?
❑Framing (dialup, POS)
❑Efficiency (POS)
❑Authentication, address negotiation (PPPoE)

58
High-Level Data Link Control (HDLC)

❑HDLC was defined by ISO for use on both point-to-point


and multipoint data links.
❑It supports full-duplex communication
❑Other similar protocols are
❑Synchronous Data Link Control (SDLC) by IBM
❑Advanced Data Communication Control Procedure (ADCCP) by
ANSI
❑Link Access Procedure, Balanced (LAP-B) by CCITT, as part of
its X.25 packet-switched network standard

59
HDLC Overview
Broadly HDLC features are as follows:
❑Reliable protocol
❑selective repeat or go-back-N
❑Full-duplex communication
❑receive and transmit at the same time
❑Bit-oriented protocol
❑use bits to stuff flags occurring in data
❑Flow control
❑adjust window size based on receiver capability
❑Uses physical layer clocking and synchronization to send
and receive frames

60
HDLC Overview
❑Defines three types of stations
❑Primary
❑Secondary
❑Combined
❑Defines three types of data transfer mode
❑Normal Response mode
❑Asynchronous Response mode
❑Asynchronous Balanced mode
❑Three types of frames
❑Unnumbered
❑information
❑Supervisory
61
HDLC
❑The three stations are :
❑Primary station
❑Has the responsibility of controlling the operation of data flow
the link.
❑Handles error recovery
❑Frames issued by the primary station are called commands.
❑Secondary station,
❑Operates under the control of the primary station.
❑Frames issued by a secondary station are called responses.
❑The primary station maintains a separate logical link with each
secondary station.
❑Combined station,
❑Acts as both as primary and secondary station.
❑Does not rely on other for sending data
62
HDLC
Unbalanced Mode

Commands
Primary
Responses

Secondary Secondary

Balanced mode

Combined Combined
commands/Responses

63
HDLC
❑ The three modes of data transfer operations are
❑Normal Response Mode (NRM)
❑Mainly used in terminal-mainframe networks. In this case,
❑Secondaries (terminals) can only transmit when specifically
instructed by the primary station in response to a polling
❑Unbalanced configuration, good for multi-point links
❑Asynchronous Response Mode (ARM)
❑Same as NRM except that the secondaries can initiate
transmissions without direct polling from the primary station
❑Reduces overhead as no frames need to be sent to allow
secondary nodes to transmit
❑Transmission proceeds when channel is detected idle , used
mostly in point-to-point-links
❑Asynchronous Balanced Mode (ABM)
❑Mainly used in point-to-point links, for communication
between combined stations
64
Non-operational Modes
❑Normal Disconnected Mode
❑Asynchronous Disconnected Mode

❑Both the above modes mean that the secondary node is


logically disconnected from the primary node

❑Initialization Mode
❑A node negotiates transmission parameters with the
other node E.g., flow control information
❑Parameters negotiated in this mode are used during
any of the data transfer modes

65
Data Link Control HDLC frame structure

(a) Frame Format

(b) Control field format

66
Data Link Control
HDLC frame structure

(c) Extended address field (d) Extended control field

67
HDLC
❑ Flag: 01111110- start and ending delimiter. Bits are stuffed for flags in data frames
❑ FCS: 16-bit CRC using generating polynomial
❑ G(x) = x16 + x12 + x5 + 1
❑ Address field:
❑ mainly used in multidrop link configuration, and not used in point-to-point
❑ In unbalanced configuration, every secondary is assigned a unique address.
Contains address of secondary station in both command and response frames
❑ In balanced mode, command frame has destination address and response frame
has sending node’s address
❑ Group addresses are also possible. E.g., One command sent to all the
secondaries
❑ In I-frames, N(s) is the sequence number of the frame being sent, and R(s) is the
sequence number of the frame being expected.
❑ The P/F bit, known as the poll/final bit, is used with different meaning in different
contexts.
❑ It is used to indicate polling, to indicate the final I-frame, etc

68
HDLC

❑There are three different classes of frames used in


HDLC
❑Unnumbered frames, used in link setup and
disconnection, and hence do not contain ACK.
❑Information frames, which carry actual information.
Such frames can piggyback ACK in case of ABM
❑Supervisory frames, which are used for error and flow
control purposes and hence contain send and receive
sequence numbers

69
HDLC
❑There are four different supervisory frames
❑SS=00, Receiver Ready (RR), and N(R) ACKs all frames
received up to and including the one with sequence number N(R)
-1
❑SS=10, Receiver Not Ready (RNR), and N(R) has the same
meaning as above
❑SS=01, Reject; all frames with sequence number N(R) or higher
are rejected, which in turns ACKs frames with sequence number
N(R) -1 or lower.
❑SS=11, Selective Reject; the receive rejects the frame with
sequence number N(R)

70
HDLC

❑The unnumbered frames can be grouped into the


following categories:
❑Mode-setting commands and responses
❑Recovery commends and responses
❑Miscellaneous commands and responses

71
Media Access Control
Ethernet
❑ Most successful local area networking technology of last 20 years.
❑ Developed in the mid-1970s by researchers at the Xerox Palo Alto
Research Centers (PARC).
❑ Uses CSMA/CD technology
❑ Carrier Sense Multiple Access with Collision Detection.
❑ A set of nodes send and receive frames over a shared link.
❑ Carrier sense means that all nodes can distinguish between an idle and a busy
link.
❑ Collision detection means that a node listens as it transmits and can therefore
detect when a frame it is transmitting has collided with a frame transmitted by
another node.
❑ Uses ALOHA (packet radio network) as the root protocol
❑ Developed at the University of Hawaii to support communication across the
Hawaiian Islands.
❑ For ALOHA the medium was atmosphere, for Ethernet the medium is a coax
cable.
73
Ethernet
❑ DEC and Intel joined Xerox to define a 10-Mbps Ethernet
standard in 1978.
❑ This standard formed the basis for IEEE standard 802.3
❑ More recently 802.3 has been extended to include a 100-Mbps
version called Fast Ethernet and a 1000-Mbps version called
Gigabit Ethernet.
❑ An Ethernet segment is implemented on a coaxial cable of up to 500 m.
❑ This cable is similar to the type used for cable TV except that it typically
has an impedance of 50 ohms instead of cable TV’s 75 ohms.
❑ Hosts connect to an Ethernet segment by tapping into it.
❑ A transceiver (a small device directly attached to the tap) detects when
the line is idle and drives signal when the host is transmitting.
❑ The transceiver also receives incoming signal.

74
Ethernet
❑ The transceiver is connected to an
Ethernet adaptor which is plugged
into the host.
❑ The protocol is implemented on the
adaptor.
❑ Multiple Ethernet segments can
be joined together by repeaters.
❑ A repeater is a device that
forwards digital signals.
❑ No more than four repeaters may
be positioned between any pair of
Ethernet transceiver and adaptor
hosts.
❑ An Ethernet has a total reach of only
2500 m.

75
Ethernet
❑Any signal placed on the
Ethernet by a host is
broadcast over the entire
network
❑Signal is propagated in both
directions.
❑Repeaters forward the signal
on all outgoing segments.
❑Terminators attached to the
end of each segment absorb
the signal. Ethernet repeater

❑Ethernet uses Manchester


encoding scheme.
76
Ethernet
❑New Technologies in Ethernet
❑ Instead of using coax cable, an Ethernet can be constructed from a thinner
cable known as 10Base2 (the original was 10Base5)
❑10 means the network operates at 10 Mbps
❑Base means the cable is used in a baseband system
❑2 means that a given segment can be no longer than 200 m
❑ Another cable technology is 10BaseT
❑T stands for twisted pair
❑Limited to 100 m in length
❑ With 10BaseT, the common configuration is to have several point to point
segments coming out of a multiway repeater, called Hub

Ethernet Hub

77
Access Protocol for Ethernet
❑ The algorithm is commonly called Ethernet’s Media Access Control
(MAC).
❑ It is implemented in Hardware on the network adaptor.
❑ Frame format
❑ Preamble (64bit): allows the receiver to synchronize with the signal
(sequence of alternating 0s and 1s).
❑ Host and Destination Address (48bit each).
❑ Packet type (16bit): acts as demux key to identify the higher level protocol.
❑ Data (up to 1500 bytes)
❑ Minimally a frame must contain at least 46 bytes of data.
❑ Frame must be long enough to detect collision.
❑ CRC (32bit)

78
Ethernet Addresses
❑ Each host on an Ethernet (in fact, every Ethernet host in the world)
has a unique Ethernet Address.
❑ The address belongs to the adaptor, not the host.
❑ It is usually burnt into ROM.
❑ Ethernet addresses are typically printed in a human readable format
❑ As a sequence of six numbers separated by colons.
❑ Each number corresponds to 1 byte of the 6 byte address and is given by a pair
of hexadecimal digits, one for each of the 4-bit nibbles in the byte
❑ Leading 0s are dropped.
❑ For example, 8:0:2b:e4:b1:2 is
❑ 00001000 00000000 00101011 11100100 10110001 00000010
❑ To ensure that every adaptor gets a unique address, each
manufacturer of Ethernet devices is allocated a different prefix that
must be prepended to the address on every adaptor they build
❑AMD has been assigned the 24bit prefix 8:0:20
79
Ethernet Addresses
❑ Each frame transmitted on an Ethernet is received by every adaptor
connected to that Ethernet.
❑ Each adaptor recognizes those frames addressed to its address and
passes only those frames on to the host.
❑ In addition, to unicast address, an Ethernet address consisting of all
1s is treated as a broadcast address.
❑ All adaptors pass frames addressed to the broadcast address up to the host.
❑ Similarly, an address that has the first bit set to 1 but is not the
broadcast address is called a multicast address.
❑ A given host can program its adaptor to accept some set of
multicast addresses. To summarize, an Ethernet adaptor receives all
frames and accepts
❑ Frames addressed to its own address
❑ Frames addressed to the broadcast address
❑ Frames addressed to a multicast addressed if it has been instructed

80
Ethernet Transmitter Algorithm
❑ When the adaptor has a frame to send and the line is idle, it transmits
the frame immediately.
❑ The upper bound of 1500 bytes in the message means that the adaptor can
occupy the line for a fixed length of time.
❑ When the adaptor has a frame to send and the line is busy, it waits
for the line to go idle and then transmits immediately.
❑ The Ethernet is said to be 1-persistent protocol because an adaptor
with a frame to send transmits with probability 1 whenever a busy
line goes idle.
❑ Since there is no centralized control it is possible for two (or more)
adaptors to begin transmitting at the same time,
❑ Either because both found the line to be idle,
❑ Or, both had been waiting for a busy line to become idle.
❑ When this happens, the two (or more) frames are said to be collide
on the network.
81
Ethernet Transmitter Algorithm
❑ Since Ethernet supports collision detection, each sender is able
to determine that a collision is in progress.
❑ At the moment an adaptor detects that its frame is colliding
with another, it first makes sure to transmit a 32-bit jamming
sequence and then stops transmission.
❑ Thus, a transmitter will minimally send 96 bits in the case of collision
❑ 64-bit preamble + 32-bit jamming sequence
❑ One way that an adaptor will send only 96 bit (called a runt
frame) is if the two hosts are close to each other.
❑ Had they been farther apart,
❑ They would have had to transmit longer, and thus send more bits,
before detecting the collision.

82
Ethernet Transmitter Algorithm
❑The worst case scenario happens when the two hosts are at
opposite ends of the Ethernet.
❑To know for sure that the frame its just sent did not collide
with another frame, the transmitter may need to send as
many as 512 bits.
❑Every Ethernet frame must be at least 512 bits (64 bytes) long.
❑14 bytes of header + 46 bytes of data + 4 bytes of CRC
❑Why 512 bits?
❑Why is its length limited to 2500 m?
❑The farther apart two nodes are, the longer it takes for a
frame sent by one to reach the other, and the network is
vulnerable to collision during this time
83
Ethernet Transmitter Algorithm
❑ A begins transmitting a frame at time t
❑ d denotes the one link latency
❑ The first bit of A’s frame arrives at B at
time t + d
❑ Suppose an instant before host A’s frame
arrives, host B begins to transmit its own
frame
❑ B’s frame will immediately collide with A’s
frame and this collision will be detected by
host B
❑ Host B will send the 32-bit jamming
sequence
❑ Host A will not know that the collision
occurred until B’s frame reaches it, which
will happen at t + 2 * d
❑ Host A must continue to transmit until this Worst-case scenario: (a) A sends a frame
at time t; (b) A’s frame arrives at B at time
time in order to detect the collision t + d; (c) B begins transmitting at time t +
❑ Host A must transmit for 2 * d to be d and collides with A’s frame; (d) B’s runt
sure that it detects all possible (32-bit) frame arrives at A at time t + 2d.
collisions 84
Ethernet Transmitter Algorithm
❑Consider that a maximally configured Ethernet is 2500 m
long, and there may be up to four repeaters between any two
hosts, the round trip delay has been determined to be 51.2
s
❑Which on 10 Mbps Ethernet corresponds to 512 bits
❑The other way to look at this situation,
❑We need to limit the Ethernet’s maximum latency to a fairly small
value (51.2 s) for the access algorithm to work
❑Hence the maximum length for the Ethernet is on the order of 2500 m.
❑ Once an adaptor has detected a collision, and stopped its transmission,
it waits a certain amount of time and tries again.
❑ Each time the adaptor tries to transmit but fails, it doubles the amount
of time it waits before trying again.

85
Ethernet Transmitter Algorithm
❑ This strategy of doubling the delay interval between each
retransmission attempt is known as Exponential Backoff.
❑ The adaptor first delays either 0 or 51.2 s, selected at random.
❑ If this effort fails, it then waits 0, 51.2, 102.4, 153.6 s (selected
randomly) before trying again;
❑ This is k * 51.2 for k = 0, 1, 2, 3
❑ After the third collision, it waits k * 51.2 for k = 0…23 – 1 (again
selected at random).
❑ In general, the algorithm randomly selects a k between 0 and 2n –
1 and waits for k * 51.2 s, where n is the number of collisions
experienced so far.

86
Experience with Ethernet
❑ Ethernets work best under lightly loaded conditions.
❑ Under heavy loads, too much of the network’s capacity is wasted by
collisions.
❑ Most Ethernets are used in a conservative way.
❑ Have fewer than 200 hosts connected to them which is far fewer than the
maximum of 1024.
❑ Most Ethernets are far shorter than 2500m with a round-trip
delay of closer to 5 s than 51.2 s.
❑ Ethernets are easy to administer and maintain.
❑ There are no switches that can fail and no routing and configuration tables
that have to be kept up-to-date.
❑ It is easy to add a new host to the network.
❑ It is inexpensive.
❑ Cable is cheap, and only other cost is the network adaptor on each host.

87
Wireless Links
❑ Wireless links transmit electromagnetic signals
❑ Radio, microwave, infrared
❑ Wireless links all share the same “wire” (so to speak)
❑ The challenge is to share it efficiently without unduly interfering with each other
❑ Most of this sharing is accomplished by dividing the “wire” along the
dimensions of frequency and space
❑ Exclusive use of a particular frequency in a particular geographic area
may be allocated to an individual entity such as a corporation
❑ Devices that use license-exempt frequencies are still subject to certain
restrictions
❑ The first is a limit on transmission power
❑ This limits the range of signal, making it less likely to interfere with another
signal
❑ For example, a cordless phone might have a range of about 100 feet.

88
Wireless Links
❑These allocations are determined by government agencies
such as FCC (Federal Communications Commission) in
USA
❑Specific bands (frequency) ranges are allocated to certain
uses.
❑Some bands are reserved for government use
❑Other bands are reserved for uses such as AM radio, FM radio,
televisions, satellite communications, and cell phones
❑Specific frequencies within these bands are then allocated to
individual organizations for use within certain geographical areas.
❑Finally, there are several frequency bands set aside for “license
exempt” usage
❑ Bands in which a license is not needed

89
Wireless Links
❑The second restriction requires the use of Spread
Spectrum technique
❑Idea is to spread the signal over a wider frequency band
❑ So as to minimize the impact of interference from other devices
❑ Originally designed for military use
❑Frequency hopping
❑Transmitting signal over a random sequence of frequencies
❑First transmitting at one frequency, then a second, then a third…
❑The sequence of frequencies is not truly random, instead computed
algorithmically by a pseudorandom number generator
❑The receiver uses the same algorithm as the sender, initializes it with
the same seed, and is
❑ Able to hop frequencies in sync with the transmitter to correctly receive
the frame

90
Wireless Links
❑ A second spread spectrum technique called Direct sequence
❑ Represents each bit in the frame by multiple bits in the transmitted signal.
❑ For each bit the sender wants to transmit
❑ It actually sends the exclusive OR of that bit and n random bits
❑ The sequence of random bits is generated by a pseudorandom number
generator known to both the sender and the receiver.
❑ The transmitted values, known as an n-bit chipping code, spread the
signal across a frequency band that is n times wider

Example 4-bit chipping sequence

91
Wireless Links
❑ Wireless technologies differ in a variety of dimensions
❑ How much bandwidth they provide
❑ How far apart the communication nodes can be
❑ Four prominent wireless technologies: Bluetooth, Wi-Fi (more formally
known as 802.11), WiMAX (802.16), 3G cellular wireless

Overview of leading wireless technologies

92
Wireless Links
❑ Mostly widely used
wireless links today
are usually
asymmetric
❑ Two end-points are
usually different kinds
of nodes
❑ One end-point usually
has no mobility, but
has wired connection
to the Internet
(known as base
station)
❑ The node at the other
end of the link is often A wireless network using a base station
mobile

93
Wireless Links
❑ Wireless communication supports point-to-multipoint communication
❑ Communication between non-base (client) nodes is routed via the base
station
❑ Three levels of mobility for clients
❑ No mobility: the receiver must be in a fix location to receive a directional
transmission from the base station (initial version of WiMAX)
❑ Mobility is within the range of a base (Bluetooth)
❑ Mobility between bases (Cell phones and Wi-Fi)
❑ Mesh or Ad-hoc network
❑ Messages may be forwarded via a chain of peer nodes
❑ Nodes are peers

94
IEEE 802.11
❑ Also known as Wi-Fi
❑ Like its Ethernet and token ring siblings, 802.11 is designed for use
in a limited geographical area (homes, office buildings, campuses)
❑ Primary challenge is to mediate access to a shared communication medium –
in this case, signals propagating through space
❑ 802.11 supports additional features
❑ power management and
❑ security mechanisms
❑ Original 802.11 standard defined two radio-based physical layer standard
❑ One using the frequency hopping
❑ Over 79 1-MHz-wide frequency bandwidths
❑ Second using direct sequence
❑ Using 11-bit chipping sequence
❑ Both standards run in the 2.4-GHz and provide up to 2 Mbps

95
IEEE 802.11
❑Then physical layer standard 802.11b was added
❑Using a variant of direct sequence 802.11b provides up to
11 Mbps
❑Uses license-exempt 2.4-GHz band
❑Then came 802.11a which delivers up to 54 Mbps
using OFDM
❑802.11a runs on license-exempt 5-GHz band
❑Most recent standard is 802.11g which is backward
compatible with 802.11b
❑Uses 2.4 GHz band, OFDM and delivers up to 54 Mbps

96
IEEE 802.11 – Collision Avoidance
❑ Consider the situation in the following figure where each of four
nodes is able to send and receive signals that reach just the nodes to
its immediate left and right
❑ For example, B can exchange frames with A and C, but it cannot reach D
❑ C can reach B and D but not A

Example of a wireless network

97
IEEE 802.11 – Collision Avoidance
❑ Suppose both A and C want
to communicate with B and
so they each send it a frame.
❑ A and C are unaware of each
other since their signals do not
carry that far
❑ These two frames collide with
each other at B
❑ But unlike an Ethernet,
neither A nor C is aware of The “Hidden Node” Problem. Although
this collision A and C are hidden from each
❑ A and C are said to hidden other, their signals can collide at B. (B’s
reach is not shown.)
nodes with respect to each
other

98
IEEE 802.11 – Collision Avoidance
❑ Another problem called exposed
node problem occurs
❑ Suppose B is sending to A. Node
C is aware of this communication
because it hears B’s transmission.
❑ It would be a mistake for C to
conclude that it cannot transmit to
anyone just because it can hear B’s
transmission.
❑ Suppose C wants to transmit to
node D. Exposed Node Problem. Although B and
C are exposed to each other’s signals,
❑ This is not a problem since C’s
there is no interference if B transmits to A
transmission to D will not interfere
while C transmits to D. (A and D’s reaches
with A’s ability to receive from B. are not shown.)

99
IEEE 802.11 – Collision Avoidance
❑802.11 addresses these two problems with an algorithm
called Multiple Access with Collision Avoidance (MACA).
❑Key Idea
❑Sender and receiver exchange control frames with each other
before the sender actually transmits any data.
❑This exchange informs all nearby nodes that a transmission is
about to begin
❑Sender transmits a Request to Send (RTS) frame to the receiver.
❑The RTS frame includes a field that indicates how long the sender wants to
hold the medium
❑ - Length of the data frame to be transmitted
❑Receiver replies with a Clear to Send (CTS) frame
❑This frame echoes this length field back to the sender

100
IEEE 802.11 – Collision Avoidance
❑Any node that sees the CTS frame knows that
❑it is close to the receiver, therefore
❑cannot transmit for the period of time it takes to
send a frame of the specified length
❑Any node that sees the RTS frame but not the
CTS frame
❑is not close enough to the receiver to interfere with
it, and
❑so is free to transmit

101
IEEE 802.11 – Collision Avoidance
❑ Using ACK in MACA
❑ Proposed in MACAW: MACA for Wireless LANs
❑ Receiver sends an ACK to the sender after successfully receiving a
frame
❑ All nodes must wait for this ACK before trying to transmit
❑ If two or more nodes detect an idle link and try to transmit an RTS
frame at the same time
❑ Their RTS frame will collide with each other
❑ 802.11 does not support collision detection
❑ So the senders realize the collision has happened when they do not receive the
CTS frame after a period of time
❑ In this case, they each wait a random amount of time before trying again.
❑ The amount of time a given node delays is defined by the same exponential
backoff algorithm used on the Ethernet.

102
IEEE 802.11 – Distribution System
❑802.11 is suitable for an ad-hoc configuration of nodes that
may or may not be able to communicate with all other
nodes.
❑Nodes are free to move around
❑The set of directly reachable nodes may change over time
❑To deal with this mobility and partial connectivity,
❑802.11 defines additional structures on a set of nodes
❑Instead of all nodes being created equal,
❑some nodes are allowed to roam
❑ some are connected to a wired network infrastructure
❑ they are called Access Points (AP) and they are connected to each other by a
so-called distribution system

103
IEEE 802.11 – Distribution System
❑ Following figure illustrates a distribution system that connects three access points,
each of which services the nodes in the same region
❑ Each of these regions is analogous to a cell in a cellular phone system with the
APIs playing the same role as a base station
❑ The distribution network runs at layer 2 of the ISO architecture
❑ Although two nodes can communicate directly with each other if they are within
reach of each other, the idea behind this configuration is
❑ Each nodes associates itself with one access point
❑ For node A to communicate with node E, A first sends a frame to its AP-1 which
forwards the frame across the distribution system to AP-3, which finally transmits the
frame to E

Access points connected


to a distribution network

104
IEEE 802.11 – Distribution System
❑ How do the nodes select their access points
❑ How does it work when nodes move from one cell to another
❑ The technique for selecting an AP is called scanning
❑ The node sends a Probe frame
❑ All APs within reach reply with a Probe Response frame
❑ The node selects one of the access points and sends that AP an Association
Request frame
❑ The AP replies with an Association Response frame
❑ A node engages this protocol whenever
❑ it joins the network, as well as
❑ when it becomes unhappy with its current AP
❑ This might happen, for example, because the signal from its current AP has
weakened due to the node moving away from it
❑ Whenever a node acquires a new AP, the new AP notifies the old AP of the
change via the distribution system

105
IEEE 802.11 – Distribution System
❑ Consider the situation shown in the following figure when node C moves from the
cell serviced by AP-1 to the cell serviced by AP-2.
❑ As it moves, it sends Probe frames, which eventually result in Probe Responses
from AP-2.
❑ At some point, C prefers AP-2 over AP-1 , and so it associates itself with that
access point.
❑ This is called active scanning since the node is actively searching for an access point
❑ APs also periodically send a Beacon frame that advertises the capabilities of the
access point; these include the transmission rate supported by the AP
❑ This is called passive scanning
❑ A node can change to this AP based on the Beacon frame simply by sending it an
Association Request frame back to the access point.

Node Mobility

106
IEEE 802.11 – Frame Format
❑Source and Destinations addresses: each 48 bits
❑Data: up to 2312 bytes
❑CRC: 32 bit
❑Control field: 16 bits
❑Contains three subfields (of interest)
❑6 bit Type field: indicates whether the frame is an RTS or CTS frame or
being used by the scanning algorithm
❑A pair of 1 bit fields : called ToDS and FromDS

Frame Format

107
IEEE 802.11 – Frame Format
❑ Frame contains four addresses
❑ How these addresses are interpreted depends on the settings of
the ToDS and FromDS bits in the frame’s Control field
❑ This is to account for the possibility that the frame had to be
forwarded across the distribution system which would mean
that,
❑ the original sender is not necessarily the same as the most recent
transmitting node
❑ Same is true for the destination address
❑ Simplest case
❑ When one node is sending directly to another, both the DS bits are 0,
Addr1 identifies the target node, and Addr2 identifies the source node

108
IEEE 802.11 – Frame Format
❑Most complex case
❑Both DS bits are set to 1
❑Indicates that the message went from a wireless node onto the
distribution system, and then from the distribution system to
another wireless node
❑With both bits set,
❑Addr1 identifies the ultimate destination,
❑Addr2 identifies the immediate sender (the one that forwarded the
frame from the distribution system to the ultimate destination)
❑Addr3 identifies the intermediate destination (the one that accepted
the frame from a wireless node and forwarded across the
distribution system)
❑Addr4 identifies the original source
❑Addr1: E, Addr2: AP-3, Addr3: AP-1, Addr4: A

109
Bluetooth
❑ Used for very short range
communication between mobile
phones, PDAs, notebook
computers and other personal or
peripheral devices
❑ Operates in the license-exempt
band at 2.45 GHz
❑ Has a range of only 10 m
❑ Communication devices
typically belong to one
individual or group
❑ Sometimes categorized as Personal
Area Network (PAN) A Bluetooth Piconet

110
Bluetooth
❑ Version 2.0 provides speeds up to 2.1 Mbps
❑ Power consumption is low
❑ Bluetooth is specified by an industry consortium called the
Bluetooth Special Interest Group
❑ It specifies an entire suite of protocols, going beyond the link layer
to define application protocols, which it calls profiles, for a range of
applications
❑ There is a profile for synchronizing a PDA with personal computer
❑ Another profile gives a mobile computer access to a wired LAN
❑ The basic Bluetooth network configuration is called a piconet
❑ Consists of a master device and up to seven slave devices
❑ Any communication is between the master and a slave
❑ The slaves do not communicate directly with each other
❑ A slave can be parked: set to an inactive, low-power state
111
ZigBee
❑ZigBee is a new technology that competes with
Bluetooth
❑Devised by the ZigBee alliance and standardized as IEEE
802.15.4
❑It is designed for situations where the bandwidth
requirements are low and power consumption must be
very low to give very long battery life
❑It is also intended to be simpler and cheaper than
Bluetooth, making it financially feasible to incorporate in
cheaper devices such as a wall switch that wirelessly
communicates with a ceiling-mounted fan

112
CS8591 COMPUTER NETWORKS

UNIT – III

Dr.A.Kathirvel, Professor & Head, Computer Science & Engg.


M N M Jain Engineering College, Chennai
Unit - III
NETWORK LAYER
Network Layer Services – Packet
switching – Performance – IPV4
Addresses – Forwarding of IP Packets –
Network Layer Protocols: IP, ICMP v4 –
Unicast Routing Algorithms – Protocols
– Multicasting Basics – IPV6 Addressing
– IPV6 Protocol.
Behrouz A. Forouzan, Data Communications and Networking, Fifth Edition
TMH, 2013 2
Network layer duties

Network layer in an internetwork

3
NETWORK LAYER SERVICES
In this section, we briefly discuss services provided by the network layer. Our discussion
is mostly based on the connectionless service, the dominant service in today’s Internet.
 Logical Addressing
 Services Provided at the Source Computer
 Services Provides at the Each Router
 Services Provided at the Destination Computer

Goal: Router is to forward packets through a set of networks.

1. Classification of Routing algorithm - Two Types


Static routing algorithm ( non – adaptive)
Dynamic routing algorithm (adaptive)
2. Routing tables

At the conceptual level, we can think of the global Internet as a black box network that connects
millions (if not billions) of computers in the world together. At this level, we are only concerned that a
message from the application layer in one computer reaches the application layer in another
computer.
4
Logical Addressing: An imaginary part of the Internet

5
Services provided at the source computer

6
Processing at each router

7
Processing at the destination computer

8
ROUTING
 Routing algorithm:: that part of the Network Layer responsible for
deciding on which output line to transmit an incoming packet.
 Remember: For virtual circuit subnets the routing decision is made
ONLY at set up.
 Algorithm properties:: correctness, simplicity, robustness,
stability, fairness, optimality, and scalability.

Routing Classification Adaptive Routing


based on current measurements
Non-Adaptive Routing
of traffic and/or topology.
1. Flooding 1. centralized
2. Static routing using shortest 2. isolated
path algorithms 3. distributed
9
SWITCHING
From the previous discussion, it is clear that the passage of a message from a source to a destination
involves many decisions. When a message reaches a connecting device, a decision needs to be made
to select one of the output ports through which the packet needs to be send out. In other words, the
connecting device acts as a switch that connects one port to another port.
 Circuit Switching
Note  Packet Switching
In circuit switching, the whole message is sent from the source to the
destination without being divided into packets.
A good example of a circuit-switched network is the early telephone systems in which the path was established between a
caller and a callee when the telephone number of the callee was dialed by the caller. When the callee responded to the call,
the circuit was established. The voice message could now flow between the two parties, in both directions, while all of the
connecting devices maintained the circuit. When the caller or callee hung up, the circuit was disconnected.

In packet switching, the message is first divided into manageable packets at the
source before being transmitted. The packets are assembled at the destination.
The NL is designed as a packet-switched network. This means that the packet at the source is divided into manageable
packets called datagrams. Individual datagrams are then transferred from S to D. The received datagrams are assembled at
the destination before recreating the original message. The packet-switched network layer of the Internet was originally
designed as a connectionless service, but recently there is a tendency to change this to a connection-oriented service.
10
Types of Services
Note Connectionless Service
 Connection-Oriented Service
In a connectionless packet-switched network, the forwarding decision is
based on the destination address of the packet.

Network
A connectionless
packet-swtiched network
R1 R2
4 3 2 1 2 Delay in a connectionless network
Sender 1
Network
4 Destination
2
3 Souce
R4 1
3 3
4 1 3 4 2 1
R3 R5 Out of order Receiver

Total delay
2

Time Time Time Time 11


Connection-oriented packet switched network

Note In a connection-oriented packet switched network, the forwarding


decision is based on the label of the packet.

Source D

Setup
4 3 2 1
2
4

Total delay
3 3 Transmission
time
2 4
1
5
4 3 2 1 4 3 2 1

Teardown
6

Time Time Time Time

Delay in a connection-oriented network

12
Forwarding of IP Packets
The network layer supervises the handling of the packets by the underlying physical networks. We
define this handling as the delivery of a packet. The delivery of a packet to its final destination is
accomplished using two different methods of delivery: direct and indirect.  Direct Delivery
Direct delivery  Indirect Delivery

Direct delivery

Direct delivery

Indirect delivery
A B

Link Link Link

Indirect delivery
Indirect delivery 13
FORWARDING
Forwarding means to place the packet in its route to its destination. Since the Internet
today is made of a combination of links (networks), forwarding means to deliver the
packet to the next hop (which can be the final destination or the intermediate connecting
device). Although the IP protocol was originally designed as a connectionless protocol,
today the tendency is to use IP as a connection-oriented protocol.

Forwarding Based on Destination Address


Forwarding Based on Label
Forwarding Based on Destination Address

4 types

Next – hop
Network Specific method
Host specific method
Default method

14
Figure 6.3 Next-hop method

15
Figure 6.4 Network-specific method

Network-specific
routing table for host S
Destination Next Hop
Host-specific
routing table for host S N2 R1

Destination Next Hop


A R1
B R1
C R1
D R1

16
Figure 6.5 Host-specific routing

Routing table for host A


Host A
Destination Next Hop
Host B R3
N2 R1
N3 R3
...... ......

N1

R1 R3
Host B

N2 R2 N3

17
Figure 6.6 Default routing

Routing table for host A N1 N2


Host A
Destination Next Hop
N2 R1 R1
...... ......
Default R2

Default
R2
router

Rest of the Internet

18
ADDRESSING
 The address in the network layer of the TCP/IP model is called Internet Address or
IP address, an IP address is a 32-bit address
 The IP addresses are unique (each connection has a different address) and
universal (must be accepted by any host wants to connect to the internet).
 Consists of 4 octets (bytes)
 Network IP addresses are managed by a nonprofit organization called ICANN
(International Corporation for Assigned Names and Numbers) to avoid conflicts.
 Assigns addresses to regional Authorities which assign numbers to ISPs

 Assigns and manages DNS (Domain Name System)

32
The address space of IPv4 is 2 or 4,294,967,296.

Network + Host: Complete IP address


Network Address: Host part set to 0
Network ID: identifies the network to
which the host is connected
Host ID: identifies the interface of the
network connection to the host not the
host itself
19
Figure Dotted-decimal notation

Example 1
Change the IP addresses from binary notation to dotted-decimal notation.
a. 10000001 00001011 00001011 11101111
b. 11111001 10011011 11111011 00001111

Solution
We replace each group of 8 bits with its equivalent decimal number and add dots for separation:
a. 129.11.11.239
b. 249.155.251.15

20
ADDRESSING
PROBLEM
Example 2 Change the IP addresses from dotted-decimal notation to binary notation.
a. 111.56.45.78
b. 75.45.34.78
Solution We replace each decimal number with its binary equivalent:

a. 01101111 00111000 00101101 01001110


b. 01001011 00101101 00100010 01001110

Example 3 Find the error, if any, in the following IP address: 75.45.301.14

Solution In dotted-decimal notation, each number is less than or equal to 255;


301 is outside this range.

Note

In classful addressing, the address space is divided into five classes:


A, B, C, D, and E.
21
Finding the classes in binary and dotted-decimal notation

Figure 19.11 Finding the address class

22
Find the class of each address:
Example 3
a. 00000001 00001011 00001011 11101111
b. 11110011 10011011 11111011 00001111
See the procedure in Figure 19.11.
Solution a. The first bit is 0; this is a class A address.
b. The first 4 bits are 1s; this is a class E address.

Figure Netid and hostid


Find the class of each address:
Example 4
a.227.12.14.87 b.252.5.15.111 c.134.11.78.56
a. The first byte is 227 (between 224 and 239); the class is D.
Solution b. The first byte is 252 (between 240 and 255); the class is E.
c. The first byte is 134 (between 128 and 191); the class is B. 23
Classful Addressing
 Class A
 Start with binary 0
 All 0 reserved (default route) or any network
 01111111 (127) reserved for loopback
 231 or 2,147,483,648 class A complete IP addresses
 27 =128 blocks (network addresses)
 Number of complete IP addresses in each block is 224=16777216 – (all zeros
host - network address, and all ones – broadcast address)
 Valid Range 1.x.x.x to 126.x.x.x (126 valid blocks)
 All allocated

 Class B
 Start with binary 10
 Range 128.x.x.x to 191.x.x.x
 230 class B complete IP addresses
 214=16384 blocks (network addresses)
 Number of addresses in each block is 216=65536 – (all zeros host, and all ones)
 All allocated
24
Classful Addressing
 Class C
 229 Class C complete IP addresses
 221=2097152 blocks (network addresses)
 Start with binary 110

 Range 192.x.x.x to 223.x.x.x

 Number of addresses in each block is 256 – (all zeros host, and all ones) class

 Nearly all allocated

 Class D Range Total


 Multicast addresses 10.0.0.0 to
224
 No network/host hierarchy 10.255.255.255
172.16.0.0 to
220
172.31.255.255
Private addresses
192.168.0.0 to
216
192.168.255.255

25
Figure 19.14 Blocks in class A

Note

Millions of class A addresses are wasted. 26


Figure 19.15 Blocks in class B

Note:

27 Many class B addresses are wasted.


Figure 19.16 Blocks in class C

Note
The number of addresses in class C block is
28
smaller than the needs of most organizations.
Figure 19.17 Network address

Note In classful addressing, the network address is


the one that is assigned to the organization.

Example 5 Given the address 23.56.7.91, find the network address.


The class is A. Only the first byte defines the netid. We can find the network address by
Solution replacing the hostid bytes (56.7.91) with 0s. Therefore, the network address is 23.0.0.0.

29
Example 6 Given the address 132.6.17.85, find the network address.
The class is B. The first 2 bytes defines the netid. We can find the network address by
Solution replacing the hostid bytes (17.85) with 0s. Therefore, the network address is 132.6.0.0.

Example 7 Given the network address 17.0.0.0, find the class.

Solution The class is A because the netid is only 1 byte.


Class B

Sample internet

Class C
Note

A network address is different from a


netid. A network address has both netid
and hostid, with 0s for the hostid. Class A
30
Note

IP addresses are designed with two levels of hierarchy.


Table 19.1 Default masks

In Dotted-
Class In Binary Using Slash
Decimal

A 11111111 00000000 00000000 00000000 255.0.0.0 /8

B 11111111 11111111 00000000 00000000 255.255.0.0 /16

C 11111111 111111111 11111111 00000000 255.255.255.0 /24

31
Figure A network with two levels of hierarchy

Addressing without Subnets

Note
A class B “Flat Network”, more than
16
The network address can be found by 2 =65536 hosts
applying the default mask to any address How to manage?
in the block (including itself).It retains the
Performance? Too many hosts on the
netid of the block and sets the hostid to 0s. same LAN (single broadcast domain) will
slowdown the LAN performance
Solution: Subnetting

32
Figure 19.23 Subnet mask

Class B

Reduces
the routing
table
entries and
size 33
Subnetting
 Dividing the network into several smaller groups (subnets) with each
group having its own subnet IP address
 Site looks to rest of internet like single network and routers outside
the organization route the packet based on the main Network address
 Local routers route within subnetted network using subnet address
 Host portion of address partitioned into subnet number (most
significant part) and host number (least significant part)
 In this case, IP address will have 3 levels (Main network, subnet, host)
 Subnet mask is a 32-bit consists of zeros and ones that indicates
which bits of the IP address are subnet number and which are host
number
 Subnet mask when ANDed with the IP address it gives the
subnetwork address

34
Figure 19.20 A network with three levels of hierarchy
(subnetted)

Routers will use subnet mask 255.255.192.0 or /18 35


Example 8 A router outside the organization receives a packet with destination address
190.240.7.91 /16. Show how it finds the network address to route the packet.
Solution
The router follows three steps:
• The router looks at the first byte of the address to find the class. It is class B.
• The default mask for class B is 255.255.0.0. or /16 The router ANDs this mask with the address
to get 190.240.0.0.
• The router looks in its routing table to find out how to route the packet to this destination.
Later, we will see what happens if this destination does not exist.

Example 9 A router inside the organization receives the same packet with D address
190.240.33.91 /19. Show how it finds the subnetwork address to route the packet.
Solution
The router follows three steps:
The router must know the mask. Is 255.255.224.0 or /19
The router applies the mask to the address, 190.240.33.91. The subnet address is 190.240.32.0.
The router looks in its routing table to find how to route the packet to this destination. Later, we will
see what happens if this destination does not exist.

36
Obtaining Host IP Address
 Once a network administrator in an organization obtained a block of
addresses from its ISP, it can then assign individual IP addresses to
the host and router interfaces
 It can be done in two ways:
 Manual configuration: IP address is stored manually by the

administrator in a configuration file


 What about a diskless computer? Or first time booted

computer with a disk?


 What about if the computer has moved from one subnet to

another?
 Solution is using a protocol called Dynamic Host Configuration

Protocol (DHCP)
 DHCP is a client-server program

37
Dynamic Host Configuration Protocol
 Dynamic Host Configuration Protocol (DHCP)
 A protocol that provide IP address, subnet mask, IP address of a

gateway router, and IP address of DNS server dynamically to a


host or to a diskless computer
 DHCP server keeps two databases (static IP addresses and unused

temporary Addresses.)
 Static IP addresses database maps physical addresses (MAC) to

permanent IP addresses (used for diskless workstations)


 When a host requests an address DHCP will look into the static

database first.
 If no address match is found, DHCP will select the dynamic IP

database. DHCP will assign a Temporary Address: selected address


from a pool of free addresses and assign it to the host
 Leasing: DHCP server assigns an IP address for a host for a
specific period of time in order not to waste IP addresses
 After the period expires, host must return the IP address or
renew the lease.
38
Address Resolution Protocol (ARP)
 At the network level hosts and routers are recognized by
their IP address
 Packets must pass through physical networks to reach hosts
and routers.
 At the physical network, hosts and routers are recognized by their
MAC addresses which is local address.
 ARP is a network layer protocol that translates between
Internet IP address and MAC sublayer (layer-2) address

Figure Encapsulation of ARP packet

39
Four cases using ARP

40
ARP operation

Note

An ARP request is
broadcast; an ARP
reply is unicast.

41
Figure 20.5 IPv4 datagram format

+ Padding

42
IPv4 datagram fields
 Minimum Header length is 20 bytes without options.
 With options the maximum can go to 60 bytes
 Largest data that can be carried in the datagram is 65535 – 20 = 65515
 Version field: will carry the version number which is 4 = (0100)2
 Header length: the length of the header in bytes after dividing it by 4. Min is 20/4 = 5 =
(0101)2 and the max is 60/4 = 15 = (1111 )2
 Total length: total length of the packet: header + data. Max = 65535 bytes
 Identification, flags, and offset used for fragmentation and reassembly at the D
 Packet can be fragmented at any node between the source and the destination but
reassembly is done ONLY at the destination node.
 Time to Live is used to prevent lost packets from circulating between routers forever. This
field is set to certain value depending on the device operating system. Each router will
decrement this field by one and check the value. If the value is zero the packet will be
dropped.
 Protocol: contains a code for what is being carried in the data field.
 Header checksum used for checking if there is error in the header only. The checksum is
recomputed at each router between the source and the destination.

Figure Maximum transfer unit (MTU)

43
Protocol field and encapsulated data

Table Protocol values in Hex

Table MTUs for


some networks

44
Internet Control Message Protocol
 used by hosts & routers to
communicate network-level Type Code description
0 0 echo reply (ping)
information
3 0 dest. network unreachable
 error reporting: 3 1 dest host unreachable
unreachable host, network, 3 2 dest protocol unreachable
port, protocol 3 3 dest port unreachable
 echo request/reply (used by
3 6 dest network unknown
3 7 dest host unknown
ping)
4 0 source quench (congestion
 network-layer “above” IP: control - not used)
 ICMP msgs carried in IP 8 0 echo request (ping)
datagrams 9 0 route advertisement
10 0 router discovery
 ICMP message: type, code 11 0 TTL expired
plus first 8 bytes of IP 12 0 bad IP header
datagram causing error
45
Traceroute and ICMP
 source sends series of UDP segments to dest
 first set has TTL =1
 second set has TTL=2, etc.
 unlikely port number
 when nth set of datagrams arrives to nth router:
 router discards datagrams
 and sends source ICMP messages (type 11, code 0)

 ICMP messages includes name of router & IP address

 when ICMP messages arrives, source records RTTs

stopping criteria:
 UDP segment eventually arrives at destination host
 destination returns ICMP “port unreachable” message (type 3, code 3)
 source stops

3 probes 3 probes

3 probes 46
IPv6: Motivation
 initial motivation: 32-bit address space soon to be completely
allocated.
 additional motivation:
 header format helps speed processing/forwarding

 header changes to facilitate QoS

 IPv6 datagram format: ver pri flow label


 fixed-length 40 byte header payload len next hdr hop limit
 no fragmentation allowed
source address
(128 bits)
priority: identify priority among destination address
datagrams in flow (128 bits)
flow Label: identify datagrams in
same “flow.” data
next header: identify upper layer
protocol for data
32 bits
47
Other changes from IPv4
 checksum: removed entirely to reduce processing time at each hop
 options: allowed, but outside of header, indicated by “Next Header” field
 ICMPv6: new version of ICMP
 additional message types, e.g. “Packet Too Big”

 multicast group management functions

Transition from IPv4 to IPv6


 not all routers can be upgraded simultaneously
 no “flag days”

 how will network operate with mixed IPv4 and IPv6 routers?

 tunneling: IPv6 datagram carried as payload in IPv4 datagram among IPv4 routers
IPv4 header fields IPv6 header fields
IPv4 payload
IPv4 source, dest addr IPv6 source dest addr
UDP/TCP payload

IPv6 datagram
IPv4 datagram
Tunneling
IPv4 tunnel
A B connecting IPv6 routers
E F
logical view: IPv6 IPv6 IPv6 IPv6

A B C D E F
physical view:
IPv6 IPv6 IPv4 IPv4 IPv6 IPv6

flow: X flow: X
src: A src:B src:B src: A
dest: F dest: F
dest: E dest: E
Flow: X Flow: X
data Src: A data
Src: A
Dest: F Dest: F

data data

A-to-B: E-to-F:
IPv6 B-to-C: B-to-C: IPv6
IPv6 inside IPv6 inside
IPv4 IPv4
49
Interplay between routing, forwarding
routing algorithm routing algorithm determines
end-end-path through network
local forwarding table

dest address output link forwarding table determines


address-range 1 3 local forwarding at this router
address-range 2 2
address-range 3 2
address-range 4 1

IP destination address in
arriving packet’s header

1
3 2

50
Unicast Routing basics
graph: G = (N,E) 5
v 3 w
N = set of routers = { u, v, w, x, y, z } 5
2
u z
2 1
E = set of links ={ (u,v), (u,x), (v,x), (v,w), (x,w), 3
1 x y 2
(x,y), (w,y), (w,z), (y,z) }
1
aside: graph abstraction is useful in other network contexts, e.g., P2P, where
N is set of peers and E is set of TCP connections
Graph abstraction: costs
c(x,x’) = cost of link (x,x’) e.g., c(w,z) = 5
cost could always be 1, or inversely related to bandwidth, or inversely
related to congestion
cost of path (x1, x2, x3,…, xp) = c(x1,x2) + c(x2,x3) + … + c(xp-1,xp)
key question: what is the least-cost path between u and z ?
routing algorithm: algorithm that finds that least cost path
51
Routing algorithm classification
 Q: global or decentralized information?
 global: all routers have complete topology, link cost info “link state”
algorithms
 decentralized:
 router knows physically-connected neighbors, link costs to neighbors
 iterative process of computation, exchange of info with neighbors
 “distance vector” algorithms
 Q: static or dynamic?
 static: routes change slowly over time
 dynamic: routes change more quickly

 periodic update

 in response to link cost changes

routing algorithms are: link state, distance vector, hierarchical routing


52
routing in the Internet : RIP, OSPF, BGP
A Link-State Routing Algorithm
 Dijkstra’s algorithm
 notation:
 net topology, link costs known
 c(x,y): link cost from node
to all nodes x to y; = ∞ if not direct
 accomplished via “link state neighbors
broadcast”  D(v): current value of cost
 all nodes have same info of path from source to dest.
v
 computes least cost paths from
one node (‘source”) to all other  p(v): predecessor node
along path from source to v
nodes
 N': set of nodes whose least
 gives forwarding table for that cost path definitively known
node
 iterative: after k iterations,
know least cost path to k dest.’s

53
Dijsktra’s Algorithm D(v) D(w) D(x) D(y) D(z)
p(v) p(w) p(x) p(y) p(z)
Step N'
1 Initialization:
2 N' = {u} 0 u 7,u 3,u 5,u ∞ ∞
3 for all nodes v 1 uw 6,w 5,u 11,w ∞
4 if v adjacent to u
5 then D(v) = c(u,v) 2 uwx 6,w 11,w 14,x

6 else D(v) = ∞ 3 uwxv 10,v 14,x

7 4 uwxvy 12,y
8 Loop 5 uwxvyz
9 find w not in N' such that D(w) is a minimum
10 add w to N' x
11 update D(v) for all v adjacent to w and not in N' : 9
12 D(v) = min( D(v), D(w) + c(w,v) )
13 /* new cost to v is either old cost to v or known 5 7
14 shortest path cost to w plus cost from w to v */ 4
15 until all nodes in N'
8
notes:
u 3 w y z

 construct shortest path tree by tracing 2


predecessor nodes 3
 ties can exist (can be broken arbitrarily)
7 4
v
54
Dijkstra’s algorithm
algorithm complexity: n nodes
 each iteration: need to check all nodes, w, not in N
 n(n+1)/2 comparisons: O(n2)
 more efficient implementations possible: O(nlogn)
oscillations possible:
 e.g., support link cost equals amount of carried traffic:
A A A A
1 1+e 2+e 2+e
0 0 2+e 0
D B D B D B D B
0 0 1+e 1 1+e 1
0 0
0 e 0 0
C 0 1 1+e 0
C C C
1 1
e given these costs,
initially
find new routing….
resulting in new costs
55
Distance vector algorithm
Bellman-Ford equation (dynamic programming)
Let dx(y) := cost of least-cost path from x to y then
dx(y) = min {c(x,v) + dv(y) }
cost from neighbor v to destination y
cost to neighbor v

min taken over all neighbors v of x

5 clearly, dv(z) = 5, dx(z) = 3, dw(z) = 3


v 3 w B-F equation says:
2 5
u z du(z) = min { c(u,v) + dv(z), c(u,x) + dx(z),
2 1
3 c(u,w) + dw(z) }
1 x y 2 = min {2 + 5, 1 + 3, 5 + 3} = 4
1
node achieving minimum is next
hop in shortest path, used in forwarding table 56
Distance vector algorithm
 Dx(y) = estimate of least cost from x to y
 x maintains distance vector Dx = [Dx(y): y є N ]

 node x:

 knows cost to each neighbor v: c(x,v)

 maintains its neighbors’ distance vectors. For each neighbor v, x

maintains Dv = [Dv(y): y є N ]
key idea:
 from time-to-time, each node sends its own distance vector estimate

to neighbors
 when x receives new DV estimate from neighbor, it updates its own

DV using B-F equation: Dx(y) ← minv{c(x,v) + Dv(y)} for each node y ∊ N


 under minor, natural conditions, the estimate Dx(y) converge to the actual least cost dx(y)

57
Distance vector algorithm
iterative, asynchronous: each each node:
local iteration caused by:
 local link cost change
 DV update message from wait for (change in local link cost or
neighbor msg from neighbor)

distributed:
 each node notifies neighbors only recompute estimates
when its DV changes
 neighbors then notify their
neighbors if necessary
if DV to any dest has changed, notify
neighbors

58
Dx(y) = min{c(x,y) + Dy(y), c(x,z) + Dz(y)} Dx(z) = min{c(x,y) +
= min{2+0 , 7+1} = 2 Dy(z), c(x,z) + Dz(z)}
= min{2+1 , 7+0} = 3
node x cost to cost to
cost to

table x y z x y z x y z
x 0 2 7 x 0 2 3 x 0 2 3

from
from

y ∞∞ ∞ y 2 0 1

from
y 2 0 1
z ∞∞ ∞ z 7 1 0 z 3 1 0
node y cost to cost to
cost to
y
table x y z x y z x y z 2 1
x ∞ ∞ ∞ x 0 2 7 x 0 2 3 x z
from

from

y y 2 7

from
2 0 1 0 1 y 2 0 1
z ∞∞ ∞ z 7 1 0 z 3 1 0
cost to cost to
node z cost to

table x y z x y z x y z
x ∞∞ ∞ x 0 2 7 x 0 2 3
from

from
from

y y 2 0 1 y 2 0 1
∞∞ ∞
z z 3 1 0 z 3 1 0
71 0
time 59
Comparison of LS and DV algorithms
message complexity robustness: what happens if router
 LS: with n nodes, E links, O(nE)
malfunctions?
msgs sent LS:
 DV: exchange between neighbors  node can advertise incorrect
only link cost
 convergence time varies
 each node computes only its

speed of convergence own table


 LS: O(n2) algorithm requires DV:
O(nE) msgs  DV node can advertise
 may have oscillations
incorrect path cost
 DV: convergence time varies
 each node’s table used by
 may be routing loops
others
 count-to-infinity problem
 error propagate thru

network
60
Hierarchical routing
scale: with 600 million destinations:
3c
 can’t store all dest’s in routing tables! 3a 2c
3b 2a
AS3 2b
 routing table exchange would swamp links! 1c
1a 1b AS1 AS2
gateway router: 1d

 at “edge” of its own AS

 has link to router in another AS Intra-AS Inter-AS


Routing Routing
algorithm algorithm
administrative autonomy
 internet = network of networks
Forwarding
table

 each network admin may want to control routing in its own network

 aggregate routers into regions, “autonomous systems” (AS)

 routers in same AS run same routing protocol

 “intra-AS” routing protocol

 routers in different AS can run different intra-AS routing protocol

61
Inter-AS tasks
 suppose router in AS1 receives datagram destined outside of AS1:
 router should forward packet to gateway router, but which one?

AS1 must: 1.learn which dests are reachable through AS2, which through AS3
2.propagate this reachability info to all routers in AS1
job of inter-AS routing!
 suppose AS1 learns (via inter-AS protocol) that subnet x reachable via AS3

(gateway 1c), but not via AS2


 inter-AS protocol propagates reachability info to all internal routers

 router 1d determines from intra-AS routing info that its interface I is on the least

cost path to 1c
 installs forwarding table entry (x,I)
x
3c

3a
3b
AS3 2c other
1c networks
2a
other
1a 2b
networks 1b
AS1 1d AS2 62
Intra-AS Routing
 also known as interior gateway protocols (IGP)
 most common intra-AS routing protocols:
 RIP: Routing Information Protocol
 OSPF: Open Shortest Path First
 IGRP: Interior Gateway Routing Protocol(Cisco prop.)
RIP: example z

w x y
A D B

C routing table in router D


destination subnet next router # hops to dest
w A 2
y B 2
z B 7
x -- 1 63
…. …. ....
RIP ( Routing Information Protocol)
 included in BSD-UNIX distribution in 1982
 distance vector algorithm
 distance metric: # hops (max = 15 hops), each link has cost 1
 DVs exchanged with neighbors every 30 sec in response message
(aka advertisement)
 each advertisement: list of up to 25 destination subnets (in IP
addressing sense) from router A to destination subnets:
subnet hops
u v u 1
A B
w v 2
w 2
x x 3
C D
z y 3
y z 2
64
RIP: link failure, recovery
 if no advertisement heard after 180 sec -> neighbor/link declared dead
 routes via neighbor invalidated

 new advertisements sent to neighbors

 neighbors in turn send out new advertisements (if tables changed)

 link failure info quickly (?) propagates to entire net

 poison reverse used to prevent ping-pong loops (infi.dist= 16 hops)

 RIP routing tables managed by application-level process called route-d


(daemon)
 advertisements sent in UDP packets, periodically repeated
routed routed

transport transprt
(UDP) (UDP)
network forwarding forwarding network
(IP) table table (IP)
link link
65
physical physical
OSPF (Open Shortest Path First)
 OSPF advertisement carries one entry per neighbor
 advertisements flooded to entire AS
 carried in OSPF messages directly over IP (rather than TCP / UDP

 IS-IS routing protocol: nearly identical to OSPF


 “open”: publicly available boundary router
backbone ro
 uses link state algorithm
backbone
 LS packet dissemination
area
 topology map at each node border
routers
 route computation using
area 3
Dijkstra’s algorithm
Hierarchical OSPF internal
area 1 routers
area 2

66
OSPF “advanced” features (not in RIP)
 security: all OSPF messages authenticated (to prevent malicious intrusion)
 multiple same-cost paths allowed (only one path in RIP)

 for each link, multiple cost metrics for different TOS (e.g., satellite link cost

set “low” for best effort ToS; high for real time ToS)
 integrated uni- and multicast support:

 Multicast OSPF (MOSPF) uses same topology data base as OSPF

 hierarchical OSPF in large domains.

Hierarchical OSPF
 two-level hierarchy: local area, backbone.

 link-state advertisements only in area

 each nodes has detailed area topology; only know direction (shortest

path) to nets in other areas.


 area border routers: “summarize” distances to nets in own area, advertise
to other Area Border routers.
 backbone routers: run OSPF routing limited to backbone.
67
 boundary routers: connect to other AS’s.
Internet inter-AS routing: BGP
 BGP (Border Gateway Protocol): the de facto inter-domain routing
protocol - “glue that holds the Internet together”
 BGP provides each AS a means to:
 eBGP: obtain subnet reachability inform. from neighboring ASs.

 iBGP: propagate reachability inform. to all AS-internal routers.

 determine “good” routes to other networks based on reachability

information and policy.


 allows subnet to advertise its existence to rest of Internet:I am here
 BGP session: two BGP routers
3c (“peers”) exchange BGP mesg:
3a
BGP  advertising paths to different
message
3b destination network prefixes
AS3 2c other (“path vector” protocol)
other
1c 2a
2b
networks
 exchanged over semi-
1a permanent TCP connections
networks 1b
AS1 1d AS2
68
 using eBGP session between 3a and 1c, AS3 sends prefix reachability info to
AS1.
 1c can then use iBGP do distribute new prefix info to all routers in AS1

 1b can then re-advertise new reachability info to AS2 over 1b-to-2a


eBGP session
 when router learns of new prefix, it creates entry for prefix in its forwarding
table. eBGP session

 advertised prefix includes BGP attributes 3b 3a iBGP session

AS3 2c other
 prefix + attributes = “route” 1c 2a networks
other
1a 2b
networks 1b
 two important attributes: AS1 1d AS2

 AS-PATH: contains ASs through which prefix advertisement has passed:

e.g., AS 67, AS 17
 NEXT-HOP: indicates specific internal-AS router to next-hop AS. (may

be multiple links from current AS to next-hop-AS)


 gateway router receiving route advertisement uses import policy to
accept/decline
 e.g., never route through AS x

 policy-based routing 69
BGP route selection
 router may learn about more than 1 route to destination AS, selects
route based on:
 local preference value attribute: policy decision
 shortest AS-PATH
 closest NEXT-HOP router: hot potato routing
 additional criteria
BGP messages : msg exchanged between peers over TCP connection
 BGP messages:

 OPEN: opens TCP connection to peer and authenticates sender

 UPDATE: advertises new path (or withdraws old)

 KEEPALIVE: keeps connection alive in absence of UPDATES;

also ACKs OPEN request


 NOTIFICATION: reports errors in previous msg; also used to

close connection
70
Multicast Basics
goal: find a tree connecting routers having local mcast group members
 tree: not all paths between routers used, 2 types

 shared-tree: same tree used by all group members

 source-based: different tree from each sender to rcvrs

legend
group
member

not group
member

router
with a
group
member

router
shared tree source-based trees without
group
member

71
Approaches for building mcast trees
Approaches
 source-based tree: one tree per sources: source
R1 2
 shortest path trees R4
1
 reverse path forwarding
R2 5
 group-shared tree: group uses one tree 3 4 R5
 minimal spanning (Steiner) R3 6
R6 R7
 center-based trees
LEGEND
router with attached
Shortest path tree group member
 mcast forwarding tree: tree of shortest router with no attached
group member
path routes from source to all receivers i link used for forwarding,
 Dijkstra’s algorithm
i indicates order link
added by algorithm
72
Reverse path forwarding
 rely on router’s knowledge of unicast shortest path from it to sender
 each router has simple forwarding behavior:

if (mcast datagram received on incoming link on shortest path


back to center)
then flood datagram onto all outgoing links
else ignore datagram

s: source LEGEND
R1 router with attached
R4 group member
R2 router with no attached
group member
R5
datagram will be
R3 forwarded
R6 R7 datagram will not be 73
forwarded
Reverse path forwarding: pruning
 forwarding tree contains subtrees with no mcast group
members
 no need to forward datagrams down subtree

 “prune” msgs sent upstream by router with no

downstream group members

s: source
R1
R4
LEGEND
R2 P P
prune message
R5
links with multicast
R3 P forwarding
R6
R7
74
Shared-tree: steiner tree
 steiner tree: minimum cost tree connecting all
routers with attached group members
 problem is NP-complete
 excellent heuristics exists
 not used in practice:
 computational complexity

 information about entire network needed

 monolithic: rerun whenever a router needs to

join/leave

75
Center-based trees
 single delivery tree shared by all
 one router identified as “center” of tree
 to join:
 edge router sends unicast join-msg addressed to center router

 join-msg “processed” by intermediate routers & fwd towards center

 join-msg either hits existing tree branch for this center, or arrives at

center
 path taken by join-msg becomes new branch of tree for this router

suppose R6 chosen as center:

R1
3 R4
LEGEND
R2 2 1 path order in which join
R5 messages generated
R3
1 R6 76
R7
Internet Multicasting Routing: DVMRP
 DVMRP: distance vector multicast routing protocol, RFC1075
 flood and prune: reverse path forwarding, source-based tree
 RPF tree based on DVMRP’s own routing tables constructed by

communicating DVMRP routers


 no assumptions about underlying unicast

 initial datagram to mcast group flooded everywhere via RPF

 routers not wanting group: send upstream prune msgs

 soft state: DVMRP router periodically (1 min.) “forgets” branches


are pruned:
 mcast data again flows down unpruned branch

 downstream router: reprune or else continue to receive data

 routers can quickly regraft to tree - following IGMP join at leaf


 odds and ends - commonly implemented in commercial router
77
Tunneling
Q: how to connect “islands” of multicast routers in a “sea” of
unicast routers?

physical topology logical topology


 mcast datagram encapsulated inside “normal” (non-multicast-addressed) datagram
 normal IP datagram sent thru “tunnel” via regular IP unicast to receiving mcast
router (recall IPv6 inside IPv4 tunneling)
 receiving mcast router unencapsulates to get mcast datagram

78
PIM: Protocol Independent Multicast
 not dependent on any specific underlying unicast routing algorithm
(works with all)
 two different multicast distribution scenarios :
dense: sparse:
 group members densely packed, in  networks with group members small wrt
“close” proximity. interconnected networks
 bandwidth more plentiful  group members “widely dispersed”
 bandwidth not plentiful
Consequences of sparse-dense
 dense  sparse:
 group membership by routers  no membership until routers
assumed until routers explicitly prune explicitly join
 data-driven construction on mcast  receiver- driven construction of
tree (e.g., RPF) mcast tree (e.g., center-based)
 bandwidth and non-group-router  bandwidth and non-group-router
processing profligate processing conservative
79
PIM- dense mode

flood-and-prune RPF: similar to DVMRP but…


 underlying unicast protocol provides RPF info for incoming datagram
 less complicated (less efficient) downstream flood than DVMRP
reduces reliance on underlying routing algorithm
 has protocol mechanism for router to detect it is a leaf-node router

80
PIM - sparse mode
 center-based approach
 router sends join msg to rendezvous point (RP)
 intermediate routers update state and forward join

 after joining via RP, router can switch to source-specific


tree
 increased performance: less concentration, shorter paths

 sender(s):
 unicast data to RP, which distributes down RP-rooted tree
 RP can extend mcast tree upstream to source
 RP can send stop msg if no attached receivers
 “no one is listening!”

81
Questions?

82
CS8591 COMPUTER NETWORKS

UNIT – IV
Unit - IV
TRANSPORT LAYER

Introduction – Transport Layer


Protocols – Services – Port Numbers
– User Datagram Protocol –
Transmission Control Protocol –
SCTP.

Behrouz A. Forouzan, Data Communications and Networking, Fifth Edition


TMH, 2013
23-1 PROCESS-TO-PROCESS DELIVERY

The transport layer is responsible for process-to-


process delivery—the delivery of a packet, part of a
message, from one process to another. Two processes
communicate in a client/server relationship, as we will
see later.
Topics discussed in this section:
Client/Server Paradigm
Multiplexing and Demultiplexing
Connectionless Versus Connection-Oriented Service
Reliable Versus Unreliable
Three Protocols
3
Figure 23.1 Types of data deliveries

Note

The transport layer is responsible for


process-to-process delivery.
4
Figure 23.2 Port numbers

Figure 23.4 IANA ranges

5
Figure 23.3 IP addresses versus port numbers

Figure 23.5 Socket address

Figure 23.6 Multiplexing and demultiplexing

6
Figure 23.7 Error control

7
Figure 23.8 Position of UDP, TCP, and SCTP in TCP/IP suite

8
23-2 USER DATAGRAM PROTOCOL (UDP)

The User Datagram Protocol (UDP) is called a


connectionless, unreliable transport protocol. It does
not add anything to the services of IP except to provide
process-to-process communication instead of host-to-
host communication.
Topics discussed in this section:
Well-Known Ports for UDP
User Datagram
Checksum
UDP Operation
Use of UDP
9
Table 23.1 Well-known ports used with UDP

10
Example 23.1

In UNIX, the well-known ports are stored in a file called


/etc/services. Each line in this file gives the name of the server and
the well-known port number. We can use the grep utility to extract
the line corresponding to the desired application. The following
shows the port for FTP. Note that FTP can use port 21 with either
UDP or TCP.

SNMP uses two port numbers 161&162, each for a different purpose.

11
Figure 23.9 User datagram format

UDP length
Note
= IP length – IP header’s length

12
Figure 23.10 Pseudoheader for checksum calculation

13
Example 23.2

Figure shows the checksum calculation for a very small user datagram
with only 7 bytes of data. Because the number of bytes of data is odd,
padding is added for checksum calculation. The pseudoheader as well
as the padding will be dropped when the user datagram is delivered to
IP.

Figure Checksum calculation of a simple UDP user datagram


14
Figure 23.12 Queues in UDP

15
23-3 TCP

TCP is a connection-oriented protocol; it creates a


virtual connection between two TCPs to send data. In
addition, TCP uses flow and error control mechanisms
at the transport level.

Topics discussed in this section:


TCP Services
TCP Features
Segment
A TCP Connection
Flow Control
Error Control
16
Table 23.2 Well-known ports used by TCP

17
Figure 23.13 Stream delivery

Note

The bytes of data being transferred in each


connection are numbered by TCP. The numbering
starts with a randomly generated number.

18
Figure 23.14 Sending and receiving buffers

19
Figure 23.15 TCP segments

20
Example 23.3
The following shows the sequence number for
each segment:

Note

The value in the sequence number field


of a segment defines the number of the
first data byte contained in that segment.
21
Figure 23.16 TCP segment format

Note

The value of the acknowledgment field in a segment


defines the number of the next byte a party expects
to receive.The acknowledgment no. is cumulative.
22
Figure 23.17 Control field

23
Figure 23.18 Connection establishment using three-way handshaking

Note
A SYN segment cannot carry data,
but it consumes one seq. no.

A SYN+ACK segment cannot carry


data, but does consume one seq. no.

An ACK segment, if carrying no data,


consumes no seq. no.

24
Figure 23.19 Data transfer

Note

The FIN segment consumes


one sequence number if it
does not carry data.

The FIN + ACK segment


consumes one sequence
number if it does not carry
data.

25
Figure 23.20 Connection termination using three-way handshaking

26
Figure 23.21 Half-close Figure 23.22 Sliding window

Note
A sliding window is used to make
transmission more efficient as
well as to control the flow of data
so that the destination does not
become overwhelmed with data.
TCP sliding windows are byte-
oriented.

27
Example 23.4
What is the value of the receiver window (rwnd) for host A if
the receiver, host B, has a buffer size of 5000 bytes and 1000
bytes of received and unprocessed data?
Solution
The value of rwnd = 5000 − 1000 = 4000. Host B can receive only
4000 bytes of data before overflowing its buffer. Host B advertises this
value in its next segment to A.

Example 23.5 : What is the size of the window for host A if the
value of rwnd is 3000 bytes and the value of cwnd is 3500 bytes?
Solution
The size of the window is the smaller of rwnd and cwnd, which is
3000 bytes.

28
Example 23.6
Figure shows an unrealistic example of a sliding window. The
sender has sent bytes up to 202. We assume that cwnd is 20 (in
reality this value is thousands of bytes). The receiver has sent an
acknowledgment number of 200 with an rwnd of 9 bytes (in reality this
value is thousands of bytes). The size of the sender window is the
minimum of rwnd and cwnd, or 9 bytes. Bytes 200 to 202 are sent, but
not acknowledged. Bytes 203 to 208 can be sent without worrying
about acknowledgment. Bytes 209 and above cannot be sent.

29
Note

Some points about TCP sliding windows:


❏ The size of the window is the lesser of rwnd and
cwnd.
❏ The source does not have to send a full window’s
worth of data.
❏ The window can be opened or closed by the
receiver, but should not be shrunk.
❏ The destination can send an acknowledgment at
any time as long as it does not result in a shrinking
window.
❏ The receiver can temporarily shut down the
window; the sender, however, can always send a
segment of 1 byte after the window is shut down.
30
Note
ACK segments do not consume sequence numbers
and are not acknowledged.

In modern implementations, a retransmission occurs if the


retransmission timer expires or three duplicate ACK
segments have arrived.

No retransmission timer is set for an ACK segment.

Data may arrive out of order and be temporarily stored by


the receiving TCP, but TCP guarantees that no out-of-order
segment is delivered to the process.

31
Figure 23.24 Normal operation

32
Figure 23.25 Lost segment

33
Figure 23.26 Fast retransmission

Note

The receiver TCP


delivers only
ordered data to
the process.

34
23-4 SCTP

Stream Control Transmission Protocol (SCTP) is a


new reliable, message-oriented transport layer
protocol. SCTP, however, is mostly designed for
Internet applications that have recently been
introduced. These new applications need a more
sophisticated service than TCP can provide.
Topics discussed in this section:
SCTP Services and Features
Packet Format
An SCTP Association
Flow Control and Error Control
35
Note

SCTP is a message-oriented, reliable protocol that


combines the best features of UDP and TCP.

Table 23.4 Some SCTP applications

36
Figure 23.27 Multiple-stream concept

Note

An association in SCTP can involve


multiple streams.
37
Figure 23.28 Multihoming concept

Note

SCTP association allows multiple IP


addresses for each end.

38
Note

In SCTP, a data chunk is numbered using a TSN.

To distinguish between different streams, SCTP uses an SI.

To distinguish between different data chunks belonging to


the same stream, SCTP uses SSNs.

TCP has segments; SCTP has packets.

39
Figure 23.29 Comparison between a TCP segment and an SCTP packet

Note

In SCTP, control information and data


information are carried in separate chunks.

40
Figure 23.30 Packet, data chunks, and streams

Note

Data chunks are identified by three items: TSN, SI, and SSN.
TSN is a cumulative number identifying the association; SI
defines the stream; SSN defines the chunk in a stream.

41
Figure 23.31 SCTP packet format Note

In SCTP, acknowledgment numbers are used to acknowledge only data


chunks; control chunks are ack. by other control chunks if necessary.

In an SCTP packet, control chunks come before data chunks.

42
Figure 23.32 General header Figure 23.33 Four-way handshaking

43
Table 23.5 Chunks

44
Note
A connection in SCTP is called an association.

No other chunk is allowed in a packet carrying an INIT or


INIT ACK chunk. A COOKIE ECHO or a COOKIE ACK chunk
can carry data chunks.

In SCTP, only DATA chunks consume TSNs; DATA chunks


are the only chunks that are acknowledged.

45
Figure 23.34 Simple data transfer

Note

The
acknowledgment
in SCTP defines
the cumulative
TSN, the TSN of
the last data
chunk received in
order.

46
Figure 23.35 Association termination

47
Figure 23.36 Flow control, receiver site

Figure 23.37 Flow control, sender site

48
Figure 23.38 Flow control scenario

49
Figure 23.39 Error control, receiver site

50
Figure 23.40 Error control, sender site

51
CS8591 COMPUTER NETWORKS

UNIT – V

Dr.A.Kathirvel, Professor & Head, Computer Science & Engg.


M N M Jain Engineering College, Chennai
Unit - V
APPLICATION LAYER

WWW and HTTP – FTP – Email –Telnet


–SSH – DNS – SNMP.

Behrouz A. Forouzan, Data Communications and Networking, Fifth Edition


TMH, 2013
26-1 WORLD WIDE WEB AND HTTP

In this section, we first introduce the World


Wide Web (abbreviated WWW or Web). We
then discuss the Hyper-Text Transfer Protocol
(HTTP), the most common client-server
application program used in relation to the
Web.

3
26.3
World Wide Web
Architectural Overview
The parts of the Web model.

4
The Client Side

(a) A browser plug-in. (b) A helper application.

5
The Server Side

A multithreaded Web server with a front end


and processing modules.

6 6
26.26.1 World Wide Web

The idea of the Web was first proposed by Tim


Berners-Lee in 1989 at CERN, the European
Organization for Nuclear Research, to allow several
researchers at different locations throughout
Europe to access each others’ researches. The
commercial Web started in the early 1990s.

7
Example 26.1
Assume we need to retrieve a scientific document that
contains one reference to another text file and one reference
to a large image. Figure 26.1 shows the situation.

The main document and the image are stored in two


separate files in the same site (file A and file B); the
referenced text file is stored in another site (file C). Since
we are dealing with three different files, we need three
transactions if we want to see the whole document.

8
Figure 26.1: Example 26.1

9
Figure 26.2: Browser

10
26.26.2 HyperText Transfer Protocol

The HyperText Transfer Protocol (HTTP) is used to


define how the client-server programs can be written
to retrieve web pages from the Web. An HTTP client
sends a request; an HTTP server returns a response.
The server uses the port number 80; the client uses a
temporary port number. HTTP uses the services of
TCP, which, as discussed before, is a connection-
oriented and reliable protocol.

11
The World Wide Web - HTTP
❑ Hypertext Transfer Protocol (HTTP) is a
communications protocol used to transfer or convey
information on intranets and the World Wide Web. Its
original purpose was to provide a way to publish and
retrieve hypertext pages, mainly scientific paper. Created in
CERN, Geneva.
❑ Development of HTTP was coordinated by the W3C
(World Wide Web Consortium) and the IETF (Internet
Engineering Task Force), culminating in the publication of a
series of RFCs, most notably
RFC 2616 (June 1999), which defines HTTP/1.1, the
current version.
❑ HTTP is a request/response protocol between a client and
a server. It works on the well known TCP port 80.

12
Example 26.3
Figure 26.3 shows an example of a nonpersistent connection. The client needs to
access a file that contains one link to an image. The text file and image are located
on the same server. Here we need two connections. For each connection, TCP
requires at least three handshake messages to establish the connection, but the
request can be sent with the third one. After the connection is established, the object
can be transferred. After receiving an object, another three handshake messages are
needed to terminate the connection.

Figure 26.3: Example 26.3

13
Example 26.4
Figure 26.4 shows the same scenario as in Example 26.3, but using a
persistent connection. Only one connection establishment and
connection termination is used, but the request for the image is sent
separately.

Figure 26.4: Example 26.4

14
Figure 26.5: Formats of the request and response messages

15
Table 26.1: Methods

16
Table 26.2: Request Header Names

17
Table 26.3: Response Header Names

18
Example 26.5
This example retrieves a document (see Figure 26.6). We use the GET method to
retrieve an image with the path /usr/bin/image26. The request line shows the method
(GET), the URL, and the HTTP version (26.1). The header has two lines that show that
the client can accept images in the GIF or JPEG format. The request does not have a
body. The response message contains the status line and four lines of header. The
header lines define the date, server, content encoding (MIME version, which will be
described in electronic mail), and length of the document. The body of the document
follows the header..

Figure 26.6:
Example 26.5

19
Example 26.6
In this example, the client wants to send a web page to be posted on the server.
We use the PUT method. The request line shows the method (PUT), URL, and
HTTP version (26.1). There are four lines of headers. The request body
contains the web page to be posted. The response message contains the status
line and four lines of headers. The created document, which is a CGI
document, is included as the body (see Figure 26.7).

Figure 26.7:
Example 26.6

20
Example 26.8
Figure 26.8 shows a scenario in which an electronic store
can benefit from the use of cookies. Assume a shopper
wants to buy a toy from an electronic store named BestToys.
The shopper browser (client) sends a request to the BestToys
server. The server creates an empty shopping cart (a list) for
the client and assigns an ID to the cart (for example, 12343).
The server then sends a response message, which contains
the images of all toys available, with a link under each toy
that selects the toy if it is being clicked. This response
message also includes the Set-Cookie header line whose
value is 12343. The client displays the images and stores the
cookie value in a file named BestToys.

22
Figure 26.8: Example 26.8

23
Example 26.9
Figure 26.9 shows an example of a use of a proxy server in a local network, such as
the network on a campus or in a company. The proxy server is installed in the local
network. When an HTTP request is created by any of the clients (browsers), the
request is first directed to the proxy server If the proxy server already has the
corresponding web page, it sends the response to the client. Otherwise, the proxy
server acts as a client and sends the request to the web server in the Internet. When
the response is returned, the proxy server makes a copy and stores it in its cache
before sending it to the requesting client.

Figure 26.9: Example


of a proxy server

24
HTML – HyperText Markup Language
❑ In 1980, physicist Tim Berners-Lee, who was an
independent contractor at CERN, proposed and
prototyped ENQUIRE, a hypertext system for CERN
researchers to use to share documents.
❑ In 1989, Berners-Lee and CERN data systems
engineer Robert Cailliau each submitted separate
proposals for an Internet-based hypertext system
providing similar functionality.
❑ In 1990, they collaborated on a joint proposal, the
World Wide Web (W3) project, which was accepted
by CERN.

25
HTML
A selection of common HTML tags. some can have additional
parameters (attributes).

26
26-2 FTP

File Transfer Protocol (FTP) is the standard protocol provided by


TCP/IP for copying a file from one host to another. Although
transferring files from one system to another seems simple and
straightforward, some problems must be dealt with first.

Control
connection

Data
connection

27
File Transfer Protocol (FTP)
❑ File Transfer Protocol (FTP) is the standard mechanism
provided by TCP/IP for copying of any kind of files from one
host to another.

❑ Defined in RFC 959 (1985).

❑ FTP uses the services of TCP. It needs two TCP


connections.

❑ The well-known TCP port 21 is used for the control


connection and the well-known port 20 for the data
connection.

28
26.2.1 Two Connections

The two connections in FTP have different lifetimes. The control


connection remains connected during the entire interactive FTP session.
The data connection is opened and then closed for each file transfer
activity. It opens each time commands that involve transferring files are
used, and it closes when the file is transferred.
26.2.2 Control Connection
For control communication, FTP uses the same approach as TELNET
(discussed later). It uses the NVT ASCII character set as used by
TELNET. Communication is achieved through commands and responses.
This simple method is adequate for the control connection because we
send one command (or response) at a time. Each line is terminated with a
two-character (carriage return and line feed) end-of-line token.

29
Table 26.4: Some FTP commands

30
Table 26.4 : Some FTP commands (continued)

Table 26.5: Some responses in FTP

31
26.2.3 Data Connection
The data connection uses the well-known port 20 at the
server site. However, the creation of a data connection is
different from the control connection. The following shows
the steps:

1.The client, not the server, issues a passive open using an


ephemeral port.
2.Using the PORT command the client sends this
port number to the server.
3. The server receives the port number and issues
an active open using the well-known port 20 and
the received ephemeral port number.
32
Example 26.10
Figure 26.11 shows an example of using
FTP for retrieving a file. The figure
shows only one file to be transferred.
The control connection remains open all
the time, but the data connection is
opened and closed repeatedly. We
assume the file is transferred in six
sections. After all records have been
transferred, the server control process
announces that the file transfer is done.
Since the client control process has no
file to retrieve, it issues the QUIT
command, which causes the service
connection to be closed.

Figure 26.11:
Example 26.12

33
Example 26.11
The following shows an actual FTP session that lists
the directories.

34
26.2.4 Security for FTP

The FTP protocol was designed when security was


not a big issue. Although FTP requires a password,
the password is sent in plaintext (unencrypted),
which means it can be intercepted and used by an
attacker. The data transfer connection also transfers
data in plaintext, which is insecure. To be secure,
one can add a Secure Socket Layer between the FTP
application layer and the TCP layer. In this case
FTP is called SSL-FTP. We also explore some secure
file transfer applications when we discuss SSH later
in the chapter.

35
26-3 ELECTRONIC MAIL

Electronic mail (or e-mail) allows users to exchange messages. The


nature of this application is different from other applications discussed
so far. This means that the idea of client/server programming should
be implemented in another way: using some intermediate computers
(servers).

26.3.1 Architecture
To explain the architecture of e-mail, we give a common scenario, as
shown in Figure 26.12. Another possibility is the case in which Alice
or Bob is directly connected to the corresponding mail server, in which
LAN or WAN connection is not required, but this variation in the
scenario does not affect our discussion.

36
Figure 26.12: Common scenario

1 9
2
8

3 7

4 5 6

37
Figure 26.13: Format of an e-mail

38
Figure 26.14: E-mail address

Figure 26.15: Protocols used in electronic mail

39
Table 26.6: SMTP Commands

40
Table 26.7: SMTP responses (Continued)

41
Table 26.7: SMTP responses (continued)

42
Example 26.12
To show the three mail transfer
phases, we show all of the steps
described above using the
information depicted in Figure
26.16. In the figure, we have
separated the messages related to
the envelope, header, and body in
the data transfer section. Note that
the steps in this figure are repeated
two times in each e-mail transfer:
once from the e-mail sender to the
local mail server and once from
the local mail server to the remote
mail server. The local mail server,
after receiving the whole e-mail
message, may spool it and send it
to the remote mail server at
another time. Fig. 26.16:Example 26.12
43
Figure 26.17: POP3

44
Figure 26.18: MIME

Figure 26.19: MIME header

45
Data
Types and
Subtypes
in MIME

Methods for Content-Transfer-Encoding


Figure 26.20: Base64 conversion

47
Table 26.10: Base64 Converting Table

48
Figure 26.21: Quoted-printable

49
26.3.2 E-Mail Security
The protocol
discussed in this
section does not
provide any security
provisions. However,
e-mail exchanges can
be secured using two
Figure 26.22: Web-based e-mail, cases I and II
application-layer
securities designed in
particular for e-mail
systems. Two of these
protocols, Pretty
Good Privacy (PGP)
and
Secure/Multipurpose
Internet Mail
Extensions
50
(S/MIME).
26-4 TELNET

It is impossible to have a client/server pair for each


type of service we need; the number of servers soon
becomes intractable. The idea is not scalable. The
solution is to have a specific client/server program
for a set of common scenarios, but to have some
generic client/server programs for the rest.

51
Trivial FTP (TFTP)
❑A very simple file transfer protocol, with the functionality of a very basic
form of FTP. Defined in 1980.
❑TFTP uses UDP port 69 (not TCP!)
❑An ex. of TFTP usage for remote boot through BOOTP protocol in a LAN:

52
FTP pros and cons
❑ Advantages:
❑ Simple implementation
❑ Universal application
❑ Wide used and standartized

❑ Disadvantages:
❑ Clear text passwords, unencrypted data.
❑ Multiple TCP/IP connections are used = > Firewalls problems.
❑ Hard to filter active mode FTP traffic on the client side by using a
firewall.
❑ It is possible to abuse the protocol's built-in proxy features to tell a server
to send data to an arbitrary port of a third computer;
❑ High latency.
❑ No integrity check on the receiver side.
❑ No date/timestamp attribute transfer.
53
26.4.1 Local versus Remote Logging
We first discuss the concept of local and remote logging as
shown in Figure 26.23.

Figure 26.23: Local versus remote logging

54
Figure 26.24: Concept of NVT

Table 26.11: Examples of interface commands

55
26-5 SECURE SHELL (SSH)

Although Secure Shell (SSH) is a secure


application program that can be used today for
several purposes such as remote logging and file
transfer, it was originally designed to replace
TELNET. There are two versions of SSH. The first
version, SSH-1, is now deprecated because of
security flaws in it. In this section, we discuss only
SSH-2.

56
26.5.1 Components
SSH is an application-layer protocol with three
components, as shown in Figure 26.25.

Figure 26.25: Components of SSH

57
26.5.2 Applications
Although SSH is often thought of as a replacement for
TELNET, SSH is, in fact, a general-purpose protocol that provides a
secure connection between a client and server. Fig 26.26: Port Forwarding

Figure 26.27: SSH Packet Format


DNS : Domain Name System
❑ To map a hostname to an IP-address and vice
versa.

Example:
www.acad.bg 194.141.0.9

❑ Each hostname may has zero or more corresponding IP-


addresses.
❑ Each IP-address may correspond to zero or more
hostnames.

59
DNS
❑ Host name to address mappings were maintained by the Network
Information Center (NIC) in a single file (HOSTS.TXT) which was
transferred to all hosts using FTP (about 25 years ago).

Disadvantages:

❑ Ineffective – Bandwidth consumed in distributing a new version by


this scheme is proportional to the square of the number of hosts in the
network.

❑ The network population was also changing in character.

❑ The applications on the Internet were getting more sophisticated and


creating a need for general purpose name service.
60
DNS design goals
❑The primary goal is a consistent name space which will be
used for referring to resources.
❑The database which holds the names must be distributed.
❑The costs of implementing such a facility dictate that it be
generally useful, and not restricted to a single application.
❑Use the same name space with different protocol families
or management.
❑Name server transactions must be independent of the
communications system that carries them.
❑The system should be useful across a wide spectrum of
host capabilities. Both personal computers and large
timeshared hosts (mainframes) should be able to use the
system, though perhaps in different ways. 61
DNS Elements: 3 main components
1. The DOMAIN NAME SPACE and RESOURCE RECORDS,
which are specifications for a tree structured name space and data
associated with the names.
2. NAME SERVERS are server programs which hold information
about the domain tree's structure and set information.
3. RESOLVERS are programs that extract information from name
servers in response to client requests.
These three components roughly correspond to the three layers or
views of the DNS:
❑ From the user's point of view, the domain system is accessed through
a simple procedure.
❑ From the resolver's point of view, the domain system is composed of
an unknown number of name servers.
❑ From a name server's point of view, the domain system consists of
separate sets of local information called zones.
62
Name space specifications and terminology
❑ The domain name space is a tree structure composed by nodes.
❑ Each node has a label, which is zero to 63 octets in length.
❑ The domain name of a node is the list of the labels on the path from
the node to the root of the tree.
❑ The name of the root node is empty string (zero length) – “”.
❑ Internally, programs that manipulate domain names should represent
them as sequences of labels, where each label is a length octet
followed by an octet string.
❑ Domain names are case-insensitive using the ASCII codes with high
order zero bit.
❑ When a user types a domain name, the length of each label is omitted
and the labels are separated by dots ("."). Since a complete domain
name ends with the root label, this leads to a printed form which ends
in a dot.
63
Example Name Space ICANN, IANA
(a graphical tree view)
One Root domain (“”)
Top Level Domains (TLD)

Delegation
com edu bg eu info

yahoo ucla acad see-


grid
2nd Level Domains

3
rd Level Domains physics amigo val www
mary joe kevin test book
64
Up to 127 levels
mail sigma
Top Level Domains
❑ Generic domains (gTLD): com, org, net, int (all around the world);
edu, gov, mil (located in USA only); aero, biz, coop, info,
museum, name, pro(new domains,since 2000)
❑ Country code domains (ccTLD): bg, uk, fr, it, ...

Resource Records
❑ Special infrastructure domain: arpa
❑ Loopback domains: localhost, localdomain
❑ And the domain eu for European Union!

❑ The distributed database which holds the


names consists of several Resource Records.
❑ Resource record - Set of resource information
associated with a particular name.
65
DNS server
A computer with software which:

❑ Holds and maintains specified part of the distributed database of


resource records.
❑ Responds to the name queries.
❑ Exchanges the zone information with other DNS servers.

These tasks are described in the DNS protocol (RFC 1035) located on
the Application Layer of the “TCP/IP reference model”.

Delegation:

❑ ICANN organization delegates root DNS servers.


❑ The root servers delegate TLD DNS servers.
❑ A TLD DNS server delegates Second Level DNS server etc. 66
The root DNS servers
At the heart of the DNS are 13 special computers, called root
servers. They are coordinated by ICANN and are distributed
around the world.
A.ROOT-SERVERS.NET. 198.41.0.4
B.ROOT-SERVERS.NET. 192.228.79.201
C.ROOT-SERVERS.NET. 192.33.4.12
D.ROOT-SERVERS.NET. 128.8.10.90
E.ROOT-SERVERS.NET. 192.203.230.10
F.ROOT-SERVERS.NET. 192.5.5.241
G.ROOT-SERVERS.NET. 192.112.36.4
H.ROOT-SERVERS.NET. 128.63.2.53
I.ROOT-SERVERS.NET. 192.36.148.17
J.ROOT-SERVERS.NET. 192.58.128.30
K.ROOT-SERVERS.NET. 193.0.14.129
L.ROOT-SERVERS.NET. 199.7.83.42
M.ROOT-SERVERS.NET. 202.12.27.33
67
K.ROOT-SERVERS.NET
(operated by RIPE NCC)

Source: http://k.root-servers.org 68
DNS servers
Primary DNS server for a given domain – holds resource records for the zone.
The zone configuration is written by the system administrator.

Secondary DNS server for a given domain – it exists for the case when the
Primary DNS server is failed or overloaded. The Secondary server
downloads the zone information from the Primary periodically or by
notification.
➢ Every domain must have one Primary DNS server and at least one
Secondary.

The Primary and Secondary DNS servers are also called authoritative for
their domain and non-authoritative for the rest of domains in the world.
E.g. the authoritative servers always hold up to date zone information for
the domain.

➢ Caching only DNS servers – they cache DNS queries and answers for
speed-up the service. These servers are not authoritative for any domain.

Most of the authoritative DNS servers are caching too. 69


DNS query flow
1. A DNS client forms the query and sends it according the OS configuration.

2. The local resolver opens a special file called hosts and looks in case the
answer is already written here. If not then next:

3. The client calls one of the OS configured DNS servers.

4. If the DNS server knows (or already cached) the answer, then returns it.

5. If the DNS server doesn’t know the answer, it sends a recursive query
through the DNS hierarchy, starting from the root domain. The recursive
query consists of several sub-queries to the corresponding DNS servers.

6. The DNS servers returns the result – the answer or error message.

70
Reverse DNS query
❑ The reverse query uses the special infrastructure domain in-
addr.arpa
❑ The IP is written before this special domain in reverse order of
numbers separated with dots.
❑ Example: 194.141.0.0 corresponds to 0.0.141.194.in-

addr.arpa
❑ The reverse query starts from a root DNS server and follows the
delegation path.
❑ Example in Unix/Linux:dig 0.0.141.194.in-addr.arpa +trace

❑ (It traces and shows the delegation path from the root name
servers down to SOA DNS server)

71
DNS protocol details
❑ The protocol uses two transport protocols from the lower layer:

❑ UDP on port 53 and


❑ TCP on port 53.

❑ The queries and answers are transferred using the unreliable protocol
UDP for speed. But it is preferred because the OS configured DNS
servers are near, usually in the same LAN.

❑ The zone transfers between the DNS servers are performed through
TCP, because it must be reliable.

❑ Each resource record consists of the following data fields


( in text readable format! ): owner type class TTL RDATA
72
Resource Records
The data fields
owner - A string which is the domain name where the RR is found.
type - which is an encoded 16 bit value that specifies the type of the resource in this
resource record. Types refer to abstract resources. Each abstract resource has memo
name:
A - a host address
CNAME - identifies the canonical name of an alias
MX - identifies a mail exchange for the domain
PTR - a pointer to another part of the domain name space etc.
class - which is an encoded 16 bit value which identifies a protocol family or instance
of a protocol. This memo uses the following classes:
IN - the Internet system or CH - the Chaos system
TTL - which is the time to live of the RR. This field is a 32 bit integer in units of
seconds, an is primarily used by resolvers when they cache RRs. The TTL describes
how long a RR can be cached before it should be discarded.
RDATA - which is the type and sometimes class dependent data which describes the
resource.
73
Resource Records
Example
(in text readable format!)

acad.bg. IN A 194.141.0.9
acad.bg. IN MX 10 mx-a.acad.bg.
IN MX 20 mx-b.acad.bg.
IN NS amigo.acad.bg.
IN NS unicom.acad.bg.
localhost IN A 127.0.0.1
poseidon IN A 194.141.0.1
backbone IN A 194.141.252.2
iris IN A 194.141.0.2
amigo IN AAAA 2001:4b58:acad::3
unicom IN AAAA 2001:4b58:acad::9
bis-21++ IN CNAME unicom.acad.bg.

3 IN PTR amigo.acad.bg.
... 74
DNS protocol details
Message in binary format
(RR means Resource Record)

75
DNS protocol details
DNS message data fields
❑ The IDENTIFICATION field is set by the client and returned by the server.

❑ The 16-bit PARAMETER consists of:


❑ 0-th bit field: 0 means the message is a query,1 means it's a response.

❑ 1-4 bit fields - OPCODE:

❑ 0000 - is a normal value (Standard query).

❑ 0001 - an inverse query.

❑ 0010 - the server status request.

❑ 5-th bit field - Authoritative answer. The name server is authoritative for the
domain in the question section.
❑ 6-th bit field is set if message truncated. With UDP this means that the total size
of the reply exceeded 512 bytes, and only the first 512 bytes the of the reply
were returned.
❑ 7-th bit field - Recursion Desired. This bit can be set in a query and is then
returned in the response.
❑ 8-th bit field - Recursion Available.

❑ 9-11 -th bits field has to be 0.

❑ 12-15 -th bits field - Return Code. 0- no error, 3- name error. 76


76
DNS protocol details
DNS message data fields
❑ The fields labeled NUMBER OF ... give each a count of entries in the
corresponding sections in the message.

❑ The QUESTION SECTION contains queries for which answers are


desired. The client fills in only the question section; the server returns
the question and answers with its response. Each question has Query
Domain Name followed by Query Type and Query Class fields (as
depicted in the next slides)

❑ ANSWER,AUTHORITY,ADDITIONAL INFORMATION sections


consist of a set of resource records that describe domain names and
mappings. Each resource record describes one name (as depicted in
the next slides)
77
DNS protocol details
The QUESTION section format in the DNS message

The DOMAIN NAME has variable length.


Clients fill in the questions; servers return them along with the answers.
78
DNS protocol details
The RESOURCE RECORD binary format returned by the DNS
servers

79
Simple Network Management Protocol (SNMP)

❑ Application layer protocol within the OSI model. It


uses UDP as transport.

❑ “The protocol that specifies how a network


management station communicates with agent
software in remote devices such as routers. SNMP
defines the format of messages and their meaning.”
- Computer Networks and Internets by Douglas E.
Comer.
80
80
SNMP – Version history
❑ Size and number of networks required a standard
protocol in order to communicate with devices on
the network.

❑ 1970’s - SNMPv1, the first network management


protocol.
❑ Originally designed as a “quick-fix” .

❑ 1988 - SNMPv2 standard designed.

❑ 2004 – SNMPv3, the current version


❑ RFC 3411 – RFC 3418 (also known as STD0062).
81
SNMP Technology
❑ Exchanges network information through PDU’s.
❑ Part of the Internet Network Management Architecture
NMS

❑ Internet Management Model


User
❑ Network elements Interface

❑ Agents
Network
❑ Managed objects Management
Application
❑ MIB’s (Management Information Bases) SNMP SNMP SNMP
❑ Syntax notation
❑ SMI (Structure of Management Info) Agent Agent Agent

❑ NMS (Network-management systems)


❑ Parties
MIB MIB MIB
❑ Management protocols
Managed Device Managed Device 82
Managed Device
SNMP Operations
❑ SNMP is a simple “request/response” protocol which uses
six operations:
❑ Get
❑ GetNext
❑ GetBulk
❑ Set
❑ Trap
❑ Inform

83
83
SNMP v1 Packet Format

❑ SNMP v1 packets contain two parts:


❑ First part contains version and community name.
❑ Second part contains PDU.

Version Community SNMP PDU

PDU Request Error Error Object 1, Object 2, Object X,


Type ID Status Index Value 1 Value 2 Value X ...

84
SNMP v2 Packet Format
❑ Like SNMP v1, SNMP v2 contain two parts:
❑ First part is called a wrapper which contains authentication,
privacy information and a context.
❑ Second contains a PDU with similarities to SNMP v1.

Wrapper SNMP PDU

PDU Request Error OR Error OR Object 1, Object X,


Type ID Status Index Value 1 Value X ...

85
85
SNMP v1 and v2
Advantages and Disadvantages

❑ Advantages ❑ Disadvantages
❑ Simple design. ❑Security holes.
❑ Easy implementation ❑Old technology.
❑ Wide spread usage.
❑ Expandability.

86
The new SNMP v3
❑ Structure, components and architecture similar to v1 and v2.
❑ New features include:
❑ Authentication and privacy.

❑ Authorization and access control.

❑ Naming of entities.

❑ People and policies.

❑ Usernames and key management.

❑ Notification destinations.

❑ Remotely configurable via SNMP operations.

87
SNMP Conclusion
❑ The goals: Integrated network management,
Interoperability, Standards.

❑ Network management applications based on SNMP rely on


the standards based TCP/IP protocol to effectively oversee
large heterogeneous networks.

❑ SNMP sits on the application layer and uses UDP protocol


to communicate with each network device.

❑ SNMP is essential in order to effectively maintain


today’s large networks. 88
Questions ?

You might also like