انت هنا الان : شبكة جامعة بابل > موقع الكلية > نظام التعليم الالكتروني > مشاهدة المحاضرة

DATA LINK LAYER DESIGN ISSUES

Share |
الكلية كلية العلوم للبنات     القسم قسم الحاسبات     المرحلة 3
أستاذ المادة سيف محمود خلف العلاك       02/12/2018 08:35:25
data link layer design issues
the data link layer uses the services of the physical layer to send and receive bits over communication channels. it has a number of functions, including:
1. providing a well-defined service interface to the network layer.
2. dealing with transmission errors.
3. regulating the flow of data so that fast senders do not swamp slow receivers.
to accomplish these goals, the data link layer takes the packets it gets from the network layer and encapsulates them into frames for transmission. each frame contains a frame header, a payload field for holding the packet, and a frame trailer, as illustrated in figure below. frame management forms the heart of what the data link layer does.

services provided to the network layer
the function of the data link layer is to provide services to the network layer. the principal service is transferring data from the network layer on the source machine to the network layer on the destination machine. on the source machine is an entity, call it a process, in the network layer that hands some bits to the data link layer for transmission to the destination. the job of the data link layer is to transmit the bits to the destination machine so they can be handed over to the network layer there, as shown in figure (a) below. the actual transmission follows the path of figure (b), but it is easier to think in terms of two data link layer processes communicating using a data link protocol. for this reason, we will implicitly use the model of figure (a) below.


the data link layer can be designed to offer various services. the actual services that are offered vary from protocol to protocol. three reasonable possibilities that we will consider in turn are:
1. unacknowledged connectionless service.
2. acknowledged connectionless service.
3. acknowledged connection-oriented service.

unacknowledged connectionless service consists of having the source machine send independent frames to the destination machine without having the destination machine acknowledge them. ethernet is a good example of a data link layer that provides this class of service. no logical connection is established beforehand or released afterward. if a frame is lost due to noise on the line, 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. it is also appropriate for real-time traffic, such as voice, in which late data are worse than bad data.

the next step up in terms of reliability is acknowledged connectionless service. when this service is offered, there are still no logical connections used, but each frame sent is individually acknowledged. in this way, the sender knows whether a frame has arrived correctly or been lost. if it has not arrived within a specified time interval, it can be sent again. this service is useful over unreliable channels, such as wireless systems. 802.11 (wifi) is a good example of this class of service. it is perhaps worth emphasizing that providing acknowledgements in the data link layer is just an optimization, never a requirement.

the network layer can always send a packet and wait for it to be acknowledged by its peer on the remote machine. if the acknowledgement is not forthcoming before the timer expires, the sender can just send the entire message again. the trouble with this strategy is that it can be inefficient. links usually have a strict maximum frame length imposed by the hardware, and known propagation delays. the network layer does not know these parameters. it might send a large packet that is broken up into, say, 10 frames, of which 2 are lost on average. it would then take a very long time for the packet to get through. instead, if individual frames are acknowledged and retransmitted, then errors can be corrected more directly and more quickly. on reliable channels, such as fiber, the overhead of a heavyweight data link protocol may be unnecessary, but on (inherently unreliable) wireless channels it is well worth the cost.
getting back to our services, the most sophisticated service the data link layer can provide to the network layer is connection-oriented service. 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. furthermore, it guarantees that each frame is received exactly once and that all frames are received in the right order. connection-oriented service thus provides the network layer processes with the equivalent of a reliable bit stream. it is appropriate over long, unreliable links such as a satellite channel or a long-distance telephone circuit. if acknowledged connectionless service were used, it is conceivable that lost acknowledgements could cause a frame to be sent and received several times, wasting bandwidth.

when connection-oriented service is used, transfers go through three distinct phases. in the first phase, the connection is established by having both sides initialize variables and counters needed to keep track of which frames have been received and which ones have not. in the second phase, one or more frames are actually transmitted. in the third and final phase, the connection is released, freeing up the variables, buffers, and other resources used to maintain the connection.
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. if the channel is noisy, as it is for most wireless and some wired links, the physical layer will add some redundancy to its signals to reduce the bit error rate to a tolerable level. however, the bit stream received by the data link layer is not guaranteed to be error free. some bits may have different values and the number of bits received may be less than, equal to, or more than the number of bits transmitted. 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 up the bit stream into discrete frames, compute a short token called a checksum for each frame, and include the checksum in the frame when it is transmitted. 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 up the bit stream into frames is more difficult than it at first appears.
a good design must make it easy for a receiver to find the start of new frames while using little of the channel bandwidth. we will look at four methods:
1. byte count.
2. flag bytes with byte stuffing.
3. flag bits with bit stuffing.
4. physical layer coding violations.

the first framing method uses a field in the header to specify the number of bytes in the frame. when the data link layer at the destination sees the byte count, it knows how many bytes follow and hence where the end of the frame is. this technique is shown in figure (a) below for four small example frames of sizes 5, 5, 8, and 8 bytes, respectively. the trouble with this algorithm is that the count can be garbled by a transmission error. for example, if the byte count of 5 in the second frame of figure (b) becomes a 7 due to a single bit flip, the destination will get out of synchronization. it will then be unable to locate the correct 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 bytes to skip over to get to the start of the retransmission. for this reason, the byte count method is rarely used by itself.


the second framing method gets around the problem of resynchronization after an error by having each frame start and end with special bytes. often the same byte, called a flag byte, is used as both the starting and ending delimiter. this byte is shown in figure (a) below as flag. two consecutive flag bytes indicate the end of one frame and the start of the next. thus, if the receiver ever loses synchronization it can just search for two flag bytes to find the end of the current frame and the start of the next frame.

however, there is a still a problem we have to solve. it may happen that the flag byte occurs in the data, especially when binary data such as photographs or songs are being transmitted. this situation would 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. thus, a framing flag byte can be distinguished from one in the data by the absence or presence of an escape byte before it. the data link layer on the receiving end removes the escape bytes before giving the data to the network layer. this technique is called byte stuffing. 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. at the receiver, the first escape byte is removed leaving the data byte that follows it (which might be another escape byte or the flag byte). some examples are shown in figure (b). in all cases, the byte sequence delivered after destuffing is exactly the same as the original byte sequence. we can still search for a frame boundary by looking for two flag bytes in a row, without bothering to undo escapes.


the third method of delimiting the bit stream gets around a disadvantage of byte stuffing, which is that it is tied to the use of 8-bit bytes. framing can be also be done at the bit level, so frames can contain an arbitrary number of bits made up of units of any size. it was developed for the once very popular hdlc (high level data link control) protocol. each frame begins and ends with a special bit pattern, 01111110 or 0x7e in hexadecimal. this pattern is 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. it also ensures a minimum density of transitions that help the physical layer maintain synchronization. usb (universal serial bus) uses bit stuffing for this reason. when the receiver sees five consecutive incoming 1 bits, followed by a 0 bit, it automatically dyestuffs (i.e., deletings) 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-5 gives an example of bit stuffing.

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.

with both bit and byte stuffing, a side effect is that the length of a frame now depends on the contents of the data it carries. for instance, if there are no flag bytes in the data, 100 bytes might be carried in a frame of roughly 100 bytes. if, however, the data consists solely of flag bytes, each flag byte will be escaped and the frame will become roughly 200 bytes long. with bit stuffing, the increase would be roughly 12.5% as 1 bit is added to every byte.

the last method of framing is to use a shortcut from the physical layer. the encoding of bits as signals often includes redundancy to help the receiver. this redundancy means that some signals will not occur in regular data. we can use some reserved signals to indicate the start and end of frames. in effect, we are using ‘‘coding violations’’ to delimit frames.

the beauty of this scheme is that, because they are reserved signals, it is easy to find the start and end of frames and there is no need to stuff the data. many data link protocols use a combination of these methods for safety. a common pattern used for ethernet and 802.11 is to have a frame begin with a well-defined pattern called a preamble. this pattern might be quite long (72 bits is typical for 802.11) to allow the receiver to prepare for an incoming packet. the preamble is then followed by a length (i.e., count) field in the header that is used to locate the end of the frame.


المادة المعروضة اعلاه هي مدخل الى المحاضرة المرفوعة بواسطة استاذ(ة) المادة . وقد تبدو لك غير متكاملة . حيث يضع استاذ المادة في بعض الاحيان فقط الجزء الاول من المحاضرة من اجل الاطلاع على ما ستقوم بتحميله لاحقا . في نظام التعليم الالكتروني نوفر هذه الخدمة لكي نبقيك على اطلاع حول محتوى الملف الذي ستقوم بتحميله .
الرجوع الى لوحة التحكم