贝尔曼 - 福特距离向量算法具有任意多个节点贝尔、福特、多个、向量

2023-09-12 21:23:49 作者:成王败寇

我想codeA程序,模拟路由器,到目前为止,我的基本设置(路由器可以通过一个模拟的服务器发送和接收的数据包来连接到其他的路由器一类服务器)。每个数据包仅包含该路由器的距离矢量。当路由器收到一个数据包,应该更新它的相应使用Bellman-Ford算法​​自己的距离向量。我遇到的问题是,我发现自己无法实现实际的算法,不作弊,用邻接矩阵。

I'm trying to code a program for a class that simulates a router and so far I have the basics set up ("router" can send and receive packets through an emulated server to other "routers" connected to the server). Each packet contains only the distance vector for that router. When a router receives a packet it is supposed to update it's own distance vector accordingly using the Bellman-Ford algorithm. The problem I'm having is that I am finding myself unable to implement the actual algorithm without cheating and using an adjacency matrix.

举例来说,假设我有3个路由器连接如下:

For example, say I have 3 routers connected as follows:

A ---1--- B ---2--- C

即,A和B为1的链路成本联系,B和C都与2的链路成本相连所以当路由器都启动,它们将发送一个分组到他们的每一个直接连接邻居含有它们的距离向量信息。因此,A将发送路由器B(0,1,INF),B就送A和C(1,0,2)和C就送B(INF,2,0),其中INF是指2路由器不直接相连。

That is, A and B are connected with a link cost of 1, and B and C are connected with a link cost of 2. So when the routers are all started, they will send a packet to each of their directly connected neighbors containing their distance vector info. So A would send router B (0, 1, INF), B would send A and C (1, 0, 2) and C would send B (INF, 2, 0) where INF means the 2 routers are not directly connected.

因此​​,让我们来看看路由器A收到路由器B的数据包要使用Bellman-Ford算法​​如下:计算最小的成本给对方路由器。

So let's look at router A receiving a packet from router B. To calculate the minimum costs to each other router using the Bellman-Ford algorithm is as follows.

Mincost(a,b) = min((cost(a,b) + distance(b,b)),(cost(a,c) + distance(c,b))

Mincost(a,c) = min((cost(a,b) + distance(b,c)),(cost(a,c) + distance(c,c))

所以,我遇到的问题是,我不能为我的生活弄清楚如何实现一个算法,将计算最小路径路由器的其它所有路由器。这是很容易使一个,如果你知道到底有多少路由器那里将要,但你会怎么做时,路由器的数量可以任意大?

So the problem I am running into is that I cannot for the life of me figure out how to implement an algorithm that will calculate the minimum path for a router to every other router. It's easy enough to make one if you know exactly how many routers there are going to be but how would you do it when the number of routers can be arbitrarily big?

推荐答案

您永远可以确保与DVMRP的最短路径。 你没有网络的一件事全球视野。每个路由器工作于尽可能多地看到,什么它认为是re​​stricted--可能会产生误导。查找DVMRP的循环问题。 DVMRP不能有充分的网络信息来处理。

You never can make sure of the shortest paths with DVMRP. You dont have the global view of the network for one thing. Each router is operating on as much as it sees and what it sees is restricted-- can be misleading. Look up the looping problem of DVMRP. DVMRP can never have the full network info to process on.

据isn`t可扩展的两种。其表现是越来越低 作为数字或路由器的增加。这是因为 距离向量更新消息充斥四周,这些消息的电流精度。

It isn`t scalable either. Its performance is increasingly lower as the number or routers increase. This is because of the distance-vector update message flooded around and current accuracy of these messages.

这是最早的组播协议之一。它的性能 相匹配的单播规模的RIP。

It is one of the earliest multicast protocols. Its performance matches that of RIP of the unicast scale.