Revision: 53659
Initial Code
Initial URL
Initial Description
Initial Title
Initial Tags
Initial Language
at November 30, 2011 21:28 by mattstabeler
Initial Code
public void onConnect(Process p, Simulation s) {
// do the business
List<BubbleHMessage> toSend = new LinkedList<BubbleHMessage>();
BubbleHProcess process = (BubbleHProcess) p;
// on N connected with encountered node P
// for each message M (for destination D) in buffer of N
// Identify bridging community (BC), smallest community containing N and
// D.
// IF P == D
// then pass the message
// ELSE IF P shares a community with D that is smaller than BC
// then pass the message.
// ELSE IF P is more central in BC than N
// then pass the message.
String hopcode = null;
// foreach message in my buffer
for (BubbleHMessage message : my_buffer) {
/**
* Identify smallest community that Self and Destination share =
* Bridging Community
* */
int my_bridge_community = my_oracle.bridgeCommunity(my_node.getID(), message.dest);
//int his_bridge_community = BubbleHeirarchyOracle.bridgeCommunity(process.getNode().getID(), message.dest, my_properties);
// if encountered node is destination
if (process.getNode().getID() == message.dest) {
// pass it on to them.
toSend.add(message);
} else {
int remote_bridge = my_oracle.bridgeCommunity(process.getNode().getID(), message.dest);
if (my_oracle.isBetter(remote_bridge, my_bridge_community)) {
// if P is in community with message.dest, that is smaller
// than BC
// pass message
toSend.add(message);
} else if (process.getCommunities().contains(my_bridge_community)) {// if both nodes are in the bridge community
// if the rank of the encountered node is higher, pass the message
if (process.getlocalRank(my_bridge_community) > getlocalRank(my_bridge_community)) {
// pass message
toSend.add(message);
message.setHopCode("RANKBC-" + my_bridge_community);
bridge_community_ranking_message_passed++;
}
} else {
// process is not destination, is not in a smaller community
// with the destination, and is not in the bridge community,
// therefore we do not pass the message to it
}
}
}
for (BubbleHMessage message : toSend) {
my_transmittedCount++;
message.hopCount++;
s.sendMessage(this, process, message);
my_buffer.remove(message); // not sure if this is strictly part of
// BubbleRap, however to get anything like
// the cost figures they quote, it seems
// like the only way!
}
}
Initial URL
Initial Description
onConnect method used by the BubbleHProcess in the ContactSim simulator.
Initial Title
BubbleHProcess onConnect method
Initial Tags
Initial Language
Java