ONE(延迟容忍网络模拟器)中,关于路由更新顺序备忘

ONE中,在对DTN更新时,会对router进行更新,本次是对router中个部分的更新进行一次梳理

//DTNHost
public void update(boolean simulateConnections, int[][] conPossible) {
		if (!isRadioActive()) {
			// Make sure inactive nodes don't have connections
			tearDownAllConnections();
			return;
		}

		if (simulateConnections) {
			for (NetworkInterface i : net) {
				i.update(conPossible);
			}
		}
		this.router.update();
		this.computeModel.update(this);
	}

//DirectDeliveryRouter
@Override
	public void update() {
		super.update();
		if (isTransferring() || !canStartTransfer()) {
			return; // can't start a new transfer
		}

		// Try only the messages that can be delivered to final recipient
		if (exchangeDeliverableMessages() != null) {
			return; // started a transfer
		}
	}

//ActiveRouter
@Override
	public void update() {
		super.update();

		/* in theory we can have multiple sending connections even though
		  currently all routers allow only one concurrent sending connection */
		for (int i=0; i<this.sendingConnections.size(); ) {
			boolean removeCurrent = false;
			Connection con = sendingConnections.get(i);

			/* finalize ready transfers */
			if (con.isMessageTransferred()) {
				if (con.getMessage() != null) {
					transferDone(con);
					con.finalizeTransfer();
				} /* else: some other entity aborted transfer */
				removeCurrent = true;
			}
			/* remove connections that have gone down */
			else if (!con.isUp()) {
				if (con.getMessage() != null) {
					transferAborted(con);
					con.abortTransfer();
				}
				removeCurrent = true;
			}

			if (removeCurrent) {
				// if the message being sent was holding excess buffer, free it
				if (this.getFreeBufferSize() < 0) {
					this.makeRoomForMessage(0);
				}
				sendingConnections.remove(i);
			}
			else {
				/* index increase needed only if nothing was removed */
				i++;
			}
		}

		/* time to do a TTL check and drop old messages? Only if not sending */
		if (SimClock.getTime() - lastTtlCheck >= TTL_CHECK_INTERVAL &&
				sendingConnections.size() == 0) {
			dropExpiredMessages();
			lastTtlCheck = SimClock.getTime();
		}

		if (energy != null) {
			/* TODO: add support for other interfaces */
			NetworkInterface iface = getHost().getInterface(1);
			energy.update(iface, getHost().getComBus());
			//System.out.println("Time: "+SimClock.getTime()+ " HostID: " + getHost().getAddress() + ", currentEnergy: " + energy.getEnergy());
		}
	}

1.执行顺序。

在执行router.update()时,需要执行DirectDeliveryRouter(以DirectDeliveryRouter为例)中的update(),于是执行其super.update(),即ActiveRouter的update()。于是执行ActiveRouter的update()中的super.update()。所以整体的执行顺序为:DTNHost的update()\rightarrowrouter.update()\rightarrowDirectDeliveryRouter.update()\rightarrowActiveRouter.update()\rightarrowMessageRouter.update()

2.更新的内容和顺序。

路由更新主要更新的内容:(1).判断是否传输结束 / 移除过期连接等;(2).丢弃TTL过期的消息;(3).更新能量;(4). 判断是否可以开始新消息传输;(5). 判断之前无法建立的连接是否可以建立,并进行消息传输

踩的坑:目前在能量更新的时候,基于当前的msgOnFly进行了能耗的更新操作。但是出现了某个主机节点在当前时间点执行了(5)操作,建立了与序号靠前的消息传输。但是当下一轮更新开始时,序号靠前的主机节点,执行(1)操作后,之前建立的消息传输直接结束,因此该消息根本没有经过(3)阶段,因此无法对该消息执行能耗信息的更新。

  • 8
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值