/**
* <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