Oct 00 Getting Started
Volume Number: 16
Issue Number: 10
Column Tag: Getting Started - Networking
Networks 201 pt. 4
by John C. Welch
Layer 2: The Data Link Layer
Refresh
Before we start with this month's installment of our look at networks, an
apology/error fix. In the last article, we stated that to find the wavelength of signal,
you would invert the frequency, via the equation 1/freq. Unfortunately, that was
incorrect. That equation actually gives you the period of the signal. To get the
wavelength, you would more correctly use the equation c/freq, where c represents the
speed of light in meters per second. Many thanks to Bruce Toback who was the first to
notify us as to the error, and all the other readers who caught it as well. Now on to
Layer 2.
Going back to the overview of the OSI model in the first article in the series, Layer 2
is the DataLink Layer, and communicates with Layers 1 and 3. The most basic
description of Layer 2's function would be that it receives data and routing information
from Layer 3, and assembles them into frames which are passed onto the Layer 1. It
also receives serial bitstreams from the Layer 1, and assembles these into frames,
which are then passed onto Layer 3. Like most networking functions, the actual duties
of this Layer are far more complex, and it is those duties, and the complexity therein
that we will look at in this article.
Layer 2
Base Function
The basic function of the Data Link Layer is to provide services to the Network Layer.
This centers around getting data from the transmitting machine to the receiving
machine intact. There are three base methods for doing this:
1. Unacknowledged Connectionless Service
2. Acknowledged Connectionless Service
3. Acknowledged Connection - Oriented Service
The first method, unacknowledged connectionless service, is where the source sends
independent frames to the source. This has some analogies to messages in a bottle. You
write the message, pop it in the bottle, and set the bottle in the water. It either gets
there, or does not. You have no way to verify that it was successfully received, or that,
in the case of multiple messages, that they were received in the proper order. This
method may sound very unreliable, but in fact it is used quite often. If the protocol you
are using, such as TCP, has provisions for connection management, message
reassembly, and acknowledgement at a higher layer, then there is no sense in having
an additional level of acknowledgement and connection management in the Data Link
Layer. As a result, most LANs use this type of service at the Data Link Layer level. The
other reason for using this service would be in real time situations, where the time
delays in setting up connections and retransmitting data would cause delays that would
impede the function of the real time applications.
The second type of service is acknowledged connectionless service. This is analogous to
registered mail with a delivery receipt. You have no idea how the mail got to its
destination, but you know that it was received or not. There are two ways to deal with
acknowledgement errors. The first is to retransmit the entire set of data. While safer
in theory, this is impractical for a number of reasons. The first is that if we are
talking about a large amount of data, retransmitting the entire data set can take an
unacceptably long time, especially over slow links. The other is that considering the
chances of a lost packet here and there get very high, especially over unreliable links,
so in theory, you could run into a situation where you would never be able to stop
retransmitting your data set. The second, and more common method is to only
retransmit those frames that were lost. This method requires more sophisticated
checking algorithms, but has a greater efficiency than retransmitting the entire
message for every error. While lost frames are not a great issue with reliable media,
such as fiber, when we talk about wireless networking, the chances for lost frames are
much greater, and in fact, this is the type of service used in the 802.11b wireless
networking standard. It is worth noting that providing acknowledgements at the Data
Link Layer level is an optimization, not a requirement. That function can be, and often
is handled at higher levels.
The final type of service is acknowledged connection - oriented service. In this class of
service, a connection is created before any data is transmitted, each frame sent over
the connection is numbered, and each frame sent is guaranteed to be received. In
addition, each frame sent is guaranteed to be received only once, and in the correct
order. This type of service creates, what is essentially a networked bit stream. There
are three phases to data transfers in this service. The first is the establishment of a
connection. As part of this, frame counters are created on both sides, to keep track of
which frames have and have not been sent. The second phase is the actual transmitting
of data, and the tracking of the frames. The final phase is the connection teardown, and
the disposal of the frame counters and other resources used.
It worth mentioning here, that as far as the Data Link Layer is concerned, the Physical
Layer doesn't really exist. Although the physical path of the data has to travel through
the Physical Layer, the logical path at the Layer 2 level would show an end - to - end
connection between Layer 2 on the transmitter, and Layer 2 on the receiver. There are
a number of reasons for this, including error correction, data delivery mechanisms,
etc. The important thing to remember is that for Layer 2, Layer 1 doesn't really exist
Frames
As we mentioned earlier, the Data Link Layer deals with frames. This is the way it both
provides service to the Network Layer, and uses the services provided by the Physical
Layer. Remember, all the Physical Layer cares about is getting bits from the Network
Layer, and shoving them out onto the line to their destination. (Actually, all the
Physical Layer cares about is shoving bits onto and receiving bits from the wire. It has
nothing to do with addressing, and in the case of things like Ethernet, will actually look
at all bits on the wire, relying on the higher layers to check things like destination
addressing.)
In any case, the structure used by the Data Link Layer is the frame. All data from the
Network Layer is encapsulated into a frame, and sent on to the Physical Layer.
Conversely, all bits from the Physical Layer is packed into frames, and sent on to the
Network Layer. Although the specific sizes and contents of frames are determined by
the hardware protocol used, such as Ethernet and Token Ring, all frames have certain
structural commonalities.
All frames have a Start Of Frame delimiter of some kind. This is some kind of
structure that says "This is where the frame starts". They also all have some kind of
End Of Frame delimiter, or Frame Check Sequence, that says "This is where the frame
ends." Since we are talking about the start and end of frame delimiters, this is a good
time to touch on exactly how frames are pulled out of bits on a wire. There are about
five ways to do this. The first, timing, is not used, and was never really used, as there
is almost no way for any network to guarantee the timing between frames, or how long
a frame takes to get from point a to point b. This leaves us with four other methods of
marking frames:
1. Character Count
2. Starting and ending characters, with character stuffing
3. Starting and ending flags, with bit stuffing.
4. Physical Layer coding violations
Method one, character count, uses a header to specify the number of characters in a
frame. When the Data Link Layer sees this header, it knows the end of the frame is
exactly X number of characters follow the character count header, and therefore,
where the frame ends. The problem with this is that there is no real way to deal with
the character count getting scrambled. If the transmitter sends a count of 25
characters, and the data gets scrambled, so that the receiver sees a count of 20
characters, then not only is that frame garbled, but all following frames as well. Once
this synchronization is lost, then even retransmission doesn't work, because there is
no way to tell how many characters to ignore so as to skip the bad frame. Not
surprisingly, the character count method is rarely used these days.