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);
+ }
}
}
}
*/
/** 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.
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);
}
}
- /* 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;