09.1 bgp routing protocol

36
HUAWEI TECHNOLOGIES CO., LTD. All rights reserved Internal www.huawei.com ODP500005 BGP Routing Protocol ISSUE 1.0

Upload: dynamicsvt

Post on 10-Nov-2015

284 views

Category:

Documents


5 download

DESCRIPTION

BGP Routing Protocol

TRANSCRIPT

ODA210005 BGP Routing Protocol Upon completion of this course, you will be able to:
Understand the principle of BGP
Understand the features of Attributes
HUAWEI TECHNOLOGIES CO., LTD.
HUAWEI TECHNOLOGIES CO., LTD.
All rights reserved
Overview Of BGP
BGP is an exterior routing protocol, used to transmit routing information between ASs
It is a kind of distance-vector(path-vector) routing protocol and avoids the occurrence of loop in design. It provides additional attribute information for the route
Transfer protocol: TCP; port No.: 179
It supports Classless Inter-Domain Routing (CIDR)
Route updating: transmit incremental routes only
Abundant route filtering and routing policies
Border Gateway Protocol (BGP) is a dynamic routing protocol. Its basic function is to automatically exchange the loopless routing information between Autonomous Systems (AS). By exchanging the path-reachable information with AS sequence attribute, it can construct the topology map of the autonomous area, thus removing the route loop and implementing the routing strategy configured by the user. Compared with protocols like OSPF and RIP, which run inside the autonomous area, BGP is a kind of Exterior Gateway Protocol (EGP) while OSPF and RIP are Interior Gateway Protocol (IGP). BGP is usually used between ISPs.
BGP has been put into use since 1989. Its three earliest versions are RFC1105 (BGP-1), RFC1163 (BGP-2) and RFC1267 (BGP-3) respectively. The current version is RFC1771 (BGP- 4). With the fast development of the Internet, the volume of the routing table expands quickly as well, and the amount of routing information exchanged between ASs is also ever increasing, which affects the network performance. BGP supports Classless Inter-Domain Routing (CIDR), which can effectively reduce the ever-expanding routing table. BGP-4 is fast turning into the actual standard of the Internet border routing protocol. Its features are described as follows:
BGP is a kind of exterior routing protocol, different from interior routing protocol like OSPF and RIP. It focuses on the control of route advertising and the selection of optimal routes, instead of route discovery and calculation.
By taking the AS path information, it can thoroughly solve the problem of route cycle.
To control the advertising and selection of routes, it provides additional route attribute information.
It uses TCP as its transfer layer protocol, thus improving the reliability of protocols.
BGP-4 supports Classless Inter-Domain Routing (CIDR, called supernet sometimes), which is an important improvement on BGP-3. CIDR treats the IP address with a totally new method and does not differentiate Class-A network, Class-B network or Class-C network any longer. For example, an illegal Class-C network address 192.213.0.0 (255.255.0.0) will become a legal super network when expressed by the CIDR method as 192.213.0.0/16. Here, "/16" means that the subnet mask consists of bite 16 counted from the left end of the address. The introduction of CIDR simplifies the Routes Aggregation (RA). In fact, RA is a procedure of combining several different routes, which turns the approach of advertising several routes into that of advertising a single route and thus simplifies the routing table.
During route updating, BGP sends the incremental routes only. In this way, the bandwidth occupied by BGP's route advertising is greatly reduced. So, it is suitable for advertising a large amount of routing information over the Internet.
Due to political and economical reasons, each autonomous system hopes to filter, select and control the routes. Therefore, BGP-4 offers abundant routing strategies, which makes BGP easy to expand so as to support the development of the Internet.
Compared with IGP protocols like OSPF and RIP, the topology map of IGP is more abstract and rough, because what IGP constructs is the topology map of the router inside AS. IGP abstracts the router as several endpoints and the links between routers as the sides. According to the parameter like the link state and certain measurement criteria, each side is assigned with certain metric to form the topology map. According to this topology map, it selects the route with the minimum cost (sum of metric of the sides passing the two points). Here, we suppose that it costs nothing for the router (endpoint) to forward a data message. However, in BGP, the endpoint of the topology map is an AS area and a side is a link between ASs. In this case, we cannot suppose that it costs nothing for the data message to pass an endpoint (AS autonomous area). The cost shall be calculated by IGP. This shows that there is a hierarchical relationship between EGP and IGP. That is, IGP selects the route with the minimum cost inside the AS while EGP selects the route with the minimum cost between ASs.
BGP, as one of EGP, takes into account the factors like link cost between Ass and cost in the AS area (configured by the BGP router) when selecting a route.
As mentioned above, IGP needs to redistribute the routes of other points in the network topology map inside the AS autonomous area. Meanwhile, it sends the routes known by this endpoint (router) like the direct route and static route to other endpoints. As an exterior gateway protocol, the unit adopted by BGP for sending and redistributing routes is the whole AS autonomous area. That is, BGP needs to send all the routes inside the AS where the local router is located, and redistribute all the routes of other AS autonomous areas (supposing no routing strategy is used to control the sending and redistribution). Obviously, the number of routes is far greater than that of routes sent and redistributed by IGP. So, it is not advisable to broadcast the routing information outward like IGP. By sending route incremental, BGP implements the advertising and maintenance of all the routing information: during the initialization, it sends all the routes to the BGP Peer, and at the same time saves the routing information already sent to the BGP Peer in the local host. When the local BGP receives a new route (for example, a new route is redistributed or a new static route is added via IGP), it will compare this new route with the saved information. If it has not been sent before, BGP will send it. Otherwise, it will be compared with the route already sent. If the new route costs less, then it will be sent. Meanwhile, the information already sent will be updated; otherwise, it will not be sent. When the local BGP finds that one route fails (e.g. the corresponding port fails) and this route was once sent, it will send a route withdrawal message to the BGP Peer.
In sum, BGP does not necessarily broadcast all the routing information each time. It only sends the variation value (incremental) of the route after initializing all the routing information. In this way, the minimum communication volume between BGP and the peer is ensured. However, it also makes the BGP more complicated. The reason is that, for IGP, the local routing protocol only needs to send all the routes known at the moment of sending instead of saving any of the information already sent, and the work of selecting routes is done by the peer, whereas the BGP must save the sent routing information for each BGP Peer, so as to confirm whether a route should be really sent before sending a new route.
To reduce the size of the routing table and the communication volume of sending a route, BGP also supports CIDR (Classless Inter-Domain Routing). It uses the route with a shorter subnet mask (compared with the natural mask) to express more routing information in a single route. For example, the range from 202.112.1.0/24 to 202.112.254.0/24 can be expressed by 202.112.0.0/16, thus reducing the size of the routing table and the network traffic volume in the case of routing information transmission.
Meanwhile, as the routing protocol between AS autonomous areas, BGP needs to control the sending and redistribution of routes according to the attributes of different routes due to political and economic factors. So, BGP has abundant routing strategy control means.
Quiz
which of the following are distance vector routing protocol? (choose all that apply)
A: OSPF
B: IS-IS
C: RIP
D: BGP
Which port number does BGP use to setup the TCP connection ?
A: 89
B: 443
C: 179
D: 23
Which one of the following statements about BGP is FALSE?
A. BGP uses TCP port 179.
B. BGP ensures reliability of updates by using the reliable transport services of TCP.
C. BGP speaker will send the update to its peers periods.
unless there is a matching prefix exists in the IP route table.
D. A TCP connection is required before exchanging updates.
HUAWEI TECHNOLOGIES CO., LTD.
which routing protocol running inside the AS
Which routing protocol running between ASs
The Autonomous System (AS) refers to a set of routers, which are managed by the same technical management organization and adopt the unified routing strategy. Each AS has a unique AS number, which is allocated by the management organization authorized by the Internet.
IGP routing protocol such as static route, OSPF , IS-IS etc
BGP only
The Autonomous System (AS) refers to a set of routers, which are managed by the same technical management organization and adopt the unified routing strategy. Each AS has a unique AS number, which is allocated by the management organization authorized by the Internet.
The basic concept of introducing the AS is to differentiate different ASs by different numbers. Thus, when the network administrator does not want his own communication data to pass some AS, this numbering method becomes very useful. Maybe the administrator's network can access this AS absolutely. However, if this AS is managed by his component or lacks enough security mechanism, he needs to avoid this AS. By adopting the routing protocol and AS number, the routers can specify the path between them and the method for routing information exchange.
The AS numbers range from 1 to 65535. Among them, the numbers from 1 to 64511 are the registered Internet number, and those from 64512 to 65535 are the private network numbers.
Quiz
How many AS number available to the public internet network?
A: 1~64511
B: 1~65525
C: 64512~65535
D: 0~65535
Working Mechanism Of BGP
As the application layer protocol, the BGP system runs on a special router. During the first startup of the system, the routing information is exchanged by sending the whole BGP routing table. Later, for the objectives of updating the routing table, only the update message is exchanged. During the operation, the system checks whether the connection is normal by receiving and sending the keep-alive message.
The router, which sends the BGP message, is called the BGP speaker. It continuously receives and generates new routing information, and advertises it to other BGP speakers. When a BGP speaker receives new route advertisement from other ASs, it will advertise this route to all the other BGP speakers inside the AS if this route is better than the currently known route, or currently there is no acceptable route. A BGP speaker calls other BGP speakers that exchange message with it as peer. Several related peers can construct a group.
Generally, a route is generated inside the AS. It is discovered and calculated by some interior routing protocol and transmitted to the boundary of the AS. Then, The Autonomous System Boundary Router (ASBR) spreads it to other ASs via the EBGP connection. During the spreading, the route may pass several ASs, which are called the transitional AS, such as AS5. If this AS has multiple boundary routers, Information will be exchanged among these routers by running IBGP. In this case, the internal routers need not know these exterior routes. They only need to maintain the IP connectivity among the boundary routers, such as AS2, AS3 and AS4. After the route reaches the AS boundary, ASBR can redistribute the route into the interior routing protocol if the interior router needs to know these exterior routes. The exterior routes have a large amount, which will usually exceed the processing capability of the interior routers. So, filtering or aggregation shall be done when redistributing the exterior route, so as to reduce the number of routes. An extreme situation is to use the default route. There is still another AS called Stub AS, such as AS1, AS6 and AS7. Inside such an AS, there is only one ASBR connected to the outside via EBGP, and the communication with other external ASs needs to be connected by the transitional AS.
For a specific ASBR, its routes are obtained in two ways: distributed in from the Peer or redistributed from IGP. For the routes distributed in, filtering will be done according their attributes (e.g. AS path, group attribute) and some attributes (e.g. local precedence, MED value) will be set. Later, specific routes can be aggregated as super network routes if necessary. BGP may distribute in routes that have the same destination from multiple peers and then select the best route according to the rules to add it to the IP routing table. For IGP route, filtering and setting shall be done by the redistribution strategy. BGP sends the preferred BGP route and redistributed IGP route to the peer.
AS1
AS7
AS6
AS5
AS4
AS3
AS2
EBGP
RTB
RTC
IBGP
RTA
RTD
RTE
EBGP
AS100
AS200
AS300
On the router, BGP runs in the following two modes: IBGP (Internal BGP), EBGP (External BGP)
If two peers that exchange BGP messages belong to the same AS, they are Internal BGP (IBGP), such as RTB and RTD.
If two peers that exchange BGP messages do not belong to the same AS, they are External BGP (EBGP), such as RTA and RTB.
Although BGP runs between ASs, it is also necessary to establish BGP connection between different border routers of an AS. Only in this way, can routing information be transmitted in the entire network, such as RTB and RTD. To establish the communication between AS100 and AS300, we need to establish IBGP connection between them.
The direct connection is not necessarily established between IBGP peers physically, but the full logical connection between them must be ensured (it suffices if TCP connection can be created).
In most of the cases, there is physically direct link between EBGP peers. However, if it is hard to realize, remedy can be done by configuring the command "neighbor neighbor-address ebgp-multihop[ttl]". Here, "ttl" is the maximum hop count. Its default value is 64 and the value range is 1-255.
Quiz
Which of the following statements about IBGP routers are true? (Select one.)
A. They must be fully meshed.
B. They can be in a different AS.
C. They must be directly connected.
D. They do not need to be directly connected.
HUAWEI TECHNOLOGIES CO., LTD.
Route Advertising Principles of BGP
BGP Speaker only selects the best one for its own use
BGP Speaker only advertises the routes used by itself to its neighbors
For the routes obtained from EBGP, the BGP Speaker will advertise them to all its neighbors (including EBGP and IBGP)
For the routes obtained from IBGP, the BGP Speaker will not advertise them to its IBGP neighbors
For the routes obtained from IBGP, whether the BGP Speaker will advertise them to its EBGP neighbors depends on the synchronization state of IGP and BGP
Once the connection is established, the BGP Speaker will advertise all its BGP routes to the new neighbors
Route advertising principles of BGP:
In the case of multiple paths, the BGP Speaker only selects the best one for its own use.
The BGP Speaker only advertises the routes used by itself to its neighbors.
For the routes obtained from EBGP, the BGP Speaker will advertise them to all its neighbors (including EBGP and IBGP).
For the routes obtained from IBGP, the BGP Speaker will not advertise them to its IBGP neighbors.
For the routes obtained from IBGP, whether the BGP Speaker will advertise them to its EBGP neighbors depends on the synchronization state of IGP and BGP.
Once the connection is established, the BGP Speaker will advertise all its BGP routes to the new neighbors.
These principles were stipulated by the BGP designers when they were developing the BGP routing protocol. Further study of the reasons is outside the scope of this document.
Quiz
what would BGP router do when the TCP connection established ?
A: exchange the routing table between the BGP neighbors
B: exchange the BGP routes between the BGP neighbors
C: check the BGP version ,as numbers to form the EBGP/IBGP relationship
D: send a keep-a-live packet to the peer
HUAWEI TECHNOLOGIES CO., LTD.
EBGP
EBGP
RTB
RTC
IBGP
RTA
RTD
RTE
RTF
E0:10.1.1.1/24
S0
S1
AS100
AS200
AS300
It is stated in the BGP protocol that: a BGP router does not advertise the routing information learnt from the internal BGP peers to the external peers, unless this information can also be obtained from IGP. If a router can learn about this routing information via IGP, then it can be considered that the route can be broadcast inside AS and the internal connection is ensured.
One of major duties of BGP is to transmit the network reachability information of this AS to other ASs. As shown in the figure above, RTB will encapsulate the routing information toward 10.1.1.1/24 into the UPDATE message, and advertise it to RTE via the TCP connection established by RTC and RTD. If RTE does not take synchronization into account, it will directly accept such routing information and report it to RTF, then if RTF or RTE has the data packet to be sent to 10.1.1.1/24, this packet must pass RTD and RTC if it wants to reach the destination. As the synchronization was not taken into account in advance, the routing tables of RTD and RTC have no routing information to 10.1.1.1/24 and the data packet will be discarded when it reaches RTD. So, BGP must be synchronous with IGP (e.g., RIP, OSPF, etc.). Synchronization means that BGP will not advertise the transitional information to other ASs until IGP broadcasts this routing information successfully in its AS . That is, after a router receives the update information of a destination from the IBGP peer, it shall attempt to verify whether this destination can be reached via the internal AS before advertising it to other EBGP peers (i.e., verify whether this destination is within IGP, and whether the non-BGP router can transmit this traffic to this destination). If IGP knows this destination, it will receive such routing information and then advertise it to EBGP peers. Otherwise, it will consider that this route is asynchronous with IGP and thus will not advertise it.
As shown in the figure above, RTE gets the route going to the network 10.1.1.1/24 inside AS100 via the IBGP neighborhood. RTE will not add it to its own routing table at once, or advertise it to RTF either. Instead, RTE will wait and see whether OSPF can also get the route going to 10.1.1.1/24. If yes, it shows that IGP and BGP are synchronous and then RTE will add this route to its routing table and advertise it to RTF. Otherwise, then IGP and BGP are asynchronous and RTE will not add the route going to 10.1.1.1/24 to its routing table or advertise this route to RTF. There are many solutions, and the simplest one is for RTB to redistribute the BGP routing information to the OSPF routing table and then OSPF advertises it to RTE. In this way, the synchronization is achieved. But this is not recommended usually, because the BGP routing table has a large size, and introducing it into OSPF will bring a heave burden for the system. Another solution is to configure a static route to 10.1.1.1/24 on RTB, and then redistribute this static route into OSPF to achieve synchronization.
HUAWEI TECHNOLOGIES CO., LTD.
OSPF discovers route 18.0.0.1/8
Dynamically redistribute the route discovered by IGP (OSPF) into the BGP routing table of RTB
18.0.0.1/8
OSPF
RTB
AS200
The BGP routing protocol runs between ASs. Its major work is to transmit routing information between ASs, instead of discovering and calculating routing information. The work of discovering and calculating routing information is done by the IGP routing protocol, e.g. RIP and OSPF. The routing information of BGP needs to be redistributed into BGP in the mode of configuration commands.
According to the redistribution mode, it can be classified into three types: purely dynamic redistribution, semi-dynamic redistribution and static redistribution.
Purely dynamic redistribution means that the router gets the routing information by IGP routing protocol and then dynamically redistributes it into BGP.
As shown in the figure above, RTB dynamically detects the routes going to the network 18.0.0.0/8 via OSPF protocol and then dynamically redistributes it into BGP. We call such a kind of route redistribution mode as purely dynamic redistribution.
The route leading to the network 18.0.0.0/8 is redistributed from OSPF. Meanwhile, other routing information of OSPF is also redistributed into BGP.
HUAWEI TECHNOLOGIES CO., LTD.
OSPF discovers the route 18.0.0.1/8
Semi-dynamically redistribute the route discovered by IGP (OSPF) into the BGP routing table of RTB
18.0.0.1/8
RTB
AS200
OSPF
Semi-dynamic redistribution means that the routing information is dynamically discovered and calculated by IGP routing protocol. Part of the specified routing information will be selectively redistributed with the network command when it is redistributed into the BGP system.
AS shown in the figure above, router B dynamically detects the route going to the network 18.0.0.0/8 via OSPF protocol and then redistributes it into BGP statically. Such a kind of route redistribution mode is called semi-dynamic redistribution.
The route to be redistributed should be be specified with the user interface of the router. As a result, only one specified OSPF route is redistributed into the BGP routing table.
HUAWEI TECHNOLOGIES CO., LTD.
Manually configure the static route 18.0.0.1/8
Redistribute the static route manually configured into the BGP routing table of RTB
18.0.0.1/8
AS200
RTB
Static redistribution means that the routing information obtained by the router is the static routing information manually configured, which will be statically redistributed into the BGP system.
As shown in the figure above, router B first establishes a static route going to the network 18.0.0.0/8 and then redistributes it into BGP. Such kind of route redistribution mode is called static redistribution.
As a result, a manually configured route is added into the BGP routing table.
How many methods can you use to installed the route to the bgp routing table ?(choose all apply)
A: Full Dynamic Redistribution
B: Semi Dynamic Redistribution
Open: greeting--"hello, let's make friends!"
Keepalive: I'm alive, don't leave me alone
Update: fresh news...
Notification: i won't play with you any more!
BGP has four types of messagesOPEN, UPDATE, NOTIFICATION and KEEPALIVE.
Between BGP peers, an OPEN message is transmitted so as to exchange information such as version, AS number, hold time and BGP identifier for negotiation.
What UPDATE message carries is route update information, including route withdrawal information, reachable information and its path attributes.
When BGP detects errors (e.g. connection interruption, negotiation error , message error), it will send the NOTIFICATION message to shut off the connection with its peers.
The KEEPALIVE messages are sent periodically between BGP neighbors , so as to ensure the connection is kept alive . The default timer is 60 seconds.
The OPEN message is mainly used to establish the neighborhood (BGP peers). It is the initial handshake information between BGP routers and shall occur before all notification information. Others will respond with the KEEPALIVE message after receiving the OPEN message. Once the handshake succeeds, these BGP neighbors can exchange messages like UPDATE, KEEPALIVE and NOTIFICATION.
Quiz
(1) How many BGP messages available for the BGP version 4(choose all apply)
A: OPEN
B: UPDATE
C: NOTIFICATION
D: KEEPALIVE
(2) How often down the BGP speaker send the KEEPALIVE message to the BGP peers
A: every 30 seconds
B: every 60 seconds
C: every 90 seconds
D: every 10 seconds
HUAWEI TECHNOLOGIES CO., LTD.
BGP messages have the same format: "message header + packet body"
The BGP header is given as follows:
Marker(16 byte)
Length(2 byte)
Type(1 byte)
The format of BGP header is as shown in the figure above. The width of each line is 4 bytes.
Marker authentication information: 16 bytes; all 1s. It is mainly used to check whether the synchronization between BGP peers is lost and verify the incoming BGP information.
Length: 2 bytes, indicating the length of the entire BGP message, including the length of the header. The minimum length of BGP message is 19 bytes (Keepalive message) and the maximum length of BGP message is 4096 bytes.
Type: 1 byte, indicating the message type, such as OPEN or UPDATE.
1.OPEN
2.UPDATE
3.NOTIFICATION
4.KEEPALIVE
Quiz
When a BGP speaker received a message with the type value is 4, which BGP message type did this message belonging to
A: OPEN
B: UPDATE
C: NOTIFICATION
D: KEEPALIVE
Open Message
Open Message consists of the Message header and the structure below
Optional Parameters
Length (1byte)
My Autonomous System: (2-byte unsigned integer), local AS number.
Hold Time: (2-byte unsigned integer), hold time suggested by the originating end.
BGP Identifier: (4-byte) identifier of the router at the originating end.
Optional parameters Len: (1-byte) the total length of optional parameters field.
Optional Parameters: (variable length) optional parameters.
The beginning of the message includes the version number of BGP and the AS number of the sending party. And what follows is the field of hold time, which is the set seconds of hold timer recommended by the sending party. The hold timer prescribes the time length within which BGP neighbors consider the information from the sending party valid. The next field is BGP identifier (BGP), i.e. the identifier of the sending party of BGP. This value is determined during the handshake operation between BGP peers. It remains the same between each local interface and each BGP peer.
HUAWEI TECHNOLOGIES CO., LTD.
Marker(16 byte)
Length(2 byte)
Type(1 byte)
The Keepalive message is mainly used to confirm the availability of links and running states between peer routers. It consists of a BGP data header only. The requirement for the exchange periodically of Keepalive message between peer routers is to ensure the peer can keep the timer within the time limit of expiry.
After a router establishes BGP connection with its neighbors, it will periodically send the Keepalive message to the peers according to the time interval set by Keepalive-interval, indicating whether this connection can be still held.
By default, the time interval between sending Keepalive is 60 seconds.
Quiz
A: every 10 seconds
B: every 30 seconds
C: every 1 minute
D: every 5 minutes
HUAWEI TECHNOLOGIES CO., LTD.
Update Message
An Update Message consists of the header and the following structure
Withdrawn Routes (variable length)
Unfeasible Routes Length (2byte)
Path Attribute Length (2byte)
Path Attribute (2byte)
Unfeasible Routes Len: (2-byte unsigned integer), length of unreachable route.
Withdrawn Routes: (variable length) withdrawn route.
Path Attribute Len: (2-byte unsigned integer), length of path attribute.
Path Attributes: (variable length) path attributes (described below in detail).
Network Layer Reachability Information: (variable length) information on Reachability of the network (destination).
Among them, the expression of the withdrawn route and destination address is <length, prefix>. "length" indicates the length of the address prefix, occupying 1 byte. "prefix" is the address prefix, occupying 1-4 bytes.
The UPDATE message is the most important information in the BGP system, used to exchange routing information between peers. It comprises three parts at most, i.e. unreachable, path attributes, and Network Layer Reachability Information (NLRI).
The UPDATE message can advertise a route to BGP peers, and also can withdraw multiple unreachable routes. The unreachable field includes a list of IP address prefixes of withdrawn routes. The path attributes field is a list of path attributes, including attribute type, attribute length and attribute value. The NLRI field includes a list of reachable IP address prefixes known by the BGP router.
One UPDATE message can advertise one route only at one time, but it can also carry multiple path attributes.
One UPDATE message can also advertise multiple routes at one time, but the path attributes must be the same.
One UPDATE message can list multiple withdrawn routes at one time.
HUAWEI TECHNOLOGIES CO., LTD.
Notification Message
A Notification packet consists of the header and the structure below
Data (variable length)
Exit
A notification message is used when error occurs or the peer connection is stopped. This message carries various error codes (e.g. timer expiry), including error code, auxiliary error code and error information.
Errorcode: (1 byte) error code:
Error subcode: (1 byte) auxiliary error code.
Data: (variable length) depending on various error codes and auxiliary error codes; used to diagnose error causes.
HUAWEI TECHNOLOGIES CO., LTD.
Active
Open-sent
Open-confirm
Established
Idle
Connect
Connect-Retry
Others
The BGP finite state machine (FSM) has six states. The procedure of transition between shows the establishment procedure of BGP neighborhood. The first state is "Idle". Once BGP starts, the state machine enters the "Connect" state. In this sate, if Connect-Retry timer expires, the BGP state machine will stay in the "Connect" state. Meanwhile, BGP will attempt to establish the TCP connection. If the creation of TCP connection fails, the BGP state machine will enter the "Active" state. If the TCP connection is established successfully, the BGP state machine will enter the "OpenSent" state directly. In "Active" state, if the TCP connection cannot be established yet, the BGP state machine will stay in the "Active" state and will not enter the "OpenSent" state until the TCP connection is established successfully. In the "OpenSent" state, once BGP receives a correct Open message, it will enter the "OpenConfirm" state. In the "OpenConfirm" state, if the KeepAlive timer expires, the BGP state machine will stay in the "OpenConfirm" state. And it will not enter the "Established" state until BGP receives the KeepAlive message. Till now, the BGP connection is really established.
In addition, when any of the five states ("Idle" excluded) has errors, the BGP state machine will return to the "Idle" state.
Idle: "Idle" is the first state of BGP connection. In this state, BGP is waiting for a start event. After such an event emerges, BGP will initialize the resources, reset the Connect-Retry timer, and initiate a TCP connection. Meanwhile, it will enter the "Connect" state.
Connect: in this state, BGP establishes the first TCP connection. If the Connect-Retry timer expires, BGP will establish the TCP connection again and continue to stay in the "Connect" state. If the TCP connection is established successfully, it will enter the "OpenSent" state. Otherwise, it will enter the "Active" state.
Active: In this state, BGP is always attempting to establish the TCP connection. If the Connect-Retry timer expires, it will return to the "Connect" state. Otherwise, it will enter the "OpenSent" state. If the TCP connection fails, it will continue to stay in the "Active" state and keep initiating the TCP connection.
OpenSent (Open message has been sent): in this state, TCP connection has been established and BGP has sent the first Open message. Then BGP will be waiting for its peer to send the Open message. Meanwhile, it will check the correctness of the received Open message. If the message has an error, the system will send an error notification and return to the "Idle" state. If no error, BGP will begin to send the Keepalive message and reset the Keepalive timer to start timing. Meanwhile, it will enter the "OpenConfirm" state.
OpenConfirm (confirmation of Open message): in this state, BGP waits for a Keepalive message, and reset the hold timer. If it receives a Keepalive message, it will enter the "Established" state, and the BGP neighborhood is established. If the TCP connection is broken, it will return to the "Idle" state.
Established (connection is established): in this state, the BGP neighborhood is established. In this case, BGP will exchange Update messages with its neighbors and meanwhile reset the hold timer.
Quiz
(1)What happens during a BGP neighbor connection setup if there is an error ?
A: the connection returns to the active state and will retry
B: The connection will go to the active state and will retry using the TCP instead
C: the connection goes to the error state and will not retry
D: the connection will return to the idle state and will retry
(2)Which stable state would be when there were no errors between two BGP speakers
A: Active
B: Established
C: Idle
D: Connected
Application of Messages in BGP
The Open message is sent when establishing a BGP connection via TCP
After the connection is established, the UPDATE message is sent to notify the peer of the routing information if a route needs to be sent or route change occurs
After stabilization, it is necessary to send the KEEPALIVE message periodically to keep the validity of the BGP connection
When an error is found during the running of local BGP, NOTIFICATION message shall be sent to notify the BGP peer
BGP establishes the connection via TCP. The local monitoring port is 179. The establishment of BGP connection needs a series of dialogs and handshakes, which is the same as that of TCP connection. TCP uses the handshake negotiation to advertise parameters like port. The handshake negotiation parameters of BGP include BGP version, hold time of BGP connection, local router ID and authorization information. They are included in the Open message.
After BGP connection is established, the Update message shall be sent to advertise the routing information to the peer end if there is a route to be sent. The Update message is mainly used to advertise the routing information, including failed (withdrawn) route. When the Update message is used to distribute out the route, the attribute of this route needs to be specified so as to help the peer BGP protocol select the best route. For the application of route attribute for BGP to select the route, please refer to the application part of he BGP protocol route attribute.
When the local BGP route changes, the Update message can also be used to correct the routing table of the peer BGP.
If, after exchanging the routing information for a period of time both the local BGP and the peer BGP have no new route advertisement, the condition becomes stable. Now the KEEPALIVE message shall be sent regularly so as to make the BGP connection remain valid. For the local BGP, if it receives no BGP message after the hold time is over, this BGP connection will be regarded as invalid and disconnection of this BGP will take place.
If, during the running, the local BGP detects an error, for example, the local BGP does not support the version of the BGP peer or receives the Update message with illegal structure, it shall send the NOTIFICATION message to notify the BGP peer. When the local BGP exits the BGP connection, it shall also send the NOTIFICATION message. After the BGP receives the NOTIFICATION message, related processing shall be made.
HUAWEI TECHNOLOGIES CO., LTD.
HUAWEI TECHNOLOGIES CO., LTD.
All rights reserved
BGP Path Attributes
A Path Attribute is a characteristic of an advertised BGP route.
Each Path Attribute falls into one of four categories:
Well-known mandatory
Well-known discretionary
Optional transitive
Optional nontransitive
Well-known means it must be recognized by all BGP implementations.
Optional means BGP implementation is not required to support the attribute.
Mandatory means the attribute must be included in all BGP Update messages
Discretionary means they may or may not be sent in a specific Update messages
Transitive means a BGP process should accept the path in which the attribute is included even if it doesn’t support this attribute and it should pass the path on to its peers
Nontransitive means a BGP process that does not recognize the attribute can quietly ignore the Update in which the attribute is included and not advertise the path to its other peers
The enterprises and service providers are often concerned about such questions: how to prevent my private network from being advertised out? How to filter the route update that comes from some neighboring route? how to make certain that I am using this link instead of any other link?. It is through the use of route attribute that BGP answers these questions.
BGP route attribute is a set of parameters. It further describes the specific route so as to enable BGP to filter and select routes. When configuring the route strategy, we often use the route attribute. However, not all of them will be involved.
In fact, route attributes are classified into the following categories:
Mandatory attribute: one that is necessary in the route update data message. In the BGP routing information, this kind of attribute domain has its unique role that cannot be substituted by any others. If it is not included, something will be wrong with the routing information. For example, AS-Path is a mandatory attribute. The BGP uses this attribute to avoid route loop. So, if this attribute is not included, the route may go wrong.
Optional attribute: optional; it is not necessarily required in the route update data message. We set it depending on the actual needs. For example, the MED attribute is an optional attribute, with which we can control the route selection.
Transitional attribute: the attribute that has the transferability between ASs. The field value of a transitional attribute can be transmitted to other ASs and continue to work. For example, as to the Origin attribute, once the origin of the routing information is determined, the field value will exist all the time no matter which AS this routing information will be sent to.
Non-transitional attribute: it only acts locally. Outside the AS, the field value will be restored to the default value, such as Local-preference.
HUAWEI TECHNOLOGIES CO., LTD.
There are six attributes that are commonly used:
Origin: it is used to define the origin of the routing information, indicating how a route becomes the BGP route, such as IGP, EGP, and Incomplete.
As-Path: it is the sequence of the ASs passed by a route, listing all the ASs passed by a route before it reaches the notified network. The BGP speaker puts its own AS preamble to the head of the received AS path, which can avoid route loop and be used for route filtering and selection.
Next hop: it includes the IP address of the next hop border router that reaches the network listed in the update information. The next hop of the BGP is somewhat different from that of IGP. It can be an address of the peer that notifies this route, such as EBGP, which is similar to the IGP. But in some other cases, the BGP uses the next hop of the third party. For example, the IBGP transmits without any change the next hop obtained from the EBGP peer in the AS. In the multiple access media, the BGP takes the actual origin of the route as the next hop, even though it is not the BGP peer.
Multi-Exit-Discriminators (MED): when some AS has multiple entries, the MED attribute can be used to help its external neighboring router select a better entry path. The smaller the MED value of a route, the higher its precedence.
Local-Preference: this attribute is used to select in the AS the route reaching some destination by preference. It reflects the preference level of the BGP speaker for each external route. The bigger the local-preference value, the higher the preference level of the route.
Community: this attribute marks a group of routing information that has the same feature, which is irrelevant with the IP subnet or AS where it is located. The accepted community values are NO-EXPORT, NO-ADVERTISE, LOCAL-AS and INTERNET.
HUAWEI TECHNOLOGIES CO., LTD.
ORIGIN Attribute
ORIGIN specifies the origin of the routing update. When BGP has multiple routes, it uses ORIGIN as one factor in determining the preferred route.
IGP NLRI (Network layer Reachability Information) was learned from a protocol internal to the originating AS. BGP routes are given an origin of IGP if they are learned from an IGP routing table via the network statement.
EGP NLRI was learned from the Exterior Gateway Protocol.
Incomplete NLRI was learned by some other means. Incomplete imply that the information for determining the origin of the route is incomplete. Routes that BGP learns through redistribution carry the incomplete origin attribute.
Which one is preferred? IGP > EGP > Incomplete
When the BGP makes the route decision, it will take the origin attribute into account to determine the precedence levels between multiple routes. Specifically, the BGP will prefer the route with the minimum origin attribute value, i.e. the IGP has the precedence over EGP, and EGP has the precedence over INCOMPLETE. We can configure these three origin attributes manually.
Generally:
If a route is redistributed into the BGP routing table with the specifically, the origin attribute shall be IGP
If a route is obtained via EGP, the origin attribute shall be EGP
Otherwise, the Origin attribute should be Incomplete
Quiz
(1)When import a route from ospf routing protocol into the BGP routing table ,which origin attribute value would this route to be ?
A: IGP
B: EGP
C: OSPF
D: Incomplete
AS_PATH Attribute
AS-PATH uses a sequence of AS numbers to describe the inter-AS path or route to the destination specified by the NLRI.
AS-PATH describes all AS it has passed through ,beginning with the most recent AS and ending with the originating AS.
D(18.0.0.0/8)
AS200
AS300
AS400
AS100
AS500
RTA
RTB
30.0.0.1
30.0.0.2
D (500 200)
The AS-Path attribute is also a mandatory one. It is the sequence of numbers of all the ASs passed by a route to a certain destination. The BGP uses the AS-path attribute as a part of the route update (message update) to ensure a loopless topology structure over the Internet. The BGP will not accept the route of this AS number contained in the AS-path attribute, because this route has been processed by this AS. In this way, route loop is avoided. For this reason, the BGP will add its own AS number to the AS-path attribute when advertising a route to the EBGP peer, so as to record the information on the AS area passed by the route.
Meanwhile, the AS-path attribute acts on route selection. In case other factors are the same, the route with shorter AS path will be selected. As shown in the figure above, the path for the network segment D18.0.0.0/8 in AS200 to reach AS100 by passing AS200, AS300, and AS400 is d1 (400 300 200) and that for it to reach AS100 by passing AS200 and AS500 is d2 (500 200). In this case, the BGP will select the shorter path d2 by precedence.
Note: when the AS-Path field of a route records the AS-number, it will always put the new AS-number in front. As shown in the figure above, the route first passes AS200 and records d2 (200); then it passes AS500 and records: d2 (500 200).
We can increase the path length by adding the pseudo AS number, so as to act on route selection, We can configure RTA to add two AS element ‘200, 200’ to the AS-Path list carried by the route it sent to 30.0.0.2. After such a configuration, the path d2 will change into 500 200 200 200, which is longer than the path d1. So now the BGP will select the shorter path d1 by precedence.
Quiz
(1) When a route is passing AS100 from other AS, where the AS 100 value would be put in the as-path field ?
A: in the front of the AS-PATH list
B: in the back of the AS-PATH list
C: in the middle of the AS-PATH list
D: any place in the AS-PATH list as you want
HUAWEI TECHNOLOGIES CO., LTD.
The Function of AS-PATH
AS can influence its incoming traffic by changing the AS_PATH of its advertising route
AS_PATH can be used for loop avoidance
D(18.0.0.0/8)
AS200
AS300
AS400
AS100
AS500
RTA
RTB
30.0.0.1
30.0.0.2
RTA
I can reach 20.0.0.0/8 via the next hop 10.0.0.3
I can reach 19.0.0.0/8 via the next hop 21.0.0.1
RTC
I can reach 19.0.0.0/8 via the next hop 10.0.0.1
I can reach 20.0.0.0/8 via the next hop 10.0.0.3
The next hop attribute is also an accepted mandatory attribute. The next hop in the BGP is different from that in the IGP. The concept of the next hop in the BGP is a little complicated. It can be one of the following three types:
When the BGP notifies the IBGP of the route obtained from other EBGPs, it does not change the next hop attribute of the route. The local BGP directly transmits the next hop attribute obtained from the EBGP to the IBGP. As shown in the figure above, the next hop attribute is 10.0.0.2 when the RTA notifies the route 18.0.0.0 to RTB via the IBGP.
When the BGP notifies the EBGP peer of the route, the next hop attribute is the port address of the connection between the BGP and its peer. As shown in the figure above, the next hop attribute is 10.0.0.2 when the RTC notifies the RTA of the route 18.0.0.0/8. And when it notifies the RTC of the route 19.0.0.0/8, the next hop attribute is 10.0.0.1.
For the multi-access network (e.g. Ethernet or frame relay), something is different with the next hop. As shown in the figure above, when RTC is advertising the route 20.0.0.0/8 to the EBGP router RTA, it finds that the local port 10.0.0.2 and the next hop 10.0.0.3 of this route are the same shared subnet. So, it uses 10.0.0.3 as the next hop to advertise the route to the EBGP, instead of 10.0.0.2.
Quiz
select the following statement which are true
A: When the BGP notifies the IBGP of the route obtained from other EBGPs, it does not change the next hop attribute of the route
B: When the BGP notifies the IBGP of the route obtained from other EBGPs, it change the next hop attribute to the local ip address.
C: When the BGP notifies the EBGP of the route obtained from other IBGPs, it does not change the next hop attribute of the route
D: When the BGP notifies the EBGP of the route obtained from other EBGPs, it change the next hop attribute to the local ip address.
HUAWEI TECHNOLOGIES CO., LTD.
LOCAL_PREF Attribute
LOCAL_PREF is used to communicate a BGP router’s degree of preference for an advertised route.
LOCAL_PREF is only in updates between internal BGP peers and it is not passed to other AS.
If an internal BGP speaker receives multiple routes to the same destination, it compares the LOCAL_PREF attribute of the routes. The route with highest LOCAL_PREF is selected.
The LOCAL_PREF attribute affects only traffic leaving the AS.
The local precedence attribute is an optional attribute. It represents the precedence level assigned to a route, with which we can compare different routes that have the same destination. The bigger the attribute value, the higher the precedence level of the route. This attribute is used only inside the AS and exchanged between IBGP peers, but not notified to the EBGP peer. In short, the local precedence attribute is used to help the router inside the AS select the optimal egress for it to go out, i.e. select the egress with higher local precedence level.
What shall be noted is: configuring the attribute value of local precedence level will only affect the traffic that leaves this AS, but not the traffic that enters this AS. By default, the value of local precedence attribute is 100.
Quiz
A BGP speaker received the same route from its two IBGP peer with different preference ,which route the BGP speaker will use by default ?
A: the route with the bigger preference value
B: the route with the smaller preference value
C: the route with the bigger router-id
D: the route with the smaller router-id
HUAWEI TECHNOLOGIES CO., LTD.
Dlocal-pref1 100
Dlocal-pref2 200 RTA will select local-pref2 that has higher local preference
AS400
AS100
AS300
AS200
RTA
RTB
RTC
RTD
RTE
RTF
Dlocal-pref1 100
Dlocal-pref2 200
As shown in the figure above, the RTB sets the local precedence level of the route received via the RTD as local-pref1 100, and the RTC sets the local precedence level of the route received via the RTE as local-pref2 200. In this way, the RTA will prefer local-pref2 which has a higher precedence level.
HUAWEI TECHNOLOGIES CO., LTD.
All rights reserved
MULTI-EXIT-DISC (MED) Attribute
MED is carried in EBGP updates and allows an AS to inform another AS of its preferred ingress points. It is meant only for a single AS to demonstrate a degree of preference when it has multiple ingress points.
MED attribute affects only the incoming traffic to the AS.
If all else is equal , an AS receiving multiple routes to the same destination compare the MED of the routes. The lowest MED value is prefered. MEDs are not compared if two routes to the same destination are received from two different AS.
The MED is passed between internal peers of the receiving AS but not passed beyond the receiving AS. MED is used only to influence traffic between two directly connected AS.
The MED attribute is optional, used to indicate the preferable path for the external neighbor router to enter some AS that has multiple entries. When some AS has multiple entries, the MED attribute can be used to help its external neighbor router select a better entry path. That is, select the entry path with smaller MED value by precedence.
A BGP speaker received the same route from its two EBGP peer with different MED value ,which route the BGP speaker will use by default ?
A: the route with the bigger MED value
B: the route with the smaller MED value
C: use tow for backup
D: the route with the smaller router-id
HUAWEI TECHNOLOGIES CO., LTD.
IBGP
As shown in the figure above, we can set the metric value of the network D notified by the RTB as metric 1 10 and that of the network D notified by the RTC as metric 2 20. In this way, the RTA will select the metric 1 that has smaller metric value by precedence.
Generally, the router only compares the MED values of respective EBGP neighbor paths from the same AS, but not those from different ASs. If comparison is required, the Quidway series routers offer the one user interface command to change this default behavior.
Note: By default, it is not allowed to compare the MED attribute values of paths from different AS neighbors, unless it can be confirmed that different ASs adopt the same IGP and route selection method.
HUAWEI TECHNOLOGIES CO., LTD.
Community Attribute
Community is designed to simplify policy enforcement. It identifies a destination as a member of some community of destinations that share one or more common properties.
The COMMUNITY attribute is a set of four octets values AA:NN. AA is AS number. NN is an administratively defined identifier.
In the range of the BGP, a community is a group of destinations that have the same nature. It is not limited to a network or an AS and has no physical boundary.
HUAWEI TECHNOLOGIES CO., LTD.
NO_EXPORT
Routes received carrying this value cannot be advertised to EBGP peers and outside of the confederation
NO_ADVERTISE
Routes received carrying this value cannot be advertised at all to either EBGP or IBGP peers.
LOCAL_AS
Routes received carrying this value cannot be advertised to EBGP peers including peers in other AS within a confederation.
INTERNET
All routes belong to this community by default. Received routes belonging to this community are advertised freely
The community attribute is an optional transitional attribute. Some communities are accepted, i.e. they have the global meaning. These communities are:
NO_EXPORT: after a route with such a community attribute value is received, it shall not be notified to the peers outside an confederation.
NO_ADVERTISE: after a route with such a community attribute value is received, it shall not be notified to any BGP peers.
LOCAL-AS: after a route with such a community attribute value is received, it shall be notified to the peers inside the local AS, but not to any EBGP peers (including the EBGP peers inside the confederation).
INTERNET: After a route with such a community attribute value is received, it shall be notified to all other routers.
Besides these accepted community attribute values, the private community attribute values can also be used for special objectives. These attribute values are marked with some numbers.
One route can have multiple community attribute values, which is similar to the case where a route can have multiple AS numbers in its AS path attribute. The BGP router, which sees multiple community attribute values in one route, can take action according to one or more or all of these attribute values. The router can add or modify the community attribute values before it transmits the route to other peers.
HUAWEI TECHNOLOGIES CO., LTD.
In general, the procedure of local BGP route selection is:
1. If the next hop of this route is unreachable, this route is not selected.
2. Select the route with a higher local preference.
3. Select the originated route by the local router (same local precedence).
4. Select the route with shortest AS path.
5. Select the route with lowest origin code (IGP lower than EGP, EGP lower than Incomplete ).
6. Select the route with smallest MED .
7.Performing load sharing on multiple routes according to the configured number of routes (in case load sharing is configured and there are multiple external routes to the same AS)
8. Select the route with smallest Router ID .
Generally, the procedure of local BGP route selection is:
(1)If the next hop of this route is unreachable, then drop this route.
(2)Select the route with a higher local precedence level.
(3)Select the originated route by the local router (the same local precedence level).
(4)Select the route whose AS path is shortest.
(5)Select the route whose origin type is IGP, EGP, and Incomplete in turn.
(6)Select the route whose MED is smallest.
(7)performing load sharing on multiple routes according to the configured number of routes (in case load sharing is configured and there are multiple external routes to the same AS)
(8)Select the route whose Router ID is smallest.
Select the best answer for the BGP route selection ( )
(1)Select the route with a higher local precedence level.
(2)Select the route whose AS path is shortest.
(3)Select the route whose MED is smallest
(4)If the next hop of this route is unreachable, then drop this route.
A: 4-1-2-3
B: 4-1-3-2
C: 1-2-3-4
D: 1-3-2-4
Principle of BGP
Answer for Quiz
which of the following are distance vector routing protocol? (choose all that apply)
A: OSPF
B: IS-IS
C: RIP
D: BGP
Which port number does BGP use to setup the TCP connection ?
A: 89
B: 443
C: 179
D: 23
Which one of the following statements about BGP is FALSE?
A. BGP uses TCP port 179.
B. BGP ensures reliability of updates by using the reliable transport services of TCP.
C. BGP speaker will send the update to its peers periods.
unless there is a matching prefix exists in the IP route table.
D. A TCP connection is required before exchanging updates.
How many AS number available to the public internet network?
A: 1~64511
B: 1~65525
C: 64512~65535
D: 0~65535
Which of the following statements about IBGP routers are true? (Select one.)
A. They must be fully meshed.
B. They can be in a different AS.
C. They must be directly connected.
D. They do not need to be directly connected.
what would BGP router do when the TCP connection established ?
A: exchange the routing table between the BGP neighbors
B: exchange the BGP routes between the BGP neighbors
C: check the BGP version ,as numbers to form the EBGP/IBGP relationship
D: send a keep-a-live packet to the peer
How many methods can you use to installed the route to the bgp routing table ?(choose all apply)
A: Full Dynamic Redistribution
B: Semi Dynamic Redistribution
D: IGP route redistribute
How many BGP messages available for the BGP version 4(choose all apply)
A: OPEN
B: UPDATE
C: NOTIFICATION
D: KEEPALIVE
How often down the BGP speaker send the KEEPALIVE message to the BGP peers
A: every 30 seconds
B: every 60 seconds
C: every 90 seconds
D: every 10 seconds
When a BGP speaker received a message with the type value is 4, which BGP message type did this message belonging to
A: OPEN
B: UPDATE
C: NOTIFICATION
D: KEEPALIVE
A: every 10 seconds
B: every 30 seconds
C: every 1 minute
D: every 5 minutes
What happens during a BGP neighbor connection setup if there is an error ?
A: the connection returns to the active state and will retry
B: The connection will go to the active state and will retry using the TCP instead
C: the connection goes to the error state and will not retry
D: the connection will return to the idle state and will retry
Which stable state would be when there were no errors between two BGP speakers
A: Active
B: Established
C: Idle
D: Connected
(1)When import a route from ospf routing protocol into the BGP routing table ,which origin attribute value would this route to be ?
A: IGP
B: EGP
C: OSPF
D: Incomplete
When a route is passing AS100 from other AS, where the AS 100 value would be put in the as-path field ?
A: in the front of the AS-PATH list
B: in the back of the AS-PATH list
C: in the middle of the AS-PATH list
D: any place in the AS-PATH list as you want
select the following statement which are true
A: When the BGP notifies the IBGP of the route obtained from other EBGPs, it does not change the next hop attribute of the route
B: When the BGP notifies the IBGP of the route obtained from other EBGPs, it change the next hop attribute to the local ip address.
C: When the BGP notifies the EBGP of the route obtained from other IBGPs, it does not change the next hop attribute of the route
D: When the BGP notifies the EBGP of the route obtained from other EBGPs, it change the next hop attribute to the local ip address.
A BGP speaker received the same route from its two IBGP peer with different preference ,which route the BGP speaker will use by default ?
A: the route with the bigger preference value
B: the route with the smaller preference value
C: the route with the bigger router-id
D: the route with the smaller router-id
A BGP speaker received the same route from its two EBGP peer with different MED value ,which route the BGP speaker will use by default ?
A: the route with the bigger MED value
B: the route with the smaller MED value
C: use tow for backup
D: the route with the smaller router-id
Select the best answer for the BGP route selection ( )
(1)Select the route with a higher local precedence level.
(2)Select the route whose AS path is shortest.
(3)Select the route whose MED is smallest
(4)If the next hop of this route is unreachable, then drop this route.
A: 4-1-2-3
B: 4-1-3-2
C: 1-2-3-4
D: 1-3-2-4