网站开发五人分工,朋友圈软文范例,无锡做网站公司费用价格,自己电脑做服务器建网站路由协议
Eigrp EIGRP:Enhanced Interior Gateway Routing Protocol 即 增强内部网关路由协议。也翻译为 加强型内部网关路由协议。 EIGRP是Cisco公司的私有协议#xff08;2013年已经公有化#xff09;。 EIGRP结合了链路状态和距离矢量型路由选择协议的Cisco专用协议2013年已经公有化。 EIGRP结合了链路状态和距离矢量型路由选择协议的Cisco专用协议采用弥散修正算法DUAL来实现快速收敛可以不发送定期的路由更新信息以减少带宽的占用支持Appletalk、IP、Novell和NetWare等多种网络层协议。该协议是一个内部网关协议。不同协议类型如下
IGP内部网关协议在一个自治系统内运行。比如RIP、OSPF、IS-IS、EIGRP等。EGP外部网关协议用于连接不同的自治系统。比如BGP
EIGRP报文
#字段解释
Cisco EIGRPVersion: 2 #协议号Opcode: Hello (5) #Opcode字段,报文类型1 Update、 3 Query、 4 Reply、 5 Hello/ACKChecksum: 0xeecb [correct][Checksum Status: Good]
# 标志(0x01表示INIT,0x02表示CR) INIT标志表示发送给新邻居的第一个初始化Update报文,这个报文将携带所有的路由信息,而以后的普通的Update报文将只携带变化了的路由信息Flags: 0x00000000.... .... .... .... .... .... .... ...0 Init: Not set.... .... .... .... .... .... .... ..0. Conditional Receive: Not setCR状态的作用
某路由器R在一个接口上有A,B,C三个邻居.它向这个接口发送了一个Update报文,然后收到了A,C的确认,但是因为某种原因没有收到B的确认,这样无法知道B是否收到了这份Update报文.此时,路由器R既不想继续等B的确认;也不希望B在没有收到第一份Update报文的情况下接收第二份Update报文,因为这种失序有可能引起混乱.于是,路由器R发了一个带有Sequense TLV的Hello报文,里面列出了B的IP地址,这样A,C就会将自己置于CR状态,B则会保持正常态.R发出的后续Update报文将在报文头中打上CR标志,这样只有A,C才会接收到这些报文,而B因为不是CR状态,将会忽略带有CR标志的报文,这样就保证了B不会接收到失序的报文.路由器R将在稍后向B依次发送B所错过的报文
.... .... .... .... .... .... .... .0.. Restart: Not set.... .... .... .... .... .... .... 0... End Of Table: Not set #分享路由信息Sequence: 0 #报文的序列号用于确认机制不需要确认的报文如Hello报文这个域为0.Acknowledge: 0 #文携带的确认信息.表示已经收到了此序列号的报文.Virtual Router ID: 0 (Address-Family)Autonomous System: 1 #自治系统号一般来说就是进程号.ParametersType: Parameters (0x0001)Length: 12K1: 1K2: 0K3: 1K4: 0K5: 0K6: 0Hold Time: 15Software Version: EIGRP12.4, TLV1.2Type: Software Version (0x0004)Length: 8EIGRP Release: 12.04EIGRP TLV version: 1.02# Sequense TLV可能出现在Hello报文中,它的TLV Type为0x0003,它的作用让某些邻居路由器进入到CR(Conditional Receive)状态.表示了一个邻居路由器的IP地址,Sequense TLV可以携带多个IP地址的列表.凡是接收到这个TLV的邻居路由器将检查自己是否在这个列表中,如果不在这个列表中,则把自己置为CR状态.只有处于CR状态的路由器,才能接收带有CR标志的报文.(EIGRP报文头部分中关于Flags字段的说明).SequenceType: Sequence (0x0003)Length: 9Address length: 4IP Address: 10.0.0.1Next Multicast Seq TLV可以出现在Hello报文中,它的TLV Type为0x0005.它需要和与Sequense TLV配合使用,单独的Next Multicast Seq TLV没有意义.在有Sequense TLV,但没有Next Multicast Seq TLV时,表示处于CR状态的邻居路由器可以接收以后所有带CR标志的报文.在有Sequense TLV和Next Multicast Seq TLV都有时,则Next Multicast Seq TLV指定了一个序列号,处于CR状态的邻居路由器只可以接收带CR标志,并且序列号为这个指定序列号的报文.Next multicast sequence: 25Type: Next multicast sequence (0x0005)Length: 8Multicast Sequence: 25 #Seq Number:下一个可以接收的多播报文的序列号.# update消息Opcode: Update (1)Checksum: 0x24b9 [correct][Checksum Status: Good]Flags: 0x00000008, End Of Table.... .... .... .... .... .... .... ...0 Init: Not set.... .... .... .... .... .... .... ..0. Conditional Receive: Not set.... .... .... .... .... .... .... .0.. Restart: Not set.... .... .... .... .... .... .... 1... End Of Table: Set #标志位Sequence: 24 Acknowledge: 23Virtual Router ID: 0 (Address-Family) #入这条路由的路由器的IP地址Autonomous System: 100 #引入这条路由的路由器所在的自治系统.Internal Route(IPv4) 192.168.1.0/24Type: Internal Route(IPv4) (0x0102) # 0x0103表示扩展路由Length: 28 NextHop: 0.0.0.0 #路由的下一跳的IP地址.#Delay,Bandwidth,MTU,Hop Count,Reliability,Load:依次是总延时,最小带宽,MTU值,跳数,可信度,负载.Legacy MetricScaled Delay: 2560 #延迟Scaled BW: 25600 #带宽MTU: 1500 #MTUHop Count: 0 #路由器跳数Reliability: 255 Load: 1Route Tag: 0Flags.... ...0 Source Withdraw: False.... ..0. Candidate Default: False.... .0.. Route is Active: False .... 0... Route is Replicated: FalsePrefix Length: 24Destination: 192.168.1.0 1.Hello用于邻居发现、建立、保活。目标地址为224.0.0.10Hello包在邻居收到后不需要确认。 用于邻居的发现和维护 5s一次 默认使用组播224.0.0.10发送目标地址 ERIP的组播地址 发现、建立、维护邻居关系 发送的时候使用接口主IP地址作为源不会使用辅IP地址 K值全部255时也叫goodbye消息 网络收敛后只有hello包发送
2.Update更新包携带路由条目信息—目标网络号度量值。通过组播发送Update数据包邻居收到后必须回复确认消息。 传递路由更新仅包含需要的路由条目 收到第一个Hello包以单播传送全部路由路由信息变化以组播方式发送变化的路由信息 当为指定neighbor的一台路由器发更新时使用Unicast(P-TO-P) 当为多台路由器发更新时使用Multicast.(MA)----可靠包
3.Query查询包当路由信息丢失并没有备用路由时使用Query数据包向邻居查询邻居必须回复确认。 当找不到Feasible Successor时发送查询报文Multicast----可靠包 若A发现路由变化先发Update再发Query
4.Reply应答包是对邻居Query数据包的回复也需要邻居回复确认。
回应查询报文单播。Unicast----可靠包//B收到Query后会先发ACKReply
5.ACK确认包是对收到的数据包的确认告诉邻居自己已经收到数据包了收到Ack后不需要再对Ack做回复因为这是没有意义的并且可能造成死循环
用来确认Update/Query/Reply (Unicast单播报文
6.SIA-QUERY:
用于避免SIA超时导致邻居关系重置
7.SIA-REPLY:
用于避免SIA超时导致邻居关系重置
使用单播传送的包replyack使用组播传送的包HelloUpdate和query 224.0.0.10可靠包UpdateQueryReply。
##hello消息的结构Opcode字段,报文类型1 Update、 3 Query、 4 Reply、 5 Hello/ACKSequence字段: the 32-bit sequence number used by the RTPACK字段如果此字段不为零的话那么这个包就是ACK包而不是Hello包TLVType / Length / ValueTLV Types分为4个大类如下TLV消息结构
ParametersType: Parameters (0x0001)Length: 12K1: 1K2: 0K3: 1K4: 0K5: 0K6: 0Hold Time: 15 默认3倍1.General TLV Types0x0001 EIGRP Parameters EIGRP参数0x0003 Sequence 序列0x0004 Software Version 软件版本0x0005 Next Multicast Sequence 下一个组播序列2.IP-Specific TLV Types0x0102 IP Internal Routes IP内部路由0x0103 IP External Routes IP外部路由3.AppleTalk-Specific TLV Types0x0202 AppleTalk Internal Routes AppleTalk内部路由0X0203 AppleTalk External Routes AppleTalk外部路由0x0204 AppleTalk Cable Configuration AppleTalk电缆配置4.IPX-Specific TLV Types0x0302 IPX Internal Routes IPX内部路由0x0303 IPX External Routes IPX外部路由hello消息 抓包报文
#普通hello消息
Cisco EIGRPVersion: 2Opcode: Hello (5)Checksum: 0xeecb [correct][Checksum Status: Good]Flags: 0x00000000Sequence: 0Acknowledge: 0 #有值时为 ack消息Virtual Router ID: 0 (Address-Family)Autonomous System: 1ParametersType: Parameters (0x0001)Length: 12K1: 1K2: 0K3: 1K4: 0K5: 0K6: 0Hold Time: 15Software Version: EIGRP12.4, TLV1.2Type: Software Version (0x0004)Length: 8EIGRP Release: 12.04EIGRP TLV version: 1.02#携带下一个组播序号的hello
Cisco EIGRPVersion: 2Opcode: Hello (5)Checksum: 0xc352 [correct][Checksum Status: Good]Flags: 0x00000000.... .... .... .... .... .... .... ...0 Init: Not set.... .... .... .... .... .... .... ..0. Conditional Receive: Not set.... .... .... .... .... .... .... .0.. Restart: Not set.... .... .... .... .... .... .... 0... End Of Table: Not setSequence: 0Acknowledge: 0Virtual Router ID: 0 (Address-Family)Autonomous System: 100ParametersType: Parameters (0x0001)Length: 12K1: 1K2: 0K3: 1K4: 0K5: 0K6: 0Hold Time: 15Software Version: EIGRP12.4, TLV1.2Type: Software Version (0x0004)Length: 8EIGRP Release: 12.04EIGRP TLV version: 1.02SequenceType: Sequence (0x0003)Length: 9Address length: 4IP Address: 10.0.0.1Next multicast sequence: 25Type: Next multicast sequence (0x0005)Length: 8Multicast Sequence: 25
update消息 抓包报文
#会话建立 1 from 1 to 2
Cisco EIGRPVersion: 2Opcode: Update (1)Checksum: 0xfd82 [correct][Checksum Status: Good]Flags: 0x00000001, Init.... .... .... .... .... .... .... ...1 Init: Set.... .... .... .... .... .... .... ..0. Conditional Receive: Not set.... .... .... .... .... .... .... .0.. Restart: Not set.... .... .... .... .... .... .... 0... End Of Table: Not setSequence: 23Acknowledge: 0Virtual Router ID: 0 (Address-Family)Autonomous System: 100
#会话建立 2 from 2 to 1
Cisco EIGRPVersion: 2Opcode: Update (1)Checksum: 0xfd6b [correct][Checksum Status: Good]Flags: 0x00000001, Init.... .... .... .... .... .... .... ...1 Init: Set.... .... .... .... .... .... .... ..0. Conditional Receive: Not set.... .... .... .... .... .... .... .0.. Restart: Not set.... .... .... .... .... .... .... 0... End Of Table: Not setSequence: 23Acknowledge: 23Virtual Router ID: 0 (Address-Family)Autonomous System: 100#路由信息传递1 from 1 to 2
Cisco EIGRPVersion: 2Opcode: Update (1)Checksum: 0x24b9 [correct][Checksum Status: Good]Flags: 0x00000008, End Of Table.... .... .... .... .... .... .... ...0 Init: Not set.... .... .... .... .... .... .... ..0. Conditional Receive: Not set.... .... .... .... .... .... .... .0.. Restart: Not set.... .... .... .... .... .... .... 1... End Of Table: SetSequence: 24Acknowledge: 23Virtual Router ID: 0 (Address-Family)Autonomous System: 100Internal Route(IPv4) 192.168.1.0/24Type: Internal Route(IPv4) (0x0102)Length: 28NextHop: 0.0.0.0Legacy MetricScaled Delay: 2560Scaled BW: 25600MTU: 1500Hop Count: 0Reliability: 255Load: 1Route Tag: 0Flags.... ...0 Source Withdraw: False.... ..0. Candidate Default: False.... .0.. Route is Active: False.... 0... Route is Replicated: FalsePrefix Length: 24Destination: 192.168.1.0#路由信息传递2 from 2 to 1
Cisco EIGRPVersion: 2Opcode: Update (1)Checksum: 0x7d9b [correct][Checksum Status: Good]Flags: 0x00000008, End Of Table.... .... .... .... .... .... .... ...0 Init: Not set.... .... .... .... .... .... .... ..0. Conditional Receive: Not set.... .... .... .... .... .... .... .0.. Restart: Not set.... .... .... .... .... .... .... 1... End Of Table: SetSequence: 24Acknowledge: 24Virtual Router ID: 0 (Address-Family)Autonomous System: 100#更新后的路由信息传递 to 组播
Cisco EIGRPVersion: 2Opcode: Update (1)Checksum: 0xa2d8 [correct][Checksum Status: Good]Flags: 0x00000002, Conditional Receive.... .... .... .... .... .... .... ...0 Init: Not set.... .... .... .... .... .... .... ..1. Conditional Receive: Set.... .... .... .... .... .... .... .0.. Restart: Not set.... .... .... .... .... .... .... 0... End Of Table: Not setSequence: 25Acknowledge: 0Virtual Router ID: 0 (Address-Family)Autonomous System: 100Internal Route(IPv4) 192.168.1.0/24Type: Internal Route(IPv4) (0x0102)Length: 28NextHop: 0.0.0.0Legacy MetricScaled Delay: 4294967295Scaled BW: 256000MTU: 1500Hop Count: 1Reliability: 255Load: 1Route Tag: 0Flags.... ...0 Source Withdraw: False.... ..0. Candidate Default: False.... .0.. Route is Active: False.... 0... Route is Replicated: FalsePrefix Length: 24Destination: 192.168.1.0#更新后的路由信息 from 2 to 1
Cisco EIGRPVersion: 2Opcode: Update (1)Checksum: 0xa2c2 [correct][Checksum Status: Good]Flags: 0x00000000.... .... .... .... .... .... .... ...0 Init: Not set.... .... .... .... .... .... .... ..0. Conditional Receive: Not set.... .... .... .... .... .... .... .0.. Restart: Not set.... .... .... .... .... .... .... 0... End Of Table: Not setSequence: 25Acknowledge: 24Virtual Router ID: 0 (Address-Family)Autonomous System: 100Internal Route(IPv4) #上一条一致
Query消息
Cisco EIGRPVersion: 2Opcode: Query (3)Checksum: 0xf9cc [correct][Checksum Status: Good]Flags: 0x00000000.... .... .... .... .... .... .... ...0 Init: Not set.... .... .... .... .... .... .... ..0. Conditional Receive: Not set.... .... .... .... .... .... .... .0.. Restart: Not set.... .... .... .... .... .... .... 0... End Of Table: Not setSequence: 5Acknowledge: 0Virtual Router ID: 0 (Address-Family)Autonomous System: 1Internal Route(IPv4) 1.1.1.0/24Type: Internal Route(IPv4) (0x0102)Length: 28NextHop: 0.0.0.0Legacy MetricScaled Delay: 4294967295Scaled BW: 0MTU: 1514Hop Count: 0Reliability: 0Load: 0Route Tag: 0Flags.... ...0 Source Withdraw: False.... ..0. Candidate Default: False.... .1.. Route is Active: True #查询消息.... 0... Route is Replicated: FalsePrefix Length: 24Destination: 1.1.1.0
reply
Cisco EIGRPVersion: 2Opcode: Reply (4)Checksum: 0xf9c4 [correct][Checksum Status: Good]Flags: 0x00000000.... .... .... .... .... .... .... ...0 Init: Not set.... .... .... .... .... .... .... ..0. Conditional Receive: Not set.... .... .... .... .... .... .... .0.. Restart: Not set.... .... .... .... .... .... .... 0... End Of Table: Not setSequence: 11Acknowledge: 5Virtual Router ID: 0 (Address-Family)Autonomous System: 1Internal Route(IPv4) 1.1.1.0/24 大概流程发送hello消息后建好邻居表使用update LSA/LSP LSDB链路状态数据库可以形成拓扑表 网络结构Layer 2 |IPV4|EIGRP|FCS protocol| 88 该消息是 先有控制层面再有数据层面数据。 EIGRP使用混合度量值进行计算路径的好坏主要包含5个方面 带宽bd 延迟delay 负载load 可靠性reliability 最大传输单元MTU基本不做计算 eigrp进行路劲好坏计算时用的两个参数AD、FD表示不同的代价代价由上面的五个参数结合k值下文权重计算。A路由器要到达C路由需要经过B路由或者D路由AD是B到C的代价FD则是A通过计算A到B的代价加上AD 得到新的A由B到C的代价FD1 或者A由D到C的代价FD2并使用 min(FD1,FD2)得到最优的路径次路径为备份路径。 建立邻居的必要条件 收到hello ack 匹配ASEIGRP两台路由器需要建立令居需要AS号相同。 相同的度量值K值 路径度量值权重 (0-255) k1 1 带宽 的权重 k2 0 负载 的权重 k3 1 延迟 的权重 k4 0 可靠性 的权重 k5 0 最大传输单元 的权重 其他条件认证通过。
报文交换建立过程
一旦收到任何符合条件AS相同度量值权重K相同邻居的hello报文则将发送者设置为邻居并向对方单播发送update报文该报文不携带路由信息其中 flag init位置位。 step1:10.0.0.2 向224.0.0.10 进行组播 step2: 10.0.0.1收到hello消息后回复给10.0.0.2 单播 update信息修改init标志位产生随机序列号。 setp4: 10.0.0.2 收到来自10.0.0.1的update消息后向10.0.0.1发送update消息并确认序列号实现握手。 step510.0.0.1 收到update消息知道10.0.0.2也是init了开始向10.0.0.2传播数据。并设置end标志位表示10.0.0.1的路由信息已传完。 路由参数
# 10.0.0.1 的一条路由信息。
Internal Route(IPv4) 192.168.1.0/24 Type: Internal Route(IPv4) (0x0102) #内部路由Length: 28 #NextHop: 0.0.0.0 #下一跳0.0.0.0表示自己Legacy Metric #度量值Scaled Delay: 25600 #延迟Scaled BW: 256000 #带宽MTU: 1500 #MTUHop Count: 0 #跳数Reliability: 255 #可靠性Load: 1 #负载Route Tag: 0 #路由标记Flags.... ...0 Source Withdraw: False.... ..0. Candidate Default: False.... .0.. Route is Active: False.... 0... Route is Replicated: FalsePrefix Length: 30Destination: 10.0.0.4 #目的地址step610.0.0.2 收到update消息获取到10.0.0.1的路由信息同时向10.0.0.1传播本机的路由数据。并设置end标志位表示10.0.0.2的路由信息已传完。下面的路由是10.0.0.2的。 step7: 10.0.0.1收到后向10.0.0.2 发送确认消息 确认号为ack 24。 下面为公告自己的最新路由信息 step8:在更新完自身的最佳路由后10.0.0.2 又发hello消息但是携带的参数更多。包括 序列并 携带下一个组播序列号接着马上发送更新后的路由信息。该信息中Sequence中的路由器不会被设置为CR但是其他都会被设置为CR方便2发送新的CR消息通知其他被设置为CR的路由 step9: 10.0.0.2 向组播地址以及 sequence中的路由器 发送update消息 传递参数携带更新的路由信息即只发送已更改的、新增或删除的路由信息而不是发送整个路由表。发送CR消息该消息10.0.0.1不会被接受其他都会被接受 step10: 10.0.0.2 向step8中的 sequence中的路由器 发送update消息 告知最近的路由信息。 step11 : 10.0.0.1 收到update消息后对10.0.0.2进行确认回复。 step12 : 10.0.0.1 向组播地址 发送update消息 传递参数携带更新的路由信息即只发送已更改的、新增或删除的路由信息而不是发送整个路由表。 step13 : 10.0.0.2 向10.0.0.1 回复确认。 更新的路由分析 这里发布的信息是更新的信息表示路由1 更新了3条路由信息以跳数为例子当中涉及其他的权重计算 最终的路由信息综合更新的路由一起。 大致的拓扑结构
两个节点未知 结构突变
1新增网段直连新增网段的设备使用更新包 update消息告知所有邻居即可
2断开网段直连断开网段的设备发出查询包Query消息通过DUAL收集应答包来重新收敛完成全网同步。
3设备无法沟通hello time 5s hold time 15s 。hold time 采取的是倒计时方式计时器结束断开邻居关系同时产生删除所有从邻居出学习到的信息
断开网段
Cisco EIGRPOpcode: Query (3)Internal Route(IPv4) 1.1.1.0/24Type: Internal Route(IPv4) (0x0102)Length: 28NextHop: 0.0.0.0Legacy MetricScaled Delay: 4294967295Scaled BW: 0MTU: 1514Hop Count: 0Reliability: 0Load: 0Route Tag: 0Flags# False即源撤回标志位未设置。该标志位通常与路由划分和路由更新相关用于指示是否有源节点撤回了路由信息。.... ...0 Source Withdraw: False #即候选默认路由标志位未设置。候选默认路由用于在没有更具体的路由匹配时作为默认路径来转发数据包。.... ..0. Candidate Default: False.... .1.. Route is Active: True #该路由是活动的被选定为转发数据流量的路径。.... 0... Route is Replicated: False#False即路由未进行复制。这表示该路由未被复制到其他设备上。Prefix Length: 24Destination: 1.1.1.0参考文献
参考文献
https://zhuanlan.zhihu.com/p/393295263
https://blog.csdn.net/Sisyphuss/article/details/132633851
https://www.cisco.com/c/en/us/support/docs/ip/enhanced-interior-gateway-routing-protocol-eigrp/16406-eigrp-toc.htmleigrp关键参数
1 AS号、系数K值是否与自己的一致。如果一致则建立邻居关系得到一个自治域的路由器列表。同时监听路由器的hello消息如果超时可能该路由已经下线。 编程将K和AS作为 自治域的 key
Cisco EIGRPVersion: 2Opcode: Hello (5) #确定消息类型 #Opcode字段,报文类型1 Update、 3 Query、 4 Reply、 5 Hello/ACKChecksum: 0xee68 [correct][Checksum Status: Good] Flags: 0x00000000 #确定update消息类型的关键参数 为1 表示 握手0x00000008表示交换路由信息Sequence: 0 Acknowledge: 0 Virtual Router ID: 0 (Address-Family)Autonomous System: 100 #确定自治域的关键参数 *******************ParametersType: Parameters (0x0001)Length: 12K1: 1 # #关键参数K2: 0 # #关键参数K3: 1 #关键参数K4: 0 #关键参数K5: 0 #关键参数K6: 0 #关键参数Hold Time: 15Software Version: EIGRP12.4, TLV1.2Type: Software Version (0x0004)Length: 8EIGRP Release: 12.04EIGRP TLV version: 1.02
2 使用update消息获取路由信息根据路由信息 统计路由表
# 1 路由A和B 相互发送该报文 但是IPV4参数不一样 flag为8 携带源ip和目的ip 根据源ip确定该路由的路由变化
Cisco EIGRPVersion: 2Opcode: Update (1) Checksum: 0x24b9 [correct][Checksum Status: Good]Flags: 0x00000008, End Of Table #关键参数 确保这是个报文交换消息Sequence: 24Acknowledge: 23Virtual Router ID: 0 (Address-Family)Autonomous System: 100Internal Route(IPv4) 192.168.1.0/24 #关键参数Internal Route(IPv4) 10.0.0.4/30Internal Route(IPv4) 192.168.3.0/24Internal Route(IPv4) 10.0.0.12/30Internal Route(IPv4) 192.168.4.0/24Internal Route(IPv4) 10.0.0.8/30Internal Route(IPv4) 192.168.2.0/24
#2 AB收到路由信息后双发 发出更新的路由信息 此时flag为0 携带源ip和目的ip 根据源ip确定该路由的路由变化
Cisco EIGRPVersion: 2Opcode: Update (1)Checksum: 0x9dd9 [correct][Checksum Status: Good]Flags: 0x00000000Sequence: 25Acknowledge: 0Virtual Router ID: 0 (Address-Family)Autonomous System: 100Internal Route(IPv4) 192.168.2.0/24Internal Route(IPv4) 10.0.0.8/30Internal Route(IPv4) 192.168.4.0/24
eigrp拓扑图 1 获取自治域。 2 获取路由器信息 根据EIGRP.flag8判断是否是交换路由消息根据EIGRP.flag0判断是否是更新消息。得到两个的报文信息。 3 获取路由器的路由表信息 4 获取具体的网口信息
处理代码-python
class As_system:自治与def __init__(self, key, as_num, routers):self.key keyself.as_num as_numself.routers routersclass Router:def __init__(self, ASNum, router_id, addr_mac, super_mac, ip):self.ASNum ASNum # 路由域self.router_id router_id # idself.addr_mac addr_mac # 路由器macself.super_mac super_mac # 上级路由器self.ip ipself.port 0self.neigbhor [] # 邻居表self.router_info_raw [] # 路由信息self.router_info_other [] # 路由信息self.router_info_new [] # 路由信息self.key hash(addr_mac)class Internal:def __init__(self):self.rouType 0self.nextHop 0self.metric 0self.dst 0class Node:def __init__(self, name):self.name nameself.edges []def add_edge(self, node, weight1):self.edges.append((node, weight))class Graph:def __init__(self):self.nodes {}def add_node(self, node):self.nodes[node.name] nodedef add_edge(self, node1, node2, weight1):if node1.name in self.nodes and node2.name in self.nodes:self.nodes[node1.name].add_edge(node2, weight)self.nodes[node2.name].add_edge(node1, weight)else:raise ValueError(Both nodes must be added to the graph before adding an edge.)def creat_router(packet):前置条件hello消息为组播global router_idglobal router_dictglobal router_ip_dictcomm packet[comm][0]eigrp packet[eigrp]asnum eigrp[ASNum]# keigrp[k] #获取到keyk 01001 # 获取到keyas_key hash((asnum, k))classic []if eigrp[flag] 8 and eigrp[opCode] 1:classic eigrp[classic]router_ip_dict[comm[srcMac]] classicif as_key in router_dict:as_system router_dict[as_key]routers as_system[routers] #routers_mac as_system[routers_mac] #if comm[srcMac] in routers_mac:router routers[comm[srcMac]]if len(classic) 0:router.router_info_raw classicelse:router_id 1router Router(asnum, router_id, comm[srcMac], comm[dstMac], comm[srcAddr])router.router_info_raw classicrouters[comm[srcMac]] routerrouters_mac.append(comm[srcMac])else:router_id 1router_dict[as_key] {key: as_key,as_num: asnum,routers: {},routers_mac: [comm[srcMac]]}routers router_dict[as_key][routers]router Router(asnum, router_id, comm[srcMac], comm[dstMac], comm[srcAddr])router.router_info_raw classicrouters[comm[srcMac]] routerglobals()[router_id] 0
globals()[router_dict] {}
globals()[router_ip_dict] {}import json# 指定本地 JSON 文件路径
file_path data/0EC0A8582C0C1C4F_192.168.88.44_1.json
# file_path data/data.json
with open(file_path, r, encodinggbk, errorsignore) as file:lines file.readlines()
data_list []
for line in lines:data json.loads(line)data_list.append(data)
for item in data_list:creat_router(item) # 创建路由集合print(end) 文章转载自: http://www.morning.qkdbz.cn.gov.cn.qkdbz.cn http://www.morning.lizimc.com.gov.cn.lizimc.com http://www.morning.przc.cn.gov.cn.przc.cn http://www.morning.bswhr.cn.gov.cn.bswhr.cn http://www.morning.ptxwg.cn.gov.cn.ptxwg.cn http://www.morning.zqnmp.cn.gov.cn.zqnmp.cn http://www.morning.tfpqd.cn.gov.cn.tfpqd.cn http://www.morning.yxlpj.cn.gov.cn.yxlpj.cn http://www.morning.3dcb8231.cn.gov.cn.3dcb8231.cn http://www.morning.bsqth.cn.gov.cn.bsqth.cn http://www.morning.rgyts.cn.gov.cn.rgyts.cn http://www.morning.dbylp.cn.gov.cn.dbylp.cn http://www.morning.qlbmc.cn.gov.cn.qlbmc.cn http://www.morning.fmswb.cn.gov.cn.fmswb.cn http://www.morning.qlckc.cn.gov.cn.qlckc.cn http://www.morning.webpapua.com.gov.cn.webpapua.com http://www.morning.nypsz.cn.gov.cn.nypsz.cn http://www.morning.hmmtx.cn.gov.cn.hmmtx.cn http://www.morning.xnlj.cn.gov.cn.xnlj.cn http://www.morning.yrblz.cn.gov.cn.yrblz.cn http://www.morning.lrjtx.cn.gov.cn.lrjtx.cn http://www.morning.srjgz.cn.gov.cn.srjgz.cn http://www.morning.cwjsz.cn.gov.cn.cwjsz.cn http://www.morning.nqyzg.cn.gov.cn.nqyzg.cn http://www.morning.glswq.cn.gov.cn.glswq.cn http://www.morning.qnywy.cn.gov.cn.qnywy.cn http://www.morning.rlpmy.cn.gov.cn.rlpmy.cn http://www.morning.rkdnm.cn.gov.cn.rkdnm.cn http://www.morning.jntcr.cn.gov.cn.jntcr.cn http://www.morning.rblqk.cn.gov.cn.rblqk.cn http://www.morning.krbjb.cn.gov.cn.krbjb.cn http://www.morning.wrtxk.cn.gov.cn.wrtxk.cn http://www.morning.youyouling.cn.gov.cn.youyouling.cn http://www.morning.qglqb.cn.gov.cn.qglqb.cn http://www.morning.xcyhy.cn.gov.cn.xcyhy.cn http://www.morning.dbjyb.cn.gov.cn.dbjyb.cn http://www.morning.qfkdt.cn.gov.cn.qfkdt.cn http://www.morning.qqhersx.com.gov.cn.qqhersx.com http://www.morning.rtpw.cn.gov.cn.rtpw.cn http://www.morning.zfqr.cn.gov.cn.zfqr.cn http://www.morning.bfmq.cn.gov.cn.bfmq.cn http://www.morning.fmrwl.cn.gov.cn.fmrwl.cn http://www.morning.bhdtx.cn.gov.cn.bhdtx.cn http://www.morning.ljllt.cn.gov.cn.ljllt.cn http://www.morning.qnbsx.cn.gov.cn.qnbsx.cn http://www.morning.kntsd.cn.gov.cn.kntsd.cn http://www.morning.sqmlw.cn.gov.cn.sqmlw.cn http://www.morning.nkpml.cn.gov.cn.nkpml.cn http://www.morning.rgxf.cn.gov.cn.rgxf.cn http://www.morning.ygth.cn.gov.cn.ygth.cn http://www.morning.bsqth.cn.gov.cn.bsqth.cn http://www.morning.czqqy.cn.gov.cn.czqqy.cn http://www.morning.mwmtk.cn.gov.cn.mwmtk.cn http://www.morning.sqqhd.cn.gov.cn.sqqhd.cn http://www.morning.nwjd.cn.gov.cn.nwjd.cn http://www.morning.fphbz.cn.gov.cn.fphbz.cn http://www.morning.pwghp.cn.gov.cn.pwghp.cn http://www.morning.lfdmf.cn.gov.cn.lfdmf.cn http://www.morning.rjhts.cn.gov.cn.rjhts.cn http://www.morning.fchkc.cn.gov.cn.fchkc.cn http://www.morning.zmwd.cn.gov.cn.zmwd.cn http://www.morning.xkzmz.cn.gov.cn.xkzmz.cn http://www.morning.dndk.cn.gov.cn.dndk.cn http://www.morning.trsmb.cn.gov.cn.trsmb.cn http://www.morning.mzzqs.cn.gov.cn.mzzqs.cn http://www.morning.mdmc.cn.gov.cn.mdmc.cn http://www.morning.msgnx.cn.gov.cn.msgnx.cn http://www.morning.jwxnr.cn.gov.cn.jwxnr.cn http://www.morning.zbnts.cn.gov.cn.zbnts.cn http://www.morning.pfbx.cn.gov.cn.pfbx.cn http://www.morning.rcfwr.cn.gov.cn.rcfwr.cn http://www.morning.nwmwp.cn.gov.cn.nwmwp.cn http://www.morning.qyjqj.cn.gov.cn.qyjqj.cn http://www.morning.eronghe.com.gov.cn.eronghe.com http://www.morning.dxgt.cn.gov.cn.dxgt.cn http://www.morning.ykkrg.cn.gov.cn.ykkrg.cn http://www.morning.zdydj.cn.gov.cn.zdydj.cn http://www.morning.dpdr.cn.gov.cn.dpdr.cn http://www.morning.kqgqy.cn.gov.cn.kqgqy.cn http://www.morning.mpszk.cn.gov.cn.mpszk.cn