一共分为5种报文open,Update,Notification,Keep alive,Router-refresh,其中keepalive为周期性报文其它都为触发式发送,这些报文有相同的头部报文,长度为19字节。
头部报文
![](https://img-blog.csdnimg.cn/img_convert/628c9efee76d8c61d51765206e554cfd.png)
![](https://img-blog.csdnimg.cn/img_convert/225d97cb0ce59e1f5940822a280cda1b.png)
标记(Marker):16字节, 可以使用检测对等体之间的同步的丢失,已经在支持验证功能时用于来验证报文,不适用时为1
长度(Lenght):报文总长度,值为19~4096
类型:BGP报文类型,取值为1~5
open报文
是TCP连接建立后发送的第一个报文,用于建立BGP对等体之间的连接关系
![](https://img-blog.csdnimg.cn/img_convert/e9624c9cccf0cd76bb74dd13fd9aa7de.png)
![](https://img-blog.csdnimg.cn/img_convert/496bb2fa29a6860a2cae0968e4cd0f07.png)
版本(version):BGPv4
我的自治系统(My Autonomous System):BGP的发起者的AS号,来比较两端是IBGP还是EBGP邻居
保持时间(Hold time):保持时间,指收到一个keepalive的等待最长时间,指定时间内为收到,则BGP连接中断,路由器两端发送的时间不一致也会成功建立邻居, 会协商选择出一个最小的时间为协商时间
BGP标识符(BGP Identifier):发送者的路由器ID,用来表示BGP路由器,每个BGP设备都得携带一个唯一的路由器ID,否则对等体之间无法建立BGP连接,和ospf的路由ID相同。
Update报文
用于在对等体之间交换路由信息。它既可以发布可达路由信息,也可以撤销不可达的路由信息。
![](https://img-blog.csdnimg.cn/img_convert/5c949a78213c2ff804f9708042aec286.png)
![](https://img-blog.csdnimg.cn/img_convert/9aacd71ce5f76556c4025cb71721a65f.png)
![](https://img-blog.csdnimg.cn/img_convert/f3bfbfaaef0a61b1ee5b5e0f46fd75b7.png)
不可用路由长度(Withdrawn routes length):撤销路由字段的整体长度,如果为0,测说明没有路由被撤销,并且报文中部位出现撤销路由字段
撤销路由(Withdrawn Routers):可变的长度和路由不可达的列表
全部路径属性长度(Total Path Attribute Length):路径属性的长度,为0则表示没有路径属性字段
路径属性(Path Attributes):用于路由控制
网络层可达信息(network Layes Reachability Information ):是可达路由的前缀长度的二元组
Notification报文
当BGP检测到错误状态时,就向对等体发出Notification报文,之后BGP连接会立即中断。
![](https://img-blog.csdnimg.cn/img_convert/e611995b57d8401bc22f5f8fc3c9a4a1.png)
![](https://img-blog.csdnimg.cn/img_convert/d7d3a59150873f10311b8046c00c8d62.png)
错误编码(Error Code):错误类型
错误字码(Error Subcode):错误类型更详细的信息
数据(Data):判断错误的原因
reset bgp all
Keepalive报文
BGP会周期性(默认为60秒)地向对等体发出Keepalive 报文,用来保持连接的有效性
Router-refresh报文
refresh bgp all import
用来要求对等体重新发送指定地址族的路由信息。
![](https://img-blog.csdnimg.cn/img_convert/e1b28c7bb1d98031c859aa5f8fb1cec6.png)
地址族标识可以是IPv4或IPv6
子地址族标识可以是单播或组播路由等