ECE333:IntroductiontoCommunicationNetworks Fall2001 Lecture5:DataLinkLayerI Introduction Framing 1

DataLinkLayer

NetworkLayer “Virtualpacketpipe” NetworkLayer DataLinkLayer DataLinkLayer PhysicalLayer PhysicalLayer “VirtualBitpipe” Logicallinkcontrol sub-layer DataLinkLayer Mediumaccess controlsub-layer

2 Notes: IntheOSIprotocolstack,thelayerdirectlyabovethephysicallayeristheDataLink Layer(DLL).TheDLLisalsoreferedtoaslayer2. When the underlying link is a broadcast medium, the DLL is separated into MAC (Media Access Control) and LLC (Logical Link Control) sub-layers. The MAC sub-layerisresponsiblefordeterminingwhichusersgettousethebroadcastmedium atanytime;wewillstudythissub-layerinseveralweeks.Withpoint-to-pointlinks, onlytheLLCsub-layerisneeded.Inthenextfewlectures,wewilldiscussissuesthat are addressed in the LLC sub-layer. As with the physical layer, the DLL still addressees"link-levelissues"-thatistheprotocolsatthislayerarebetweentwoDLL peers-oneateachendofacommunicationlink. DLL protocols can be implemented either in hardware or software. They can be implementedineitheracomputer'smainCPUorinspecialpurposehardware,known asanetworkadapterorNetworkInterfaceCard(NIC).Acommonexampleofthe latercaseisanNIC.

3

DATALINKLAYER Router

2 3 2 2 3 2

DataLink protocol

2DLLpeer'sforeachlink.

4 Notes: Recall,thephysicallayerprovidestheDLLwitha“virtualbitpipe,”whichallowsDLL peerstoexchangeacontinuousstreamofbits.Loosely,thegoalofthedatalinklayer istoconvertthisbitpipeinto"virtualpacketpipe"thatwillallowpeersatthenetwork layertoexchangepackets(stringsofbits).Therearetwomainissueswewillconsider here:(1)Framingand(2)Errorcontrol.Framingreferstotheproblemofdeciding which bits belong to which packets of data at the receiving DLL peer. Error control arisesbecausethebitpipeprovidedbythephysicallayermayintroduceerrorsinthe packets, it may also add additional bits or remove some bits in some cases. Both of theseissuesalsoariseathigherlayers. We discuss several possible characteristics of the service provided by the data link layer(thesetermswillalsobeusedindiscussingtheserviceprovidedbyotherlayers). First we consider the reliability of the service. The service may be confirmed or acknowledged meaning that the transmitting DLL informs the network layer whetherornotapacketwascorrectlyreceived.Theservicemayalsobeunconfirmed, in which case no confirmation is given if apacketarrivesornot.Finallytheservice may be reliable, meaning that the DLL guarantees that every packet is received correctly,inorderandonlyonce. Another classification of the offered service is as either connection-oriented or connectionless. Recall, we used this distinction to classify networks in Lecture 1 - hereweareusingittoclassifyaserviceattheDLL,butthemeaningisthesame.A connectionless DLL would not require any connection setup before packets could be sent,whileaconnection-orientedDLLwouldrequiresuchasetup. 5

Encapsulation Header Layer3Packet Trailer

Layer2Frame Headerand/orTraileraddedatDLL. Repeatsathigherlayers. 6 Encapsulation L a y e r N

L a y e r N + 1

L a y e r N + 2

L a y e r N + 3

7

Notes: To provide the required services, the sending DLL peer needs to add some additional information or overhead to each packet received from the network layer. This overheadistypicallyintheformofeitheraheaderatthebeginningofthe packetandatrailerattheendofthepacket.Thecombinationofheader,network layerpacket,andtrailercanbeconsideredanewpacket-todistinguishthisfrom the network layer packets; the string of bits formed at the DLL is sometimes referredtoasaframe.Theprocessistypicallyrepeatedathigherlayers;ateach layerthedatafromthehigherlayerisencapsulatedinalargerpacketbyadding aheaderand/ortrailer.(Sometimes,however,higherlayerpacketsaredividedor grouped together at the next layer - we will discuss this when we consider the networklayer.) 8 Framing Issues: 1.Separatepacketsfromeachother 2.Separatepacketsfromidle. Fourapproaches: 1.CharacterCount 2.Startingandendingcharacters 3.Startingandendingflags 4.Physicallayercodingviolations 9

CharacterCount: Placenumberofbits(orcharacters)inframeasfirstpieceofinformation. Problems?

10 FramingCharacters Basedonparticularcharacterset,e.g.ASCIIcharactercode BegineachframewithDLESTX. EndeachframewithDLEETX. DLE - DataLinkEscape STX - StartofText ETX - EndofText

DLE STX ••• DLE ETX WhathappensifaDLEETXoccursinthemiddleofthedata? 11

CharacterStuffing AnyDLEthatoccursinthedataisdoubled.

DLE STX ••• DLE DLE ETX DLE ETX

Stuffed ReceiverinterpretssingleDLEasescapeindicatingthenext character isacontrolcharacter. IftwoDLE'sinsuccession,thefirstisdiscardedandthesecondis regardedasdata

12 FramingBits Bit pattern framing uses a particular sequence of bits called a flag for framing. Usesbitstuffingtopreventthesequenceinthedata. Example: Flag= 01111110 (beginsandendsframe.) Transmitterautomaticallystuffsa0after5consecutive1'sindata. onlytime61'sarereceivedisinflag. OriginalData1111111111001011

SentData?

13

FramingbyIllegalCode Recallcertainphysicallayersusealinecodefortimingreasons. E.G.: ManchesterEncoding 1=>

0=> Codesofallloworallhigharen'tusedfordataandthereforecanbeused forframing. 14 Notes: Framingreferstotechniquesthatareusedtotellwhenaframebeginsandends.In caseswherethephysicallayerisa"synchronousbitpipe"(seelecture3),itmustbe suppliedwithbitsatafixedrate,evenwhenthereisnodatatosend(onereason for this is that the receiver relies on the arriving bits to maintain timing information)WhenthereisnodatatotransmittheDLLmustinsert“idlefill”,in such cases framing techniques are also used to differentiate idle fill from useful data. The problem of framing is complicated by the fact that errors can occur in the received data. These errors can cause a loss of framing that must be recovered from. Characterorlengthcountsworkbysimplyplacingthenumberofcharactersinthe frame as the first pieceofinformation.Assumingthebeginningofsomeframeis known,thenextframeboundarycanbefoundbycounting.Therearelengthcounts in the convergence sub-layers of ATM, in IP, and in many transport protocols. A disadvantage is that resynchronization is difficult after an error in the length count.Alsolengthcountsdonotaddresstheidlefillproblem. Theuseofframingcharactershavetheirrootsinprotocolsdevelopedinthe1960's to connect terminals to main-frames, such as DECNET and BISYNC. When character-based framing is used each frame is required to contain an integral numberofcharactersperframe.

15

Using framing bits is just an implementational variation of character-based framing. With bit-based approach, the data in a frame is not tied to a particular characterset. Notetheuseillegalcodesforframingbreaksstrictlayerboundarieswithphysical layer.Thatistheframingserviceprovidedthenetworklayeristiedtoaninternal detailofthephysicallayerimplementation. Inpractice,variousframingmethodsareoftencombined.Forexample,bitstuffing may be used for framing and a character count may also be present, for extra protection.AnotherexampleistheframingusedinEthernetgivenbelow. Example:FraminginIEEE802.3(Ethernet) An illegal Manchester coding is used for framing. A character count is also includedintheframeheader.Also,sinceallframeshaveanintegralnumberof bytes,ifthereceivedframedoesnotendonabyteboundary,frameisconsidered tobereceivedinerror.

16