Skip to content

Commit

Permalink
PacketSender updated hasIP + hasMANET
Browse files Browse the repository at this point in the history
  • Loading branch information
Michał Kit committed Feb 11, 2014
1 parent ab8635c commit 317f57b
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions jdeeco-core/src/cz/cuni/mff/d3s/deeco/network/PacketSender.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,32 +26,42 @@ public abstract class PacketSender implements KnowledgeDataSender {
private static int CURRENT_MESSAGE_ID = Integer.MIN_VALUE;

private final String host;

private final int packetSize;
private final boolean hasMANETNic;
private final boolean hasIPNic;

//FIXME: this would not work if distributed on multiple JVMs
public synchronized static int getNextMessageId() {
CURRENT_MESSAGE_ID++;
return CURRENT_MESSAGE_ID;
}


/**
* Minimum fragment size is at least 12 bytes.
*
*/
public PacketSender(String host, int packetSize) {
public PacketSender(String host, int packetSize, boolean hasMANETNic, boolean hasIPNic) {
// At least 12 because: 4 bytes for the initial frame marker, 4 bytes
// for message id and 4 bytes for packet count.
assert packetSize >= 12;
this.packetSize = packetSize;
this.host = host;
this.hasIPNic = hasIPNic;
this.hasMANETNic = hasMANETNic;

Log.d(String.format("PacketSender at %s uses packetSize = %d", host, packetSize));
}

public PacketSender(String host) {
this(host, Integer.getInteger(DeecoProperties.PACKET_SIZE, DEFAULT_PACKET_SIZE));
this(host, Integer.getInteger(DeecoProperties.PACKET_SIZE, DEFAULT_PACKET_SIZE), true, true);
}

public boolean hasMANETNic() {
return hasMANETNic;
}

public boolean hasIPNic() {
return hasIPNic;
}

@Override
Expand Down

0 comments on commit 317f57b

Please sign in to comment.