Physical Layer & Data Link Layer
Physical Layer & Data Link Layer
1. Physical layer
- Lowest layer in OSI, sends bits from one device to another.
- Responsible for sending raw data as bits over physical medium, converts data
into signals that can travel through wires.
- Functions – bit-by-bit transmission, encoding & decoding, signal transmission,
modulation & demodulation, data rate control, transmission modes (simplex, half-
duplex, full duplex)
- Transmission media is physical medium through which data is transmitted from
one device to another within a N/W. (Can be wired/guided or wireless/unguided)
a. Guided Media
o Referred as wired/bounded media, signals are transmitted using physical
links.
o Twisted Pair Cable:
Consists of 2 separately insulated conductor wires twisted about each
other, several such pairs are bundled together in protective sheath.
2 types – UTP & STP
UTP consists of two insulated copper wires twisted around one
another, has the ability to block interference & doesn’t depend
on physical shield for it. Used for telephonic applications.
Advantages of UTP – least expensive, easy to install, high
speed capacity.
Disadvantages of UTP – lower capacity & performance
compared to STP, short distance transmission due to
attenuation.
STP consists of special jacket (a copper braid covering or a foil
shield) to block external interference. Used in fast data rate
Ethernet & in voice & data channels of telephone lines.
Advantages of STP – better performance at higher data rate
compared to UTP, eliminates crosstalk, comparatively faster.
Disadvantages of STP – difficult to install & manufacture, more
expensive, bulky
1
o Coaxial Cable:
Has outer plastic covering containing insulation layer made of
PVC/Teflon & 2 parallel conductors each having separate insulated
protection cover.
Transmits info in 2 modes – baseband mode (dedicated with cable
B/W) & broadband mode (cable B/W is split into separate ranges)
Advantages – high B/W, easy to install, more reliable & durable, less
affected by noise/cross-talk/EM interference, support multiple
channels.
Disadvantages – expensive, must be grounded inorder to prevent any
crosstalk, bulky (due to multiple layers)
o Stripline:
A transverse EM (TEM) transmission line medium, uses a conducting
material to transmit high-frequency waves, also called waveguide.
Conducting material is sandwiched between 2 layers of ground plane
which are shorted to provide EMI immunity.
2
o Microstripline:
Consists of flat, narrow conducting strip (made of metal) placed on top
of dielectric material (insulating layer), with metal ground plane on
other side.
Used to carry high-frequency signals, commonly found in microwave
& radio frequency circuits.
b. Unguided Media
o Referred to as wireless/unbounded transmission media, no physical
medium required for transmission of EM signals.
o 3 types – radio waves, microwaves, infrared
o Radio waves
Easy to generate, can penetrate through buildings, sending &
receiving antennas need not be aligned.
Frequency range: 3KHz – 1GHz.
Types – Short wave, VHF, UHF
Components – transmitter, receiver
o Micro waves
Line of sight transmission (sending & receiving antennas need to be
properly aligned with each other)
Distance covered by signal is directly proportional to height of
antenna.
Frequency Range: 1GHz – 300GHz
3
Advantages – cheaper, freedom from land acquisition, ease of
communication, communication over oceans
Disadvantages – insecure communication, out of phase signal,
susceptible to weather conditions, B/W is limited, high cost of design
implementation & maintenance.
o Infrared
Used for very short distance communication, cannot penetrate
through obstacles preventing interference between systems.
Frequency range: 300GHz – 400THz.
c. Wireless Transmission
o Involves no physical link established between 2 or more devices, signals
are spread all over within its frequency range.
i. Electromagnetic Spectrum
4
Infrared (IR) 700 nm – 1 mm 300 GHz – 430 Remote controls, thermal
THz imaging
Visible Light 400 – 700 nm 430 – 770 THz What human eyes can see
(ROYGBIV)
ii. Switching
Process of transferring data packets from one device to another in
N/W or vice-versa using specific devices called switches. (refer switch
N/W device)
Takes place at DLL, immediate next process after generation of data
packets in physical layer.
Switch decides port through which data packet shall pass with the
help of its dest MAC address, maintains switching table (forwarding
table).
Switching process:
5
1. Circuit-Switched Networks
A connection establishes between src & dest beforehand,
connection receives complete B/W of N/W until data is
transferred completely.
2. Packet Switching
Requires data to be broken down into smaller components, data
frames or packets. Data frames are then transferred to their
dest according to available resources in N/W at particular time.
Each data frame contains additional info about dest & other info
required for proper transfer through N/W components.
6
o Inefficient because in practical, fewer than 25% of
crosspoints are in use at any given time, rest are idle.
Multistage switch
o Solution to limitations of crossbar switch is multistage
switch, combines crossbar switches in different stages
(normally 3 stage)
o In single crossbar switch, only one row or column is active
for any connection, so N x N crosspoints are needed. If
multiple paths allowed inside switch, we can decrease no.
of crosspoints.
o Each crosspoint in middle stage can be accessed by
multiple crosspoints in 1st or 3rd stage.
7
o Provides 3 types of services:
Unacknowledged & connectionless services – sender machine sends
independent frames without any acknowledgement from sender, no
logical connection established.
Acknowledged & connectionless services – no logical connected
established, each frame is acknowledged by receiver, if frame didn’t
reach receiver in specific time sends again, useful in wireless system.
Acknowledged & connection-oriented services – logical connection
established before data is transmitted, each frame is numbered so
receiver can ensure all frames have arrived exactly once.
b. Framing
o Function of DLL, provides a way for sender to transmit a set of bits that are
meaningful to receiver.
o Frames have headers that contain info like error checking codes.
o At DLL, it extracts message from sender & provides to receiver by providing
senders’ & receivers’ addresses.
o Process of dividing data into frames & reassembling it is handled by DLL.
o Problems in framing – detecting start of frame, detecting end of frame,
handling errors, framing overhead, framing incompatibility, framing
synchronization, framing efficiency.
o Types – Fixed-size & variable-size
o Fixed-size – frame is of fixed size & no need to provide boundaries to
frame, length of frame acts as delimiter. Suffers internal fragmentation if
data size is less than frame size.
o Variable size – no need to define end of frame/beginning of next frame to
distinguish. Can be done in 2 ways:
Length field – introduce a length field in frame to indicate length of
frame. Problem – sometimes length field might get corrupted.
End Delimiter (ED) – introduce and ED (pattern) to indicate end of
frame. Problem – ED can occur in data; solve by character/byte
stuffing or bit stuffing
Character/Byte Stuffing – used when frames consist of characters. If
data contains ED then a byte is stuffed into data to differentiate it from
ED.
Bit Stuffing – Sender stuffs a bit to break the pattern, receiver
removes the stuffed bit.
8
c. Error Control
o Done to prevent duplication of frames, errors introduced during
transmission from src to dest must be detected & corrected at dest.
d. Flow Control
o Done to prevent flow of data frame at receiver end. The src must not send
data frames at a rate faster than capacity of dest to accept them.
3. Error Detection & Correction
- A condition when receiver’s info does not match sender’s info. Digital signals
suffer from noise during transmission that can introduce errors in binary bits (0 bit
may change to 1 or 1 bit may change to 0)
- Types of errors – single bit error, multiple bit error, burst error
o Single bit error – error that occurs when one bit of transmitted data unit is
altered during transmission, resulting in incorrect/corrupted data unit.
o Multiple bit error – arises when more than one bit in data transmission is
affected.
o Burst error – several consecutive bits are flapped mistakenly in digital
transmission creates burst error. This error causes a sequence of
consecutive incorrect values.
- To detect errors, introduce redundant bits that provide additional info.
a. Hamming Code
o It’s a block of code capable of detecting up to two simultaneous bit errors &
correcting single bit errors.
o The src encodes message by inserting redundant bits, when dest receives
message, it performs recalculations to detect errors & find the bit position
that has error.
o Encoding message:
r 1is parity bit for all data bits in positions whose binary representation
includes a 1 in least significant position excluding 1 (3,5,7,9,11 and so on)
r 2is parity bit for all data bits in positions whose binary representation
includes a 1 in position 2 from right except 2 (3,6,7,10,11 and so on)
r 3is parity bit for all data bits in positions whose binary representation
includes a 1 in position 3 from right except 4 (5-7,12-15,20-23 and so on)
o Decoding message:
o Two dimensional parity check bits are calculated for each row, equivalent to
a simple parity check. Parity check bits are also calculated for all columns
then both are sent along with data. At receiving end, they are compared
with parity bits calculated on received end.
c. CRC
o Based on binary division. A sequence of redundant bits, called cyclic
redundancy check bits are appended to end of data unit so resulting data
unit becomes exactly divisible be a second, predetermined binary number.
o At dest, incoming data unit is divided by same no. if at this step there is no
remainder, data unit is assumed to be correct & is accepted.
o A remainder indicates that data unit has been damaged & must be rejected.
10
o Working:
At Sender At Receiver
Rule 1 – send one data packet at a Rule 1 – send one
time. acknowledgement after receiving &
consuming a data packet
Rule 2 – send next packet only after Rule 2 – after consuming packet,
receiving acknowledgement of acknowledgement need to be sent
previous
b. Sliding Window
o A technique for controlling flow of data between two devices, guarantees
that data is sent consistently & effectively, allowing many packets to be sent
before requiring an acknowledgement for first, maximizes use of available
B/W.
o Sender has a buffer called sending window, receiver has buffer called
receiving window. Size of sending window determines sequence no. of
outbound frames. If sequence no. of frames is n-bit field, then range of
sequence nos. that can be assigned is 0 to 2n−1. Size of receiving window is
maximum no. of frames that receiver can accept at a time, it determines
maximum no. of frames that sender can send before receiving
acknowledgement.
i. Go Back N
It’s a sliding window protocol used in N/W for reliable data
transmission. It is part of ARQ protocols, which ensure data is
correctly received & any lost/corrupted packets are retransmitted.
Go Back means sender has to go back N places from last transmitted
packet in unacknowledged window & not from point where packet is
lost.
13
Window size determines how many packets sender can transmit
without needing an acknowledgement (limit on how much data can be
sent before sender has to stop & wait for confirmation)
Sequence numbers are used to label packets so receiver knows their
order & can detect any missing packets.
Window size should be smaller than or equal to range of available
sequence numbers.
Consider the diagram given below. We have sender window size of 4.
Assume that we have lots of sequence numbers just for the sake of
explanation. Now the sender has sent the packets 0, 1, 2 and 3. After
acknowledging the packets 0 and 1, receiver is now expecting packet
2 and sender window has also slided to further transmit the packets 4
and 5. Now suppose the packet 2 is lost in the network, Receiver will
discard all the packets which sender has transmitted after packet 2 as
it is expecting sequence number of 2. On the sender side for every
packet send there is a time out timer which will expire for packet
number 2. Now from the last transmitted packet 5 sender will go back
to the packet number 2 in the current window and transmit all the
packets till packet number 5. That’s why it is called Go Back N.
5. Piggybacking
- Technique of delaying outgoing acknowledgement temporarily & attaching it to
next data packet, when data frame arrives receiver waits & doesn’t send control
frame back immediately. Receiver waits until its N/W layer moves to next data
packet. Acknowledgement is associated with this outgoing data frame.
Acknowledgement travels along with next data frame.
- Use each channel to transmit frame (front & back) both ways, with both channels
having same capacity.
- Working:
Instead of two separate messages a single message (ACK + DATA) over wire.
Piggybacking improves efficiency of bidirectional protocols.
1. If host A has both acknowledgement & data, which it wants to send, then data
frame will be sent with ACK field which contains sequence no. of frame.
2. If host A contains only one acknowledgement, wait for some time, if any data
frame found, it piggybacks acknowledgment, otherwise send ACK frame.
3. If host A is left only with data frame, add last acknowledgement to it. Host A
can send data frame with ACK field containing no acknowledgement bit.
15
6. HDLC (High-Level Data Link Control)
- Provides reliable delivery of data frames over N/W or communication link.
- Provides operations such as framing, data transparency, error detection &
correction & flow control.
- Each frames of HDLC includes atleast 6-7 fields like start/end flag field, control
field, info field, FCS (Frame Check Sequence) field.
- Standard HDLC protocol contains 6 fields (supports only one protocol), Cisco
HDLC (cHDLC) contains one extra protocol (supports multiple protocol
environments due to protocol field in header).
o Address field – to identify & specify type of packet present in cHDLC frame.
Can be 0*0F for unicast & 0*8F for Broadcast packets.
o Control field – always set to zero i.e. 0*00
o Protocol field – required to specify & identify type of protocol being
encapsulated within cHDLC frame. Can be 0x0800 for IP.
7. Medium Access Protocols
- Control how data is transmitted when multiple devices are trying to communicate
over same N/W. These protocols ensure data packets are sent & received
efficiently without collisions or interference. Manage traffic.
- When there's no dedicated link between sender and receiver, multiple stations
share the same channel, leading to possible collisions and data loss. To manage
this, multiple access protocols are used to control how stations transmit data,
ensuring orderly communication.
a. Random Access
o All stations have same superiority. Any station can send data depending on
medium’s state (idle/busy).
o Features – no fixed time for sending, no fixed sequence of stations sending
data.
o Subdivided into: Aloha (pure & slotted), CSMA, CSMA/CD, CSMA/CA
o Aloha:
Designed for wireless LAN but also applicable for shared medium.
Multiple stations can transmit data at same time & can lead to
collision.
Pure aloha – when station sends data it waits for acknowledgement, if
acknowledgement doesn’t come within allotted time then station waits
for random amount of time called back-off time (T b) & resends data.
16
Since different stations wait for different amount of time, probability of
further collision decreases.
Slotted aloha – similar to pure aloha except that time slots are divided
& sending of data is allowed only at beginning of these slots. If station
misses out allowed time, it must wait for next slot reducing probability
of collision.
o CSMA (Carrier Sense Multiple Access)
Ensures fewer collisions as station is required to first sense medium
(idle/busy) before transmitting data. If idle then sends data, else waits
till channel becomes idle.
Due to propagation delay, there are chances of collision in CSMA.
CSMA modes – 1-persistent, Non-persistent, P-persistent, O-
persistent
1-persistent: node senses channel, if idle sends data, else
continuously keeps checking medium for being idle & transmits
unconditionally (with 1 probability) as soon as channel gets idle.
Non-persistent: node senses channel, if idle sends data, else checks
medium after random amount of time (not continuous) & transmits
when found idle.
P-persistent: node senses medium, if idle sends data with p
probability. If data not transmitted it waits for some time & checks
medium again, if found idle it sends with p probability. This continues
until frame is sent.
O-persistent: superiority of nodes is decided beforehand &
transmission occurs in that order. If medium is idle node waits for its
time slot to send data.
o CSMA/CD – CSMA with collision detection, stations can terminate
transmission of data if collision is detected.
o CSMA/CA
CSMA with collision avoidance, if collision occurs & there are two
signals, to distinguish between these collisions must have a lot of
impact on received signal, so CSMA/CA is used.
Interframe space – station waits for medium to become idle, if found
idle it doesn’t immediately send data rather waits for period of time
called interframe space/IFS. After this, checks medium again for being
idle. IFS duration depends on priority of station.
Contention window – it’s amount of time divided into slots. If sender is
ready to send data, chooses random no. of slots as wait time which
doubles every time medium not found idle. If medium found busy it
doesn’t restart entire process, rather restarts timer when channel is
found idle again.
Acknowledgement – sender retransmits data if ACK not received
before timeout.
b. Controlled Access
17
o Ensure that only one device uses N/W at a time. (like taking turns in convo
so everyone can speak without talking over each other.)
o Data is sent by that station which is approved by all other stations.
c. Channelization
o Available B/W of link is shared in time, frequency & code to multiple stations
to access channel simultaneously.
o Frequency Division Multiple Access (FDMA) – available B/W is divided into
equal bands so that each station can be allocated its own band. Guard
bands are added so that no two bands overlap to avoid crosstalk & noise.
o Time Division Multiple Access (TDMA) – B/W is shared between multiple
stations. To avoid collision time is divided into slots & stations are allotted
slots to transmit data. There’s overhead of synchronization as each station
needs to know its time slot, this is resolved by adding synchronization bits
to each slot. Propagation delay is also issue with TDMA (resolved by
addition of guard bands)
o Code Division Multiple Access (CDMA) – one channel carries all
transmissions simultaneously. No division of B/W or time. Data from
different stations can be transmitted simultaneously in different code
languages.
o Orthogonal Frequency DMA (OFDMA) – available B/W divided into small
subcarriers inorder to increase overall performance. Data is transmitted
through small subcarriers.
o Spatial Division Multiple Access (SDMA) – uses multiple antennas at
transmitter & receiver to separate signals of multiple users that are located
in different spatial directions.
8. Ethernet Protocol
- The Ethernet protocol is one of the most widely used technologies in computer
networking, particularly in local area networks (LANs). It defines how devices on
the same physical network communicate and share data.
- Key features:
o Data Link Layer Protocol (Layer 2 of the OSI Model)
o Uses MAC (Media Access Control) addresses for device identification
o Typically uses CSMA/CD (Carrier Sense Multiple Access with Collision
Detection) for medium access (though less relevant in modern switched
networks)
o Common speeds: 10 Mbps, 100 Mbps (Fast Ethernet), 1 Gbps (Gigabit
Ethernet), 10/40/100 Gbps
- Ethernet Frame structure:
Field Description
Preamble Synchronization (7 bytes)
Start frame delimiter (SFD) Indicates the start of the frame (1 byte)
Destination MAC MAC address of the receiver (6 bytes)
Source MAC MAC address of the sender (6 bytes)
18
Type/Length EtherType or frame length (2 bytes)
Payload Actual data (46–1500 bytes)
CRC Error checking (4 bytes)
- Types of Ethernet:
o Standard Ethernet (10 Mbps):
o Fast Ethernet (100 Mbps): This type of Ethernet network uses cables
called twisted pair or CAT5. It can transfer data at a speed of around 100
Mbps (megabits per second). Fast Ethernet uses both fiber optic and
twisted pair cables to enable communication. There are three categories of
Fast Ethernet: 100BASE-TX, 100BASE-FX, and 100BASE-T4.
o Gigabit Ethernet (1 Gbps+): This is an upgrade from Fast Ethernet and is
more common nowadays. It can transfer data at a speed of 1000 Mbps or 1
Gbps (gigabit per second). Gigabit Ethernet also uses fiber optic and
twisted pair cables for communication. It often uses advanced cables like
CAT5e, which can transfer data at a speed of 10 Gbps.
o 10-Gigabit Ethernet (10 Gbps+): This is an advanced and high-speed
network that can transmit data at a speed of 10 gigabits per second. It uses
special cables like CAT6a or CAT7 twisted-pair cables and fiber optic
cables. With the help of fiber optic cables, this network can cover longer
distances, up to around 10,000 meters.
o Switched Ethernet: This type of network involves using switches or hubs
to improve network performance. Each workstation in this network has its
own dedicated connection, which improves the speed and efficiency of data
transfer. Switch Ethernet supports a wide range of speeds, from 10 Mbps to
10 Gbps, depending on the version of Ethernet being used.
- Working:
19
Self-learning:
1. Differentiate Link Layer in IOT Network & Normal Network
20