Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dasv2 #56

Open
wants to merge 98 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
Commits
Show all changes
98 commits
Select commit Hold shift + click to select a range
8adc69e
back to sample assignment based on id
srene Sep 15, 2023
72b37c5
dht fix
srene Sep 15, 2023
c57f36c
disable initial elaborate response dht
srene Sep 15, 2023
9ca67c9
fix starting multiple builder issue
srene Oct 3, 2023
181e548
fix sampling to node mapping
srene Oct 3, 2023
098e22d
getting extra samples in case some fail for random sampling
srene Oct 3, 2023
8a8bb02
xback to sample assignment based on id
srene Sep 15, 2023
ac2f663
add neighbour and search table refresh
srene Sep 15, 2023
6e87164
ttl discovery done
srene Sep 15, 2023
6d9b822
discoveries reporting
srene Sep 29, 2023
15ecb62
discovery reporting fix + ttl time based
srene Sep 30, 2023
661082e
discoveries report extended
srene Sep 30, 2023
9edb090
targeted discovery for missing samples
srene Oct 3, 2023
ac7cba9
updating neighbours seen time search table
srene Oct 4, 2023
f1307d4
fixing turbulance
srene Oct 4, 2023
e758a7c
adding num random samples as parameter
srene Oct 4, 2023
34343e8
disable global node knowledge / enable node discovery
srene Oct 5, 2023
6d742c9
remove builder from discovery
srene Oct 6, 2023
dd44dfe
increase radius to reasign when missing nodes for samples
srene Oct 15, 2023
6e07a1b
switch to learned nodes + bug fix
srene Oct 16, 2023
b5d583f
filtering builder address from searchtable
srene Oct 16, 2023
bf61d53
load builder searchtable with validators
srene Oct 17, 2023
9b17b40
pull from builder in seeding phase
srene Oct 18, 2023
788c1eb
caching samples requests to reply later on when samples received
srene Oct 18, 2023
228b301
adapt sampling to caching requests + activate turbulence
srene Oct 19, 2023
64ec510
removed non-responding nodes from search table
srene Oct 19, 2023
bd33de3
turbulence fix filling routing table
srene Oct 19, 2023
9d6d156
update last seen only when direct contact neighbour
srene Oct 19, 2023
58d9214
refresh search table in config
srene Oct 19, 2023
47fe624
refresh search table in config
srene Oct 19, 2023
6e1506b
fix bug when no nodes found for a sample
srene Oct 19, 2023
f8b54f3
fix bug do sampling
srene Oct 20, 2023
1a5e3e7
fix bug das turbulence
srene Oct 23, 2023
a21af02
enable periodic lookup
srene Oct 23, 2023
a3bc0dd
removing logs
srene Oct 23, 2023
6e67845
disable periodic kad lookups
srene Oct 24, 2023
9839c88
update in search table, avoid dead nodes discovery
srene Oct 25, 2023
e79327b
add report discovery in the configuration
srene Oct 26, 2023
da8e551
fix bug removing fetching samples from queried nodes
srene Oct 26, 2023
682f4d1
avoid adding builder search table
srene Oct 26, 2023
a4ae8fe
removing logs
srene Oct 26, 2023
44732b9
reducing memory usage
srene Oct 27, 2023
19308ec
validator evil class
srene Oct 27, 2023
4228a5c
init evil nodes
srene Oct 27, 2023
9887a5e
return other evil nodes discovery by malicious
srene Oct 27, 2023
efc9545
clean code
srene Oct 27, 2023
b7f8c54
make report msg optional
srene Oct 27, 2023
d0f881d
evil das protocol + config
srene Oct 30, 2023
0f6768c
disable discovery table reporting for evil nodes
srene Oct 30, 2023
a558284
return random nodes search table
srene Oct 30, 2023
2c01ddb
limit number of evil nodes returned search table
srene Oct 30, 2023
ad439a0
adding extra nodes in the same row/column for sampling to overcome ma…
srene Oct 30, 2023
9242555
back to multiple samples per message
srene Nov 1, 2023
791870c
solved bug in random sampling process sample counting
srene Nov 1, 2023
42acbe6
adding extra nodes for random sampling
srene Nov 1, 2023
0e60318
bug fixed when timeouts to continue sampling
srene Nov 5, 2023
3027f7f
send samples after reconstruction
srene Nov 11, 2023
1903c72
alternative fetching when malicious
srene Nov 29, 2023
de874cc
adding extra nodes for missing samples progressively with aggressiven…
srene Dec 4, 2023
1f07393
reducing cached samples
srene Dec 26, 2023
01bb4b4
configs
srene Dec 26, 2023
137bc86
cleaning
srene Dec 29, 2023
94795f6
all nodes known
srene Dec 30, 2023
bd8ee84
adding extra nodes disables
srene Dec 30, 2023
a5b8ce2
minor
srene Dec 31, 2023
13039a4
single search table
srene Dec 31, 2023
c187486
fixing
srene Dec 31, 2023
d950cf5
no kv
srene Jan 1, 2024
5712199
minor edit
srene Jan 2, 2024
80bc792
random col/row sampling
srene Jan 3, 2024
c2329fc
sorting sampling nodes
srene Jan 3, 2024
80b2d6d
minor edit
srene Jan 3, 2024
21f2a1a
sorting sampling nodes
srene Jan 3, 2024
c27c3b9
sorting sampling nodes
srene Jan 3, 2024
cbad094
fixing non found samples in non-validator
srene Jan 3, 2024
ffb88fc
fixing non found samples in non-validator
srene Jan 3, 2024
42ff296
logs
srene Jan 3, 2024
a7931dd
extra nodes sampling
srene Jan 6, 2024
01f0a07
canceling pending requests
srene Jan 13, 2024
101c9be
fix
srene Jan 13, 2024
3492c01
messages report
srene Jan 13, 2024
0602522
assignig samples when missing nodes in id space
srene Jan 14, 2024
b7ea351
node type in msg report
srene Jan 14, 2024
155377d
reporting only related messages
srene Jan 14, 2024
8bc497b
msg reporting fix
srene Jan 14, 2024
22075a6
fix
srene Jan 14, 2024
42051f8
increasing radius for validator sampling
srene Jan 14, 2024
a3256fb
configs
srene Jan 14, 2024
15e3146
minor
srene Jan 19, 2024
e1ed0ff
adding evil ids
srene Mar 2, 2024
f57351a
more results
srene Sep 5, 2024
f9fa308
config
srene Nov 3, 2024
0d0f62b
wip
srene Dec 1, 2024
ccb9988
file
srene Dec 1, 2024
16230e5
seeding ok
srene Jan 18, 2025
bffe919
validator sampling
srene Jan 18, 2025
9c27af9
add random sampling
srene Jan 19, 2025
4ca396f
nonval random sampling
srene Jan 19, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
discoveries reporting
  • Loading branch information
srene committed Oct 18, 2023
commit 6d9b8224f183210133d26e23d188bb5dcd32101a
6 changes: 5 additions & 1 deletion simulator/config/dasprotocol.cfg
Original file line number Diff line number Diff line change
@@ -82,7 +82,7 @@ init.1uniqueNodeID.protocoldasbuilder 4dasprotocol
init.1uniqueNodeID.protocoldasvalidator 5dasprotocol
init.1uniqueNodeID.protocoldasnonvalidator 6dasprotocol
init.1uniqueNodeID.protocolEvildas 7evildasprotocol
init.1uniqueNodeID.validator_rate 0.5
init.1uniqueNodeID.validator_rate 1.0
init.1uniqueNodeID.evilNodeRatioValidator 0.0
init.1uniqueNodeID.evilNodeRatioNonValidator 0.0

@@ -110,10 +110,14 @@ control.2turbolenceAdd.protocolevildas 7evildasprotocol
control.2turbolenceAdd.transport 2unreltr
control.2turbolenceAdd.step TURBULENCE_STEP
<<<<<<< HEAD
<<<<<<< HEAD
control.2turbolenceAdd.p_idle 0.9
=======
control.2turbolenceAdd.p_idle 0.09
>>>>>>> 62b294e (back to sample assignment based on id)
=======
control.2turbolenceAdd.p_idle 0.9
>>>>>>> 54bd3fd (discoveries reporting)
control.2turbolenceAdd.p_rem 0.05
control.2turbolenceAdd.p_add 0.05

31 changes: 31 additions & 0 deletions simulator/src/main/java/peersim/kademlia/KademliaObserver.java
Original file line number Diff line number Diff line change
@@ -11,6 +11,8 @@
import peersim.core.CommonState;
import peersim.core.Control;
import peersim.core.Network;
import peersim.kademlia.das.Neighbour;
import peersim.kademlia.das.SearchTable;
import peersim.kademlia.operations.Operation;
import peersim.util.IncrementalStats;

@@ -54,6 +56,10 @@ public class KademliaObserver implements Control {
private static HashMap<Long, Map<String, Object>> operations =
new HashMap<Long, Map<String, Object>>();

/** Log of operations in the Kademlia network */
private static HashMap<Long, Map<String, Object>> peerDiscoveries =
new HashMap<Long, Map<String, Object>>();

/** Name of the folder where experiment logs are written */
private static String logFolderName;

@@ -124,6 +130,9 @@ public static void writeOut() {
if (!operations.isEmpty()) {
writeLogs(operations, logFolderName + "/" + "operation.csv");
}
if (!peerDiscoveries.isEmpty()) {
writeLogs(peerDiscoveries, logFolderName + "/" + "peerDiscoveries.csv");
}
}

/**
@@ -193,4 +202,26 @@ public static void reportOperation(Operation op) {
op.setStopTime(CommonState.getTime() - op.getTimestamp());
operations.put(op.getId(), op.toMap());
}

public static void reportPeerDiscovery(Message m, SearchTable st) {

if (m.src == null) return;
// Add the message to the message log, but first check if it hasn't already been added
assert (!messages.keySet().contains(m.id));
Map<String, Object> result = new HashMap<String, Object>();
Neighbour[] neighs = (Neighbour[])m.value;

int notKnown=0;
for(Neighbour n : neighs){
if(!st.isNeighbourKnown(n))notKnown++;
}
result.put("message_id", m.id);
result.put("dst_id",m.dst.getId());
result.put("src_id",m.src.getId());
result.put("total_peers", st.getAllNeighboursCount());
result.put("peers_in_message", neighs.length);
result.put("peers_not_known", notKnown);

messages.put(m.id, result);
}
}
15 changes: 12 additions & 3 deletions simulator/src/main/java/peersim/kademlia/das/DASProtocol.java
Original file line number Diff line number Diff line change
@@ -94,6 +94,8 @@ public abstract class DASProtocol implements Cloneable, EDProtocol, KademliaEven

protected TreeSet<BigInteger> nonValidatorsIndexed; // , samplesIndexed;

protected boolean isEvil;

/**
* Replicate this object by returning an identical copy.<br>
* It is called by the initializer and do not fill any particular field.
@@ -111,6 +113,7 @@ public abstract class DASProtocol implements Cloneable, EDProtocol, KademliaEven
public DASProtocol(String prefix) {

DASProtocol.prefix = prefix;
isEvil = false;
_init();
tid = Configuration.getPid(prefix + "." + PAR_TRANSPORT);
// samplesRequested = 0;
@@ -236,6 +239,10 @@ public boolean isValidator() {
return this.isValidator;
}

public boolean isEvil() {
return this.isEvil;
}

public void setBuilderAddress(BigInteger address) {
this.builderAddress = address;
searchTable.setBuilderAddress(address);
@@ -422,7 +429,7 @@ protected void sendMessage(Message m, BigInteger destId, int myPid) {
// interface
// Timeout t = new Timeout(destId, m.id, m.operationId);
Sample[] samples = (Sample[]) m.body;
BigInteger[] nghbrs = (BigInteger[]) m.value;
Neighbour[] nghbrs = (Neighbour[]) m.value;
double samplesSize = 0.0;
if (samples != null) samplesSize = samples.length * KademliaCommonConfigDas.SAMPLE_SIZE;
double nghbrsSize = 0.0;
@@ -630,7 +637,8 @@ public void operationComplete(Operation op) {
list.remove(builderAddress);
// searchTable.addNodes(list.toArray(new BigInteger[0]));
for (BigInteger id : list) {
searchTable.addNeighbour(new Neighbour(id));
Node n = Util.nodeIdtoNode(id, kademliaId);
searchTable.addNeighbour(new Neighbour(id, n, n.getDASProtocol().isEvil()));
}
logger.warning(
"Search table operation complete"
@@ -672,7 +680,8 @@ public void nodesFound(Operation op, BigInteger[] neighbours) {
}
// searchTable.addNodes(list.toArray(new BigInteger[0]));
for (BigInteger id : list) {
searchTable.addNeighbour(new Neighbour(id));
Node n = Util.nodeIdtoNode(id, kademliaId);
searchTable.addNeighbour(new Neighbour(id, n, n.getDASProtocol().isEvil()));
}
logger.info(
"Search table nodes found "
Original file line number Diff line number Diff line change
@@ -9,6 +9,7 @@ public class EvilDASProtocol extends DASProtocol {
public EvilDASProtocol(String prefix) {
super(prefix);
EvilDASProtocol.prefix = prefix;
isEvil = true;
}

@Override
28 changes: 27 additions & 1 deletion simulator/src/main/java/peersim/kademlia/das/Neighbour.java
Original file line number Diff line number Diff line change
@@ -1,15 +1,20 @@
package peersim.kademlia.das;

import java.math.BigInteger;
import peersim.core.Node;

public class Neighbour implements Comparable<Neighbour> {

BigInteger id;
int last_seen;
Node n;
boolean isEvil;

Neighbour(BigInteger id) {
Neighbour(BigInteger id, Node n, boolean isEvil) {
this.id = id;
this.last_seen = 0;
this.n = n;
this.isEvil = isEvil;
}

public void updateLastSeen() {
@@ -21,6 +26,14 @@ public boolean expired() {
else return false;
}

public Node getNode() {
return n;
}

public boolean isEvil() {
return isEvil;
}

@Override
public int compareTo(Neighbour arg0) {
if (this.last_seen < arg0.last_seen) return 1;
@@ -30,4 +43,17 @@ else if (this.last_seen == arg0.last_seen) {
return -1;
}
}

@Override
public boolean equals(Object object)
{
boolean sameSame = false;

if (object != null && object instanceof Neighbour)
{
sameSame = this.id.compareTo(((Neighbour) object).id)==0;
}

return sameSame;
}
}
24 changes: 24 additions & 0 deletions simulator/src/main/java/peersim/kademlia/das/SearchTable.java
Original file line number Diff line number Diff line change
@@ -186,6 +186,30 @@ public Neighbour[] getNeighbours() {
return result.toArray(new Neighbour[0]);
}

public int getAllNeighboursCount() {
return neighbours.size();
}

public int getAllAliveNeighboursCount() {
int count = 0;
for (Neighbour neigh : neighbours) {
if (neigh.getNode().isUp()) count++;
}
return count;
}

public int getMaliciousNeighboursCount() {
int count = 0;
for (Neighbour neigh : neighbours) {
if (neigh.isEvil()) count++;
}
return count;
}

public boolean isNeighbourKnown(Neighbour neighbour){
return neighbours.contains(neighbour);
}

public void refresh() {

List<Neighbour> toRemove = new ArrayList<>();