如何将最短路径更改为度量标准以进行路由选择 [英] how to change shortest path to wieght metric for route selection

查看:69
本文介绍了如何将最短路径更改为度量标准以进行路由选择的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

亲爱的所有人,
您能否帮助我如何将最短路径更改为用于度量选择的度量标准.对代码进行修改以进行网络仿真.

Dear all,
Could you help me on how can I change shortest path to wieght metric for route selection.The code is modified for network simulation.

OLSR_rt_entry* entry = rtable_.find_send_entry(entry);
assert(entry != NULL);
ch->next_hop() = entry->next_addr();





OLSR_rt_entry*
OLSR_rtable::find_send_entry(OLSR_rt_entry* entry) {
    OLSR_rt_entry* e = entry;
    while (e != NULL && e->dest_addr() != e->next_addr())
            e = lookup(e->next_addr());
        return e;
}





typedef struct OLSR_rt_entry {
	nsaddr_t	dest_addr_;	//< Address of the destination node.
	nsaddr_t	next_addr_;	//< Address of the next hop.
	nsaddr_t	iface_addr_;	//< Address of the local interface.
	u_int32_t	dist_;		//< Distance in hops to the destination.
	double energy_;		//keep energy value
			
inline nsaddr_t&	dest_addr()	{ return dest_addr_; }
	inline nsaddr_t&	next_addr()	{ return next_addr_; }
	inline nsaddr_t&	iface_addr()	{ return iface_addr_; }
	inline u_int32_t&	dist()		{ return dist_; }
	inline double& energy()    {return energy_;}
} OLSR_rt_entry;




传统仅基于跳数进行选择,但是如果我想更改以使距离相同,则选择能量最高的那个

提前谢谢您.




the traditional is select based only on hop count but if i ''d like to change such that if the distance is the same select the one that have the highest energy

thank you in advance

推荐答案

好吧,发布的代码没有显示任何选择",仅显示了一些查找,结构和其他内容.

在某个地方,您必须数跳数"才能确定最小跳数"(我在这里看不到).在某个地方,您必须尝试多个起点或遍历所有可能的互连,并为最小跃点"保留最佳候选"(我在这里看不到).

因此,在该算法中,当您计算跃点"时,还应该对能量"求和.当您结束遍历一条路径时,您将知道该路径的总跳跃"以及该路径使用的总能量".

使用两个值来确定哪个是最佳候选人",其中跳跃"优先,而能量"则是平局.

那是我能用很少的信息做的最好的事情.
Well, the code posted does not show any "choosing", only some lookups and structures and other things.

Somewhere, you have to be counting "hops" to determine "least hops" (I don''t see that here). Somewhere, you have to be trying multiple starting points or traversing all the possible interconnections and retaining the "best candidate" for the "least hops" (I don''t see that here).

So, in that algorithm, while you''re counting "hops", you should also be summing "energy". When you end traversing one path, you will know the total "hops" for that path and the total "energy" used by that path.

Use both values in deciding which is the "best candidate", with "hops" taking precedence and "energy" being the tie breaker.

That''s the best I can do with so little information.


感谢您的指导.实际上文件确实很大,一开始我仍然找不到该路径我认为它是在我显示的节点中计算的.如果找到,我会立即将其发布.
thank you for your guide.Actually the file is really huge and I still couldn''t find that path as at first i think it calculate in the node I showed.If i find,i''ll post it immediately.


我认为与之相关的另一部分是

Another part i think it related is

void
OLSR::rtable_computation() {
for (int h = 0; ; h++) {

for (topologyset_t::iterator it = topologyset().begin();
		it != topologyset().end();
		it++) {
		OLSR_topology_tuple* topology_tuple = *it;
		OLSR_rt_entry* entry1 = rtable_.lookup(topology_tuple->dest_addr());
		OLSR_rt_entry* entry2 = rtable_.lookup(topology_tuple->last_addr());
if (entry1 == NULL && entry2 != NULL && entry2->dist() == h) {							rtable_.add_entry(topology_tuple->dest_addr(),
			entry2->next_addr(),
			entry2->iface_addr(),
			h+1,
			entry2->reserved());
			}
		}
}


这篇关于如何将最短路径更改为度量标准以进行路由选择的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆