1-Introduction-To-Computer-Networking 3 UNIT
1-Introduction-To-Computer-Networking 3 UNIT
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. 3-4(a) for four frames of
sizes 5, 5, 8, and 8 characters, respectively.
A character stream. (a) Without errors. (b) With one
error.
he 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. 3-4(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.
The second framing method gets around the problem of resynchronization after
an error by having each frame start and end with special bytes. 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 Fig. 3-5(a) as FLAG. In this way, if the receiver ever loses
synchronization, it can just search for the flag byte to find the end of the current
frame. Two consecutive flag bytes indicate the end of one frame and start of the
next one.
a) A frame delimited by flag bytes
The new technique allows data frames to contain an arbitrary number of
bits and allows character codes with an arbitrary number of bits per
character. It works like this. Each frame begins and ends with a special
bit pattern, 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 bit stuffing is analogous to
byte stuffing, in which an escape byte is stuffed into the outgoing
character stream before a flag byte in the data.
When the receiver sees five consecutive incoming 1 bits, followed by a 0
bit, it automatically destuffs (i.e., deletes) the 0 bit. Just as byte stuffing is
completely transparent to the network layer in both computers, so is bit
stuffing. If the user data contain the flag pattern, 01111110, this flag is
transmitted as 011111010 but stored in the receiver's memory as
01111110. Figure 3-6 gives an example of bit stuffing.
Figure 3-6. Bit stuffing. (a) The original data. (b)
The data as they appear on the line. (c) The data as
they are stored in the receiver's memory after
destuffing.
With bit stuffing, the boundary between two frames can be
unambiguously recognized by the flag pattern. Thus, if the receiver
loses track of where it is, all it has to do is scan the input for flag
sequences, since they can only occur at frame boundaries and never
within the data.
ERRORDETECTION
Why we need it ?
To avoid retransmissionof whole packet or
message
What to do if error detected ?
Discard, and request a new copy of the frame:
explicitly or implicitly
Try to correcterror, if possible
2
Data can be corrupted during
transmission.
Some applications require that errors be
detected and corrected
REDUNDANCY
To detect or correct errors, we need to send extra
(redundant) bits with data.
SENDERSITE
1. The message is divided into 16-bit words.
2. The value of the checksum word is set to O.
3. All words including the checksum are
added using one's complement addition.
4. The sum is complemented and becomes
the checksum.
5. The checksum is sent with the data
3
RECEIVERSITE
1. The message (including checksum) is
divided into 16-bit words.
2. All words are added using one's
complement addition.
3. The sum is complemented and becomes
the new checksum.
4. If the value of checksum is 0, the message
is accepted; otherwise, it is rejected.
4