Unit 2
Unit 2
Unit 2
1
Link Layer services
2
Link Layer services
• Two main functions of the data link layer are
• Data link control (Node-to-node communication)
• Media access control (How to share the link)
• Link layer Services are
• Framing,
• Physical Addressing
• Flow Control
• Error control
• Access Control
3
Framing
4
Framing
• Pack bits into frames, so that each frame is distinguishable from another.
• Framing separates a message from one source to a destination, or from other
messages to other destinations, by adding a sender address and a destination
address.
• In very large frame, even a single-bit error require retransmission of whole
message.
• When a message is divided into smaller frames then more single-bit error.
5
Framing
• Fixed-Size Framing
• There is no need for defining the boundaries of the frames.
• The size itself can be used as a delimiter.
• Example: ATM network uses frames of fixed size called Cells
• Variable-Size Framing
• Used in Local Area Networks
• Have to define end of frame and beginning of next frame
• Two approaches: Character-oriented approach and Bit-oriented approach
6
Character-Oriented Protocols
• Data to be carried are 8-bit characters from a coding system such as ASCII.
• Header - Source address, destination address and other control information.
• Trailer - Error detection or correction redundant bits, are also multiples of 8 bits.
• To separate one frame from next, an 8-bit (1-byte) flag is added at beginning and
end of frame.
• Flag is composed of protocol-dependent special characters, signals indicating
start or end of a frame.
• Protocol is suitable for text exchange only.
• If graphs, audio, and video are send, flag could also be part of information.
• Receiver encounters this pattern in middle of data, thinks it has reached end of
frame.
• To fix this problem, a byte-stuffing strategy was added.
7
Character-Oriented Protocols
• Problem 2
• Universal coding systems like Unicode have 16-bit and 32-bit characters that
conflict with 8-bit characters.
9
Bit Oriented Protocols
• Sequence of bits to be interpreted by upper layer as text, graphic, audio, and
video.
• Special 8-bit pattern flag 01111110 as delimiter to define beginning and end of
frame
10
Bit Oriented Protocols
11
Flow Control
12
Flow Control
• Eg: Items are produced faster than they can be consumed.
Items are produced more slowly than they can be consumed.
• Flow control is a feedback from the receiving node to the sending node to stop
or slow down pushing frames.
13
Flow Control
• How much data it can transmit before it must wait for an acknowledgment
from the receiver.
• Each receiving device has a block of memory, called a buffer, reserved for
storing incoming data until they are processed.
• Flow control refers to a set of procedures used to restrict the amount of
data that the sender can send before waiting for acknowledgment.
14
Error Control
15
Error Control
16
Error Control
• Two methods. In both methods, a CRC is added to the frame header by the
sender and checked by the receiver.
Method 1: If the frame is corrupted, it is discarded;
If it is not corrupted, the packet is delivered to the network layer.
This method is used mostly in wired LANs such as Ethernet.
Method 2: If the frame is corrupted, it is discarded;
If it is not corrupted, an acknowledgment is sent to the sender.
17
• No flow or error control
• Receiver can immediately handle any frame it receives.
• FSM - Finite State Machine
18
19
• Uses both flow and error control.
• Sender sends one frame at a time and waits for an acknowledgment before
sending the next frame.
• To detect corrupted frames, add a CRC to each data frame.
• If an acknowledgment arrives before the timer expires, the timer is stopped
and the sender sends the next frame (if it has one to send).
• If the timer expires, the sender resends the previous frame, assuming that the
frame was either lost or corrupted. 20
21
Stop and Wait
• Sender States - Initially in ready state, but move between states.
❑ Ready State: Sender waiting for a packet from the network layer.
❑ Blocking State: Three events occur:
a. If a time-out occurs, the sender resends the saved copy of the frame
and restarts the timer.
b. If a corrupted ACK arrives, it is discarded.
c. If an error-free ACK arrives, the sender stops the timer and discards
the saved copy of the frame. It then moves to the ready state.
22
Stop and Wait
• Receiver - Always in the ready state. Two events may occur:
a. If an error-free frame arrives, the message in the frame is delivered
to the network layer and an ACK is sent.
b. If a corrupted frame arrives, the frame is discarded.
• Sequence and Acknowledgment Numbers
• Add sequence numbers to the data frames and acknowledgment numbers
to the ACK frames.
• Sequence numbers are 0, 1, 0, 1, 0, 1, . . . ;
• Acknowledgment numbers can also be 1, 0, 1, 0, 1, 0, …
• In other words, the sequence numbers start with 0, the acknowledgment
numbers start with 1.
• An acknowledgment number always defines the sequence number of
the next frame to receive.
23
24
STOP and WAIT
• 3 possibilities
• Everything is OK (Data & ACK is transmitted alternatively)
• ACK frame is lost (duplication of data, sequence number, ACK with number)
25
Media Access Control
26
Media Access Control
• When nodes or stations are connected and use a common link (multipoint or
broadcast link), multiple-access protocol is used to coordinate access to the link.
• The problem of controlling the access to the medium.
• Many protocols have been devised to handle access to a shared link. All of these
protocols belong to a sublayer in the data-link layer called Media Access
Control (MAC).
• Data link layer divided into two functionality-oriented sublayers
27
28
Evolution of CSMA/CD
29
Random Access
• In random access or contention methods, no station is superior to
another station and none is assigned the control over another.
• No station permits, or does not permit, another station to send.
• At each instance, a station that has data to send uses a procedure defined
by the protocol to make a decision on whether or not to send.
• Two features
• No scheduled time for a station to transmit. Transmission is random
among the stations (Random Access).
• No rules specify which station should send next. Stations compete
with one another to access the medium (contention methods)
30
Random Access
• If more than one station tries to send, there is an access conflict called collision
and frames will be either destroyed or modified.
• Each station follows a procedure that answers following questions:
❑ When can station access medium?
❑ What can station do if medium is busy?
❑ How can station determine success or failure of transmission?
❑ What can station do if there is an access conflict?
31
ALOHA
• ALOHA stands for Additive Links On-line Hawaii Area
32
Pure ALOHA
• Each station sends a frame whenever it has a frame to send.
• Only one channel to share, there is possibility of collision between frames
from different stations.
• Relies on acknowledgments from receiver.
• Dictates that when time-out period passes, each station waits a random
amount of time (backoff time TB) before resending its frame. Randomness
will help avoid more collisions.
33
Frames in a pure ALOHA network
34
Procedure for pure ALOHA protocol
35
Vulnerable time for pure ALOHA protocol
37
Vulnerable time for slotted ALOHA protocol
• Carrier sense multiple access (CSMA) requires that each station first
listen to medium (or check state of medium) before sending.
39
Space/time model of collision in CSMA
40
Vulnerable time in CSMA
• Propagation time Tp
• A sends a frame at time t1 which reaches rightmost station D at time t1 + Tp.
41
Behavior of three persistence methods
42
Behavior of three persistence methods
• p-persistent method - slot duration equal to or greater than maximum propagation
time, reduces chance of collision and improves efficiency.
1. With probability p, station sends its frame
2. With probability q = 1 − p, station waits for beginning of next time slot and checks
line again.
a. If line is idle, it goes to step 1.
b. If line is busy, it acts as though a collision has occurred and uses backoff
procedure.
43
Flow diagram for three persistence methods
44
CSMA/CD
45
Collision of the first bit in CSMA/CD
46
Collision and abortion in CSMA/CD
Frame transmission time Tfr must be atleast two times maximum propagation time Tp
47
Example
1. A network using CSMA/CD has a bandwidth of 10 Mbps. If the
maximum propagation time (including the delays in the devices and
ignoring the time needed to send a jamming signal) is 25.6 μs, what is
the minimum size of the frame?
Solution
The frame transmission time is Tfr = 2 × Tp = 51.2 μs.
In worst case, station needs to transmit for a period of 51.2 μs to detect
collision.
Minimum size of frame is 10 Mbps × 51.2 μs = 512 bits or 64 bytes.
This is actually minimum size of frame for Standard Ethernet.
48
Flow diagram for the CSMA/CD
49
Energy level during transmission, idleness, or
collision
50
CSMA/CD
• Difference between ALOHA and CSMA/CD:
• Addition of persistence process
• Do not send entire frame
• Short jamming signal
• Throughput of CSMA/CD is greater than that of pure or slotted ALOHA
• For 1-persistent method, maximum throughput is around 50% when G = 1.
• For nonpersistent method, maximum throughput can go up to 90% when G
is between 3 and 8
51
Token Ring
52
Token Ring
• Token Ring network was originally developed by IBM in 1970s.
• It is still IBM's primary local-area network (LAN) technology.
• Resource sharing
• Round Robin
• Token
• Simple placeholder frame that is passed from station to station around
the ring.
• A station may send data only when it has possession of token
• Token ring allows each station to send one frame per turn
53
Access Method :Token Passing
54
Access Method :Token Passing
• This token is passed from NIC (Red box) to NIC in sequence until it
encounters a station with data to send.
• That station (a,b,c,d) waits for token to enter its network board.
• If token is free, station may then send a data frame.
• It keeps token and sets a bit inside its NIC as a reminder that it has done so,
then sends its one data frame.
• This data frame proceeds around the ring, being regenerated by each station.
• Each intermediate station examines the destination address, finds that frame is
address to another station and relays it to its neighbor.
55
Access Method :Token Passing
• Intended recipient recognizes its own address, copies message, checks for
errors and changes four bits in last byte of frame to indicate address
recognized and frame copied
• Full packet then continues around ring until it returns to station that sent it
• Sender receives frame and recognized itself in source address field
• It then examines the address-recognized bits
• If they are set, it knows frame was received.
• Sender then discards used data frame and release token back to ring
56
Priority and reservation
• The busy token can be reserved by a station waiting to transmit, regardless of that
station’s location on the ring
• Each station has a priority code
• As a frame pass by, a station waiting to transmit may reserve the next open token by
entering its priority code in the Access Control (AC) field of the token or data
frame.
• A station with a higher priority may remove a lower priority reservation and
replace it with its own
• Among station of equal priority, process is first come, first serve.
57
Time Limits
• Token ring – Imposes time limit (any station use the ring)
58
Problems: Monitor Station
59
1. One station on the ring designated as a monitor
3. If token does not reappear in allotted time – assumed lost and monitor
generates a new tokens and introduces it to ring.
Addressing
• Uses 6-byte address
Electrical specification
• Signaling – Uses differential Manchester encoding
• Data Rate – Support data rates of upto 18 Mbps.
61
Token Ring Frame
Access-control byte
• Priority field - Most significant 3 bits
• Reservation field - Least significant 3 bits
• Token bit - Used to differentiate a token from a data/command frame
• Monitor bit - Used by active monitor to determine whether a frame is
circling ring endlessly.
64
Data Frame Fields
65
Fields in Frame Format
• Frame-control bytes
• Indicates whether frame contains data or control information.
• In control frames, this byte specifies type of control information.
• Data
• Indicates length of field - limited by ring token holding time
• Defines maximum time a station can hold token.
66
Data Frame Fields
67
Fields in Frame Format
• Frame-check sequence (FCS)
• Filed by source station with a calculated value dependent on frame contents.
• Destination station recalculates the value
• If frame was damaged in transit, frame is discarded.
• End Delimiter
• Signals end of token or data/command frame.
• Contains bits to indicate a damaged frame
• Identify frame that is last in a logical sequence.
• Frame Status
• It is a 1-byte field terminating a command/data frame.
• Frame Status field includes address-recognized indicator and frame-copied
indicator. 68
Implementation
RING
Ring in token ring consists of a series of 150-ohm, Node
shielded twisted-pair sections linking each station to its
intermediate neighbours. Node Node
Each section connects an output port on one station
to an input port on next, creating a ring with Ring
unidirectional traffic flow.
Output from final station connects to input of first Node Node
to complete ring.
A frame is passed to each station in sequence,
where it is examined, regenerated and then sent on to Node
next station.
71
MAU
72
FDDI
73
Fiber Distributed Data Interface (FDDI)
• LAN protocol standardised by ANSI and ITU-U.
74
Access Method: Token Passing
• Access is limited by time.
• A station may send a many frames as it can within its allotted access
period.
• Two types of data frames - Synchronous and Asynchronous.
• Synchronous (S frame) - Information is time sensitive.
• Asynchronous (A frame) - Information is not time sensitive.
• Every station that captures token first transmits S-frame then A-frame.
75
Time Registers
• 3 time registers to control circulation of token and distribute link access opportunity
among nodes equally.
• Each station has three registers - Synchronous Allocation (SA), Target Token Rotation
Time (TTRT), Absolute Maximum Time (AMT)
• Registers hold time values that control operation of ring.
• Values are set when ring is initiazed and do not vary during operation
• Synchronous Allocation (SA)
• Indicates length of time allowed each station for sending synchronous data.
• Value is different for each station and is negotiated during initialization of ring.
76
Time Registers
• Target Token Rotation Time (TTRT)
• Indicates average time required for a token to circulate around ring exactly once.
• Value is same for all stations and is negotiated during initialization of ring.
• Actual time of any rotation will be greater or less than this value.
79
FDDI Operation
80
FDDI Operation
• In round 0, token travels from station to station. Each station sets TRT timer to
0, no data transfer occurs.
• In round 1, station 1 receives token at time a. TRT is 4 and THT is 26
(THT = TTRT - TRT)
• TRT reset to 0, station 1 sends 2 data unit of synchronous data.
• THT is decremented to 24 (26 -2), station 1 send 24 data unit of asynchronous
data.
• In same round, station 2 follow same procedure. Token arriving time is 31
(4+26+1 = 31)
81
Example of Access Method
82
Example of Access Method
83
FDDI Layers
84
MAC Sublayer - FDDI Frames
85
Physical Sublayer
• Independent of transmission medium.
• It defines data rate and is responsible for encoding and decoding of data and
synchronization.
• Fixed data rate of 100 Mbps
• NRZ-I encoding.
• Block encoding mechanism
called 4 Bits/5 Bits (4 bit
segment of data replaced
by 5 bit code that contains
no more than 2 consecutive
0’s)
86
87
88
FDDI Encoding
• Bandwidth to create encoded data in FDDI is 125 Mbaud (5 bits sent for 4
bits of actual data)
89
PMD Sublayer - FDDI Rings
• Data transmission in primary ring
• Secondary ring (self healing) in case primary fails
90
FDDI Ring Failure
• Nodes connect to one or to both rings using Media Interface connector (MIC)
• Every MIC has two fiber ports
91
FDDI Nodes
94
Switched Network
96
Switching
• Switching can happen at several layers of the TCP/IP protocol suite.
• At physical layer
• Only circuit switching.
• No packets exchanged.
• Allow signals to travel in one path or another.
• At data-link layer
• Packet switching using a virtual-circuit approach.
• Frames or cells.
• At network layer
• Packet switching using virtual-circuit approach or datagram approach can be
used.
• At application layer,
• Only message switching (e-mail)
97
Circuit-Switched Network
• Delay for setup = Propagation time of source computer request, request signal
transfer time, propagation time of acknowledgment from destination computer,
and signal transfer time of acknowledgment.
• Delay for data transfer = Propagation time and data transfer time.
100
Example: 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.
101
Packet Switching
102
• Packet switching – Data and non-voice transmission
• In a packet-switched network, there is no resource reservation; resources are
allocated on demand.
103
Datagram Approach
104
Datagram Approach
• Packets are called datagrams and treated independently.
• Happen at Network layer.
• Transport layer to reorder datagrams.
• Connectionless networks - Switches does not keep information about
connection state
• Multiplexing – TDM or FDM.
• No setup or teardown phases
105
• A switch in a datagram network uses a
routing table that is based on destination
address.
• In datagram network, Destination address
in header of a packet remains same
during entire journey of packet.
• Efficiency is better - Resources can be
reallocated during delay
• Greater delay - Packet may experience a
wait at a switch
106
Datagram Approach, Multiple Channels
107
Packet travels through two switches, three transmission times (3T), three
propagation delays (slopes 3τ of the lines), and two waiting times (w1 + w2).
Total delay = 3T + 3τ + w1 + w2
108
Virtual-Circuit Networks
• A cross between a circuit-switched network and a datagram network.
• Characteristics:
1. There are setup, data transfer phase and teardown phases
2. Resources allocated during setup phase (circuit-switched
network) or on demand (datagram network).
3. Data are packetized and each packet carries an address in header
(Datagram network).
4. All packets follow the same path established during connection
(circuit-switched network).
5. A virtual-circuit network in data-link layer, circuit-switched network
in physical layer and a datagram network in network layer.
109
110
Virtual-Circuit Networks
• Addressing - Two types of addressing are involved: global and local
(Virtual-Circuit Identifier)
• Virtual-Circuit Identifier (VCI) or label - A small number that has only
switch scope
111
112
113
114
115
• 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.
116
Delay in a virtual-circuit network
• Packet is traveling through two switches (routers).
• There are three transmission times (3T), three propagation times (3τ), data
transfer depicted by sloping lines, a setup delay (which includes transmission
and propagation in two directions), and a teardown delay (which includes
transmission and propagation in one direction).
• Ignore processing time in each switch.
• Total delay time is
Total delay = 3T + 3τ + setup delay + teardown delay
117
Message Switching
118
VLANs
119
VLANs
• Virtual Local Area Network
• Configured by software, not by physical wiring.
120
121
VLAN
• Divide a LAN into logical (VLAN) instead of physical segments.
• Each VLAN is a work group in organization.
• If a person moves from one group to another, there is no need to change physical
configuration.
• Group membership in VLANs is defined by software, not hardware.
• Any station can be logically moved to another VLAN.
• All members belonging to a VLAN can receive broadcast messages sent to that
particular VLAN.
• Vendors use different characteristics such as interface numbers, port numbers,
MAC addresses, IP addresses, IP multicast addresses, or a combination of two
or more of these.
122
VLAN
• Interface Numbers
- VLAN vendors use switch interface numbers as a membership characteristic
- Stations connecting to ports 1, 2, 3, and 7 belong to VLAN 1
• MAC Addresses
- VLAN vendors use the 48-bit MAC address as a membership characteristic.
- Stations having MAC addresses E2:13:42:A1:23:34 belong to VLAN 1
• IP Addresses
- VLAN vendors use the 32-bit IP address as a membership characteristic.
- Stations having IP addresses 181.34.23.67 belong to VLAN 1.
123
VLAN
• Multicast IP Addresses
- VLAN vendors use multicast IP address as a membership characteristic.
124
VLAN Configuration
• Three ways: manually, semi-automatically, and automatically.
• Manual Configuration
- VLAN software to manually assign stations into different VLANs at setup
- Migration from one VLAN to another is done manually
- Administrator types port numbers, IP addresses, or other characteristics,
using VLAN software
125
VLAN Configuration (Contd..)
• Automatic Configuration
- Stations are automatically connected or disconnected from a VLAN using
criteria defined by administrator.
- Administrator can define project number as criterion for being a member of a
group.
- When a user changes projects, he or she automatically migrates to a new VLAN.
• Semi-automatic Configuration
- Between a manual configuration and an automatic configuration.
- Initializing is done manually, with migrations done automatically
126
Communication between Switches
• In a multi-switched backbone, each switch must know which station belongs to
which VLAN and also the membership of stations connected to other switches.
• Switch A must know membership status of stations connected to switch B, and
switch B must know same about switch A.
• Three methods: Table maintenance, Frame tagging, and Time Division
Multiplexing.
• Table Maintenance
- When a station sends a broadcast frame to its group members, switch creates an
entry in a table and records station membership.
- Switches send their tables to one another periodically for updating.
127
Communication between Switches (Contd..)
• Frame Tagging
- When a frame is traveling between switches, an extra header is added to
MAC frame to define destination VLAN.
- Receiving switches determine VLANs to be receiving broadcast message.
• IEEE Standard
- In 1996, IEEE 802.1 subcommittee passed a standard called 802.1Q that
defines format for frame tagging.
- It defines format to be used in multi-switched backbones and enables
use of multivendor equipment in VLANs.
129
Advantages of VLANs
• Cost and Time Reduction
- Reduce migration cost of stations going from one group to another.
- Easier and quicker to move it by using software.
• Creating Virtual Work Groups
- VLANs can be used to create virtual work groups.
- Reduce traffic if the multicasting capability of IP was previously used.
• Security
- VLANs provide an extra measure of security.
- Users in other groups will not receive these messages.
130
Wireless LANs
131
Wireless LANs
• Two types
- IEEE 802.11 project (Wireless Ethernet).
- Personal wireless LAN, Bluetooth (Personal Area Network or PAN).
• Medium is air, signal is generally broadcast.
• Sharing same medium
• Host is not physically connected to network, it can move freely and can use
services provided by network
• Wireless isolated LAN (Adhoc network) is a set of hosts that communicate
freely with each other.
• Wireless LAN may be connected to a wired infrastructure network, to a
wireless infrastructure network, or to another wireless LAN.
• Operates only in lower two layers of TCP/IP protocol suite 132
Wireless LAN
133
Characteristics
• Attenuation - Strength of electromagnetic signals decreases rapidly because
signal disperses in all directions.
• Interference - Receive signals not only from intended sender, but also from
other senders if they are using same frequency band
• Multipath Propagation - Receiver may receive more than one signal from
same sender because electromagnetic waves can be reflected back from
obstacles such as walls, ground, or objects
• Error - Errors and error detection are more serious issues, it measures ratio
of good stuff to bad stuff (signal to noise).
134
Access Control
• CSMA/CD algorithm does not work in wireless LANs for three reasons:
- Wireless hosts do not have enough power to do duplex transmission.
- Distance between stations can be great
- Hidden station problem
135
IEEE 802.11 Project
• WiFi (Wireless Fidelity)
• Certified by the WiFi Alliance.
• Architecture
- Two kinds of services: Basic Service Set (BSS) and
Extended Service Set (ESS)
136
Basic Service Set
• Made of stationary or mobile wireless stations and an optional central base
station, known as the access point (AP).
138
Extended Service Set
• Made up of two or more BSSs with APs
• BSSs are connected through a distribution system which connects APs.
• Two types of stations: Mobile (normal stations) and
Stationary (AP stations that are part of a wired LAN)
• When BSSs are connected, stations within reach of one another can
communicate without use of an AP.
• Communication between a station in a BSS and outside BSS occurs via AP.
• Each BSS is consider as a cell and each AP to be a base station.
• Note that a mobile station can belong to more than one BSS at same time.
139
Station Types
• Three types of stations :
- No-transition mobility (stationary or moving only inside a BSS)
- BSS-transition mobility (move from one BSS to another, but inside one ESS)
- ESS-transition mobility (move from one ESS to another)
140
MAC Sublayer
• Two MAC sublayers: Distributed Coordination Function (DCF) and
Point Coordination Function (PCF)
141
Distributed Coordination Function
• CSMA/CA as access method
• Frame Exchange Time Line
- Distributed interframe space (DIFS)
- Short interframe space (SIFS)
- Request to send (RTS)
- Clear to send (CTS)
• Network Allocation Vector
142
143
Point Coordination Function
144
Frame control (FC)
145
Frame Types
• Three categories of frames:
- Management frames (initial communication between stations and AP)
- Control frames (accessing the channel and acknowledging frames)
- Data frames ( data and control information)
146
147
148
149
Physical Layer
150
Physical Layer
151
Reference
1. Behrouz A Foruzan, Data Communications and Networking, 5th Edition.
152