BGP基于TCP,端口号179.

每隔30S主动发起TCP连接,邻居进入Active

BGP(Border Gateway Protocol )边界网关协议01_CISCO

1.由于邻居没有启用BGP,邻居被重置2.可以看出,BGP的TCP连接是由先发起TCP连接的路由器去发送,去访问邻居的高端口

BGP(Border Gateway Protocol )边界网关协议01_CISCO_02

 

Neighbor        V    AS MsgRcvd MsgSent   TblVer  InQ OutQ Up/Down  State/PfxRcd

12.0.0.1        4     1       0       0        0    0    0 never    Active

 

BGP基于TCP,端口号179

TCP三次连接:

BGP(Border Gateway Protocol )边界网关协议01_职场_03

BGP报头:

BGP(Border Gateway Protocol )边界网关协议01_BGP_04

OPEN消息:

BGP(Border Gateway Protocol )边界网关协议01_BGP_05

 

如果接收到得OPEN消息是可接受的,就发送一条KEEPLIVE,用来确认OPEN消息。

BGP(Border Gateway Protocol )边界网关协议01_职场_06

 

Keeplive:

Keeplive以保持时间的1/3(不能小于1S)来交换,保持时间为0的话,就不发送Keeplive

Keeplive中只有16byte的标志+2byte的长度+1byte的类型=keeplive19 byte

BGP(Border Gateway Protocol )边界网关协议01_职场_07

 

Update消息:

BGP(Border Gateway Protocol )边界网关协议01_BGP_08

 

每一个Update报文只能宣告一条可行路由,撤销多条不可行路由。因为路径属性只可能描述一条路由,如果有多条路由存在,无法判断路径属性描述的是哪条路由。 

Update报文可选的还有一个 withdraw routes  该字段列出一个要退出服务的路由器列表,以长度,前缀二元组形式表示。

 

notification 消息:

检测到差错后发送此消息,发出消息后,立即关闭BGP连接

BGP(Border Gateway Protocol )边界网关协议01_休闲_09

 

BGP状态机

第一台启动BGP进程的路由器(主动)

*Oct  2 21:43:44.411: BGP: 12.0.0.1 open active, local address 12.0.0.2

*Oct  2 21:43:44.471: BGP: 12.0.0.1 went from Active to OpenSent

*Oct  2 21:43:44.471: BGP: 12.0.0.1 sending OPEN, version 4, my as: 2, holdtime 180 seconds

*Oct  2 21:43:44.475: BGP: 12.0.0.1 send message type 1, length (incl. header) 45

*Oct  2 21:43:44.571: BGP: 12.0.0.1 rcv message type 1, length (excl. header) 26

*Oct  2 21:43:44.575: BGP: 12.0.0.1 rcv OPEN, version 4, holdtime 180 seconds

*Oct  2 21:43:44.575: BGP: 12.0.0.1 rcv OPEN w/ OPTION parameter len: 16

*Oct  2 21:43:44.575: BGP: 12.0.0.1 rcvd OPEN w/ optional parameter type 2 (Capability) len 6

*Oct  2 21:43:44.575: BGP: 12.0.0.1 OPEN has CAPABILITY code: 1, length 4

*Oct  2 21:43:44.579: BGP: 12.0.0.1 OPEN has MP_EXT CAP for afi/safi: 1/1

*Oct  2 21:43:44.579: BGP: 12.0.0.1 rcvd OPEN w/ optional parameter type 2 (Capability) len 2

*Oct  2 21:43:44.579: BGP: 12.0.0.1 OPEN has CAPABILITY code: 128, length 0

*Oct  2 21:43:44.579: BGP: 12.

R2(config)#0.0.1 OPEN has ROUTE-REFRESH capability(old) for all address-families

*Oct  2 21:43:44.579: BGP: 12.0.0.1 rcvd OPEN w/ optional parameter type 2 (Capability) len 2

*Oct  2 21:43:44.583: BGP: 12.0.0.1 OPEN has CAPABILITY code: 2, length 0

*Oct  2 21:43:44.583: BGP: 12.0.0.1 OPEN has ROUTE-REFRESH capability(new) for all address-families 

BGP: 12.0.0.1 rcvd OPEN w/ remote AS 1

*Oct  2 21:43:44.583: BGP: 12.0.0.1 went from OpenSent to OpenConfirm

*Oct  2 21:43:44.583: BGP: 12.0.0.1 went from OpenConfirm to Established

Active:

BGP尝试与邻居初始化TCP连接,如果TCP连接成功,发送OPEN报文,并迁移到Opensent状态。

OpenSent:

已经发送了Open报文,等待来自邻居的Open消息,然后检查必要参数,如果存在差错则会发送notification消息,并迁移到空闲状态

                                                                                                      如果没有错,发送Keeplive消息并协商保持时间和Keeplive定时器。并迁移到openconfirm

Openconfirm:

等待Keeplive或notification消息,如果接收到得是前者,转入established,如果是后者或断开TCP连接的请求,则转入idle状态。

established:

BGP对等连接已经完全建立。

 

第二台启动的路由器(被动)

*Oct  2 21:43:21.895: BGP: 12.0.0.2 went from Idle to Active

*Oct  2 21:43:21.907: BGP: 12.0.0.2 open active delayed 31051ms (35000ms max, 28% jitter)

R1(config-router)#

*Oct  2 21:43:44.539: BGP: 12.0.0.2 passive open to 12.0.0.1

*Oct  2 21:43:44.543: BGP: 12.0.0.2 went from Active to Idle

*Oct  2 21:43:44.543: BGP: 12.0.0.2 went from Idle to Connect

*Oct  2 21:43:44.555: BGP: 12.0.0.2 rcv message type 1, length (excl. header) 26

*Oct  2 21:43:44.555: BGP: 12.0.0.2 rcv OPEN, version 4, holdtime 180 seconds

*Oct  2 21:43:44.555: BGP: 12.0.0.2 went from Connect to OpenSent

*Oct  2 21:43:44.559: BGP: 12.0.0.2 sending OPEN, version 4, my as: 1, holdtime 180 seconds

*Oct  2 21:43:44.559: BGP: 12.0.0.2 rcv OPEN w/ OPTION parameter len: 16

*Oct  2 21:43:44.559: BGP: 12.0.0.2 rcvd OPEN w/ optional parameter type 2 (Capability) len 6

*Oct  2 21:43:44.559: BGP: 12.0.0.2 OPEN has CAPABILITY code: 1, length 4

*Oct  2 21:43:44.559: BGP: 12.0.0.2 OPEN has MP_EXT CAP for afi/safi: 1/1

*Oct  2 21:43:44.563: BGP: 12.0.0.2 rcvd OPEN w/ optional parameter type 2 (Capability) len 2

*Oct  2 21:43:44.563: BGP: 12.0.0.2 OPEN has CAPABILITY code: 128, length 0

R1(config-router)#

*Oct  2 21:43:44.563: BGP: 12.0.0.2 OPEN has ROUTE-REFRESH capability(old) for all address-families

*Oct  2 21:43:44.563: BGP: 12.0.0.2 rcvd OPEN w/ optional parameter type 2 (Capability) len 2

*Oct  2 21:43:44.563: BGP: 12.0.0.2 OPEN has CAPABILITY code: 2, length 0

*Oct  2 21:43:44.567: BGP: 12.0.0.2 OPEN has ROUTE-REFRESH capability(new) for all address-families 

BGP: 12.0.0.2 rcvd OPEN w/ remote AS 2

*Oct  2 21:43:44.567: BGP: 12.0.0.2 went from OpenSent to OpenConfirm

*Oct  2 21:43:44.567: BGP: 12.0.0.2 send message type 1, length (incl. header) 45

*Oct  2 21:43:44.611: BGP: 12.0.0.2 went from OpenConfirm to Established

 

idle:

该状态拒绝所有连接,初始化去往邻居的TCP连接。侦听来自邻居的TCP初始化并将状态更改为连接状态。(neighbor以后,会从idle迁移到active,去尝试TCP连接,但这时候已经接受到邻居发来的TCP连接——passive open to 12.0.0.1)

由active状态下,接收到邻居发来的OPEN报文,将状态从active转入到idle,并从idle转入connect,来等待TCP连接完成。

connect:

该状态下,一直等待TCP连接完成,如果TCP连接成功,BGP将发送OPEN报文并进入OPENSENT状态。