当前位置:网站首页>Read the BGP agreement in 6 minutes.

Read the BGP agreement in 6 minutes.

2022-07-04 12:51:00 Programmer cxuan

See for the last article Ten thousand words long text burst liver routing protocol !

We talked above RIP 、OSPF Agreements are based on AS That is, the agreement within the autonomous system , They can be considered as intra domain routing protocols ; Now we are going to talk about AS The agreement between , This is also called Inter domain routing protocol , Or external gateway protocol , One of its most famous agreements is BGP agreement , At present, the most used protocol version is BGP The fourth version of BGP - 4, Referred to as BGP ( Border Gateway Protocol ).

stay RIP and OSPF Among these agreements , By IP Network address for routing control , and BGP The protocol requires routing control through the entire Internet , The scope is much larger .

BGP The environment and RIP、OSPF The environment is different , The main reason is that the scale of the Internet is too large , It makes the routing between autonomous systems more difficult . The router on the Internet is right for any IP The address can find its destination network through the routing table . This is a very large collection , If link state protocol is used RIP and OSPF Words , You must maintain a very large set of routes , On the one hand, the efficiency of routing table retrieval is very low , And such a huge data item is not easy to maintain . Another point is for each router metric Dissimilarity , It's possible that this metric It's through 100 Routes , And that link arrives 100 A route may directly report an error .

And the routing between autonomous systems must consider the policy problem , These strategies need to put politics 、 regional 、 Safety or economic considerations .

Due to the existence of these special circumstances ,BGP The protocol is just to choose a better route to the destination network , Instead of choosing the best route ,BGP Adopted Path vector routing protocol , It is associated with RIP and OSPF There's a big difference .

stay BGP Agreement , Every AS There are many within the autonomous system BGP Border router , This BGP The border router is quite a spokesman within the autonomous system . Different AS Between BGP If the border router wants to exchange routing information , You need to establish TCP Connect , And then switch on this connection BGP Message to establish BGP conversation , adopt TCP Able to provide reliable service . Two exchange messages BGP Border routers are called each other's temporary stations ( The angel ) Or peer station .

The following figure is a use BGP Border router and AS Diagram of the relationship :

image-20220607204710359

chart 14-18

BGP The network accessibility information exchanged is a series of routes to reach a certain network . When each BGP Once the border router exchanges reachability information , You will choose one to reach each AS Better routing path .

BGP Support classless inter domain routing CIDR, therefore BGP The routing table of should also include the current destination network prefix 、 Next hop router , And what it takes to reach the destination network AS .

stay BGP Just running ,BGP The next stop is to exchange the whole BGP Routing table , In the future, just update the part with new changes when changes occur . This will save network bandwidth and reduce router overhead , This feature and OSPF Very similar .

BGP - 4 There are mainly the following types of messages :

  • OPEN ( open ) message , Used with adjacent BGP Area boundary routers establish relationships , Perform communication initialization .
  • UPDATE ( to update ) message , Used to announce routing information , And list multiple routes that need to be updated .
  • KEEPALIVE ( Keep alive ) message , It is used to periodically verify the connectivity of adjacent stations .
  • NOTIFICATION ( notice ) message , Used to send detected errors .

If two adjacent stations belong to two different autonomous systems , And when one of the temporary stations plans to exchange routes with other temporary stations , At this time, there should be a process of route negotiation . The negotiation process includes whether the temporary router can also accept additional routing information . Therefore, you should send it first when you start the negotiation OPEN message , If the temporary station can accept this relationship , Just use KEEPALIVE Message response . After response , Two temporary stations are even established .

After the relationship is established , We need to maintain each other , This is after establishing the relationship with the couple , As masters, you can't ignore others for three days or two ? As the saying goes , Feelings need to be maintained , Then this routing relationship also needs to be maintained . Each of the two communicating parties needs to be sure whether the other party already exists , So two BGP Border routers need to be switched regularly KEEPALIVE message , Generally, this regular time is 30 s.

BGP Border routers can use UPDATE Message to update the route : Including removing previously notified routes and adding new routes . You can undo multiple routes at a time , But add a new route UPDATE Only one message can be added .

Of course. BGP Does not exist in the " Good news spreads fast, bad news spreads slowly " The problem of ( Feeling RIP The problem of was played out ). because BGP There is not only one border router , And when a router or link fails , because BGP The border router can obtain routing information from more than one adjacent station , So it's easy to choose a new route .

Here is BGP The message format of :

image-20220607204724906

chart 14-19

The four message types introduced above have common message headers , The first one is 19 byte , The general header is mainly divided into three fields .

  • Mark marker Field is 16 Byte length , Used to identify received BGP message , If you don't use authentication , The marking field should be set to all 1.
  • The length field indicates the entire length, including the generic header BGP The length of the message , In bytes , The minimum is 19, The maximum is 4096.
  • The value of the type field is 1 To 4, Corresponding to the introduction sequence of the above messages .

OPEN There are 6 A field , As shown in the following picture

image-20220605080629139

chart 14-20

The first three fields are BGP General message header , The following fields are Version edition ( 1 byte , The value is 4 ), My AS This autonomous system number ( 2 byte , It is the only one in the world 16 Bit system number ) , Hold Time Retention time ( 2 byte , The time in seconds to maintain the relationship as a temporary station ),BGP Identifier BGP identifier ( 4 byte , The router IP Address ), Here are optional lengths and optional parameters .

KEEPALIVE Message only BGP 19 General header of bytes .

image-20220605080701943

chart 14-21

UPDATE The message has five fields , As shown in the figure below

image-20220605080906081

chart 14-22

In the message Unfeasible routes length Indicates infeasible route length , There is a field message behind that is not listed , Namely Withdrawn Routes , List of routes to undo , hinder Total Path Attribute Length Indicates the total length of path attributes , hinder Path attributes It means path attribute , final NLRI Identify the network that sent this message .

NOTIFICATION The message has three fields , As shown in the figure below

image-20220605080711723

chart 14-23

Mainly including error codes ( 1 byte ), Error subcode ( 1 byte ) , There are error data behind .

Link to the original text :6 Minutes to watch BGP agreement .

原网站

版权声明
本文为[Programmer cxuan]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/185/202207041103096330.html