You are on page 1of 5

7/31/2016

DatalinklayerWikipedia,thefreeencyclopedia

Datalinklayer
FromWikipedia,thefreeencyclopedia

Thedatalinklayerorlayer2isthesecondlayerofthesevenlayerOSImodelofcomputernetworking.This
layeristheprotocollayerthattransfersdatabetweenadjacentnetworknodesinawideareanetwork(WAN)or
betweennodesonthesamelocalareanetwork(LAN)segment.[1]Thedatalinklayerprovidesthefunctionaland
proceduralmeanstotransferdatabetweennetworkentitiesandmightprovidethemeanstodetectandpossibly
correcterrorsthatmayoccurinthephysicallayer.
ThedatalinklayerisconcernedwithlocaldeliveryofframesbetweendevicesonthesameLAN.Datalink
frames,astheseprotocoldataunitsarecalled,donotcrosstheboundariesofalocalnetwork.Internetwork
routingandglobaladdressingarehigherlayerfunctions,allowingdatalinkprotocolstofocusonlocaldelivery,
addressing,andmediaarbitration.Thisway,thedatalinklayerisanalogoustoaneighborhoodtrafficcopit
endeavorstoarbitratebetweenpartiescontendingforaccesstoamedium,withoutconcernfortheirultimate
destination.Whendevicesattempttouseamediumsimultaneously,framecollisionsoccur.Datalinkprotocols
specifyhowdevicesdetectandrecoverfromsuchcollisions,andmayprovidemechanismstoreduceorprevent
them.
ExamplesofdatalinkprotocolsareEthernetforlocalareanetworks(multinode),thePointtoPointProtocol
(PPP),HDLCandADCCPforpointtopoint(dualnode)connections.IntheInternetProtocolSuite(TCP/IP),the
datalinklayerfunctionalityiscontainedwithinthelinklayer,thelowestlayerofthedescriptivemodel.

Contents
1 Overview
2 Sublayers
2.1 Logicallinkcontrolsublayer
2.2 Mediaaccesscontrolsublayer
3 Services
4 Errordetectionandcorrection
5 Protocolexamples
6 RelationtotheTCP/IPmodel
7 Seealso
8 References
9 Externallinks

Overview
Layer2devicesdeliverframesusinguniquehardwareaddresses.Aframe'sheadercontainssourceanddestination
addressesthatindicatewhichdeviceoriginatedtheframeandwhichdeviceisexpectedtoreceiveandprocessit.In
contrasttothehierarchicalandroutableaddressesofthenetworklayer,layer2addressesareflat,meaningthatno
partoftheaddresscanbeusedtoidentifythelogicalorphysicalgrouptowhichtheaddressbelongs.
Thedatalinkthusprovidesdatatransferacrossthephysicallink.Thattransfercanbereliableorunreliablemany
datalinkprotocolsdonothaveacknowledgmentsofsuccessfulframereceptionandacceptance,andsomedata
linkprotocolsmightnotevenhaveanyformofchecksumtocheckfortransmissionerrors.Inthosecases,higher
levelprotocolsmustprovideflowcontrol,errorchecking,andacknowledgmentsandretransmission.
https://en.wikipedia.org/wiki/Data_link_layer

1/5

7/31/2016

DatalinklayerWikipedia,thefreeencyclopedia

Insomenetworks,suchasIEEE802localareanetworks,thedatalinklayerisdescribedinmoredetailwithmedia
accesscontrol(MAC)andlogicallinkcontrol(LLC)sublayersthismeansthattheIEEE802.2LLCprotocolcan
beusedwithalloftheIEEE802MAClayers,suchasEthernet,tokenring,IEEE802.11,etc.,aswellaswithsome
non802MAClayerssuchasFDDI.Otherdatalinklayerprotocols,suchasHDLC,arespecifiedtoincludeboth
sublayers,althoughsomeotherprotocols,suchasCiscoHDLC,useHDLC'slowlevelframingasaMAClayerin
combinationwithadifferentLLClayer.IntheITUTG.hnstandard,whichprovidesawaytocreateahighspeed
(upto1Gigabit/s)localareanetworkusingexistinghomewiring(powerlines,phonelinesandcoaxialcables),the
datalinklayerisdividedintothreesublayers(applicationprotocolconvergence,logicallinkcontrolandmedium
accesscontrol).
WithinthesemanticsoftheOSInetworkarchiteure,thedatalinklayerprotocolsrespondtoservicerequestsfrom
thenetworklayerandtheyperformtheirfunctionbyissuingservicerequeststothephysicallayer.

Sublayers
Thedatalinklayerhastwosublayers:logicallinkcontrol(LLC)andmediaaccesscontrol(MAC).[2]

Logicallinkcontrolsublayer
Theuppermostsublayer,LLC,multiplexesprotocolsrunningatopthedatalinklayer,andoptionallyprovidesflow
control,acknowledgment,anderrornotification.TheLLCprovidesaddressingandcontrolofthedatalink.It
specifieswhichmechanismsaretobeusedforaddressingstationsoverthetransmissionmediumandfor
controllingthedataexchangedbetweentheoriginatorandrecipientmachines.

Mediaaccesscontrolsublayer
MACmayrefertothesublayerthatdetermineswhoisallowedtoaccessthemediaatanyonetime(e.g.
CSMA/CD).OthertimesitreferstoaframestructuredeliveredbasedonMACaddressesinside.
Therearegenerallytwoformsofmediaaccesscontrol:distributedandcentralized.[3]Bothofthesemaybe
comparedtocommunicationbetweenpeople.Inanetworkmadeupofpeoplespeaking,i.e.aconversation,we
lookforcluesfromourfellowtalkerstoseeifanyofthemappeartobeabouttospeak.Iftwopeoplespeakatthe
sametime,theywilleachpausearandomamountoftimeandthenattempttospeakagain,effectivelyestablishing
alongandelaborategameofsaying"no,youfirst".
TheMediaAccessControlsublayeralsodetermineswhereoneframeofdataendsandthenextonestartsframe
synchronization.Therearefourmeansofframesynchronization:timebased,charactercounting,bytestuffingand
bitstuffing.
Thetimebasedapproachsimplyputsaspecifiedamountoftimebetweenframes.Themajordrawbackof
thisisthatnewgapscanbeintroducedoroldgapscanbelostduetoexternalinfluences.
Charactercountingsimplynotesthecountofremainingcharactersintheframe'sheader.Thismethod,
however,iseasilydisturbedifthisfieldgetsfaultyinsomeway,thusmakingithardtokeepup
synchronization.
BytestuffingprecedestheframewithaspecialbytesequencesuchasDLESTXandsucceedsitwithDLE
ETX.AppearancesofDLE(bytevalue0x10)havetobeescapedwithanotherDLE.Thestartandstop
marksaredetectedatthereceiverandremovedaswellastheinsertedDLEcharacters.
Similarly,bitstuffingreplacesthesestartandendmarkswithflagconsistingofaspecialbitpattern(e.g.a0,
six1bitsanda0).Occurrencesofthisbitpatterninthedatatobetransmittedareavoidedbyinsertingabit.
Tousetheexamplewheretheflagis01111110,a0isinsertedafter5consecutive1'sinthedatastream.The
flagsandtheinserted0'sareremovedatthereceivingend.Thismakesforarbitrarylongframesandeasy
https://en.wikipedia.org/wiki/Data_link_layer

2/5

7/31/2016

DatalinklayerWikipedia,thefreeencyclopedia

synchronizationfortherecipient.Notethatthisstuffedbitisaddedevenifthefollowingdatabitis0,which
couldnotbemistakenforasyncsequence,sothatthereceivercanunambiguouslydistinguishstuffedbits
fromnormalbits.

Services
Encapsulationofnetworklayerdatapacketsintoframes
Framesynchronization
Logicallinkcontrol(LLC)sublayer:
Errorcontrol(automaticrepeatrequest,ARQ),inadditiontoARQprovidedbysometransportlayer
protocols,toforwarderrorcorrection(FEC)techniquesprovidedonthephysicallayer,andtoerror
detectionandpacketcancelingprovidedatalllayers,includingthenetworklayer.Datalinklayer
errorcontrol(i.e.retransmissionoferroneouspackets)isprovidedinwirelessnetworksandV.42
telephonenetworkmodems,butnotinLANprotocolssuchasEthernet,sincebiterrorsareso
uncommoninshortwires.Inthatcase,onlyerrordetectionandcancelingoferroneouspacketsare
provided.
Flowcontrol,inadditiontotheoneprovidedonthetransportlayer.Datalinklayererrorcontrolisnot
usedinLANprotocolssuchasEthernet,butinmodemsandwirelessnetworks.
Mediaaccesscontrol(MAC)sublayer:
Multipleaccessprotocolsforchannelaccesscontrol,forexampleCSMA/CDprotocolsforcollision
detectionandretransmissioninEthernetbusnetworksandhubnetworks,ortheCSMA/CAprotocol
forcollisionavoidanceinwirelessnetworks.
Physicaladdressing(MACaddressing)
LANswitching(packetswitching),includingMACfiltering,SpanningTreeProtocol(STP)and
ShortestPathBridging(SPB)
Datapacketqueuingorscheduling
Storeandforwardswitchingorcutthroughswitching
QualityofService(QoS)control
VirtualLANs(VLAN)

Errordetectionandcorrection
Besideframing,datalinklayersalsoincludemechanismstodetectandevenrecoverfromtransmissionerrors.For
areceivertodetecttransmissionerror,thesendermustaddredundantinformation(intheformofbits)asanerror
detectioncodetotheframesent.Whenthereceiverobtainsaframewithanerrordetectioncodeitrecomputesit
andverifieswhetherthereceivederrordetectioncodematchesthecomputederrordetectioncode.Iftheymatch
theframeisconsideredtobevalid.
Anerrordetectioncodecanbedefinedasafunctionthatcomputesther(amountofredundantbits)corresponding
toeachstringofNtotalnumberofbits.Thesimplesterrordetectioncodeistheparitybit,whichallowsareceiver
todetecttransmissionerrorsthathaveaffectedasinglebitamongthetransmittedN+rbits.Iftherearetwoor
morebitsinerror,thereceivermaynotbeabletodetectthetransmissionerror.
H E L L O
8 5 12 12 15
Asimpleexampleofhowthisworksusingmetadataistransmittingtheword"HELLO",byencodingeachletteras
itspositioninthealphabet.Thus,theletterAiscodedas1,Bas2,andsoonasshowninthetableontheright.
Addinguptheresultingnumbersyields8+5+12+12+15=52,and5+2=7calculatesthemetadata.Finally,
the"851212157"numberssequenceistransmitted,whichthereceiverwillseeonitsendifthereareno
transmissionerrors.Thereceiverknowsthatthelastnumberreceivedistheerrordetectingmetadataandthatall
https://en.wikipedia.org/wiki/Data_link_layer

3/5

7/31/2016

DatalinklayerWikipedia,thefreeencyclopedia

databeforeisthemessage,sothereceivercanrecalculatetheabovemathandifthemetadatamatchesitcanbe
concludedthatthedatahasbeenreceivederrorfree.Though,ifthereceiverseessomethinglikea"751212157"
sequence,itcanrunthecheckbycalculating7+5+12+12+15=51and5+1=6,anddiscardthereceiveddata
asdefectivesince6doesnotequal7.

Protocolexamples
AddressResolutionProtocol(ARP)
ARCnet
ATM
CiscoDiscoveryProtocol(CDP)
ControllerAreaNetwork(CAN)
Econet
Ethernet
EthernetAutomaticProtectionSwitching(EAPS)
FiberDistributedDataInterface(FDDI)
FrameRelay
HighLevelDataLinkControl(HDLC)
IEEE802.2(providesLLCfunctionstoIEEE802MAClayers)
IEEE802.11wirelessLAN
IC
LattisNet
LinkAccessProcedures,Dchannel(LAPD)
LinkLayerDiscoveryProtocol(LLDP)
LocalTalk
MILSTD1553
MultiprotocolLabelSwitching(MPLS)
NortelDiscoveryProtocol(NDP)
OpenFlow(SDN)
PointtoPointProtocol(PPP)
Profibus
SpaceWire
SerialLineInternetProtocol(SLIP)(obsolete)
Splitmultilinktrunking(SMLT)
IEEE802.1aqShortestPathBridging
SpanningTreeProtocol
StarLan
Tokenring
UnidirectionalLinkDetection(UDLD)
UNI/O
1Wire
andmostformsofserialcommunication.

RelationtotheTCP/IPmodel
IntheInternetProtocolSuite(TCP/IP),OSI'sdatalinklayerfunctionalityiscontainedwithinitslowestlayer,the
linklayer.TheTCP/IPlinklayerhastheoperatingscopeofthelinkahostisconnectedto,andonlyconcernsitself
withhardwareissuestothepointofobtaininghardware(MAC)addressesforlocatinghostsonthelinkand
transmittingdataframesontothelink.ThelinklayerfunctionalitywasdescribedinRFC1122andisdefined
differentlythantheDataLinkLayerofOSI,andencompassesallmethodsthataffectthelocallink.
https://en.wikipedia.org/wiki/Data_link_layer

4/5

7/31/2016

DatalinklayerWikipedia,thefreeencyclopedia

TheTCP/IPmodelisnotatopdowncomprehensivedesignreferencefornetworks.Itwasformulatedforthe
purposeofillustratingthelogicalgroupsandscopesoffunctionsneededinthedesignofthesuiteof
internetworkingprotocolsofTCP/IP,asneededfortheoperationoftheInternet.Ingeneral,directorstrict
comparisonsoftheOSIandTCP/IPmodelsshouldbeavoided,becausethelayeringinTCP/IPisnotaprincipal
designcriterionandingeneralconsideredtobe"harmful"(RFC3439).Inparticular,TCP/IPdoesnotdictatea
stricthierarchicalsequenceofencapsulationrequirements,asisattributedtoOSIprotocols.

Seealso
ODI
NDIS
SANAIIStandardAmigaNetworkingArchitecture,version2

References
1."Whatislayer2,andWhyShouldYouCare?".accelnetworks.com.Archivedfromtheoriginalon20100218.
Retrieved20090929.
2.RegisJ.BatesandDonaldW.Gregory(2007).Voice&datacommunicationshandbook(5thed.).McGrawHill
Professional.p.45.ISBN9780072263350.
3.G.MiaoG.Song(2014).Energyandspectrumefficientwirelessnetworkdesign.CambridgeUniversityPress.
ISBN1107039886.

S.Tanenbaum,Andrew(2005).ComputerNetworks(4thed.).482,F.I.E.,Patparganj,Delhi110092:Dorling
Kindersley(India)Pvt.Ltd.,licensesofPearsonEducationinSouthAsia.ISBN8177581651.
Odom,Wendel(2013).CCENT/CCNAICND1100101,CCENTOfficialcertguide.PaulBoger,ciscopress.
ISBN1587143852.

Externallinks
DataLinklayersimulation,writteninC#(http://www.codeproject.co
m/Articles/57072/DataLinkSimulator)
DataLinkLayer,Part2:ErrorDetectionandCorrection(http://www.c
s.gmu.edu/~huangyih/656/error.pdf)

WikimediaCommonshas
mediarelatedtoDatalink
layer.

Retrievedfrom"https://en.wikipedia.org/w/index.php?title=Data_link_layer&oldid=732187764"
Categories: OSIprotocols Linkprotocols
Thispagewaslastmodifiedon30July2016,at06:49.
TextisavailableundertheCreativeCommonsAttributionShareAlikeLicenseadditionaltermsmayapply.
Byusingthissite,youagreetotheTermsofUseandPrivacyPolicy.Wikipediaisaregisteredtrademark
oftheWikimediaFoundation,Inc.,anonprofitorganization.

https://en.wikipedia.org/wiki/Data_link_layer

5/5