Skip to content

Commit

Permalink
Fixed EOL and other whitespace
Browse files Browse the repository at this point in the history
  • Loading branch information
akeranen committed Nov 14, 2015
1 parent 9aa57fd commit 304ede9
Show file tree
Hide file tree
Showing 325 changed files with 35,291 additions and 35,109 deletions.
4 changes: 2 additions & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Contributing

If you would like to contribute to the development of the ONE simulator, please fork us on GitHub and send your contributions as pull requests.
If you would like to contribute to the development of the ONE simulator, please fork us on GitHub and send your contributions as pull requests.

If you are not sure where to start, new tests are always very welcome! Bugfixes are also highly appreciated.

Expand All @@ -10,4 +10,4 @@ If you want to add new features, there are some things to take into consideratio
* If the new feature requires changes to existing classes, make sure the feature is generic and shared by many use cases.
* In particular one should avoid features that slow down simulation even when the new feature is not in use (e.g., if it requires checks for each simulation round)

When doing contributions, please try to follow the coding style of the existing code.
When doing contributions, please try to follow the coding style of the existing code.
410 changes: 205 additions & 205 deletions HISTORY.txt

Large diffs are not rendered by default.

1,256 changes: 628 additions & 628 deletions LICENSE.txt

Large diffs are not rendered by default.

1,446 changes: 723 additions & 723 deletions README.txt

Large diffs are not rendered by default.

58 changes: 29 additions & 29 deletions applications/PingApplication.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
/*
* Copyright 2010 Aalto University, ComNet
* Released under GPLv3. See LICENSE.txt for details.
* Released under GPLv3. See LICENSE.txt for details.
*/

package applications;
Expand All @@ -17,14 +17,14 @@
import core.World;

/**
* Simple ping application to demonstrate the application support. The
* Simple ping application to demonstrate the application support. The
* application can be configured to send pings with a fixed interval or to only
* answer to pings it receives. When the application receives a ping it sends
* a pong message in response.
*
*
* The corresponding <code>PingAppReporter</code> class can be used to record
* information about the application behavior.
*
*
* @see PingAppReporter
* @author teemuk
*/
Expand All @@ -43,10 +43,10 @@ public class PingApplication extends Application {
public static final String PING_PING_SIZE = "pingSize";
/** Size of the pong message */
public static final String PING_PONG_SIZE = "pongSize";

/** Application ID */
public static final String APP_ID = "fi.tkk.netlab.PingApplication";

// Private vars
private double lastPing = 0;
private double interval = 500;
Expand All @@ -57,10 +57,10 @@ public class PingApplication extends Application {
private int pingSize=1;
private int pongSize=1;
private Random rng;
/**

/**
* Creates a new ping application with the given settings.
*
*
* @param s Settings to use for initializing the application.
*/
public PingApplication(Settings s) {
Expand All @@ -87,14 +87,14 @@ public PingApplication(Settings s) {
this.destMin = destination[0];
this.destMax = destination[1];
}

rng = new Random(this.seed);
super.setAppID(APP_ID);
}
/**

/**
* Copy-constructor
*
*
* @param a
*/
public PingApplication(PingApplication a) {
Expand All @@ -109,45 +109,45 @@ public PingApplication(PingApplication a) {
this.pingSize = a.getPingSize();
this.rng = new Random(this.seed);
}
/**

/**
* Handles an incoming message. If the message is a ping message replies
* with a pong message. Generates events for ping and pong messages.
*
*
* @param msg message received by the router
* @param host host to which the application instance is attached
*/
@Override
public Message handle(Message msg, DTNHost host) {
String type = (String)msg.getProperty("type");
if (type==null) return msg; // Not a ping/pong message

// Respond with pong if we're the recipient
if (msg.getTo()==host && type.equalsIgnoreCase("ping")) {
String id = "pong" + SimClock.getIntTime() + "-" +
String id = "pong" + SimClock.getIntTime() + "-" +
host.getAddress();
Message m = new Message(host, msg.getFrom(), id, getPongSize());
m.addProperty("type", "pong");
m.setAppID(APP_ID);
host.createNewMessage(m);

// Send event to listeners
super.sendEventToListeners("GotPing", null, host);
super.sendEventToListeners("SentPong", null, host);
}

// Received a pong reply
if (msg.getTo()==host && type.equalsIgnoreCase("pong")) {
// Send event to listeners
super.sendEventToListeners("GotPong", null, host);
}

return msg;
}

/**
/**
* Draws a random host from the destination range
*
*
* @return host
*/
private DTNHost randomHost() {
Expand All @@ -159,15 +159,15 @@ private DTNHost randomHost() {
World w = SimScenario.getInstance().getWorld();
return w.getNodeByAddress(destaddr);
}

@Override
public Application replicate() {
return new PingApplication(this);
}

/**
/**
* Sends a ping packet if this is an active application instance.
*
*
* @param host to which the application instance is attached
*/
@Override
Expand All @@ -182,10 +182,10 @@ public void update(DTNHost host) {
m.addProperty("type", "ping");
m.setAppID(APP_ID);
host.createNewMessage(m);

// Call listeners
super.sendEventToListeners("SentPing", null, host);

this.lastPing = curTime;
}
}
Expand Down
64 changes: 32 additions & 32 deletions core/Application.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
/*
* Copyright 2010 Aalto University, ComNet
* Released under GPLv3. See LICENSE.txt for details.
* Released under GPLv3. See LICENSE.txt for details.
*/
package core;

Expand All @@ -14,12 +14,12 @@
* properties of the message before returning it or return null to signal
* to the router that it wants the message to be dropped.
* </p>
*
*
* <p>
* In addition, the application's <code>update()</code> method is called every
* simulation cycle.
* </p>
*
*
* <p>
* Configuration of application is done by picking a unique application instance
* name (e.g., mySimpleApp) and setting its <code>type</code> property to the
Expand All @@ -28,90 +28,90 @@
* <code>Group.application</code> setting: <code>Group1.application =
* mySimpleApp</code>.
* </p>
*
*
* @author mjpitka
* @author teemuk
*/
public abstract class Application {

private List<ApplicationListener> aListeners = null;

public String appID = null;

public Application(){
public Application(){
}

/**
* Copy constructor.
*
*
* @param app
*/
public Application(Application app){
public Application(Application app){
this.aListeners = app.getAppListeners();
this.appID = app.appID;
}

/**
* This method handles application functionality related to
* processing of the bundle. Application handles a messages,
* which arrives to the node hosting this application. After
* performing application specific handling, this method returns
* a list of messages. If node wishes to continue forwarding the
* This method handles application functionality related to
* processing of the bundle. Application handles a messages,
* which arrives to the node hosting this application. After
* performing application specific handling, this method returns
* a list of messages. If node wishes to continue forwarding the
* incoming
*
*
* @param msg The incoming message.
* @param host The host this application instance is attached to.
* @return the (possibly modified) message to forward or <code>null</code>
* if the application wants the router to stop forwarding the
* message.
*/
public abstract Message handle(Message msg, DTNHost host);


/**

/**
* Called every simulation cycle.
*
*
* @param host The host this application instance is attached to.
*/
public abstract void update(DTNHost host);
/**

/**
* <p>
* Returns an unique application ID. The application will only receive
* messages with this application ID. If the AppID is set to
* <code>null</code> the application will receive all messages.
* </p>
*
*
* @return Application ID.
*/
public String getAppID() {
return this.appID;
}
/**

/**
* Sets the application ID. Should only set once when the application is
* created. Changing the value during simulation runtime is not recommended
* unless you really know what you're doing.
*
*
* @param appID
*/
public void setAppID(String appID) {
this.appID = appID;
}

public abstract Application replicate();

public void setAppListeners (List<ApplicationListener> aListeners){
this.aListeners = aListeners;
}

public List<ApplicationListener> getAppListeners(){
return this.aListeners;
}
/**

/**
* Sends an event to all listeners.
*
*
* @param event The event to send.
* @param params Any additional parameters to send.
* @param host The host which where the app is running.
Expand Down
34 changes: 17 additions & 17 deletions core/ApplicationListener.java
Original file line number Diff line number Diff line change
@@ -1,35 +1,35 @@
/*
/*
* Copyright 2010 Aalto University, ComNet
* Released under GPLv3. See LICENSE.txt for details.
* Released under GPLv3. See LICENSE.txt for details.
*/
package core;

package core;

/**
* <p>
* Interface for classes that want to be informed about messages
* <p>
* Interface for classes that want to be informed about messages
* between hosts.
* </p>
*
*
* <p>
* Report classes wishing to receive application events should implement this
* interface. Note that the application event names are defined by the
* applications so any class wishing to interpret them must know the
* application.
* </p>
*
*
* @author teemuk
* @author mjpitka
*/
public interface ApplicationListener {
/**
* @author mjpitka
*/
public interface ApplicationListener {

/**
* Application has generated an event.
*
*
* @param event Event name.
* @param params Additional parameters for the event
* @param app Application instance that generated the event.
* @param host The host this application instance is running on.
*/
*/
public void gotEvent(String event, Object params, Application app,
DTNHost host);
}
DTNHost host);
}
Loading

0 comments on commit 304ede9

Please sign in to comment.