Skip to content

Commit

Permalink
added previous node handling to epidemic strat. rdt router bugfix.
Browse files Browse the repository at this point in the history
  • Loading branch information
lh70 committed Aug 26, 2024
1 parent cad1b31 commit e51f281
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
20 changes: 20 additions & 0 deletions Modules/DTN/shared/src/main/scala/dtn/routing/EpidemicRouter.scala
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import java.util.concurrent.ConcurrentHashMap
import scala.concurrent.ExecutionContext.Implicits.global
import scala.concurrent.Future
import scala.jdk.CollectionConverters.*
import dtn.PreviousNodeBlock

/*
Includes the standalone EpidemicRouter and the extracted EpidemicStrategy for use in other routers.
Expand Down Expand Up @@ -43,6 +44,7 @@ class EpidemicRouter(ws: WSEroutingClient, monitoringClient: MonitoringClientInt
}

override def onIncomingBundle(packet: Packet.IncomingBundle): Unit = {
epidemicStrategy.onIncomingBundle(packet)
println("received incoming bundle. information not used for routing. ignoring.")
}

Expand Down Expand Up @@ -93,4 +95,22 @@ class EpidemicStrategy {
()
}
}

def onIncomingBundle(packet: Packet.IncomingBundle): Unit = {
packet.bndl.other_blocks.collectFirst {
case x: PreviousNodeBlock => x
} match {
case None => println("received incoming bundle without previous node block. ignoring")
case Some(previous_node_block) => {
delivered.get(packet.bndl.id) match {
case null =>
delivered.put(packet.bndl.id, Set(previous_node_block.previous_node_id.extract_node_name()))
()
case x: Set[String] =>
delivered.put(packet.bndl.id, (x + previous_node_block.previous_node_id.extract_node_name()))
()
}
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,8 @@ class RdtRouter(
println(s"destination nodes: $destination_nodes")

// for these destination nodes select the best neighbours to forward this bundle to
var best_neighbours = destination_nodes.flatMap(node => likelihoodState.get_sorted_neighbours(node).take(5))
var best_neighbours =
destination_nodes.flatMap(node => likelihoodState.get_sorted_neighbours(node).take(topNNeighbours))
println(s"best neighbours: $best_neighbours")

// remove previous node and source node from ideal neighbours if available
Expand Down

0 comments on commit e51f281

Please sign in to comment.