The Sparse Flooding Algorithm
© 2005 LIRIS Lyon - Pascal BIHLER
action onMsgReceived(msg,emitter)
if not(isEntityInDeck(msg.eid)) //No information about the entity in database
if not(isFullDXM(msg))
sendFullDXMRequest(emitter,msg.eid)
return //End action and wait for new message
if not(isInteresting(msg))
return //Discard message
storeEntityInDeck(msg)
foreach neighbors as neighbor
if neighbor != emitter
sendDXM(neighbor,msg) //Flood full message
else //There is already a knowledge about the entity in database
currentInfo = getEntityFromDeck(msg.eid)
if msg.timestamp <= currentInfo.timestamp
return //Message to old
//Make msg a complete InformationCard
if not(isFullDXM(msg))
msg = mergeInfos(currentInfo,msg)
//Get the records which have changed
infoDiff = getInfoChanges(currentInfo,msg)
if isEmpty(infoDiff)
return //Nothing has changed
if not(isInteresting(msg))
removeEntityFromDeck(msg.eid)
return //Discard entity
storeEntityInDeck(msg)
foreach neighbors as neighbor
if neighbor != emitter
sendDXM(neighbor,infoDiff) //Flood partial message
return //End action onMsgReceived
action onFullDXMRequestReceived(eid,questioner)
if eid != null //Send particular InformationCard
infoCard = getEntityFromDeck(eid)
sendDXM(questioner,infoCard)
else //Demand for all known entities
foreach entitiesInDeck as infoCard
sendDXM(questioner,infoCard)
return //End action onFullDXMRequestReceived