cnnnNOTES 4
cnnnNOTES 4
FRAMING:
To provide service to the network layer, the data link layer must use the
service provided to it by the physical layer. What the physical layer does is
accept a raw bit stream and attempt to deliver it to the destination. This bit
stream is not guaranteed to be error free. The number of bits received may be
less than, equal to, or more than the number of bits transmitted, and they
may have different values. It is up to the data link layer to detect and, if
necessary, correct errors. 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). When a frame arrives at the destination, the
checksum is recomputed. If the newly computed checksum is different from
the one contained in the frame, the data link layer knows that an error has
occurred and takes steps to deal with it (e.g., discarding the bad frame and
possibly also sending back an error report).We will look at four framing
methods:
1. Character count.
2. Flag bytes with byte stuffing.
3. Starting and ending flags, with bit stuffing.
4. Physical layer coding violations.
Character count 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) For four frames of sizes 5, 5,
8, and 8 characters, respectively.
A character stream. (a) Without errors. (b) With one error
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.
Flag bytes with byte stuffing 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. (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 (b) Four examples of byte sequences
before and after byte stuffing
It may easily happen that the flag byte's bit pattern occurs in the data.
This situation will usually interfere with the framing. One way to solve this
problem is to have the sender's data link layer insert a special escape byte
(ESC) just before each ''accidental'' flag byte in the data. The data link layer
on the receiving end removes the escape byte before the data are given to
the network layer. This technique is called byte stuffing or character stuffing.
Thus, a framing flag byte can be distinguished from one in the data by the
absence or presence of an escape byte before it.
What happens if an escape byte occurs in the middle of the data? The
answer is that, it too is stuffed with an escape byte. Thus, any single escape
byte is part of an escape sequence, whereas a doubled one indicates that a
single escape occurred naturally in the data. Some examples are shown in
Fig. (b). In all cases, the byte sequence delivered after de stuffing is exactly
the same as the original byte sequence.
A major disadvantage of using this framing method is that it is closely
tied to the use of 8-bit characters. Not all character codes use 8-bit
characters. For example UNICODE uses 16-bit characters, so a new technique
had to be developed to allow arbitrary sized characters
Starting and ending flags, with bit stuffing 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 de- stuffs (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.
Fig: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.
Physical layer coding violations method of framing is only applicable to
networks in which the encoding on the physical medium contains some
redundancy. For example, some LANs encode 1 bit of data by using 2 physical
bits. Normally, a 1 bit is a high-low pair and a 0 bit is a low-high pair. The
scheme means that every data bit has a transition in the middle, making it
easy for the receiver to locate the bit boundaries. The combinations high-
high and low-low are not used for data but are used for delimiting frames in
some protocols.
Simplest Protocol
It is very simple. The sender sends a sequence of frames without even thinking
about the receiver. Data are transmitted in one direction only. Both sender &
receiver always ready. Processing time can be ignored. Infinite buffer space is
available. And best of all, the communication channel between the data link
layers never damages or loses frames. This thoroughly unrealistic protocol,
which we will nickname ‘‘Utopia,’’ .The utopia protocol is unrealistic because it
does not handle either flow control or error correction
Stop-and-wait Protocol
It is still very simple. The sender sends one frame and waits for feedback from
the receiver. When the ACK arrives, the sender sends the next frame
It is Stop-and-Wait Protocol because the sender sends one frame, stops until it
receives confirmation from the receiver (okay to go ahead), and then sends
the next frame. We still have unidirectional communication for data frames,
but auxiliary ACK frames (simple tokens of acknowledgment) travel from the
other direction. We add flow control to our previous protocol.
NOISY CHANNELS
Although the Stop-and-Wait Protocol gives us an idea of how to add flow
control to its predecessor, noiseless channels are nonexistent. We can ignore
the error (as we sometimes do), or we need to add error control to our
protocols. We discuss three protocols in this section that use error control.
Sliding Window Protocols:
1 Stop-and-Wait Automatic Repeat
Request
The link utilization is only 1000/20,000, or 5 percent. For this reason, for a link
with a high bandwidth or long delay, the use of Stop-and-Wait ARQ wastes the
capacity of the link.
The sender window at any time divides the possible sequence numbers
into four regions.
The first region, from the far left to the left wall of the window, defines
the sequence numbers belonging to frames that are already acknowledged.
The sender does not worry about these frames and keeps no copies of them.
The second region, colored in Figure (a), defines the range of sequence
numbers belonging to the frames that are sent and have an unknown status.
The sender needs to wait to find out if these frames have been received or
were lost. We call these outstanding frames.
The third range, white in the figure, defines the range of sequence
numbers for frames that can be sent; however, the corresponding data
packets have not yet been received from the network layer.
Finally, the fourth region defines sequence numbers that cannot be used
until the window slides
The send window is an abstract concept defining an imaginary box of
size 2m − 1 with three variables: Sf, Sn, and Ssize. The variable Sf defines
the sequence number of the first (oldest) outstanding frame. The variable Sn
holds the sequence number that will be assigned to the next frame to be sent.
Finally, the variable Ssize defines the size of the window.
Figure (b) shows how a send window can slide one or more slots to the
right when an acknowledgment arrives from the other end. The
acknowledgments in this protocol are cumulative, meaning that more than one
frame can be acknowledged by an ACK frame. In Figure, frames 0, I, and 2 are
acknowledged, so the window has slide to the right three slots. Note that the
value of Sf is 3 because frame 3 is now the first outstanding frame.The send
window can slide one or more slots when a valid acknowledgment
arrives.
Below figure is an example(if ack lost) of a case where the forward channel is
reliable, but the reverse is not. No data frames are lost, but some ACKs are
delayed and one is lost. The example also shows how cumulative
acknowledgments can help if acknowledgments are delayed or lost