CN Unit2 (Ppt)
CN Unit2 (Ppt)
CN Unit2 (Ppt)
2. Framing
3. Error Control
4. Flow Control
1. SERVICES PROVIDED TO THE NETWORK LAYER
• The usual approach is for the data link layer to break the bit
stream up into discrete frames and compute the checksum
for each frame (framing).
1. Character count.
2. Byte stuffing.
3. Bit stuffing.
4. Physical layer coding violations.
FRAMING – CHARACTER COUNT
• The first framing method uses a field in the header to specify
the number of characters in the frame. When the data link layer
at the destination sees the character count, it knows how many
characters follow and hence where the end of the frame is. This
technique is shown in fig a) four frames of sizes 5,5,8,8
characters respectively(without errors) fig.b) with errors
• The trouble with this algorithm is that the count can be garbled
by a transmission error.
• For example, if the character count of 5 in the second frame of
Fig. (b) becomes a 7, the destination will get out of
synchronization and will be unable to locate the start of the next
frame. Even if the checksum is incorrect so the destination knows
that the frame is bad, it still has no way of telling where the next
frame starts.
• Sending a frame back to the source asking for a retransmission
does not help either, since the destination does not know how
many characters to skip over to get to the start of the
retransmission. For this reason, the character count method is
rarely used anymore.
FRAMING – BYTE / CHARACTER STUFFING
• In the past, the starting and ending bytes were different, but in
recent years most protocols have used the same byte, called a
flag byte, as both the starting and ending delimiter, as shown in
below figure as FLAG.
• Each frame starts and ends with a FLAG byte. Thus adjacent
frames are separated by two flag bytes.
• A serious problem occurs with this method is when binary data is
transmitted ,It is possible that FLAG is actually a part of the data.
• Error Detection
• Error Correction
Error Detection
•Checksum
• One extra bit is sent along with the original bits to make
number of 1s either even in case of even parity, or odd in case
of odd parity.
• The sender while creating a frame counts the number of 1s in
it. For example, if even parity is used and number of 1s is
even then one bit with value 0 is added.
• This way number of 1s remains even.If the number of 1s is
odd, to make it even a bit with value 1 is added.
1.30
1.31
1.32
Drawbacks Of Single Parity Checking
•It can only detect single-bit errors which are very rare.
•If two bits are interchanged, then it cannot detect the
errors.
• Before sending the actual bits, the sender adds the remainder at
the end of the actual bits. Actual data bits plus the remainder is
called a code word. The sender transmits data bits as
codewords.
CRC is a redundancy error technique used to determine the error.
Following are the steps used in CRC for error detection:
•In CRC technique, a string of n 0s is appended to the data unit, and this n
number is less than the number of bits in a predetermined number, known
as division which is n+1 bits.
•Secondly, the newly extended data is divided by a divisor using a process is
known as binary division. The remainder generated from this division is
known as CRC remainder.
•Thirdly, the CRC remainder replaces the appended 0s at the end of the
original data. This newly generated unit is sent to the receiver.
•The receiver receives the data followed by the CRC remainder. The receiver
will treat this whole unit as a single unit, and it is divided by the same divisor
that was used to find the CRC remainder.
•If the resultant of this division is zero which means that it has no error, and
the data is accepted.
•If the resultant of this division is not zero which means that the data
consists of an error. Therefore, the data is discarded.
Example1
10.40
Example 2:
Suppose the original data is 11100 and divisor is 1001.
CRC Generator
•A CRC generator uses a modulo-2 division. Firstly, three zeroes are
appended at the end of the data as the length of the divisor is 4 and we
know that the length of the string 0s to be appended is always one less than
the length of the divisor.
•Now, the string becomes 11100000, and the resultant string is divided by
the divisor 1001.
•The remainder generated from the binary division is known as CRC
remainder. The generated value of the CRC remainder is 111.
•CRC remainder replaces the appended string of 0s at the end of the data
unit, and the final string would be 11100111 which is sent across the
network.
CRC Checker
•The functionality of the CRC checker is similar to the CRC generator.
•When the string 11100111 is received at the receiving end, then CRC
checker performs the modulo-2 division.
•A string is divided by the same divisor, i.e., 1001.
•In this case, CRC checker generates the remainder of zero. Therefore, the
data is accepted.
CHECKSUM
• In the sender’s end the segments are added using 1’s complement
arithmetic to get the sum. The sum is complemented to get the
checksum.
• At the receiver’s end, all received segments are added using 1’s
complement arithmetic to get the sum. The sum is complemented.
At Sender At Receiver
The Sender follows the given steps: The Receiver follows the given steps:
• The block unit is divided into k secti • The block unit is divided into k secti
ons, and each of n bits. ons and each of n bits.
• All the k sections are added togethe • All the k sections are added togethe
r by using one's complement to get th r by using one's complement algorith
e sum. m to get the sum.
• The sum is complemented and it be • The sum is complemented.
comes the checksum field. • If the result of the sum is zero, then
• The original data and checksum fiel the data is accepted otherwise the da
d are sent across the network. ta is discarded.
Example
•Suppose that the sender wants to send 4 frames each of 8 bits,
where the frames are 11001100, 10101010, 11110000 and
11000011.
•The sender adds the bits using 1s complement arithmetic. While
adding two numbers using 1s complement arithmetic, if there is a
carry over, it is added to the sum.
•After adding all the 4 frames, the sender complements the sum to
get the checksum, 11010011, and sends it along with the data
frames.
•The receiver performs 1s complement arithmetic sum of all the
frames including the checksum. The result is complemented and
found to be 0. Hence, the receiver assumes that no error has
occurred.
HAMMING CODE ERROR DETECTION & CORRECTION
•Parity bit P2 covers all data bits in positions whose binary representation
has 1 in the second least significant position(010, 011, 110, 111, etc.). Thus
P2 checks the bit in locations 2, 3, 6, 7, etc.
•Parity bit P3 covers all data bits in positions whose binary representation
has 1 in the third least significant position(100, 101, 110, 111, etc.). Thus P3
checks the bit in locations 4, 5, 6, 7, etc.
•Each parity bit checks the corresponding bit locations and assign the bit
value as 1 or 0, so as to make the number of 1s as even for even parity and
odd for odd parity.
Example problem 1
Encode a binary word 11001 into the even parity hamming code.
Given, number of data bits, n =5.
To find the number of redundant bits,
Let us try P=4.
•For P2: Bit locations 3, 6, 7 have two 1s. To have even parity, P2 must be 0.
•For P3: Bit locations 5, 6, 7 have one 1s. To have even parity, P3 must be 1.
•For P4: Bit locations 8, 9 have one 1s. To have even parity, P2 must be 1.
•After checking all the parity bits, a binary word is formed taking the result bits
for P1 as LSB. So formed binary word gives the bit location, where there is an
error.
•If the formed binary word has 0 bits, then there is no error in the message.
Example problem 2
Let us assume the even parity hamming code from the above
example (111001101) is transmitted and the received code is
(110001101). Now from the received code, let us detect and
correct the error.
To detect the error, let us construct the bit location table.
Checking the parity bits
•For P1 : Check the locations 1, 3, 5, 7, 9. There is three 1s in this
group, which is wrong for even parity. Hence the bit value for P1 is
1.
•For P2 : Check the locations 2, 3, 6, 7. There is one 1 in this group,
which is wrong for even parity. Hence the bit value for P2 is 1.
•For P3 : Check the locations 3, 5, 6, 7. There is one 1 in this group,
which is wrong for even parity. Hence the bit value for P3 is 1.
•For P4 : Check the locations 8, 9. There are two 1s in this group,
which is correct for even parity. Hence the bit value for P4 is 0.
•The resultant binary word is 0111. It corresponds to the bit
location 7 in the above table. The error is detected in the data bit
D4. The error is 0 and it should be changed to 1. Thus the corrected
code is 111001101.
ELEMENTARY DATA LINK LAYER PROTOCOLS
•Protocols in the data link layer are designed so that this layer
can perform its basic functions: framing, error control and flow
control.
•Framing is the process of dividing bit - streams from physical
layer into data frames whose size ranges from a few hundred to
a few thousand bytes.
•Error control mechanisms deals with transmission errors and
retransmission of corrupted and lost frames.
•Flow control regulates speed of delivery and so that a fast
sender does not drown a slow receiver.
Types of Data Link Protocols
Data link protocols can be broadly divided into two categories,
depending on whether the transmission channel is noiseless or
noisy.
Simplest Protocol
• The Simplex protocol is hypothetical protocol designed for
unidirectional data transmission(i.e from sender to receiver)
over an ideal channel, i.e. a channel through which
transmission can never go wrong.
• The sender, after having sent a frame, must wait for the
acknowledge frame from the receiver before sending another
frame.
• This protocol is known as stop and wait protocol
Design of Stop and wait Protocol
Flow control for stop and wait
Drawbacks:
1.Only one frame can be in transmission at a time.
2.This leads to inefficiency if propagation delay is much longer than
transmission delay.
Stop & Wait ARQ(Automatic Repeat Request)
• Stop & Wait ARQ is a sliding window protocol for flow control
and it overcomes the limitations of Stop & Wait, we can say that
it is the improved or modified version of Stop & Wait protocol.
• Working of Stop & Wait ARQ is almost like Stop & Wait
protocol, the only difference is that it includes some additional
components, which are:
Data packet sent by the sender can Data packet sent by the sender may
never get corrupt. get corrupt.
A negative acknowledgement is sent
There is no concept of negative
by the receiver if the data packet is
acknowledgements.
found to be corrupt.
• We can consider the data link layer as two sub layers. The upper
sub layer is responsible for data link control, and the lower sub
layer is responsible for resolving access to the shared media
MULTIPLE ACCESS PROTOCOLS
• The upper sub layer that is responsible for flow and error
control is called the logical link control (LLC) layer; the lower
sub layer that is mostly responsible for multiple access
resolution is called the media access control (MAC) layer.
1. Pure ALOHA
•In slotted ALOHA we divide the time into slots of Tfr s and
force the station to send only at the beginning of the time slot.
Figure 3 shows an example of frame collisions in slotted
ALOHA
Collisions in slotted ALOHA
• Because a station is allowed to send only at the beginning of
the synchronized time slot, if a station misses this moment, it
must wait until the beginning of the next time slot.
• 1-persistent method
• non-persistent method
• p-persistent method
• 1-Persistent: In this method, after the station finds the line
idle, it sends its frame immediately (with probability 1).
This method has the highest chance of collision because
two or more stations may find the line idle and send their
frames immediately.
•The station then transmits a jam signal onto the link and waits for
random time interval before it resends the frame. After some
random time, it again attempts to transfer the data and repeats
above process.
1.32
Collision-Free Protocols
• Bit-map Protocol
• Binary Countdown
• The Adaptive Tree Walk Protocol
1. Bit-map Protocol:
• The IEEE has subdivided the data link layer into two sub
layers: logical link control (LLC) and media access
control(MAC).
Figure 13.1 IEEE standard for LANs
IEEE has also created several physical layer standards for
different LAN protocols
STANDARD ETHERNET
Frame Format
• The Ethernet frame contains seven fields: preamble, SFD,
DA, SA, length or type of protocol data unit (PDU), upper-
layer data, and the CRC.
- Uses of bridges
- Learning bridges
- Spanning Tree bridges
-Repeaters, hubs, bridges, switches, routers,
and gateways
Uses of bridges
• A bridge is a network device that connects multiple LANs (local
area networks) together to form a larger LAN.
All switches will find the best way to elect a root bridge and
the redundant links will be blocked
If switch C choose the path through switch B then the cost will
be (4+4=8) but if it chooses the directly connected path to
switch A then the cost will be 4 therefore both switch B and
switch C will choose the ports connected to switch A as their
root ports.
Now as the link between switch B and switch C as the same cost
to the root bridge therefore the switch with lowest bridge I’d will
be in forwarding mode therefore switch C port will be in
forwarding mode and switch B port will be in block mode.
Repeaters, Hubs, Bridges, Switches,
Routers, and Gateways
1. Repeater
• A repeater operates at the physical layer. Its job is to
regenerate the signal over the same network before the signal
becomes too weak or corrupted.
• An important point to be noted about repeaters is that they do
not amplify the signal. When the signal becomes weak, they
copy the signal bit by bit and regenerate it at the original
strength. It is a 2 port device.
2. Hub
• A hub is basically a multiport repeater. A hub connects
multiple wires coming from different branches, for example,
the connector in star topology which connects different
stations.
• Hubs cannot filter data, so data packets are sent to all
connected devices.
3. Bridge
• A bridge operates at data link layer. A bridge is a repeater, with
add on the functionality of filtering content by reading the MAC
addresses of source and destination.
• It is also used for interconnecting two LANs working on the
same protocol. It has a single input and single output port, thus
making it a 2 port device.
4. Switch
• A switch is a device that connects other devices together. Multiple
data cables are plugged into a switch to enable communication
between different networked devices. A switch is a data link layer
device.
• The switch can perform error checking before forwarding data, that
makes it very efficient as it does not forward packets that have
errors and forward good packets selectively to correct port only.
5.Routers A router is a device like a switch that routes data
packets based on their IP addresses. Router is mainly a Network
Layer device. Routers normally connect LANs and WANs
together and have a dynamically updating routing table based on
which they make decisions on routing the data packets.
A gateway is a hardware device that acts as a "gate" between
two networks. It may be a router, firewall, server, or
other device that enables traffic to flow in and out of the
network.