⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 bgp.tex

📁 BCAST Implementation for NS2
💻 TEX
📖 第 1 页 / 共 3 页
字号:
old route MUST be freed because no-one else can do so.  If the inputroute is not modified, the filter MUST NOT free the route because itis stored elsewhere.\subsection{CacheTable Class}The CacheTable class has one parent RouteTable and one childRouteTable.  Its purpose is to ensure that routes changed by precedingfilter-banks are actually stored somewhere.  Primarily it is anoptimization to prevent the filters from having to be applied everytime {\tt lookup\_route} is called, but it also simplifies memory managementbecause downstream tables no longer need to be concerned with whethera route needs to be freed or not. The CacheTable takes as input InternalMessages from its parent, andpasses them through downstream to its child.  If the route in themessage does not have the Changed flag set, then the CacheTable is ano-op.  If the route in the message has the Changed flag set, then theCacheTable will store the route (or delete it from storage in the caseof {\tt delete\_route}).  Thus all InputMessages sent downstream have theChanged flag cleared.A CacheTable in the outgoing branch is flushed (all stored routesdeleted) when the peering corresponding to the relevant plumbingbranch down.  This is because when the peering comes back up, theoutgoing branch should restart with no stored state.  The incomingbranch CacheTable is not explicitly flushed, because the routes willbe removed as the DeletionTable gets round to deleting them.Prematurely flushing the input branch CacheTables would potentiallyresult in the DecisionTable seeing inconsistent inputs.Note that assertion failures in the CacheTable usually indicate thatthe code upstream is incorrectly propagating changes (for exampleeither a delete with no add, two deletes, or two adds).\subsection{NhLookupTable Class}The BGP decision process implemented in DecisionTable is relativelycomplex, and takes into account many possible factors including ``IGPdistance''.  IGP distance is the IGP routing metric for the route toreach the BGP NextHop (which is often a number of IP hops away in thecase of IBGP).  Also of interest is whether the BGP NextHop isactually reachable according to the IGP protocols.  Because of themulti-process architecture of XORP, BGP does not know the IGP distanceor whether the nexthop is reachable.  To find out this information,BGP must query the RIB, and this is done by the NextHopResolver classinstance.  If DecisionTable had to perform this lookup, it wouldbecome very complex because it would have to handle suspending thedecision process while waiting for results from the RIB.  Amulti-threaded implementation would solve this problem, but wouldcause other issues.To solve these problems we insert an NhLookupTable upstream of theDecisionTable.  NhLookupTable queues any updates with NextHopinformation that the NextHopResolver does not know about, pending theresponse from the RIB process.  Thus by the time an update reaches theDecisionTable, the NextHopResolver already has access to the IGPinformation related to the BGP NextHop.A complication comes with {\tt lookup\_route}:\begin{itemize}\item if the lookup matches an {\tt add\_route} in the NhLookupTable queue,the NhLookupTable must return ``lookup unsuccessful''.\item if the lookup matches a{\tt replace\_route} entry in the NhLookupTable's queue, the oldanswer must be given.\end{itemize}In general, the behaviour should be as if the queued updates had notyet been received from the relevant peer.  Note that the time for theRIB to respond should normally be very small compared to the usualdelays for propagating Update messages between peers.\subsection{DecisionTable Class}The DecisionTable is the core of the BGP process.  It takes routechanges from the input branches, and decides whether those changes arebetter or worse than the routes it has already seen.When DecisionTable receives an {\tt add\_route} from one input branch,it queries the other peers input branches using {\tt lookup\_route}.\begin{itemize}\item If none of the other branches returns an answer, then the route is anew one, and can be passed on downstream so long as the BGP NextHop isresolvable.  \item If one or more of the other branches returns ananswer, one of these answers will have been the previous winner.  Thenew route is compared against the previous winner - if it is betterthen a {\tt replace\_route} message is propagated downstream.  If itis worse, then no further action is taken.\end{itemize}When DecisionTable receives a {\tt delete\_route} from one inputbranch, it queries the other peers' input branches in the same way:\begin{itemize}\item If none of the other branches returns an answer, the the {\ttdelete\_route} can be passed on downstream so long as the BGP NextHopwas previously resolvable.\item If one or more of the other branches returns ananswer, one of these answers will be the new winner.  The routes arecompared, and a {\tt replace\_route} will be sent downstream.\end{itemize}The processing for {\tt replace\_route} is similar to that for {\ttdelete\_route} followed by {\tt add\_route}, except that only a singlereplace (or delete in the case where the new nexthop is unreachableand there are no alternatives) will be sent downstream.\subsection{NextHopResolver Class}Unlike most of the previous classes, NextHopResolver is not aRouteTable sub-class.  A BGP implementation has a single NextHopResolverinstance per address family.  The NextHopResolver takes requests toresolve a BGP NextHop address and attempts to resolve the address tothat of the immediate neighbor router that would be used to forwardpackets to the NextHop address.When it receives an address to resolve, the NextHopResolver firstchecks its own routing table.  If the nexthop address can be resolvedthere, then the answer can be returned immediately.  Alternatively, ifits own routing table indicates that the address definitely cannot beresolved, then a negative response can be given immediately.Otherwise it needs to contact the XORP RIB using XRLs to answer thequestion.  In this way, the NextHopResolver obtains a copy of the relevant subsetof the RIBs database related to the NextHops given by BGP.  The RIBwill also keep track of the subset that it has told BGP about.  Ifthis information changes in any way BGP will be informed by the RIB,either directly of the change or that some information is no longercorrect and BGP must query again.The information held by the NextHopResolver is reference-counted sothat it can be removed when it is no longer relevant.  If theinformation contained changes, a notification of the change will bepassed to the DecisionTable, which will propagate the notificationback upstream to the RibIn tables.\subsection{FanoutTable Class}The principle task of the FanoutTable is to distribute route changesthat passed the DecisionTable, and therefore are real changes not justpossible changes.  FanoutTable passes a change to all the outputbranches except the one where the change originated.  In the case of{\tt add\_route} or {\tt delete\_route}, this is simple but a {\ttreplace\_route} may contain an old route and a new route thatoriginate from different peers, so it may be propagated as an {\ttadd\_route} to the peer where the old route originated, as a {\ttdelete\_route} to the peer where the new route originated, and as a{\tt replace\_route} to all the other peers.The secondary task of the FanoutTable is to serve as a queuing pointfor changes when the BGP peers are not capable of keeping up withupdates at the rate we are propagating them.  The advantage of queuingupdates in the FanoutTable as opposed to in the RibOut or PeerHandleris that only one copy of the change needs to be kept, no matter howmany peers are not keeping up.  This is particularly important in thecase where the peer from which we heard most of our routes goes down,and a large number of deletions occur in a short period of time.These deletions need to go to all the remaining peers, and it islikely that we can generate them faster than TCP can transfer them tothe peer.Thus there is a single update queue in the FanoutTable, and a separatepointer into this queue is maintained for each outgoing branch (andhence each peer).  If a output branch indicates it is busy, theFanoutTable will stop propagating changes to it, and instead queue thechanges.  Only when a change has been propagated to all the intendedpeers will it be removed from the queue.  \subsection{RibOutTable Class}The purpose of the RibOutTable is to communicate changes to theoutgoing PeerHandler and hence on to the relevant BGP peer.  TheRibOutTable class accumulates changes (add, delete or replace) in aqueue, and waits for a flush request.  The reason for the queue isthat the incoming PeerHandler split up a single incoming Update messageinto many changes, each with the same Path Attributes.  On output, wewant to accumulate these changes again, so that we can send them on toour peers in a single Update message.  Thus, after the incomingPeerHandler has sent the last change to the RibIn, it sends a flushmessage through.  When this reaches the RibOut, it is the signal totake all the changes that have been queued, and build one or moreUpdate messages from them.  Of course the nature of the decisionprocess and filters mean that changes that arrived together do notalways result in outgoing changes that share the same PathAttributes.  Thus multiple passes over the RibOut queue are required,each accumulating changes that share the same Path Attributes so thatthey can be sent on in the same Update message.In principle, the RibOut could also store pointers to the routinginformation that was passed on to the peer so that Route Refresh(RFC 2918) could be handled efficiently.  In our current implementationwe do not do this - the RibOut maintains no record of the routespassed to the peer.\subsection{RibIpcHandler Class}The RibIpcHandler class is a subclass of PeerHandler, with basicallythe same interface as far as communication with the RibIn and RibOutare concerned. However, instead of communicating with BGP peers, theRibIpcHandler communicates routes to and from the XORP RIB.  Routesare received from the RIB if the RIB has been configured toredistribute routes to BGP.  In addition, all routes we pass to otherpeers are also communicated to the XORP RIB, and hence on to theforwarding engine, so that we can forward packets based on the routinginformation.\section{Background Tasks}The XORP BGP implementation, like all XORP processes, issingle-threaded.  However, certain simple events can cause BGP toperform a great deal of work.  For example:\begin{itemize}\item When a peering goes down, all the routes in the RibIn associatedwith that peer must be deleted, which either results in Withdrawsbeing sent to all remaining peers, or Updates being sent to indicate

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -