Escolar Documentos
Profissional Documentos
Cultura Documentos
UNIT-III
Framing:
Framing in the data link layer 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.
When a message is carried in one very large frame, even a single bit error would require the
retransmission of the whole message. When a message is divided into smaller frames, a
single bit error affects only that small frame.
1. Fixed-size framing
2. Variable-size framing
Fixed-size framing , the frames are of fixed size, specifying the start of frame and end of the
frame is not necessary.
Variable-size framing, the size of frames changes. Here it is necessary to specify end of
frame and the beginning of next frame. We are used two approaches for this framing.
In character oriented framing, only text was exchanged by the data link layers. The flag
could be selected to be any character not used for text communication. Any pattern used
for the flag could also be part of the information. If the receiver encounters this pattern in
the middle of the data, thinks it has reached the end of the frame. To fix this problem, a
byte stufing strategy was added to character oriented framing. In byte stuffing a special
byte is added to the data secton of the frame when there is a character with the same
pattern as the flag.
B.SRIKANTH,ASST.PROF Page 1
Computer Networks III B.TECH I SEM PACE ITS
Byte stuffing is the process of adding 1 extra byte whenever there is a flag or escape
character in the text.
The new technique allows data frames to contain an arbitrary number of bits. Each frame
begins and ends with a special bit patern, 01111110 (in fact, a flag byte). Whenever the
sender's data link layer encounters five consecutive 1s in the data, it automatically stuffs a 0
bit into the outgoing bit stream. This is known as bit stufing. When the receiver sees five
consecutive incoming 1 bits, followed by a 0 bit, it automatically de-stuffs (i.e., deletes) the
0 bit.
B.SRIKANTH,ASST.PROF Page 2
Computer Networks III B.TECH I SEM PACE ITS
Error Control:
Error control is both error detection and error correction. It allows the receiver to inform
the sender of any frames lost or damaged in transmission and coordinates the
retransmission of those frames by the sender.
Any time an error is detected in an exchange, specified frames are retransmitted. This
process is called automatic repeat request.
Flow Control:
It is the responsibility of the data link layer is what to do with a sender that
systematically wants to transmit frames faster than the receiver can accept them. This
situation can easily occur when the sender is running on a fast computer and the receiver is
running on a slow machine. at a certain point the receiver will simply be unable to handle
the frames as they arrive and will start to lose some.
The protocol has a built-in mechanism that limits the rate at which senders may transmit
data, without using feedback from the receiver
The receiver sends back information to the sender giving it permission to send more data or
at least telling the sender how the receiver is doing.
Networks must be able to transfer data from one device to another with acceptable
accuracy. Any time data are transmitted from one node to the next, they can be corrupted
in passage. Many factors can alter one or more bits of a message.
B.SRIKANTH,ASST.PROF Page 3
Computer Networks III B.TECH I SEM PACE ITS
Types of Errors:
Whenever bits flow from one point to another, they are unpredictable changes because of
interference. This interference can change the shape of the signal.
Burst error:
A burst error means that 2 or more bits in the data unit have changed.
The duration of noise is normally longer than the duration of 1 bit, which means that when
noise affects data, it affects a set of bits.
Redundancy:
The central concept in detecting or correcting errors is redundancy. For detect or correct
errors, we need to send some extra bits with our data. These redundant bits are added by
the sender and removed by the receiver.
B.SRIKANTH,ASST.PROF Page 4
Computer Networks III B.TECH I SEM PACE ITS
Coding:
Modular arithmetic:
Block Coding:
B.SRIKANTH,ASST.PROF Page 5
Computer Networks III B.TECH I SEM PACE ITS
If the following two conditions are met, the receiver can detect a change in the original code
word.
B.SRIKANTH,ASST.PROF Page 6
Computer Networks III B.TECH I SEM PACE ITS
Sender creates codewords out of datawords by using a generator that applies the rules and
procedures of encoding. Each encode sent to the receiver may change during transmission.
If the received codeword is the same as one of the valid codewords, the word is accepted.
The corresponding dataword is extracted for use. If the received codeword is not valid, it is
discarded.
Assume the sender encodes the dataword 01 as 011 and sends it to the receiver. Consider
the following cases.
1. The receiver receives 011. It is valid codeword. The receiver extracts the dataword
01 from it.
2. Te codeword is corrupted during transmission and 111 is received. This is not a valid
codeword and is discarded.
3. The codeword is corrupted during transmission and 000 is received. This is a valid
codeword. The receiver incorrectly extracts the dataword 00. Two corrupted bits
have made the error undectable.
4. An error detecting code can detect only the types of errors for which it is designed,
other types of errors may remain undetected.
B.SRIKANTH,ASST.PROF Page 7
Computer Networks III B.TECH I SEM PACE ITS
Error Correction:
The idea of error correction is same as error detection but the checker function are much
more complex.
Here we are adding more redundant bits to see, if the receiver can correct an error without
knowing what was actually sent. We add 3 redundant bits for a 2 bit dataword to make 5 bit
codewords.
Assume the dataword is 01. The sender consults to create a codeword 01011. The codeword
is corrupted during transmission, and 01001 is received. First the receiver finds that the
received codeword is in table or not. It checks which one is nearest to the codewords in the
table.
Hamming Distance:
d(01, 00) = ?
d(11, 00) = ?
B.SRIKANTH,ASST.PROF Page 8
Computer Networks III B.TECH I SEM PACE ITS
d(010, 100) = ?
d(0011, 1000) = ?
How many 8-bit words are n bits away from 10000111?
The minimum Hamming distance is the smallest Hamming distance between all possible
pairs in a set of words.
The hamming distance between the received codeword and the sent codeword is the
number of bits that are corrupted during transmission.
Using the minimum hamming distance in a code, we detect up to s errors. If s errors occur
during transmission, the hamming distance between the sent codeword and received
codeword is s. If our code is to detect up to s errors, the minimum distance between the
valid codes must be s+1.
Error correction is more complex than error detection. When a received codeword is not a
valid codeword, the receiver needs to decide which valid codeword was actually sent.
To guarantee correction of up to t errors in all cases, the minimum distance in a block code
must be dmin = 2t+1.
B.SRIKANTH,ASST.PROF Page 9
Computer Networks III B.TECH I SEM PACE ITS
Linear block code is a code in which the exclusive OR of two valid codewords creates
another valid codeword.
In this code, k-bit dataword is changed to an n-bit codeword where n=k+1. The extra bit
called parity bit, is selected to make the total number of 1’s in the codeword even.
Parity Check:
Suppose the sender wants to send the word world. In ASCII the five characters are coded
(with even parity) as
B.SRIKANTH,ASST.PROF Page 10
Computer Networks III B.TECH I SEM PACE ITS
Parity-Check: Encoding/Decoding
The encoder uses a generator that takes a copy of a 4-bit dataword (a0, a1, a2, a3) and
generates a parity bit r0. The dataword bits and the parity bit create the 5-bit codeword. The
parity bit that is added makes the number of 1s in the codeword even.
r0 = a3+a2+a1+a0 ( modulo-2)
if the number of 1s is even, the result is 0. If the number of 1 is odd, the result is 1.
The sender sends the codeword which may be corrupted during transmission. The receiver
receives a 5-bit word. The checker at the receiver does the same thing as the generator in
the sender with one exception. The result is called syndrome, is just 1 bit. The syndrome is 0
when the number of 1s in the received codeword is even, otherwise it is 1.
S0 = b3+b2+b1+b0 ( modulo-2)
2D Parity Check:
The dataword to be sent give 7-bit bytes are put in separate rows. For each row and each
column, 1 parity check bit is calculated.
The shole table is then sent to receiver, which finds the syndrome for each row and each
column.
B.SRIKANTH,ASST.PROF Page 11
Computer Networks III B.TECH I SEM PACE ITS
B.SRIKANTH,ASST.PROF Page 12
Computer Networks III B.TECH I SEM PACE ITS
Cyclic codes:
Cyclic codes are special linear block codes with one extra property. In a cyclic code, if a
codeword is cyclically shifed the result is another codeword.
For example, if 1011000 is a codeword and we cyclically left shift, then 0110001 is also a
codeword. In this case, if we call the bits in the first word a0 to a6, and the bits in the second
word b0 to b6.
In the encoder, the data work has k bits(4), the codeword has n bits (7). The size of the
dataword is augmented by using n-k. we can add 0’s to the right hand side of the word.
The n-bit result is fed into the generator. The generator uses a divisor of size n-k+1. The
generator divides the augmented dataword by the divisor.
The quotient of the division is discarded. The remainder (r2,r1,r0) is appended to the
dataword to create the codeword.
B.SRIKANTH,ASST.PROF Page 13
Computer Networks III B.TECH I SEM PACE ITS
CRC Encoder/Decoder
CRC Generator
Checking CRC
B.SRIKANTH,ASST.PROF Page 14
Computer Networks III B.TECH I SEM PACE ITS
Polynomials:
A pattern of 0’s and 1’s can be represented as a polynomial with coeficients of 0 and 1. The
power of each term shows the positions of the bit, the coefficient shows the value of bit.
The main advantage is, a 7 bit patern can be replaced by three terms.
Degree of a polynomials:
6
Eg: x + x + 1, degree is 6.
Adding and subtracting polynomials is done by combining terms and deleting pairs of
identical terms.
5 4 2 6 4 2
Polynomials are x +x +x and x +x +x
6 5
Additional / subtraction of the polynomials are x +x .
4 3 4+3 7
x +x =x =x
For dividing, just subtract the power of the second term from the power of first.
4 3
x /x is x.
B.SRIKANTH,ASST.PROF Page 15
Computer Networks III B.TECH I SEM PACE ITS
Decoder:
3 6 3 2 3
x + x + 1 ) x + x + x + x (x +x
6 4 3
x +x +x
4 2
x +x +x
4 2
x +x +x
0 0 0
Strength of CRC
B.SRIKANTH,ASST.PROF Page 16
Computer Networks III B.TECH I SEM PACE ITS
Received message is
Receiver does not detect any error when E(x) is divisible by G(x), which means
either:
E(x) 0 No error
E(x) 0 Undetectable error
If G(x) contains at least two terms, then all single-bit errors can be detected
t
If G(x) cannot divide x + 1 (0 t < n), then all isolated double errors can be detected
If G(x) contains a factor of (x+1), all odd-numbered errors can be detected
Standard Polynomials
Checksum:
Checksum is an error detection method. The checksum is used in the internet by several
protocols. Like linear and cyclic codes, the checksum is based on the concept of redundancy.
For example, data is a list of five 4-bit numbers that we want to send a destination. In
addition to sending these numbers, we send the sum of numbers.
B.SRIKANTH,ASST.PROF Page 17
Computer Networks III B.TECH I SEM PACE ITS
At the receiver side, receiver adds 5 numbers and compares the result with the sum. If the
two are same, the receiver assumes no error.
In the job of receiver easer if we send the negative of the sum, called checksum.
Receiver adds 5 numbers and it checks the result is 0, it assumes no error, otherwise, there
is an error.
One’s complement:
In the above example, we add only 4-bit data, except checksum. If the data is more than 4-
bit, we use this one’s complement method.
n
In this we can represent unsigned numbers between 0 to 2 -1.
For example,
7 7
11 11
12 12
0 7,11,12,0,6,9 0
6 6
0 9
Sum ----36 Sum ----45
Wrapped sum –6 Wrapped sum 15
Checksum -----9 Checksum -----0
B.SRIKANTH,ASST.PROF Page 18
Computer Networks III B.TECH I SEM PACE ITS
At sender site:
sum is 36
we remove highest degree bits remaining of 4-bits and add that bits to 4-bit data.
0100
10
0110 ----- 6
At receiver site:
Sum is 45
we remove highest degree bits remaining of 4-bits and add that bits to 4-bit data.
1101
10
1111 ----- 15
Internet checksum:
B.SRIKANTH,ASST.PROF Page 19
Computer Networks III B.TECH I SEM PACE ITS
For example, the checksum for a text of 8 characters (“Forouzan”). The text needs to be
divided into 2-byte(16-bit) words. We use ASCII to change each byte t a 2-digit hexa decimal.
Note:
a b c d e f g h i j k l m
Decimal 97 98 99 100 101 102 103 104 105 106 107 108 109
Hexa 61 62 63 64 65 66 67 68 69 6A 6B 6C 6D
n o p q r s t u v w x y Z
Decimal 110 111 112 113 114 115 116 117 118 119 120 121 122
Hexa 6E 6F 70 71 72 73 74 75 76 77 78 79 7A
Similarly
A B C D E F
Decimal 65 66 67 68 69 70
Hexa 41 42 43 44 45 46
sender site receiver site
4 6 6 F (Fo) 4 6 6 F (Fo)
7 2 6 F (ro) 7 2 6 F (ro)
7 5 7 A (uz) 7 5 7 A (uz)
6 1 6 E (an) 6 1 6 E (an)
0 0 0 0 (intial checksum) 7 0 3 8 (intial checksum)
1 0 1 3 1 0 1 3
8 F C 6 F F F E
1 1
8 F C 7 Sum F F F F
15'
Comp 7 0 3 8 (Checksum) 0 0 0 0 (checksum new)
B.SRIKANTH,ASST.PROF Page 20
Computer Networks III B.TECH I SEM PACE ITS
Performance:
The traditional checksum uses a small number of bits (16 bits) to detect errors in a message
of any size. However, it is not as strong as the CRC in error checking capability.
For example, if the value of one word is incremented and the value of another word is
decremented by the same amount, the two errors can not be detected. Because the sum
and checksum remain the same.
The physical layer, data link layer, and network layer are independent processes that
communicate by passing messages back and forth.
In many cases, the physical and data link layer processes will be running on a
processor inside a special network I/O chip and the network layer code will be
running on the main CPU.
the physical and data link layers as procedures called by the network layer process.
Another key assumption is that machine A wants to send a long stream of data to
machine B, using a reliable, connection-oriented service.
We also assume that machines do not crash. i.e these protocols deal with
communication errors, but not hardware problems .
When the data link layer accepts a packet, it encapsulates the packet in a frame by adding a
data link header and trailer to it.
Thus, a frame consists of control information (in the header), and a checksum (in the
trailer). The frame is then transmited to the data link layer on the other machine. The
transmiting hardware computes and appends the checksum
When a frame arrives at the receiver, the hardware computes the checksum. If the
checksum is incorrect then the data link layer sent, event = cksum_err.
If the frame arrived undamaged, the data link layer is also informed
event = frame_arrival
Then the receiving data link layer checks the control information in the header, and
if it is right, passes the packet portion to the network layer.
There is a good reason why the network layer must never be given any part of the
frame header: to keep the network and data link protocols completely separate.
B.SRIKANTH,ASST.PROF Page 21
Computer Networks III B.TECH I SEM PACE ITS
boolean, A boolean is an enumerated type and can take on the values true and false
seq_nr, A seq_nr is a small integer used to number the frames. These sequence
numbers run from 0 up to and including MAX_SEQ
packet, A packet is the unit of information exchanged between the network layer
and the data link layer on the same machine
frame_kind, this define the type if the frame that is control or information frame.
frame.
1. kind, The kind field tells whether there are any data in the frame
2. seq, The seq field is used for sequence numbers
3. ack, The ack field is used for acknowledgements
4. info, The info field of a data frame contains a single packet. A more realistic
implementation would use a variable-length info field
5. The first three of which contain control information and the last of which may
contain actual data to be transferred. These control fields are collectively
called the frame header.
6. Note: it is important that the relationship between a packet and a frame.
7. The network layer builds a packet by taking a message from the transport
layer and adding the network layer header to it. This packet is passed to the
data link layer for inclusion in the info field of an outgoing frame.
8. When the frame arrives at the destination, the data link layer extracts the
packet from the frame and passes the packet to the network layer.
B.SRIKANTH,ASST.PROF Page 22
Computer Networks III B.TECH I SEM PACE ITS
a) A sender
b) A receiver.
The sender runs in the data link layer of the source machine, and the receiver runs in the
data link layer of the destination machine.
B.SRIKANTH,ASST.PROF Page 23
Computer Networks III B.TECH I SEM PACE ITS
NOTE: Only the info field of the frame is used by this protocol, because there are no errors
or flow control restrictions here.
Now we will drop the most unrealistic restriction used in Unrestricted Simplex Protocol, the
ability of the receiving network layer to process incoming data infinitely.
The main problem we have to deal with here is how to prevent the sender from flooding the
receiver with data faster than the later is able to process them. In essence, if the receiver
requires a time t to execute from_physical_layer plus to_network_layer, the sender must
transmit at an average rate less than one frame per time t. Moreover, if we assume that no
automatic buffering and queuing are done within the receiver's hardware, the sender must
never transmit a new frame until the old one has been fetched by from_physical_layer, lest
the new one overwrite the old one. A solution to this problem is to have the receiver
provide feedback to the sender. After having passed a packet to its network layer, the
receiver sends a litle dummy frame back to the sender which, in efect, gives the sender
permission to transmit the next frame. Protocols in which the sender sends one frame and
then waits for an acknowledgement before proceeding are called stop-and-wait
Advantages:-
B.SRIKANTH,ASST.PROF Page 24