Skip to content

Commit

Permalink
find by distance messages
Browse files Browse the repository at this point in the history
  • Loading branch information
srenevic14 committed Aug 25, 2022
1 parent 76cb905 commit db6abad
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 24 deletions.
1 change: 1 addition & 0 deletions simulator/config/example.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ protocol.2unreltr.transport 1uniftr
protocol.3kademlia peersim.kademlia.KademliaProtocol
protocol.3kademlia.transport 2unreltr
protocol.3kademlia.BITS 256
protocol.3kademlia.NBUCKETS 17


# ::::: INITIALIZERS :::::
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ public class KademliaCommonConfig {
public static int NBUCKETS = 256; // number of buckets in the routing table

public static int MAXREPLACEMENT = 10; // number of items in the replacement list for each bucket

public static int FINDMODE = 0; // find mode: 0 find by node id / 1 find by distance to node
/**
* short information about current mspastry configuration
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ public class KademliaProtocol implements Cloneable, EDProtocol {
final String PAR_K = "K";
final String PAR_ALPHA = "ALPHA";
final String PAR_BITS = "BITS";
final String PAR_FINDMODE = "FINDMODE";

private static final String PAR_TRANSPORT = "transport";
private static String prefix = null;
Expand Down Expand Up @@ -109,6 +110,9 @@ private void _init() {
KademliaCommonConfig.BITS =
Configuration.getInt(prefix + "." + PAR_BITS, KademliaCommonConfig.BITS);

KademliaCommonConfig.FINDMODE =
Configuration.getInt(prefix + "." + PAR_FINDMODE, KademliaCommonConfig.FINDMODE);

_ALREADY_INSTALLED = true;
}

Expand Down
34 changes: 10 additions & 24 deletions simulator/src/main/java/peersim/kademlia/Message.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,39 +36,36 @@ public class Message extends SimpleEvent {
/** Message Type: INIT_FIND (command to a node to start looking for a node) */
public static final int MSG_INIT_FIND = 2;

/** Message Type: INIT_FIND (command to a node to start looking for a node by distance) */
public static final int MSG_INIT_FIND_DIST = 13;

/** Message Type: FINDVALUE (message regarding value find) */
public static final int MSG_FIND = 3;

/** Message Type: FINDVALUE (message regarding value find) finding by distance */
public static final int MSG_FIND_DIST = 14;
public static final int MSG_FIND_DIST = 4;

/** Message Type: RESPONSE (respons message to a findvalue or findnode) */
public static final int MSG_RESPONSE = 4;
public static final int MSG_RESPONSE = 5;

/** Message Type: REGISTER (register the node under a topic) */
public static final int MSG_REGISTER = 5;
public static final int MSG_REGISTER = 6;

/** Message Type: INIT_REGISTER (start registering under a topic) */
public static final int MSG_INIT_REGISTER = 6;
public static final int MSG_INIT_REGISTER = 7;
/** Message Type: TICKET_REQUEST (obtain a ticket to later register a topic) */
public static final int MSG_TICKET_REQUEST = 7;
public static final int MSG_TICKET_REQUEST = 8;

/** Message Type: TICKET_RESPONSE (return a ticket back to the origin) */
public static final int MSG_TICKET_RESPONSE = 8;
public static final int MSG_TICKET_RESPONSE = 9;

/** Message Type: TOPIC_QUERY (send a query for topics) */
public static final int MSG_TOPIC_QUERY = 9;
public static final int MSG_TOPIC_QUERY = 10;

/** Message Type: REGISTER_RESPONSE (response to register request) */
public static final int MSG_REGISTER_RESPONSE = 10;
public static final int MSG_REGISTER_RESPONSE = 11;

/** Message Type: TOPIC_QUERY_REPLY (respond to topic queries) */
public static final int MSG_TOPIC_QUERY_REPLY = 11;
public static final int MSG_TOPIC_QUERY_REPLY = 12;

public static final int MSG_INIT_TOPIC_LOOKUP = 12;
public static final int MSG_INIT_TOPIC_LOOKUP = 13;

// ______________________________________________________________________________________________
/** This Object contains the body of the message, no matter what it contains */
Expand Down Expand Up @@ -145,17 +142,6 @@ public static final Message makeInitFindNode(Object body) {
return new Message(MSG_INIT_FIND, body);
}

// ______________________________________________________________________________________________
/**
* Encapsulates the creation of a find node request by distance
*
* @param body Object
* @return Message
*/
public static final Message makeInitFindNodeDist(Object body) {
return new Message(MSG_INIT_FIND_DIST, body);
}

// ______________________________________________________________________________________________
/**
* Encapsulates the creation of a find value request
Expand Down

0 comments on commit db6abad

Please sign in to comment.