Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,4 @@ doc/package-list
.project
/target/
.settings/org.eclipse.*
/bin/
2 changes: 1 addition & 1 deletion compile.bat
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ set targetdir=target

IF NOT EXIST "%targetdir%" mkdir %targetdir%

javac -sourcepath src -d %targetdir% -extdirs lib/ src/core/*.java src/movement/*.java src/report/*.java src/routing/*.java src/gui/*.java src/input/*.java src/applications/*.java src/interfaces/*.java
javac -sourcepath src -d %targetdir% -extdirs lib/ src/core/*.java src/movement/*.java src/report/*.java src/routing/*.java src/gui/*.java src/input/*.java src/applications/*.java src/interfaces/*.java src/buffermanagement/*.java src/routing/community/*.java src/routing/centrality/*.java



Expand Down
2 changes: 1 addition & 1 deletion compile.sh
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ targetdir=target

if [ ! -d "$targetdir" ]; then mkdir $targetdir; fi

javac -sourcepath src -d $targetdir -extdirs lib/ src/core/*.java src/movement/*.java src/report/*.java src/routing/*.java src/gui/*.java src/input/*.java src/applications/*.java src/interfaces/*.java
javac -sourcepath src -d $targetdir -extdirs lib/ src/core/*.java src/movement/*.java src/report/*.java src/routing/*.java src/gui/*.java src/input/*.java src/applications/*.java src/interfaces/*.java src/buffermanagement/*.java src/routing/community/*.java src/routing/centrality/*.java

if [ ! -d "$targetdir/gui/buttonGraphics" ]; then cp -R src/gui/buttonGraphics target/gui/; fi

2 changes: 2 additions & 0 deletions default_settings.txt
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ Scenario.nrofHostGroups = 6
# router: router used to route messages (valid class name from routing package)
# activeTimes: Time intervals when the nodes in the group are active (start1, end1, start2, end2, ...)
# msgTtl : TTL (minutes) of the messages created by this host group, default=infinite
# dropPolicy: if specified a custom drop policy is used (see the classes in the buffermanagement package).
# dropMsgBeingSent: define if the custom drop policy is allowed to drop messages being sent.

## Group and movement model specific settings
# pois: Points Of Interest indexes and probabilities (poiIndex1, poiProb1, poiIndex2, poiProb2, ... )
Expand Down
Empty file modified doc/create_docs.sh
100755 → 100644
Empty file.
15 changes: 15 additions & 0 deletions example_settings/bubblerap_settings.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
Scenario.nrofHostGroups = 1
Group1.router = BubbleRapRouter
Group1.nrofHosts = 126

# Configure the community detection algorithm
BubbleRapRouter.communityAlg = DistributedKCliqueCommunityDetection
BubbleRapRouter.k = 3
BubbleRapRouter.familiarThreshold = 3600

# Configure the centrality algorithm
BubbleRapRouter.centralityAlg = CWindowCentrality
BubbleRapRouter.timeWindow = 86400

Report.report1 = CommunityReport
Report.report2 = CentralityReport
4 changes: 4 additions & 0 deletions example_settings/drop_policy_settings.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Configure the drop policy used
Group.dropPolicy = MOFODropPolicy
# Defines if messages being sent can be dropped, the default value is true
Group.dropMsgBeingSent = false
Empty file modified one.sh
100755 → 100644
Empty file.
47 changes: 47 additions & 0 deletions src/buffermanagement/DropPolicy.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
/*
* Copyright 2016, Michael D. Silva (micdoug.silva@gmail.com)
* Released under GPLv3. See LICENSE.txt for details.
*/

package buffermanagement;

import core.Message;
import core.Settings;
import routing.ActiveRouter;


/**
* Defines the basic structure for implementing a message drop policy. A message drop policy is used by the hosts
* when their buffers haven't enough space to receive an incoming message.
*/
public abstract class DropPolicy {

/**
* Drop message being sent -setting id ({@value}). The configuration that defines
* if messages being sent can be dropped.
*/
private static final String DROP_MSG_BEING_SENT = "dropMsgBeingSent";

/**
* Defines if messages being sent can be dropped.
*/
protected boolean dropMsgBeingSent = true;

/**
* Constructor with the signature required to be instantiated by the simulator.
* @param s Settings applied
*/
public DropPolicy(Settings s) {
if (s.contains(DROP_MSG_BEING_SENT)) {
this.dropMsgBeingSent = s.getBoolean(DROP_MSG_BEING_SENT);
}
}

/**
* Try to remove messages from the buffer until enough space for receive the incoming message is freed.
* @param router A reference to the receiver router.
* @param incomingMessage The incoming message.
* @return True if it was possible to freed enough space, false otherwise.
*/
public abstract boolean makeRoomForMessage(ActiveRouter router, Message incomingMessage);
}
76 changes: 76 additions & 0 deletions src/buffermanagement/EDropPolicy.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
/*
* Copyright 2016, Michael D. Silva (micdoug.silva@gmail.com)
* Released under GPLv3. See LICENSE.txt for details.
*/

package buffermanagement;

import java.util.Iterator;
import core.Message;
import core.Settings;
import routing.ActiveRouter;

/**
* Implementation of the E-Drop policy as proposed in the paper
* "E-DROP: An Effective Drop Buffer Management Policy for DTN Routing Protocols"
* that can be found at
* http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.206.3719&rep=rep1&type=pdf
*/
public class EDropPolicy extends DropPolicy {

/**
* Store a settings reference to pass to FIFO constructor when needed.
*/
private Settings settings;

public EDropPolicy(Settings s) {
super(s);
this.settings = s;

// It doesn't need specific settings.
}

@Override
public boolean makeRoomForMessage(ActiveRouter router, Message incomingMessage) {

int size = incomingMessage == null ? 0 : incomingMessage.getSize();

if (size > router.getBufferSize()) {
return false; // message too big for the buffer
}

long freeBuffer = router.getFreeBufferSize();

while (freeBuffer < size) {
Iterator<Message> iter = router.getMessageCollection().iterator();

if (!iter.hasNext()) {
return false; // There is no message that can be dropped
}

// Try to find a message with size greater or equals to the incoming message size
Message msg = null;
while (iter.hasNext()) {
Message temp = iter.next();
if (temp.getSize() >= size && (this.dropMsgBeingSent || !router.isSending(temp.getId()))) {
msg = temp;
break;
}
}

// If there is a message to drop
if (msg != null) {
router.deleteMessage(msg.getId(), true);
freeBuffer += msg.getSize();
}
else {
// If there aren't messages with size equals or greater than the incoming, works like FIFO
FIFODropPolicy fifo = new FIFODropPolicy(this.settings);
return fifo.makeRoomForMessage(router, incomingMessage);
}
}
return true;
}


}
78 changes: 78 additions & 0 deletions src/buffermanagement/FIFODropPolicy.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
/*
* Copyright 2016, Michael D. Silva (micdoug.silva@gmail.com)
* Released under GPLv3. See LICENSE.txt for details.
*/

package buffermanagement;

import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;

import core.Message;
import core.Settings;
import routing.ActiveRouter;

/**
* Drop the messages that arrived first, i.e., the messages that have the minimum
* receive time.
*/
public class FIFODropPolicy extends DropPolicy{

public FIFODropPolicy(Settings s) {
super(s);
// It doesn't need specific settings.
}

@Override
public boolean makeRoomForMessage(ActiveRouter router, Message incomingMessage) {

int size = incomingMessage == null ? 0 : incomingMessage.getSize();

// Check if the incoming message size exceeds the buffer capacity
if (size > router.getBufferSize()) {
return false;
}

long freeBuffer = router.getFreeBufferSize();

// Check if there is enough space to receive the message before sorting the buffer
if (freeBuffer >= size) {
return true;
}

// Sort the messages by receive time
ArrayList<Message> messages = new ArrayList<Message>(router.getMessageCollection());
Collections.sort(messages, new FIFOComparator());

/* Delete messages from the buffer until there is enough space */
while (freeBuffer < size) {

if (messages.size() == 0) {
return false; // couldn't remove more messages
}

// Get the message that was received first
Message msg = messages.remove(0);

// Check if the router is sending this message
if (this.dropMsgBeingSent || !router.isSending(msg.getId())) {
// Delete the message and send signal "drop"
router.deleteMessage(msg.getId(), true);
freeBuffer += msg.getSize();
}
}

return true;
}

private class FIFOComparator implements Comparator<Message> {

@Override
public int compare(Message m1, Message m2) {
return ((Double)m1.getReceiveTime()).compareTo(m2.getReceiveTime());
}

}

}
78 changes: 78 additions & 0 deletions src/buffermanagement/MOFODropPolicy.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
/*
* Copyright 2016, Michael D. Silva (micdoug.silva@gmail.com)
* Released under GPLv3. See LICENSE.txt for details.
*/

package buffermanagement;

import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import core.Message;
import core.Settings;
import routing.ActiveRouter;

/**
* Drop the messages with the maximum number of transmissions first, i.e., the most forwarded
* messages.
*/
public class MOFODropPolicy extends DropPolicy {


public MOFODropPolicy(Settings s) {
super(s);
// It doesn't need specific settings.
}

@Override
public boolean makeRoomForMessage(ActiveRouter router, Message incomingMessage) {

int size = incomingMessage == null ? 0 : incomingMessage.getSize();

if (size > router.getBufferSize()) {
return false; // message too big for the buffer
}

long freeBuffer = router.getFreeBufferSize();

// Check if there is enough space to receive the message before sorting the buffer
if (freeBuffer >= size) {
return true;
}

// Sort the messages by forward count
ArrayList<Message> messages = new ArrayList<Message>(router.getMessageCollection());
Collections.sort(messages, new MOFOComparator());

/* Delete messages from the buffer until there is enough space */
while (freeBuffer < size) {

if (messages.size() == 0) {
return false; // couldn't remove more messages
}

// Get the message that was most forwarded
Message msg = messages.remove(messages.size()-1);

// Check if the router is sending this message
if (this.dropMsgBeingSent || !router.isSending(msg.getId())) {
// Delete the message and send signal "drop"
router.deleteMessage(msg.getId(), true);
freeBuffer += msg.getSize();
}
}

return true;

}

private class MOFOComparator implements Comparator<Message> {

@Override
public int compare(Message msg0, Message msg1) {
return ((Integer)msg0.getForwardCount()).compareTo(msg1.getForwardCount());
}

}

}
35 changes: 35 additions & 0 deletions src/buffermanagement/PassiveDropPolicy.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/*
* Copyright 2016, Michael D. Silva (micdoug.silva@gmail.com)
* Released under GPLv3. See LICENSE.txt for details.
*/

package buffermanagement;

import core.Message;
import core.Settings;
import routing.ActiveRouter;

/**
* This implementation always refuses to drop a message. It can be used for specific tests.
*/
public class PassiveDropPolicy extends DropPolicy{

public PassiveDropPolicy(Settings s) {
super(s);
// It doesn't need specific settings.
}

@Override
public boolean makeRoomForMessage(ActiveRouter router, Message incomingMessage) {

// Get the incoming message size.
int size = incomingMessage == null ? 0 : incomingMessage.getSize();

// Get the available space.
long freeBuffer = router.getFreeBufferSize();

// Return if it is possible to receive the incoming message, it does not drop any messages
return size <= freeBuffer;
}

}
Loading