From 21f38881e2b39579501fc8f979cd0fa929ca7120 Mon Sep 17 00:00:00 2001 From: gnawali Date: Sat, 27 Sep 2008 17:00:54 +0000 Subject: [PATCH] updates to the compare bit interface/use of white bit --- tos/lib/net/4bitle/LinkEstimatorP.nc | 22 ++++++++++++++-------- tos/lib/net/ctp/CompareBit.nc | 8 +++++--- tos/lib/net/ctp/CtpRoutingEngineP.nc | 12 +++--------- 3 files changed, 22 insertions(+), 20 deletions(-) diff --git a/tos/lib/net/4bitle/LinkEstimatorP.nc b/tos/lib/net/4bitle/LinkEstimatorP.nc index 7e5c9dac..d0f30756 100644 --- a/tos/lib/net/4bitle/LinkEstimatorP.nc +++ b/tos/lib/net/4bitle/LinkEstimatorP.nc @@ -644,14 +644,20 @@ implementation { initNeighborIdx(nidx, ll_addr); } else { dbg("LI", "No room in the table\n"); - if (signal CompareBit.shouldInsert(msg, - call Packet.getPayload(msg, call Packet.payloadLength(msg)), - call Packet.payloadLength(msg), - call LinkPacketMetadata.highChannelQuality(msg))) { - nidx = findRandomNeighborIdx(); - if (nidx != INVALID_RVAL) { - signal LinkEstimator.evicted(NeighborTable[nidx].ll_addr); - initNeighborIdx(nidx, ll_addr); + + /* if the white bit is set, lets ask the router if the path through + this link is better than at least one known path - if so + lets insert this link into the table. + */ + if (call LinkPacketMetadata.highChannelQuality(msg)) { + if (signal CompareBit.shouldInsert(msg, + call Packet.getPayload(msg, call Packet.payloadLength(msg)), + call Packet.payloadLength(msg))) { + nidx = findRandomNeighborIdx(); + if (nidx != INVALID_RVAL) { + signal LinkEstimator.evicted(NeighborTable[nidx].ll_addr); + initNeighborIdx(nidx, ll_addr); + } } } } diff --git a/tos/lib/net/ctp/CompareBit.nc b/tos/lib/net/ctp/CompareBit.nc index 3f9528d7..ddebdac6 100644 --- a/tos/lib/net/ctp/CompareBit.nc +++ b/tos/lib/net/ctp/CompareBit.nc @@ -25,8 +25,9 @@ */ /** Link estimator asks the routing engine if this entry - * should be inserted into the neighbor table given the - * white bit. The return value is the "pin bit" - if true + * should be inserted into the neighbor table if the + * white bit on a link is set but there is no room for the link + * on the link table. The return value is the "pin bit" - if true * insert into the neighbor table. In the reference implementation * the router will return true if the path through the source * will be better than a path through at least one current neighbor. @@ -38,5 +39,6 @@ interface CompareBit { /* should the source of this message be inserted into the neighbor table? */ - event bool shouldInsert(message_t * ONE msg, void* COUNT_NOK(len) payload, uint8_t len, bool white_bit); + /* expect to be called only for links with the white bit set */ + event bool shouldInsert(message_t * ONE msg, void* COUNT_NOK(len) payload, uint8_t len); } diff --git a/tos/lib/net/ctp/CtpRoutingEngineP.nc b/tos/lib/net/ctp/CtpRoutingEngineP.nc index 35293803..bd213db9 100644 --- a/tos/lib/net/ctp/CtpRoutingEngineP.nc +++ b/tos/lib/net/ctp/CtpRoutingEngineP.nc @@ -636,26 +636,20 @@ implementation { } - /* This should see if the node should be inserted in the table. - * If the white_bit is set, this means the LL believes this is a good - * first hop link. - * The link will be recommended for insertion if it is better* than some + /* The link will be recommended for insertion if it is better* than some * link in the routing table that is not our parent. * We are comparing the path quality up to the node, and ignoring the link * quality from us to the node. This is because of a couple of things: - * 1. because of the white bit, we assume that the 1-hop to the candidate - * link is good (say, etx=1) + * 1. we expect this call only for links with white bit set * 2. we are being optimistic to the nodes in the table, by ignoring the * 1-hop quality to them (which means we are assuming it's 1 as well) * This actually sets the bar a little higher for replacement * 3. this is faster - * 4. it doesn't require the link estimator to have stabilized on a link */ - event bool CompareBit.shouldInsert(message_t *msg, void* payload, uint8_t len, bool white_bit) { + event bool CompareBit.shouldInsert(message_t *msg, void* payload, uint8_t len) { bool found = FALSE; uint16_t pathEtx; - //uint16_t linkEtx = evaluateEtx(0); uint16_t neighEtx; int i; routing_table_entry* entry; -- 2.39.2