CN Unit Ii
CN Unit Ii
2. Framing
3. Error Control
4. Flow Control
In Unacknowledged connectionless service, the source machine send independent frames to the destination
machine without having the destination machine acknowledge them. No logical connection is established
before communication or released after communication. If a frame is lost due to noise, no attempt is made to
detect the loss or recover from it in the data link layer. This class of service is appropriate when the error rate
is very low, so recovery is left to higher layers. This type of communication is best suited for voice
communication, where late data is worse than bad data.
Acknowledged connectionless services offer a better reliability service than Unacknowledged connectionless
service. When this service is offered, even though there is no logical connection, an acknowledgement frame
from the receiver to sender makes the sender to know whether the frame is received at sender or not. This
makes the sender to retransmit the missed frames. This service is useful over unreliable channels, such as
wireless systems eg. WiFi.
B.Arun Kumar, Asst.Prof Computer Networks UNIT-II
The most sophisticated services the data link layer can provide to the network layer is connection-oriented
services. With this service, the source and destination machines establish a connection before any data are
transferred. Each frame sent over the connection is numbered, and the data link layer guarantees that each
frame sent is indeed received.
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 to accept a raw bit stream and attempt to deliver
it to the destination. This bit stream is not guaranteed tobe 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 linklayer to detect and, if necessary, correct errors.
The usual approach is for the data linklayer to break the bit stream up into discrete frames and
compute the checksum for each frame. 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).
Breaking the bit stream up into frames is more difficult than it at first appears. Oneway to achieve
this framing is to insert time gaps between frames, much like the spaces between words in ordinary text.
However, networks rarely make any guarantees about timing, so it is possible these gaps might be
squeezed out or other gaps might be inserted during transmission.
Since it is too risky to count on timing to mark the start and end of each frame, other methods
have been devised.
The first framing method, Character Count 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
below figure with four frames of sizes 5, 5, 8, and 8 characters respectively.
B.Arun Kumar, Asst.Prof Computer Networks UNIT-II
Figure. 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.
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.(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.
Figure . (a) A frame delimited by flag bytes. (b) Four examples of byte sequences before and after
byte stuffing.
B.Arun Kumar, Asst.Prof Computer Networks UNIT-II
A serious problem occurs with this method when binary data, such as object programs or
floating-point numbers, are being transmitted. 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.
Of course, the next question is: 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 destuffing is the
same as the original bytesequence.
A major disadvantage of using byte stuffing 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, as networks developed, the disadvantages of embedding the character code length in
the framing mechanism became increasingly clear, so a new technique had to be developed to allow
arbitrary sized characters.
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 streambefore 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 inthe receiver's memory as 01111110.
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 should do is scan the input for flag
sequences, since they can only occur at frame boundaries and never within the data. The last method
B.Arun Kumar, Asst.Prof Computer Networks UNIT-II
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.
As a final note on framing, many data link protocols use combination of a character
count with one of the other methods for extra safety. When a frame arrives,the count field is used to
locate the end of the frame. Only if the appropriate delimiter is present at that position and the
checksum is correct is the frame accepted as valid. Otherwise, the input stream is scanned for the next
delimiter.
Flow Control
The data link layer regulates flow control so that a fast sender does not drown a slow receiver. When the
sender sends frames at very high speeds, a slow receiver may not be able to handle it. There will be
frame losses even if the transmission is error-free. The two commonapproaches for flow control are
Error Control
The data link layer ensures error free link for data transmission. The issues it caters to withrespect to
error control are
The receiver simply counts the number of 1s in a frame. If the count of 1s is even and even parity is
used, the frame is considered to be not-corrupted and is accepted. If the count of 1s is odd and odd
parity is used, the frame is still not corrupted.
If a single bit flips in transit, the receiver can detect it by counting the number of 1s. But when more than
one bits are erro neous, then it is very hard for the receiver to detect the error.
Solution-
The generator polynomial G(x) = x4 + x + 1 is encoded as 10011.
Clearly, the generator polynomial consists of 5 bits.
So, a string of 4 zeroes is appended to the bit stream to be transmitted.
The resulting bit stream is 11010110110000.
Now, the binary division is performed as-
B.Arun Kumar, Asst.Prof Computer Networks UNIT-II
Error Detecting Codes (Implemented either at Data link or Transport Layer) Whenever a message
is transmitted, it may get scrambled by noise or data may get corrupted. To avoid this, we use error-
detecting codes which are additional data added to a given digital message to help us detect if any
error has occurred during transmission of the message.
Basic approach used for error detection is the use of redundancy bits, where additional bits areadded 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
1. Simple Parity check
Blocks of data from the source are subjected to a check bit or parity bit generator form, wherea parity of
:
1 is added to the block if it contains odd number of 1’s, and
0 is added if it contains even number of 1’s
This scheme makes the total number of 1’s even, that is why it is called even parity checking.
1. Checksum
In checksum error detection scheme, the data is divided into k segments each of m bits.
In the sender’s end the segments are added using 1’s complement arithmetic to get thesum.
The sum is complemented to get the checksum.
The checksum segment is sent along with the data segments.
At the receiver’s end, all received segments are added using 1’s complement arithmetic to get the
sum. The sum is complemented.
If the result is zero, the received data is accepted; otherwise discarded.
2. Cyclic redundancy check (CRC)
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 appendedto 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.
B.Arun Kumar, Asst.Prof Computer Networks UNIT-II
Example :
Error Correction
Hamming Code
Hamming code is a block code that is capable of detecting up to two simultaneous bit errors and
correcting single-bit errors. It was developed by R.W. Hamming for error correction.
In this coding method, the source encodes the message by inserting redundant bits within the message.
These redundant bits are extra bits that are generated and inserted at specific positions in the message itself
to enable error detection and correction. When the destination receives this message, it performs
recalculations to detect errors and find the bit position that has error.
Using the same formula as in encoding, the number of redundant bits are ascertained. 2r ≥ m + r
+ 1 where m is the number of data bits and r is the number of redundant bits.
Ex.1001101 2r>=m+r+1
2r>=7+r+1
r=1,2,3,4….
21>=7+1+1 false
22>=7+2+1 false
23>=7+3+1 false
r1,r2, r3…..
r2=21(2nd Position)
r3=22(4th Position)
B.Arun Kumar, Asst.Prof Computer Networks UNIT-II
r4=23(8thPosition)
B.Arun Kumar, Asst.Prof Computer Networks UNIT-II
IEEE Standards
In 1985, the Computer Society of the IEEE started a project, called Project 802, to set standards to enable
intercommunication among equipment from a variety of manufacturers. The IEEE has subdivided the
data link layer into two sublayers: logical link control (LLC) and media access control (MAC). IEEE has
also created several physical layer standards for different LAN protocols.
functions. One set contains the end user portion of the HDLC frame – the logical address, control
information and data. These functions are handled by the IEEE 802.2 logical link control (LLC)
Protocol.
Protocol Data Unit (PDU)
Framing LLC defines a protocol data unit (PDU) that is somewhat similar to that of HDLC. The header
contains a control field like the one in HDLC; this field is used for flow and error control. The two other
header fields define the upper-layer protocol at the source and destination that uses LLC. These fields
are called the destination service access point (DSAP)and the source service access point (SSAP).
Figure 2.47 HDLC frame compared with LLC and MAC frames
MAC Sublayer
In Standard Ethernet, the MAC sublayer governs the operation of the access method. It alsoframes
data received from the upper layer and passes them to the physical layer.
The Ethernet frame contains seven fields: preamble, SFD, DA, SA, length or type of protocol data unit
(PDU), upper-layer data, and the CRC. Ethernet does not provide any mechanism for acknowledging
received frames, making it what is known as an unreliable medium. Acknowledgments must be
implemented at the higher layers.
B.Arun Kumar, Asst.Prof Computer Networks UNIT-II
All standard implementations use digital signaling (baseband) at 10 Mbps. At the sender, data are
converted to a digital signal using the Manchester scheme; at the receiver, the received signal is
interpreted as Manchester and decoded into data. Manchester encoding is self synchronous, providing a
transition at each bit interval. Figure 2.60 shows the encoding scheme for Standard Ethernet.
The first implementation is called 10Base5, thick Ethernet, or Thicknet. The nickname derives from the
size of the cable, which is roughly the size of a garden hose and too stiff to bend with your hands.
10Base5 was the first Ethernet specification to use a bus topology with an external transceiver
(transmitter/receiver) connected via a tap to a thick coaxial cable.
The second implementation is called 10Base2, thin Ethernet, or Cheapernet. 10Base2 also uses a bus
topology, but the cable is much thinner and more flexible. The cable can be bent to pass very close to the
stations. In this case, the transceiver is normally part of the network interface card (NIC), which is
installed inside the station.
B.Arun Kumar, Asst.Prof Computer Networks UNIT-II
The third implementation is called 10Base-T or twisted-pair Ethernet. 10Base-T uses a physical star
topology. The stations are connected to a hub via two pairs of twisted cable.
Note that two pairs of twisted cable create two paths between the station and the hub.
Any collision here happens in the hub. Compared to 10Base5 or 10Base2, we can see that the hub
actually replaces the coaxial cable as far as a collision is concerned. The maximum length of the twisted
cable here is defined as 100 m, to minimize the effect of attenuation in the twistedcable.
Although there are several types of optical fiber 10-Mbps Ethernet, the most common is called10Base-F.
10Base-F uses a star topology to connect stations to a hub. The stations are connected to the hub using
two fiber-optic cables.
IEEE 802.11
IEEE has defined the specifications for a wireless LAN, called IEEE 802.11, which covers the physical
and data link layers.
Architecture: The standard defines two kinds of services: the basic service set (BSS) and the extended
service set (ESS).
Basic Service Set
IEEE 802.11 defines the basic service set (BSS) as the building block of a wireless LAN.
A basic service set is made of stationary or mobile wireless stations and an optional central base station,
known as the access point (AP).
The BSS without an AP is a stand-alone network and cannot send data to other BSSs. It is called an ad
hoc architecture. In this architecture, stations can form a network without the need of an AP; they can
locate one another and agree to be part of a BSS. A BSS with an AP is sometimes referred to as an
infrastructure network.
MAC Sublayer
IEEE 802.11 defines two MAC sublayers: the distributed coordination function (DCF) and point
coordination function (PCF). The following figure shows the relationship between the two MAC
sublayers, the LLC sublayer, and the physical layer.
One of the two protocols defined by IEEE at the MAC sublayer is called the distributedcoordination
function (DCF). DCF uses CSMAICA as the access method.
Wireless LANs cannot implement CSMA/CD for three reasons:
1. For collision detection a station must be able to send data and receive collision signals at thesame
time. This can mean costly stations and increased bandwidth requirements.
2. Collision may not be detected because of the hidden station problem.
3. The distance between stations can be great. Signal fading could prevent a station at one endfrom
hearing a collision at the other end.
Frame Format
The MAC layer frame consists of nine fields.
Frame control (FC): The FC field is 2 bytes long and defines the type of frame andsome
control information.
D. In all frame types except one, this field defines the duration of the transmission that is used to set
the value of NAY. In one control frame, this field defines the ID of the frame.
Management Frames: Management frames are used for the initial communication between
stations and access points.
Control Frames Control frames are used for accessing the channel and acknowledging frames.
Data Frames: Data frames are used for carrying data and control information.
B.Arun Kumar, Asst.Prof Computer Networks UNIT-II