Tải bản đầy đủ - 0 (trang)
Chapter 18. Radix Tree Routing Tables

Chapter 18. Radix Tree Routing Tables

Tải bản đầy đủ - 0trang

Chapter18.RadixTreeRouting

Tables

Section18.1.Introduction

Section18.2.RoutingTableStructure

Section18.3.RoutingSockets

Section18.4.CodeIntroduction

Section18.5.RadixNodeData

Structures

Section18.6.RoutingStructures





Section18.7.Initialization:route_init

andrtable_initFunctions

Section18.8.Initialization:rn_initand

rn_initheadFunctions

Section18.9.DuplicateKeysandMask

Lists

Section18.10.rn_matchFunction



Section18.11.rn_searchFunction

Section18.12.Summary



Team-Fly









Top



Team-Fly











TCP/IPIllustrated,Volume2:The

ImplementationByGaryR.Wright,

W.RichardStevens

TableofContents



Chapter18.RadixTreeRouting

Tables



18.1Introduction

TheroutingperformedbyIP,whenit

searchestheroutingtableanddecides

whichinterfacetosendapacketouton,is

aroutingmechanism.Thisdiffersfroma

routingpolicy,whichisasetofrulesthat

decideswhichroutesgointotherouting

table.TheNet/3kernelimplementsthe

routingmechanismwhilearouting

daemon,typicallyroutedorgated,

implementstheroutingpolicy.The

structureoftheroutingtablemust

recognizethatthepacketforwarding

occursfrequentlyhundredsorthousandsof

timesasecondonabusysystemwhile

routingpolicychangesarelessfrequent.



Routingisadetailedissueandwedivide

ourdiscussionintothreechapters.

Thischapterlooksatthestructureof

theradixtreeroutingtablesusedby

theNet/3packetforwardingcode.The

tablesareconsultedbyIPeverytimea

packetissent(sinceIPmustdetermine

whichlocalinterfacereceivesthe

packet)andeverytimeapacketis

forwarded.

Chapter19looksatthefunctionsthat

interfacebetweenthekernelandthe

radixtreefunctions,andalsoatthe

routingmessagesthatareexchanged

betweenthekernelandrouting

processesnormallytheroutingdaemons

thatimplementtheroutingpolicy.

Thesemessagesallowaprocessto

modifythekernel'sroutingtable(adda

route,deletearoute,etc.)andletthe

kernelnotifythedaemonswhenan

asynchronouseventoccursthatmight

affecttheroutingpolicy(aredirectis

received,aninterfacegoesdown,and

soon).







Chapter20presentstheroutingsockets

thatareusedtoexchangerouting

messagesbetweenthekernelanda

process.



Team-Fly









Top



Team-Fly



TCP/IPIllustrated,Volume2:TheImplementationByGaryR.Wrig

W.RichardStevens

TableofContents



Chapter18.RadixTreeRoutingTables



18.2RoutingTableStructure



BeforelookingattheinternalstructureoftheNet/3ro

table,weneedtounderstandthetypeofinformation

containedinthetable.Figure18.1isthebottomhalfo

Figure1.17:thefoursystemsontheauthor'sEthernet



Figure18.1.Subnetusedforroutingtableexamp



Figure18.2showstheroutingtableforbsdiinFigure1



Figure18.2.Routingtableonthehostbsdi.



Wehavemodifiedthe"Flags"columnfromthenormal

output,makingiteasiertoseewhichflagsaresetfort

variousentries.



Theroutesinthistablewereenteredasfollows.Steps

5,8,and9areperformedatsysteminitializationwhen

/etc/netstartshellscriptisexecuted.



1. Adefaultrouteisaddedbytheroutecommand

thehostsun(140.252.13.33),whichcontains

linktotheInternet.



Theentryfornetwork127istypicallycreatedbyaro

daemonsuchasgated,oritcanbeenteredwiththero

commandinthe/etc/netstartfile.Thisentrycausesal

packetssenttothisnetwork,otherthanreferencesto

host127.0.0.1(whicharecoveredbythemorespecific



enteredinthenextstep),toberejectedbytheloopba

driver(Figure5.27).

Theentryfortheloopbackinterface(127.0.0.1)is

configuredbyifconfig.



Theentryforvangogh.cs.berkeley.edu(128.32.33.5)

createdbyhandusingtheroutecommand.Itspecifies

samerouterasthedefaultroute(140.252.13.33),but

ahost-specificroute,insteadofusingthedefaultroute

thishost,allowsroutingmetricstobestoredinthisen

Thesemetricscanoptionallybesetbytheadministrato

usedbyTCPeachtimeaconnectionisestablishedtoth

destinationhost,andareupdatedbyTCPwhenthe

connectionisclosed.Wedescribethesemetricsinmor

withFigure27.3.



Theinterface1e0isinitializedusingtheifconfigcomm

Thiscausestheentryfornetwork140.252.13.32tobe

enteredintotheroutingtable.



TheentriesfortheothertwohostsontheEthernet,s

(140.252.13.33)andsvr4(140.252.13.34),werecreat

ARP,aswedescribeinChapter21.Thesearetemporar

entriesthatareremovediftheyarenotusedforacert

periodoftime.



Theentryforthelocalhost,140.252.13.35,iscreate



firsttimethehost'sownIPaddressisreferenced.The

interfaceistheloopback,meaninganyIPdatagramss

thehost'sownIPaddressareloopedbackinternally.T

automaticcreationofthisentryisnewwith4.4BSD,as

describeinSection21.13.



Theentryforthehost140.252.13.65iscreatedwhen

SLIPinterfaceisconfiguredbyifconfig.



Theroutecommandaddstheroutetonetwork224th

theEthernetinterface.



Theentryforthemulticastgroup224.0.0.1(theall-h

group)wascreatedbyrunningthePingprogram,ping

address224.0.0.1.Thisisalsoatemporaryentrythat

removedifnotusedforacertainperiodoftime.



The"Flags"columninFigure18.2needsabriefexplan

Figure18.25providesalistofallthepossibleflags.

U Therouteisup.



G Therouteistoagateway(router).Thisiscalledan

route.Ifthisflagisnotset,thedestinationisdirectly

connected;thisiscalledadirectroute.



H Therouteistoahost,thatis,thedestinationisaco

hostaddress.Ifthisflagisnotset,therouteistoa

network,andthedestinationisanetworkaddress:a

networkID,oracombinationofanetworkIDanda

ID.Thenetstatcommanddoesn'tshowit,buteach

networkroutealsocontainsanetworkmask.Ahost

hasanimpliedmaskofallonebits.



S Therouteisstatic.Thethreeentriescreatedbyther

commandinFigure18.2arestatic.



C Therouteisclonedtocreatenewroutes.Twoentries

thisroutingtablehavethisflagset:(1)theroutefor

localEthernet(140.252.13.32),whichisclonedbyA

createthehost-specificroutesofotherhostsonthe

Ethernet,and(2)therouteformulticastgroups(224

whichisclonedtocreatespecificmulticastgrouprou

suchas224.0.0.1



L Theroutecontainsalink-layeraddress.Thehostrou

thatARPclonesfromtheEthernetnetworkroutesall

thelinkflagset.Thisappliestounicastandmulticas

addresses.



R Theloopbackdriver(thenormalinterfaceforroutes

thisflag)rejectsalldatagramsthatusethisroute.



Theabilitytoenteraroutewiththe"reject"flagw

providedinNet/2.Itprovidesasimplewayof

preventingdatagramsdestinedtonetwork127fro

appearingoutsidethehost.SeealsoExercise6.6



Before4.3BSDReno,twodistinctroutingtablesweremaintainedbythekernelfor

addresses:oneforhostroutesandonefornetworkroutes.Agivenroutewasente

onetableortheother,basedonthetypeofroute.Thedefaultroutewasstoredin

networkroutingtablewithadestinationaddressof0.0.0.0.Therewasanimplied

asearchwasmadeforahostroutefirst,andifnotfoundasearchwasmadefora

route,andifstillnotfound,asearchwasmadeforadefaultroute.Onlyifallthree

failedwasthedestinationunreachable.Section11.5of[Leffleretal.1989

hashtablewithlinkedlistsusedforthehostandnetworkroutingtablesinNet/1.



Majorchangestookplaceintheinternalrepresentationoftheroutingtablewith4

Reno[Sklower1991].Thesechangesallowthesameroutingtablefunctionstoacc

routingtableforotherprotocolsuites,notablytheOSIprotocols,whichusevariab

addresses,unlikethefixed-length32-bitInternetaddresses.Theinternalstructure

changed,toprovidefasterlookups.



TheNet/3routingtableusesaPatriciatreestructure[Sedgewick1990]toreprese

hostaddressesandnetworkaddresses.(Patriciastandsfor"PracticalAlgorithmto

InformationCodedinAlphanumeric.")Theaddressbeingsearchedforandtheadd

thetreeareconsideredassequencesofbits.Thisallowsthesamefunctionstoma

searchonetreecontainingfixed-length32-bitInternetaddresses,anothertreeco

fixed-length48-bitXNSaddresses,andanothertreecontainingvariable-lengthOS

addresses.



TheideaofusingPatriciatreesfortheroutingtableisattributedtoVanJacobson

[Sklower1991].Theseareactuallybinaryradixtrieswithone-waybranchingrem



Anexampleistheeasiestwaytodescribethealgorithm.Thegoalofroutinglooku

themostspecificaddressthatmatchesthegivendestination:thesearchkey.The

specificimpliesthatahostaddressispreferredoveranetworkaddress,whichisp



Tài liệu bạn tìm kiếm đã sẵn sàng tải về

Chapter 18. Radix Tree Routing Tables

Tải bản đầy đủ ngay(0 tr)

×