Sie sind auf Seite 1von 5

12/10/2014

IPRoutingandSubnets

EventHelix.com
eventstudiomodelobjectand
messageflows
visualetherWiresharkpcap
tocallflow
systemdesignLTEIMSGSMTCP/IP
EmbeddedOOAD
companycontactus
support
facebooklikeusand
stayconnected
Share

Share
Share
Share
Share
More

IPRoutingandSubnets
ThisarticledescribesthebasicsofIProuting.Wewillconsidertheexampleofasimplenetworkand
tracethelifeofapacketasitgetsroutedfromonenodetoanother.Theroutingtablesateachnodewill
bediscussed.
BeforewegointodepthofIProuting,weneedtounderstandIPaddresses.Thisiscoveredinthenext
section.

IPAddressClassification
IPaddressesare32bitintegerswhicharerepresentedinthefamiliardotbasednotation.Thedotbased
notationisnothingbutadecimalrepresentationforeachbyteoftheIPaddress.Forexample,anIP
addresswithahexvalueof0x800A080Bisrepresentedas128.10.8.11.
Theinternet,asthenamesuggests,isanetworkofnetworks.Thustouniquelyidentifyahostonthe
internet,oneneedstoknowthenetwork'sidandthehost'sidinthenetwork.ThusIPaddressconsistof
twocomponents,thenetworkidandthehostid.Thenetworkidisthenumberassignedtoanetworkin
theinternet.Hostidrepresentstheidassignedtoahostinthenetwork.
ThefigurebelowshowsdifferentclassesofIPaddresses.Theseaddressesdifferinthenumberofbits
assignedtothenetworkandhostids.Differentclassesofaddressesservedifferentneeds.Forexample,a
classAIPaddressissuitablewhentheinternetconsistsofasmallnumberofnetworksbuteachnetwork
consistsofalargenumberofhosts.Ontheotherextreme,classCaddressingissuitableforinternetswith
averylargenumberofnetworks,withasmallnumberofhostspernetwork.
s earc h t his webs it e
http://www.eventhelix.com/realtimemantra/networking/ip_routing.htm#.VIhUT9KUdlw

1/5

12/10/2014

IPRoutingandSubnets

AnExampleInternet
Subnets
Thefigurebelowdescribesasmallinternetconsistingofthreenetworks128.8,128.9.1and128.9.2.
Strictlyspeaking,theinternetconsistsof128.8networkand128.9.1and128.9.2subnetworks(subnets).
Aswehaveseenintheprevioussection,128.8and128.9shouldhavebeenclassifiedasthenetwork
portionofaclassBIPaddress.Inthisnetwork128.9hasbeendividedintotwosubnetworks(128.9.1
and128.9.2)byusingoneofthebytesofthetwobytehostidassubnetworkid.
AnotherwaytolookatthisisthatthefirstthreebytesofIPaddressesin128.9.1and128.9.2subnetsare
usedforroutingthepacket.TheotherbitsintheIPaddressaredon'tcarefromroutingpointofview.The
specificationofbitsthatshouldbeusedforroutingisspecifiedbyassociatingasubnetmaskwitha
routingentry.Inthisexample,thesubnetmaskis255.255.255.0(0xFFFFFF00).

IPRouting
Networksintheinternetareconnectedtoeachotherviarouters.Routerscarrytrafficfromone
network/subnettoanother.RoutersmaintainaroutingtabletodecidehowtoroutetheIPpackets.Each
routingentryconsistsofthedestinationaddress,subnetmaskand"routeto"field.Whenamessageneeds
toberoutedtoanIPaddress,thefollowingstepsarefollowed:
1. ThedestinationIPaddressismaskedwiththesubnetmaskandthencomparedwiththedestination
fieldforallentriesintheroutingtable.
2. Thiscomparisonmayyieldamatchwithmorethanoneentrytheentrywiththelongestsubnet
maskwillbeselected.E.g.,apacketdestinedfor128.8.1.2reachingHostAwouldmatchthe
entriescorrespondingto128.8.1.2and128.8.0.Theentrycorrespondingto128.8.1.2willbe
selected,asithasalongersubnetmask.
3. Onceanentryhasbeenselected,the"routeto"fieldisconsultedandtheactiontakendependson
thecontentsofthisfield:
Ifthe"routeto"fieldcontainsSELFthepacketismeantforthisnode.TheIPpacketis
passedtotheOSforapplicationprocessing
http://www.eventhelix.com/realtimemantra/networking/ip_routing.htm#.VIhUT9KUdlw

2/5

12/10/2014

IPRoutingandSubnets

Ifthe"routeto"fieldcontainsaLANinterfaceid,thepacketisdestinedforaLANthatis
directlyconnectedtotherouter/host.Inthiscase,thepacketisrouteddirectlyontheLAN.
Ifthe"routeto"fieldcontainsanIPaddress,thepacketisforwardedtotheIPaddress
specified.FurtherroutingofthepacketwillbecarriedoutbythespecifiedIPaddress.
Note:IProutingalsosupportsadefaultentry.Ifthepacketdoesnotmatchanyotherentry,itisrouted
accordingtothedefaultentry.

MultipleIPAddresses
AnotherimportantaspectofinternetsisanodeintheinternetcanhavemultipleIPaddresses.Therewill
beoneIPaddressperinterface.Forexample,theRouterinthefigureabovehasthreeIPaddresses,viz.
128.8.1.1,128.9.1.1and128.9.2.1.

RoutingofaPacketfromHostAtoHostC
HerewewilltracethepathtakenbyanIPpacketsentfromHostAtoHostC.Routingrelatedfieldsin
theEthernetMACheaderandIPheaderareshown.

HostAoriginatesanIPpackettowardsHostC
http://www.eventhelix.com/realtimemantra/networking/ip_routing.htm#.VIhUT9KUdlw

3/5

12/10/2014

IPRoutingandSubnets

1. ApplicationsendsamessagetoHostCbysendingitto128.9.2.2IPaddress(HostC'sIPaddress).
2. ThisIPaddressmatchestheentrycorrespondingto128.9.0.0.The"routeto"fieldfortheselected
entrycontainsanotherIPaddress128.8.1.1.ThisistheIPaddressoftheRouter.
3. TheIProutingtableisaccessedagainfor128.8.1.1. 128.9.2.2 AND subnet = 128.9.0.0
4. Theentrythatmatches128.8.1.1containsLAN0interfaceid.Thisspecifiesthatthedestination
still in host A routing table
nodeisdirectlyconnectedtothehost.
5. Thispacketispassedtothedevicedriver.
6. DevicedriverconsultstheARPcachetoidentifytheEthernetMACaddresscorrespondingtothe
128.8.1.1.(ARPiscoveredinanotherarticle).
7. EthernetframeissenttotheMACaddressfoundbyARP.
Thepacketsentonthe128.8LANis:
EthernetMACHeader
IPPacketPayload
DestinationMACAddress SourceMACAddress DestinationIPAddress SourceIPAddress Payload
RouterMACAddress
HostAMACAddress 128.9.2.2
128.8.1.2

RoutersendtheIPpackettoHostC
1. RouterreceivestheEthernetframeandpassesittotheIPlayer.
2. IProutingtableisconsultedandamatchingentryisfoundcorrespondingto128.9.2subnet.
3. PacketisroutedontheLAN2interface.
4. HostC'sMACaddressisfoundfromtheARPcache.
5. EthernetframeisaddressedtoHostCMACAddress.
Thepacketsentoverthe128.9.2LANis:
EthernetMACHeader
IPPacketPayload
DestinationMACAddress SourceMACAddress DestinationIPAddress SourceIPAddress Payload
HostCMACAddress
RouterMACAddress 128.9.2.2
128.8.1.2

HostCreceivestheIPpacket

Source IP and destination IP are not changed.


Using MAC address to send packet between two adjacent nodes.

1. HostCreceivestheEthernetframeandpassesittotheIPlayer.
2. IProutingtableissearchedandamatchisdetectedwith128.9.2.2entry.
3. The"routeto"fieldcontainsSELF,sothemessageispassedtothehigherlayerfordeliverytothe
application.
EventStudio

callflowgallery
sequencediagrams
usecases&more
testimonials
downloadfreetrial
VisualEther

http://www.eventhelix.com/realtimemantra/networking/ip_routing.htm#.VIhUT9KUdlw

4/5

12/10/2014

IPRoutingandSubnets

Wiresharkgallery
protocolanalyzer
visualizeWireshark
reverseengineer
downloadfreetrial
Telecom+networking

LTEtutorialsandcallflows
IMScallflows
telecomcallflows
TCP/IPprotocolflows
SoftwareDesign

objectorienteddesign
designpatterns
embeddeddesign
faulthandling
congestioncontrol
Follow

facebook
twitter
linkedin
tumblr
google+
Share

Share
Share
Share
Share
More
Company

contactus
blog
2014EventHelix.comInc.

http://www.eventhelix.com/realtimemantra/networking/ip_routing.htm#.VIhUT9KUdlw

5/5

Das könnte Ihnen auch gefallen