关于TheOne的仿真机制-由运动模型产生连接数据

本文探讨了TheOne仿真框架中的连接网格机制,如何通过节点的坐标变化来更新连接关系。传统的遍历所有节点检测方法在大规模网络中效率低下,因此采用网格系统,使得节点只需检查本网格及相邻网格内的节点,提高效率。TheOne的接口更新流程由节点运动驱动,断开超距连接并寻找新连接,利用(optimizer.getNearInterfaces(this))获取潜在连接。了解更多详情,可以参考相关博客链接。
摘要由CSDN通过智能技术生成
/**
 * <P>
 * Overlay grid of the world where each interface is put on a cell depending
 * of its location. This is used in cell-based optimization of connecting
 * the interfaces.</P>
 * 
 * <P>The idea in short:<BR>
 * Instead of checking for every interface if some of the other interfaces are close
 * enough (this approach obviously doesn't scale) we check only interfaces that
 * are "close enough" to be possibly connected. Being close enough is
 * determined by keeping track of the approximate location of the interfaces 
 * by storing them in overlay grid's cells and updating the cell information
 * every time the interfaces move. If two interfaces are in the same cell or in 
 * neighboring cells, they have a chance of being close enough for
 * connection. Then only that subset of interfaces is checked for possible
 * connectivity. 
 * </P>
 * <P>
 * <strong>Note:</strong> this class does NOT support negative
 * coordinates. Also, it makes sense to normalize the coordinates to start
 * from zero to conserve memory. 
 */
public class ConnectivityGrid extends ConnectivityOptimizer {
  

上面是TheOne中对连接网格的介绍,节点运动对应坐标改变,坐标改变需要更新连接关系,对于某一个节点来说,如果没有连接网格的支持,需要遍历所有的节点来判断两者是否满足传输range的要求,来决定能否建立connection,这显然不可扩展scale,因为随着网络的增大,这种检测将变得不可行。

所以采用一种网格,将节点对应到网格内,这样每次检测某个节点能否和其它节点建立连接,只需要检测本网格和邻居网络的节点即可。

有点类似Opnet的rxgroup。

/**
	 * Notifies all the connection listeners about a change in connections.
	 * @param type Type of the change (e.g. {@link #CON_DOWN} )
	 * @param otherHost The other host on the other end of the connection.
	 */
	private void notifyConnectionListeners(int type, DTNHost otherHost) {
		if (this.cListeners == null) {
			return;
		}
		for (ConnectionListener cl : this.cListeners) {
			switch (type) {
			case CON_UP:
				cl.hostsConnected(this.host, otherHost);
				break;
			case CON_DOWN:
				cl.hostsDisconnected(this.host, otherHost);
				break;
			default:
				assert false : type;	// invalid type code
			}
		}
	}
上面的代码是在NetworkInterface下,能够通知所有的连接监听成员当前连接的变化情况。
# The Tram groups
Group4.groupID = t
Group4.bufferSize = 50M
Group4.movementMode
  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值