Unit-2 CN
Unit-2 CN
The Data Link Layer: Data link layer design issues, Error detection and correction, Elementary data
link protocols, and Sliding window protocols.
The Medium Access Control Sub layer: The channel allocation problem, multiple access protocols,
ETHERNET and Wireless LANs.
DATA LINK LAYER
The data link layer uses the services of the physical layer to send and receive bits over
communication channels. It has a number of functions, including :
DATA LINK LAYER DESIGN ISSUES:
Functions of data link layer are
1. Providing well defined service interface to the network layer.
2. Dealing with transmission errors.
3. Regulating the flow of data.
To achieve these goals, the data link layer takes the packets it gets from the network layer and change
as them into frames for transmission.
Each frame contains a frame header, a payload field for holding the packet, and a frame trailer.
In data link layer these are the requirements and objectives for effective data communication
between two directly connected transmitting-receiving stations:
Frame synchronization-Data are sent in blocks called frames. The beginning and end of
each frame must be detectible.
Flow control-The sending station must not send frames at a faster rate than the receiving
station.
Error control-Any bit errors introduced by the transmission system must be corrected
Control and data on same link- It is not desirable to have a separate physically
communications path for control information. Accordingly, the receiver must be able to distinguish
control information from the data being transmitted.
Link management- Initiation, maintenance, and termination of a sustained data exchange
requires a fair amount of coordination and cooperation among stations.
1
Services provided to the Network layer:
The principal service of data link layer is transferring data from the network layer on the
source machine to the network layer on the destination machine.
Three commonly provided services are:
1. Unacknowledged connection less service.
2. Acknowledged connection less service.
3. Acknowledged connection-oriented service.
2
- The data link layer software checks to see if this is the frame expected, and if so, gives the packet
contained in the payload field to the routing software.
-
FRAMING:
- In order to provide services to the network layer, the data link layer must use the services from
the physical layer.
- The physical layer sends the bit stream to the data link layer.
- The no. of bits received may be different from the no. of bits transmitted.
- The data link layer convert the bit stream into data frames and compute the checksum for each
frame.
- At the destination, the check sum is recomputed.
- If the recomputed check sum is different from the one contained in the frame.
- An error has occurred and the data link layer deals with the errors.
- To mark the start and end of each frame, we use four methods. They are
1. Character count.
2. Flag bytes with byte stuffing.
3. Starting and ending flags with bit stuffing.
4. Physical layer coding violations.
1. Character count:
This method uses a field in the header to specify the number of characters in the frame.
- At the destination the data link layer sees the character count, it knows how many characters
follow and where the end of the frame is
Fig . (a) A frame delimited by flag bytes. (b) Four examples of byte sequences before and
after byte stuffing.
- The sender’s data link layer inserts a special escape byte “ESC
“just before each flag byte the data.
- At the receiving end, the data link layer removes the escape byte before the data are given to the
network layer. This technique is called” byte stuffing” or “character stuffing”.
- A framing flag byte can be identified by the absence or presence of an escape byte in the data.
- If an escape byte occurs in the middle of data that, too, is stuffed with an escape byte.
- Any single escape byte is part of an escape sequence, where as a doubled one indicates that a
single escape occurred naturally in the data.
- Examples of the byte sequences before &after byte stuffing.
- A major disadvantage of this framing method is it is used for 8-bit character only.
- Not all character codes use 8-bit characters, some use 16-bit characters, so a new technique had
to developed to allow sized characters.
3. Starting and ending flags, with bit stuffing:
- In this method, each frame begins and ends with a special bit pattern, 01111110 a flag byte.
- When the sender’s data link layer encounters five consecutive 1’s in the data, it automatically
stuffs a 0 bit into outgoing bit stream.
- This bit stuffing is similar to byte stuffing.
- When the receiver sees five consecutive incoming 1 bits, followed by a 0 bit, it automatically
deletes the 0 bit.
4
- The boundary between two frames can be recognized by the flag pattern.
- If the receiver losses its track the receives has to scan the input for flag sequences.
- The flag sequences occur only at frame boundaries and never with in the data.
5
- Even if the transmission is error free, the receiver will simply be unable to handle the frames as
they arrive & will start to lose them.
- Feed back based flow control & rate based flow control are the two approaches that are
commonly used.
- In feedback –based flow control, the receiver sends back information to the sender giving it
permission to send more data.
- In rate based flow control, the protocol has a built – in –mechanism that limits the rate at which
senders may transmit data, with out using feedback from the receiver.
Error detection and correction:
- Error-Correcting Codes
- We will examine four different error-correcting codes:
- 1. Hamming codes.
- 2. Binary convolutional codes.
- 3. Reed-Solomon codes.
- 4. Low-Density Parity Check codes.
Error detecting codes:
Basic approach used for error detection is the use of redundancy bits, where additional bits are
added to facilitate detection of errors.
Some popular techniques for error detection are:
1. Simple Parity check
2. Two-dimensional Parity check
3. Checksum
4. Cyclic redundancy check
CRC cyclic redundancy check
Unlike checksum scheme, which is based on addition, CRC is based on binary division.
In CRC, a sequence of redundant bits, called cyclic redundancy check bits, are appended to
the end of data unit so that the resulting data unit becomes exactly divisible by a second,
predetermined binary number.
At the destination, the incoming data unit is divided by the same number. If at this step
there is no remainder, the data unit is assumed to be correct and is therefore accepted.
A remainder indicates that the data unit has been damaged in transit and therefore must be
rejected
If the data unit, received by the receiver is without any error then the remainder obtained from
step 6 will be zero.
Ex: using error detecting code find the transmitted frame for a given frame of 1101011011
using the generator.
Frame: 1101011011
Generator it becomes 10011
6
In the given generator the highest power is 4, so we have to add 4 zero’s to the frame.
7
2) A Simple stop-and-wait Protocol:
The communication channel is error free.
Mai problem is how to prevent the sender from flooding the receiver with data faster than it is
able to process it.
To prevent sender from sending more frames than the receiver can accept.
After a packet is passed to the network layer, the receiver sends a little dummy frame back to the
sender, so it gets permission to transmit the next frame.
Sender sends one frame and then waits for an acknowledgement before proceeding is called
“Stop-and-wait”.
This protocol has strict alternation of flow first the sender sends a frame, the receiver sends an
acknowledgement, then only the sender sends another frame, then the receiver sends &soon.
3) A Simplex protocol for a Noisy channel:
The communication channel makes errors. Frames may be damaged or lost completely.
If a frame is damaged the receiver hardware will detect the error when it computes the checksum.
If a damaged frame arrived at the receiver, it would be discarded.
The sender sends the frame again after the time out.
The receiver must be able to distinguish a frame from retransmission.
To achieve this sender put a sequence number in the header of each frame it sends.
The receiver checks the sequence number of each arriving frame to see if it is a new frame.
If it is duplicate frame, it is discarded.
Protocols I which the sender waits for a positive acknowledgement before advancing to the next
data is called (Positive Acknowledgement with Retransmission) PAR or (Automatic Repeat
request) ARQ.
8
The receiver maintains a set of frames it is permitted to accept. These frames are in “receiving
windows”
The three sliding windows protocols differ in terms of efficiency complexity and buffer
requirements.
The three sliding windows protocol are
1) A one bit sliding window protocol
2) A Protocol using go back n
3) A protocol using selective repeat
Fig. Two scenarios for protocol 4. (a) Normal case. (b)Abnormal case. The notation is (seq, ack,
packet number). An asteriskindicates where a network layer accepts a packet.
2) A protocol using go back n
To achieve better efficiency the solution is to allow the sender to transmit up to w frames
before blocking instead of 1.
9
If we take ‘w’ as 26, the sender begins sending frames 0 at t=520 it has finished sending 26
frames, the acknowledgement for frame 0 will have just arrived.
Acknowledgements will arrive after every 20 m sec sender always get’s permission to
continues when it’s it
This technique is known as “pipelining”
Pipelining frames over a communication channel has same problems. If a damaged frames
occurs in the middle of a long steam frame.
Go-back-n and selective repeat are the two ways to deal with errors in pipelining
In Go-back-n the receiver simple discards all subsequent frames, sender no
acknowledgements for the discarded frames.
After the senders time out it retransmit all unacknowledged frames in order, starting with
managed or lost one.
It wastes a lost of band width, if error rate is high.
Fig. Pipelining and error recovery. Effect of an error when (a)receiver's window size is 1 and (b)
receiver's window size is large.
10
Medium Access Sub Layer
MAC (medium access control) sub layer deals with broadcast network and their protocols.
o In broadcast network the key issue is how to determine to use the channel when there is
competition for it.
o Broadcast channels are also called multi access or Random access channels. Eg: conference
call
o The protocols used to determine who goes next on a multi-access channel belong to a sub
layer of the data link layer called MAC.
o How to allocate a single broadcast channel among computing users is called channel
allocation problem.
o Channel allocation problems are two types
1.static channel allocation
2. dynamic channel allocation
Static channel allocation:
o Allocating a static channel among multiple users is by using frequency division
multiplexing(FDM)
o If there are ‘n’ users the bandwidth is divided into n equal sized portions each user assigned
one portion.
o When there are small and fixed no of users FDM is simple & efficient.
o If there are n regions fewer than n users are currently interested in communicating a large
piece of information will be wasted.
o If more than ‘n’ users want to communicate some of them will be denied permission for lack
of bandwidth.
o One of the users is not using the portion no one else is allowed to use it.
11
o Most of the channels will be idle most of the time.
o Static FDM use poor performance.
T=1/uc where T-meantime delay
C-channel capacity bits/ sec
-arrival rate of frames / sec
1/u-mean bits/ frame.
o Single channel is divided into ‘n’ independent sub channels with capacity c=c/n
bits/sec.(symbols)
Dynamic channel allocation:
Channel allocation problem assumptions : there are 5 key assumption.
1. Station model: the model consists of ‘n’ stations each with a one program or user that
generates frames for transmission.
- once a frame has been generated the station is blocked & does nothing until the frame
has been successfully transmitted.
- Stations are independent.
2. Single channel assumption:
A single channel is available for all types of communication.
3. Collision assumption:
If two frames are transmitted simultaneously they overlap in time called collision.all
stations can detect collisions.
4. Continuous time:
Frame transmission can begin at any time. There is no master clock dividing the time into
discrete intervals. Slotted times: time is divided into discrete intervals.
- Frame transmission always begins at the start of a slot.
5.carrier sence:
- Stations can tell if the channel is in use before trying to use it.
- If the channel is sensed as busy no station will attempted to use it until it goes idle.
No carrier sence: stations cannot sence the channel before trying to use it.
2. Multiple access protocol:
12
2.1 ALOHA
A new and elegant method to solve the channel allocation problem is called the ALOHA
system, used ground-based radio broadcasting, the basic idea is applicable to any system in which
uncoordinated users are competing for the use of a single shared channel.
ALOHA 2 types PURE aloha & slotted aloha
a) PURE ALOHA: not divided according to time intervals do not require global time
synchronization.
b) SLOTTED ALOHA: divided according to time intervals. Slotted ALOHA need global time
synchronization.
a) PURE ALOHA:
o When data is ready in it, it sends it directly.
o We do not know whether the channel is empty or not then the frames undergo collisions.
o All the frame lengths should be equal, then we get high throughput.
o Checksum recognizes if there is collision or not. It detects the collisions.
o If there is collision will wait for some random time & transmit the next frame. This is known
as retransmission.
Contention system: having single communication channel, where multiple users are
competing for that channel then those systems are contention systems.
Figure 4-1. In pure ALOHA, frames are transmitted at completely arbitrary times.
Whenever two frames try to occupy the channel at the same time, there will be a collision and both
will be garbled. If the first bit of a new frame overlaps with just the last bit of a frame almost finished,
both frames will be totally destroyed and both will have to be retransmitted later.
o Work load increasing.
o If N>1 , then we are unable to handle problems.
0<N<1, at least handle and transmit the frames.
N-represents data frames which are to be sent.
G-represents retransmit.
S-represents the total probability.
13
o When less no of data frames, then G=S (low loads) when load is over & over(high loads) G>S
o At low loads pure aloha is working well.
o Probability is given by S=GP0 (pure aloha)
P0-the frame which is transmitted without undergoing a collision..
- A frame will not suffer a collision if no other frames are sent within one frame
time of its start, as shown in Fig. 4-2. Let t be the time required to send a frame.
If any other user has generated a frame between time t0 and t0 + t, the end of that
frame will collide with the beginning of the shaded one.
- Since in pure ALOHA a station does not listen to the channel before transmitting,
it has no way of knowing that another frame was already underway.
- Similarly, any other frame started between t0 + t and t0 + 2t will bump into the
end of the shaded frame.
Vulnerable period: the last bits of one frame are collided with the starting bits of another
frame is called vulnerable period.
o Here we have more collisions in aloha in this period.
o If we have ‘K’ frames which are to be sent then, position distribution equation.
o so the probability of zero frames is just e-G. In an interval two frame times long, the mean
number of frames generated is 2G. The probability of no other traffic being initiated during
the entire vulnerable period is thus given by P0 = e -2G. Using S = GP0, we get
S = Ge-2G
The relation between the offered traffic and the throughput is shown in Fig. 4-3. The
maximum throughput occurs at G = 0.5, with S = 1/2e, which is about 0.184. In other words,
the best we can hope for is a channel utilization of 18 percent.
14
b) SLOTTED ALOHA:
- Roberts published a method for doubling the capacity of an ALOHA system (Roberts, 1972).
- His proposal was to divide time into discrete intervals, each interval corresponding to one
frame. This approach requires the users to agree on slot boundaries.
- In Roberts' method, which has come to be known as slotted ALOHA, in contrast to
Abramson's pure ALOHA, a computer is not permitted to send whenever a carriage return is
typed.
- Instead, it is required to wait for the beginning of the next slot. Thus, the continuous pure
ALOHA is turned into a discrete one. Since the vulnerable period is now halved, the
probability of no other traffic during the same slot as our test frame is e-G which leads to,
S = Ge-G
o It need global time synchronization
o Slotted aloha is better than pure aloha in channel utilization.
o If retransmission G increases, collision also increases if G decreases, graph falls down.
o Slotted aloha is not sensing the channel before transmit ion
o The total channel efficiency for pure aloha is S=1/2e.
o the total channel efficiency for slotted aloha is S=1/e.
o
P-persistent CSMA:
o It applies to slotted channels
o When a station ready to sends it senses the channel.
o If it is idle, it transmits with a probability P.
o With a probability Q=1-p it differs until the next slot.
o This process repeat until either the frame has been transmitted.
o If the station initially senses the channel busy, it waits until the next slot& applies the
algorithm.
16
Fig. Comparison of the channel utilization versus load for various random access protocols.
17
MACA-multiple access with collision avoidance
MACAW-MACA improves its performance & renamed their new protocol MACAW.
If A sends message RTS to B, if RTS is reached B it sends message CTS to A.
RTSrequest to send.
CTS clear to send.
Fig: The MACA protocol. (a) A sending an RTS to B. (b) B responding with a CTS to A.
802.3 Ethernet:
- Ethernet refers to the cable.
- Four types of cabling are commonly used
18
- Two more are for control signals in and out. The fifth pair, which is not always used, allows
the computer to power the transceiver electronics
The transceiver cable terminates on an interface board inside the computer. The interface
board contains a controller chip that transmits frames to, and receives frames from, the
transceiver.
- The controller is responsible for assembling the data into the proper frame format, as well as
computing checksums on outgoing frames and verifying them on incoming frames.
- 10 base 2 also called as thin Ethernet.
- Connections are made using industry standards BNC connectors to form T junctions,
rather than using vampire taps.
- With 10 base2, the connection to the cable is just a passive BNC t-junction connector. BNC
connectors are easier to use and more reliable.
- Thin Ethernet is much cheaper and easier to install, but it can run for only 185 meters per
segment, each of which can handle only 30 machines.
- Detecting cable breaks, excessive length, bad taps, or loose connectors can be a major
problem with both media.
For this reason, techniques have been developed to track them down.
A pulse of known shape is injected into the cable. If the pulse hits an obstacle or the end of
the cable, an echo will be generated and sent back.
By carefully timing the interval between sending the pulse and receiving the echo, it is
possible to localize the origin of the echo. This technique is called time domain
reflectometry.
10 base T uses twisted pair cable.
In 10 base T all stations have a cable running to a central hub.
With 10 base T, there is no cable at all just hub.
Adding or removing a station is simpler in this configuration, & cable breaks can be detected
easily.
The advantage is the maximum cable run from the hub is only 100 meters.
base F uses fiber optics.
This is expensive due to the cost of the connectors and terminators.
We use for different topologies they are linear, spine , tree, & segmented.
To allow larger networks, multiple cable can be connected by repeaters.
A repeater is a physical layer device it receives, amplifiers & retransmits signals in both
directions.
19
Fig: Three kinds of Ethernet cabling. (a) 10Base5. (b) 10Base2.(c) 10Base-T.
- A fourth cabling option for Ethernet is 10Base-F, which uses fiber optics. This
alternative is expensive due to the cost of the connectors and terminators, but it has
excellent noise immunity and is the method of choice when running between
buildings or widely-separated hubs.
- Runs of up to km are allowed. It also offers good security since wiretapping fiber is
much more difficult than wiretapping copper wire.
Manchester Encoding:
- To determine the start, end, or middle of each bit without reference to an external clock.
Two such approaches are called Manchester encoding & differential Manchester encoding.
- With Manchester encoding, each bit period is devided into two equal intervals.
- A binary 1 bit is sent by having first high & then low.
- A binary is 0 is just reverse first low & then high.
- Every bit period has a transition in the middle, making it easy for the receave to
synchronize with the sender.
- The disadvantages is it requires twice as much bandwidth as straight binary encoding.
- Differential Manchester encoding is a variation of basic Manchester encoding.
- A 1 bit is indicated by the absence of a transition at the start of the interval.
- A 0 bit is indicated by the presence of a transition at the start of the interval.
- In both cases, the transition in the middle.
Fig: (a) Binary encoding. (b) Manchester encoding. (c)Differential Manchester encoding
20