Commit 8e78f5af authored by Tobias Meuser's avatar Tobias Meuser
Browse files

Finshed offlaoding

parent 863a0954
...@@ -2,17 +2,17 @@ ...@@ -2,17 +2,17 @@
* Copyright (c) 2005-2010 KOM – Multimedia Communications Lab * Copyright (c) 2005-2010 KOM – Multimedia Communications Lab
* *
* This file is part of PeerfactSim.KOM. * This file is part of PeerfactSim.KOM.
* *
* PeerfactSim.KOM is free software: you can redistribute it and/or modify * PeerfactSim.KOM is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or * the Free Software Foundation, either version 3 of the License, or
* any later version. * any later version.
* *
* PeerfactSim.KOM is distributed in the hope that it will be useful, * PeerfactSim.KOM is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with PeerfactSim.KOM. If not, see <http://www.gnu.org/licenses/>. * along with PeerfactSim.KOM. If not, see <http://www.gnu.org/licenses/>.
* *
...@@ -31,10 +31,10 @@ import de.tudarmstadt.maki.simonstrator.api.component.network.NetworkComponent.N ...@@ -31,10 +31,10 @@ import de.tudarmstadt.maki.simonstrator.api.component.network.NetworkComponent.N
* all parameter-related stuff has to be implemented in the {@link Link}. This * all parameter-related stuff has to be implemented in the {@link Link}. This
* enum is used throughout the new {@link LinkLayer} and also on application * enum is used throughout the new {@link LinkLayer} and also on application
* level if you want to explicitly specify which component to use. * level if you want to explicitly specify which component to use.
* *
* It provides basic defaults for MTU and Drop rates in the medium, which might * It provides basic defaults for MTU and Drop rates in the medium, which might
* be used inside the MacLayer or as part of a {@link Link} * be used inside the MacLayer or as part of a {@link Link}
* *
* @author Bjoern Richerzhagen * @author Bjoern Richerzhagen
* @version 1.0, 25.02.2012 * @version 1.0, 25.02.2012
*/ */
...@@ -44,16 +44,16 @@ public enum PhyType { ...@@ -44,16 +44,16 @@ public enum PhyType {
* Direct wireless connections between adjacent hosts or AP-based (decided * Direct wireless connections between adjacent hosts or AP-based (decided
* by the MAC/TopologyView used). Based on * by the MAC/TopologyView used). Based on
* "WiFi in Ad Hoc Mode: A Meaurement Study" by Anastasi et al. (2004), * "WiFi in Ad Hoc Mode: A Meaurement Study" by Anastasi et al. (2004),
* *
* Assuming the following defaults: 1% drop-rate of LinkLayer-Packets * Assuming the following defaults: 1% drop-rate of LinkLayer-Packets
* (LinkLayer might add retransmission behavior as in 802.11), 5MBit/s netto * (LinkLayer might add retransmission behavior as in 802.11), 5MBit/s netto
* (802.11b) BW, 500us latency, 2,2kB MTU, Broadcast * (802.11b) BW, 500us latency, 2,2kB MTU, Broadcast
*/ */
WIFI(NetInterfaceName.WIFI, 0.01, 5 * Rate.Mbit_s, 500 * Time.MICROSECOND, WIFI(NetInterfaceName.WIFI, 0.01, 12 * Rate.Mbit_s, 500 * Time.MICROSECOND,
2334, true), 2334, true),
/** /**
* A wired connection based on a TopologyView * A wired connection based on a TopologyView
* *
* Assuming the following defaults: 0.1% link-layer loss, 100 Mbit/s, 1ms * Assuming the following defaults: 0.1% link-layer loss, 100 Mbit/s, 1ms
* Link-Latency, 1,5kB MTU * Link-Latency, 1,5kB MTU
*/ */
...@@ -71,7 +71,7 @@ public enum PhyType { ...@@ -71,7 +71,7 @@ public enum PhyType {
500 * Simulator.MICROSECOND_UNIT, 1472, false), 500 * Simulator.MICROSECOND_UNIT, 1472, false),
/** /**
* *
* Bluetooth, short-ranged wireless transmissions between adjacent hosts * Bluetooth, short-ranged wireless transmissions between adjacent hosts
* *
* Assuming the following defaults: zero link-layer packet loss, 3Mbit/s BW, * Assuming the following defaults: zero link-layer packet loss, 3Mbit/s BW,
...@@ -101,7 +101,7 @@ public enum PhyType { ...@@ -101,7 +101,7 @@ public enum PhyType {
private NetInterfaceName netInterfaceName; private NetInterfaceName netInterfaceName;
/** /**
* *
* @param defaultDropProbability * @param defaultDropProbability
* @param defaultRawBW * @param defaultRawBW
* bw in bit/s * bw in bit/s
...@@ -133,7 +133,7 @@ public enum PhyType { ...@@ -133,7 +133,7 @@ public enum PhyType {
/** /**
* The Default BW of a link (unidirectional) in bit/s * The Default BW of a link (unidirectional) in bit/s
* *
* @return * @return
*/ */
public long getDefaultBW() { public long getDefaultBW() {
...@@ -144,7 +144,7 @@ public enum PhyType { ...@@ -144,7 +144,7 @@ public enum PhyType {
* has to return true if the medium is by its nature a broadcast medium (ie. * has to return true if the medium is by its nature a broadcast medium (ie.
* sending a message will prohibit sending for all other hosts in range). If * sending a message will prohibit sending for all other hosts in range). If
* the medium supports Multiplexing such as UMTS, set this to false. * the medium supports Multiplexing such as UMTS, set this to false.
* *
* @return * @return
*/ */
public boolean isBroadcastMedium() { public boolean isBroadcastMedium() {
...@@ -153,7 +153,7 @@ public enum PhyType { ...@@ -153,7 +153,7 @@ public enum PhyType {
/** /**
* Long-term replacement of PHY * Long-term replacement of PHY
* *
* @return * @return
*/ */
public NetInterfaceName getNetInterfaceName() { public NetInterfaceName getNetInterfaceName() {
......
...@@ -2,17 +2,17 @@ ...@@ -2,17 +2,17 @@
* Copyright (c) 2005-2010 KOM – Multimedia Communications Lab * Copyright (c) 2005-2010 KOM – Multimedia Communications Lab
* *
* This file is part of PeerfactSim.KOM. * This file is part of PeerfactSim.KOM.
* *
* PeerfactSim.KOM is free software: you can redistribute it and/or modify * PeerfactSim.KOM is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or * the Free Software Foundation, either version 3 of the License, or
* any later version. * any later version.
* *
* PeerfactSim.KOM is distributed in the hope that it will be useful, * PeerfactSim.KOM is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with PeerfactSim.KOM. If not, see <http://www.gnu.org/licenses/>. * along with PeerfactSim.KOM. If not, see <http://www.gnu.org/licenses/>.
* *
...@@ -60,16 +60,16 @@ import de.tudarmstadt.maki.simonstrator.api.component.network.NetID; ...@@ -60,16 +60,16 @@ import de.tudarmstadt.maki.simonstrator.api.component.network.NetID;
* As with the {@link ModularLinkLayer} you should extend this class to add a * As with the {@link ModularLinkLayer} you should extend this class to add a
* more advanced MAC to ensure basic functionality and consistent behavior. For * more advanced MAC to ensure basic functionality and consistent behavior. For
* this reason, some methods in this class are marked as final... * this reason, some methods in this class are marked as final...
* *
* If a MAC wants to implement a protocol (ie. send messages to other MACs * If a MAC wants to implement a protocol (ie. send messages to other MACs
* without triggering a deliver to higher layers) it can do so by implementing a * without triggering a deliver to higher layers) it can do so by implementing a
* corresponding Message type and/or {@link MacEventInformation}. <b>A Message * corresponding Message type and/or {@link MacEventInformation}. <b>A Message
* is only delivered to the higher layers if notifyLinkLayer is called</b>. * is only delivered to the higher layers if notifyLinkLayer is called</b>.
* *
* This Layer takes care of energy consumption, as long as the sendUnicast and * This Layer takes care of energy consumption, as long as the sendUnicast and
* sendBroadcast-methods are used to dispatch all messages (also the * sendBroadcast-methods are used to dispatch all messages (also the
* control-messages, if a protocol is implemented) * control-messages, if a protocol is implemented)
* *
* @author Bjoern Richerzhagen * @author Bjoern Richerzhagen
* @version 1.0, 21.02.2012 * @version 1.0, 21.02.2012
*/ */
...@@ -98,7 +98,7 @@ public abstract class AbstractMacLayer implements MacLayer { ...@@ -98,7 +98,7 @@ public abstract class AbstractMacLayer implements MacLayer {
* Our own MacAddress on this PHY * Our own MacAddress on this PHY
*/ */
private MacAddress macAddress; private MacAddress macAddress;
/** /**
* Our own IP used by the NetLayer on this PHY. Not available during initialization. * Our own IP used by the NetLayer on this PHY. Not available during initialization.
*/ */
...@@ -127,7 +127,7 @@ public abstract class AbstractMacLayer implements MacLayer { ...@@ -127,7 +127,7 @@ public abstract class AbstractMacLayer implements MacLayer {
private final boolean enableErrorControl; private final boolean enableErrorControl;
/** /**
* *
*/ */
private boolean isOnline; private boolean isOnline;
...@@ -156,7 +156,7 @@ public abstract class AbstractMacLayer implements MacLayer { ...@@ -156,7 +156,7 @@ public abstract class AbstractMacLayer implements MacLayer {
* Returns an approximation of the current bandwidth * Returns an approximation of the current bandwidth
*/ */
protected final BandwidthEstimator currentBandwidth; protected final BandwidthEstimator currentBandwidth;
private final Random random = Randoms.getRandom(AbstractMacLayer.class); private final Random random = Randoms.getRandom(AbstractMacLayer.class);
/* /*
...@@ -179,7 +179,7 @@ public abstract class AbstractMacLayer implements MacLayer { ...@@ -179,7 +179,7 @@ public abstract class AbstractMacLayer implements MacLayer {
/** /**
* Create a new MacLayer without bounds on the outgoing message queue (ie. * Create a new MacLayer without bounds on the outgoing message queue (ie.
* endless size, no limit on the waiting time). * endless size, no limit on the waiting time).
* *
* @param ownMacAddress * @param ownMacAddress
* @param phy * @param phy
* @param maxRetransmissions * @param maxRetransmissions
...@@ -198,7 +198,7 @@ public abstract class AbstractMacLayer implements MacLayer { ...@@ -198,7 +198,7 @@ public abstract class AbstractMacLayer implements MacLayer {
/** /**
* Create a new MacLayer with a bounded outgoing queue (max length) and a * Create a new MacLayer with a bounded outgoing queue (max length) and a
* timeout for messages in said queue. * timeout for messages in said queue.
* *
* @param ownMacAddress * @param ownMacAddress
* @param phy * @param phy
* @param maxQueueLength * @param maxQueueLength
...@@ -291,7 +291,7 @@ public abstract class AbstractMacLayer implements MacLayer { ...@@ -291,7 +291,7 @@ public abstract class AbstractMacLayer implements MacLayer {
/** /**
* Use this component to account for energy consumption. This is safe to * Use this component to account for energy consumption. This is safe to
* use, as it is always backed by a stub - it is never null. * use, as it is always backed by a stub - it is never null.
* *
* @return * @return
*/ */
@Override @Override
...@@ -301,7 +301,7 @@ public abstract class AbstractMacLayer implements MacLayer { ...@@ -301,7 +301,7 @@ public abstract class AbstractMacLayer implements MacLayer {
/** /**
* Current size of the outgoing Queue * Current size of the outgoing Queue
* *
* @return * @return
*/ */
protected final int getQueueSize() { protected final int getQueueSize() {
...@@ -310,7 +310,7 @@ public abstract class AbstractMacLayer implements MacLayer { ...@@ -310,7 +310,7 @@ public abstract class AbstractMacLayer implements MacLayer {
/** /**
* Maximum length of the outgoing queue, if equal to zero there is no limit * Maximum length of the outgoing queue, if equal to zero there is no limit
* *
* @return * @return
*/ */
protected final int getMaxQueueLength() { protected final int getMaxQueueLength() {
...@@ -319,7 +319,7 @@ public abstract class AbstractMacLayer implements MacLayer { ...@@ -319,7 +319,7 @@ public abstract class AbstractMacLayer implements MacLayer {
/** /**
* Gets the maximal retransmissions. * Gets the maximal retransmissions.
* *
* @return the maximal retransmissions. * @return the maximal retransmissions.
*/ */
public final int getMaxRetransmissions() { public final int getMaxRetransmissions() {
...@@ -329,7 +329,7 @@ public abstract class AbstractMacLayer implements MacLayer { ...@@ -329,7 +329,7 @@ public abstract class AbstractMacLayer implements MacLayer {
/** /**
* Maximum time a message is kept in the outgoing queue. If equal to zero * Maximum time a message is kept in the outgoing queue. If equal to zero
* there is no limit. * there is no limit.
* *
* @return * @return
*/ */
protected final long getMaxTimeInQueue() { protected final long getMaxTimeInQueue() {
...@@ -339,7 +339,7 @@ public abstract class AbstractMacLayer implements MacLayer { ...@@ -339,7 +339,7 @@ public abstract class AbstractMacLayer implements MacLayer {
/** /**
* Retrieves and <b>removes</b> the first element in the Queue, after all * Retrieves and <b>removes</b> the first element in the Queue, after all
* entries that already timed out are deleted. * entries that already timed out are deleted.
* *
* @return * @return
*/ */
protected final QueueEntry getQueueHead() { protected final QueueEntry getQueueHead() {
...@@ -351,7 +351,7 @@ public abstract class AbstractMacLayer implements MacLayer { ...@@ -351,7 +351,7 @@ public abstract class AbstractMacLayer implements MacLayer {
* Removes all messages that are already waiting longer than maxTimeInQueue, * Removes all messages that are already waiting longer than maxTimeInQueue,
* notifying messageDropped() for each dropped message. The reason will be * notifying messageDropped() for each dropped message. The reason will be
* QUEUE_TIMEOUT in this case. * QUEUE_TIMEOUT in this case.
* *
*/ */
private void removeOutdatedQueueEntries() { private void removeOutdatedQueueEntries() {
if (maxTimeInQueue == 0) { if (maxTimeInQueue == 0) {
...@@ -371,11 +371,11 @@ public abstract class AbstractMacLayer implements MacLayer { ...@@ -371,11 +371,11 @@ public abstract class AbstractMacLayer implements MacLayer {
/** /**
* This is called whenever a drop occurs within the MAC/PHY. A great * This is called whenever a drop occurs within the MAC/PHY. A great
* opportunity to add an Analyzer or some error handling for higher layers. * opportunity to add an Analyzer or some error handling for higher layers.
* *
* Please note, that this might happen asynchronously - the messages are not * Please note, that this might happen asynchronously - the messages are not
* removed from the queue the second their timeout expires but instead as * removed from the queue the second their timeout expires but instead as
* soon as a new send() or a new getQueueHead() is issued. * soon as a new send() or a new getQueueHead() is issued.
* *
* @param reason * @param reason
* @param msg * @param msg
*/ */
...@@ -402,7 +402,7 @@ public abstract class AbstractMacLayer implements MacLayer { ...@@ -402,7 +402,7 @@ public abstract class AbstractMacLayer implements MacLayer {
/** /**
* Notification: a message arrived! * Notification: a message arrived!
* *
* @param message * @param message
* the message itself * the message itself
* @param info * @param info
...@@ -413,7 +413,7 @@ public abstract class AbstractMacLayer implements MacLayer { ...@@ -413,7 +413,7 @@ public abstract class AbstractMacLayer implements MacLayer {
/** /**
* This is to be called by the MAC if a Message should be passed to upper * This is to be called by the MAC if a Message should be passed to upper
* layers (ie. it is no MAC_ctrl-Message) * layers (ie. it is no MAC_ctrl-Message)
* *
* @param eventInfo * @param eventInfo
*/ */
protected final void notifyLinkLayer(LinkMessageEvent eventInfo) { protected final void notifyLinkLayer(LinkMessageEvent eventInfo) {
...@@ -424,7 +424,7 @@ public abstract class AbstractMacLayer implements MacLayer { ...@@ -424,7 +424,7 @@ public abstract class AbstractMacLayer implements MacLayer {
/** /**
* Send a Message to the MAC on the receiver-side (event scheduling). * Send a Message to the MAC on the receiver-side (event scheduling).
* *
* @param receiver * @param receiver
* @param eventInformation * @param eventInformation
* @param delay * @param delay
...@@ -454,7 +454,7 @@ public abstract class AbstractMacLayer implements MacLayer { ...@@ -454,7 +454,7 @@ public abstract class AbstractMacLayer implements MacLayer {
/** /**
* Use this method to dispatch a broadcast message in your MAC-Layer. It * Use this method to dispatch a broadcast message in your MAC-Layer. It
* will take care of energy consumption and scheduling. * will take care of energy consumption and scheduling.
* *
* @param eventInfo * @param eventInfo
* an implementation of {@link MacEventInformation} containing * an implementation of {@link MacEventInformation} containing
* information about the message to send as well as the message * information about the message to send as well as the message
...@@ -516,7 +516,7 @@ public abstract class AbstractMacLayer implements MacLayer { ...@@ -516,7 +516,7 @@ public abstract class AbstractMacLayer implements MacLayer {
/** /**
* Send an unicast message * Send an unicast message
* *
* @param toSend * @param toSend
*/ */
protected final long sendUnicast(MacEventInformation eventInfo) { protected final long sendUnicast(MacEventInformation eventInfo) {
...@@ -592,13 +592,13 @@ public abstract class AbstractMacLayer implements MacLayer { ...@@ -592,13 +592,13 @@ public abstract class AbstractMacLayer implements MacLayer {
* broadcast, the BW should be constant across all links (we assume the PHY * broadcast, the BW should be constant across all links (we assume the PHY
* selects a fixed, more robust modulation for Broadcasts), as there is no * selects a fixed, more robust modulation for Broadcasts), as there is no
* handshaking. Therefore, Broadcasts have no retransmits. * handshaking. Therefore, Broadcasts have no retransmits.
* *
* This method <b>must be called exactly once</b> for every receiver of a * This method <b>must be called exactly once</b> for every receiver of a
* message (in the unicast case, it will be called only once). The receiver * message (in the unicast case, it will be called only once). The receiver
* is determined by the link-object. Access this method via the sendUnicast * is determined by the link-object. Access this method via the sendUnicast
* and sendBroadcast methods to ensure correct behavior of all callbacks and * and sendBroadcast methods to ensure correct behavior of all callbacks and
* events. * events.
* *
* @param eventInfo * @param eventInfo
* containing the Message * containing the Message
* @param l * @param l
...@@ -758,10 +758,10 @@ public abstract class AbstractMacLayer implements MacLayer { ...@@ -758,10 +758,10 @@ public abstract class AbstractMacLayer implements MacLayer {
* sending would be possible at the full RawBandwidth of the PHY). A more * sending would be possible at the full RawBandwidth of the PHY). A more
* advanced MAC will add some coding (making the message larger) and access * advanced MAC will add some coding (making the message larger) and access
* control scheme for multiple transmissions. * control scheme for multiple transmissions.
* *
* This time is later used to account for energy consumption at sender and * This time is later used to account for energy consumption at sender and
* receiver. * receiver.
* *
* @param msg * @param msg
* @param l * @param l
* @return * @return
...@@ -782,7 +782,7 @@ public abstract class AbstractMacLayer implements MacLayer { ...@@ -782,7 +782,7 @@ public abstract class AbstractMacLayer implements MacLayer {
/** /**
* Overwrite this method to implement additional event handling, if needed. * Overwrite this method to implement additional event handling, if needed.
* *
* @param se * @param se
*/ */
protected void handleEvent(Object data, int type) { protected void handleEvent(Object data, int type) {
...@@ -896,7 +896,7 @@ public abstract class AbstractMacLayer implements MacLayer { ...@@ -896,7 +896,7 @@ public abstract class AbstractMacLayer implements MacLayer {
public final MacAddress getMacAddress() { public final MacAddress getMacAddress() {
return macAddress; return macAddress;
} }
@Override @Override
public NetID getNetId() { public NetID getNetId() {
if (netID == null) { if (netID == null) {
...@@ -926,7 +926,7 @@ public abstract class AbstractMacLayer implements MacLayer { ...@@ -926,7 +926,7 @@ public abstract class AbstractMacLayer implements MacLayer {
/** /**
* An entry in the Message queue of the MAC * An entry in the Message queue of the MAC
* *
* @author Bjoern Richerzhagen * @author Bjoern Richerzhagen
* @version 1.0, 21.02.2012 * @version 1.0, 21.02.2012
*/ */
...@@ -965,7 +965,7 @@ public abstract class AbstractMacLayer implements MacLayer { ...@@ -965,7 +965,7 @@ public abstract class AbstractMacLayer implements MacLayer {
* A Stub for an {@link EnergyCommunicationComponent} to allow simulations * A Stub for an {@link EnergyCommunicationComponent} to allow simulations
* without an energy model. Otherwise we would have to flood the code with * without an energy model. Otherwise we would have to flood the code with
* if == null statements. * if == null statements.
* *
* @author Bjoern Richerzhagen * @author Bjoern Richerzhagen
* @version 1.0, 27.02.2012 * @version 1.0, 27.02.2012
*/ */
...@@ -1028,14 +1028,14 @@ public abstract class AbstractMacLayer implements MacLayer { ...@@ -1028,14 +1028,14 @@ public abstract class AbstractMacLayer implements MacLayer {
@Override @Override
public void doFakeStateChange() { public void doFakeStateChange() {
// TODO Auto-generated method stub // TODO Auto-generated method stub
} }
} }
/** /**
* A Live-Analyzer that aggregates Message Drop reasons inside the MAC. * A Live-Analyzer that aggregates Message Drop reasons inside the MAC.
* *
* @author Bjoern Richerzhagen * @author Bjoern Richerzhagen
* @version 1.0, 26.03.2012 * @version 1.0, 26.03.2012
*/ */
......
...@@ -2,17 +2,17 @@ ...@@ -2,17 +2,17 @@
* Copyright (c) 2005-2010 KOM – Multimedia Communications Lab * Copyright (c) 2005-2010 KOM – Multimedia Communications Lab
* *
* This file is part of PeerfactSim.KOM. * This file is part of PeerfactSim.KOM.
* *
* PeerfactSim.KOM is free software: you can redistribute it and/or modify * PeerfactSim.KOM is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or * the Free Software Foundation, either version 3 of the License, or
* any later version. * any later version.
* *
* PeerfactSim.KOM is distributed in the hope that it will be useful, * PeerfactSim.KOM is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with PeerfactSim.KOM. If not, see <http://www.gnu.org/licenses/>. * along with PeerfactSim.KOM. If not, see <http://www.gnu.org/licenses/>.
* *
...@@ -37,7 +37,7 @@ import de.tudarmstadt.maki.simonstrator.api.Time; ...@@ -37,7 +37,7 @@ import de.tudarmstadt.maki.simonstrator.api.Time;
* the other (this does not imply that this MAC handles collisions on a * the other (this does not imply that this MAC handles collisions on a
* broadcast medium). It just mimics the behavior of the ModularNetLayer with a * broadcast medium). It just mimics the behavior of the ModularNetLayer with a
* TrafficControl-Strategy enabled. * TrafficControl-Strategy enabled.
* *
* @author Bjoern Richerzhagen * @author Bjoern Richerzhagen
* @version 1.0, 24.03.2012 * @version 1.0, 24.03.2012
*/ */
...@@ -64,7 +64,7 @@ public class EnqueuingMac extends AbstractMacLayer { ...@@ -64,7 +64,7 @@ public class EnqueuingMac extends AbstractMacLayer {
* A MAC that provides an outgoing queue (messages are sent one after the * A MAC that provides an outgoing queue (messages are sent one after the
* other). This may lead to packet drop if the queue is bound or if a * other). This may lead to packet drop if the queue is bound or if a
* timeout is configured and the message has been in the queue for too long. * timeout is configured and the message has been in the queue for too long.
* *
* @param ownMacAddress * @param ownMacAddress
* @param phy * @param phy
* @param maxQueueLength * @param maxQueueLength
......
...@@ -145,6 +145,8 @@ public class DefaultConfigurator implements Configurator { ...@@ -145,6 +145,8 @@ public class DefaultConfigurator implements Configurator {
private Map<String, String> variables = new LinkedHashMap<String, String>(); private Map<String, String> variables = new LinkedHashMap<String, String>();
private boolean _parseOnly = false;
/** /**
* Create new configurator instance with the configuration data in the given * Create new configurator instance with the configuration data in the given
* XML file. * XML file.
...@@ -199,6 +201,13 @@ public class DefaultConfigurator implements Configurator { ...@@ -199,6 +201,13 @@ public class DefaultConfigurator implements Configurator {
} }
} }
public Map<String, String> parseAllDefaults() throws ConfigurationException {
_parseOnly = true;
configureAll();
_parseOnly = false;
return getVariables();
}
/** /**
* Configure all components of the simulator. The single components are * Configure all components of the simulator. The single components are
* either registered via the <code>register(name, component)</code> method * either registered via the <code>register(name, component)</code> method
...@@ -273,7 +282,9 @@ public class DefaultConfigurator implements Configurator { ...@@ -273,7 +282,9 @@ public class DefaultConfigurator implements Configurator {
} else if (elem.getName().equals(Configurator.DEFAULT_TAG)) { } else if (elem.getName().equals(Configurator.DEFAULT_TAG)) {
configureDefaults(elem); configureDefaults(elem);
} else { } else {
configureComponent(elem); if (!_parseOnly) {
configureComponent(elem);
}
} }
} }
} }
......
...@@ -416,7 +416,10 @@ public class DefaultCachingComponent implements CachingComponent, ConnectivityLi ...@@ -416,7 +416,10 @@ public class DefaultCachingComponent implements CachingComponent, ConnectivityLi
@Override @Override
public String getNodeDescription() { public String getNodeDescription() {
return " " + getHost().getId(); if (getHost().getId().value() > 47) {
return " " + getHost().getId();
}
return "";
} }
@Override @Override
......
...@@ -20,6 +20,8 @@ ...@@ -20,6 +20,8 @@
package de.tud.kom.p2psim.impl.vehicular.decision; package de.tud.kom.p2psim.impl.vehicular.decision;
import java.util.List;
import de.tudarmstadt.maki.simonstrator.api.Event; import de.tudarmstadt.maki.simonstrator.api.Event;
import de.tudarmstadt.maki.simonstrator.api.EventHandler; import de.tudarmstadt.maki.simonstrator.api.EventHandler;
import de.tudarmstadt.maki.simonstrator.api.Host; import de.tudarmstadt.maki.simonstrator.api.Host;
...@@ -27,6 +29,8 @@ import de.tudarmstadt.maki.simonstrator.api.Monitor; ...@@ -27,6 +29,8 @@ import de.tudarmstadt.maki.simonstrator.api.Monitor;
import de.tudarmstadt.maki.simonstrator.api.Time; import de.tudarmstadt.maki.simonstrator.api.Time;
import de.tudarmstadt.maki.simonstrator.api.component.ComponentNotAvailableException; import de.tudarmstadt.maki.simonstrator.api.component.ComponentNotAvailableException;
import de.tudarmstadt.maki.simonstrator.api.component.core.MonitorComponent.AnalyzerNotAvailableException; import de.tudarmstadt.maki.simonstrator.api.component.core.MonitorComponent.AnalyzerNotAvailableException;
import de.tudarmstadt.maki.simonstrator.api.component.sensor.environment.EnvironmentSensor;
import de.tudarmstadt.maki.simonstrator.api.component.sensor.environment.data.Environment;
import de.tudarmstadt.maki.simonstrator.api.component.vehicular.VehicleDecisionComponent; import de.tudarmstadt.maki.simonstrator.api.component.vehicular.VehicleDecisionComponent;
import de.tudarmstadt.maki.simonstrator.api.component.vehicular.VehicleInformationComponent; import de.tudarmstadt.maki.simonstrator.api.component.vehicular.VehicleInformationComponent;
import de.tudarmstadt.maki.simonstrator.api.component.vehicular.caching.CachingComponent; import de.tudarmstadt.maki.simonstrator.api.component.vehicular.caching.CachingComponent;
...@@ -45,6 +49,8 @@ public abstract class AbstractVehicleDecisionComponent implements VehicleDecisio ...@@ -45,6 +49,8 @@ public abstract class AbstractVehicleDecisionComponent implements VehicleDecisio
private boolean _routeAnalyzerInit = false; private boolean _routeAnalyzerInit = false;
private VehicleRouteAnalyzer _routeAnalyzer = null; private VehicleRouteAnalyzer _routeAnalyzer = null;
private EnvironmentSensor _sensors;
public AbstractVehicleDecisionComponent(Host pHost) { public AbstractVehicleDecisionComponent(Host pHost) {
_host = pHost; _host = pHost;
} }
...@@ -52,7 +58,8 @@ public abstract class AbstractVehicleDecisionComponent implements VehicleDecisio ...@@ -52,7 +58,8 @@ public abstract class AbstractVehicleDecisionComponent implements VehicleDecisio
@Override @Override
public void initialize() { public void initialize() {
try { try {
_cache = getHost().getComponent(CachingComponent.class); _cache = getHost().getComponent(CachingComponent.class);
_sensors = getHost().getComponent(EnvironmentSensor.class);
} catch (ComponentNotAvailableException e) { } catch (ComponentNotAvailableException e) {
throw new AssertionError(e); throw new AssertionError(e);
} }
...@@ -90,29 +97,27 @@ public abstract class AbstractVehicleDecisionComponent implements VehicleDecisio ...@@ -90,29 +97,27 @@ public abstract class AbstractVehicleDecisionComponent implements VehicleDecisio
case EVENT_DECISION_MAKING_CYCLE: case EVENT_DECISION_MAKING_CYCLE:
RoadNetworkRoute currentRoute = getVehicleInformation().getCurrentRoute(); RoadNetworkRoute currentRoute = getVehicleInformation().getCurrentRoute();
if (currentRoute != null && currentRoute.getRoute().size() > 2) { if (currentRoute != null) {
boolean changed = false; boolean changed = false;
if (currentRoute.getRoute().size() > 2) {
BenefitBasedRoute optimalRouteWithBenefit = getOptimalRoute(currentRoute, BenefitBasedRoute optimalRouteWithBenefit = getOptimalRoute(currentRoute,
_cache.getDecidedCacheEntries(RoadInformation.class)); _cache.getDecidedCacheEntries(RoadInformation.class), _sensors.getEnvironment());
if (optimalRouteWithBenefit != null) { if (optimalRouteWithBenefit != null) {
RoadNetworkRoute optimalRoute = optimalRouteWithBenefit.getRoute(); RoadNetworkRoute optimalRoute = optimalRouteWithBenefit.getRoute();
if (optimalRouteWithBenefit.getRoute().getRoute().size() > 1) { if (optimalRouteWithBenefit.getRoute().getRoute().size() > 1) {
if (currentRoute.getRoute().get(1) != optimalRoute.getRoute().get(1)) { if (currentRoute.getRoute().get(1) != optimalRoute.getRoute().get(1)) {
if (hasRouteAnalyzer()) { if (hasRouteAnalyzer()) {
getRouteAnalyzer().routeChanged(getHost().getId(), currentRoute, optimalRoute); getRouteAnalyzer().routeChanged(getHost().getId(), currentRoute, optimalRoute);
} }
changed = true; changed = true;
getVehicleInformation().changeCurrentRoute(optimalRouteWithBenefit.getRoute()); getVehicleInformation().changeCurrentRoute(optimalRouteWithBenefit.getRoute());
} }
} }
} }
}
if (!changed) { if (!changed && hasRouteAnalyzer()) {
if (hasRouteAnalyzer()) { getRouteAnalyzer().routeUnchanged(getHost().getId(), currentRoute);
getRouteAnalyzer().routeUnchanged(getHost().getId(), currentRoute); }
}
}
} }
Event.scheduleWithDelay(Time.SECOND, this, null, EVENT_DECISION_MAKING_CYCLE); Event.scheduleWithDelay(Time.SECOND, this, null, EVENT_DECISION_MAKING_CYCLE);
......
...@@ -23,6 +23,7 @@ package de.tud.kom.p2psim.impl.vehicular.decision; ...@@ -23,6 +23,7 @@ package de.tud.kom.p2psim.impl.vehicular.decision;
import java.util.List; import java.util.List;
import de.tudarmstadt.maki.simonstrator.api.Host; import de.tudarmstadt.maki.simonstrator.api.Host;
import de.tudarmstadt.maki.simonstrator.api.component.sensor.environment.data.properties.RoadProperty;
import de.tudarmstadt.maki.simonstrator.api.component.vehicular.information.RoadInformation; import de.tudarmstadt.maki.simonstrator.api.component.vehicular.information.RoadInformation;
import de.tudarmstadt.maki.simonstrator.api.component.vehicular.roadnetwork.RoadNetworkRoute; import de.tudarmstadt.maki.simonstrator.api.component.vehicular.roadnetwork.RoadNetworkRoute;
......
/*
* Copyright (c) 2005-2010 KOM – Multimedia Communications Lab
*
* This file is part of PeerfactSim.KOM.
*
* PeerfactSim.KOM is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
*
* PeerfactSim.KOM is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with PeerfactSim.KOM. If not, see <http://www.gnu.org/licenses/>.
*
*/
package de.tud.kom.p2psim.impl.vehicular.decision;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import de.tudarmstadt.maki.simonstrator.api.Host;
import de.tudarmstadt.maki.simonstrator.api.component.sensor.environment.data.properties.RoadProperty;
import de.tudarmstadt.maki.simonstrator.api.component.vehicular.information.RoadInformation;
import de.tudarmstadt.maki.simonstrator.api.component.vehicular.roadnetwork.RoadNetwork;
import de.tudarmstadt.maki.simonstrator.api.component.vehicular.roadnetwork.RoadNetworkEdge;
import de.tudarmstadt.maki.simonstrator.api.component.vehicular.roadnetwork.RoadNetworkRoute;
import de.tudarmstadt.maki.simonstrator.api.component.vehicular.roadnetwork.routing.DijkstraAlgorithm;
public class LatestPossibleVehicleDecisionComponent extends AbstractVehicleDecisionComponent {
public LatestPossibleVehicleDecisionComponent(Host pHost) {
super(pHost);
}
@Override
public BenefitBasedRoute getOptimalRoute(RoadNetworkRoute pInvestigatedRoute, List<RoadInformation> knownInformation) {
List<RoadInformation> actualKnownInformation = new ArrayList<>();
if (getVehicleInformation().isValid() && knownInformation != null) {
for (RoadInformation roadInformation : knownInformation) {
RoadProperty property = roadInformation.getValue();
if (!property.getValue().equals(property.getDefaultProperty().getValue())) {
if (pInvestigatedRoute.getStart().getAccessibleEdges().contains(roadInformation.getEdge())) {
actualKnownInformation.add(roadInformation);
}
}
}
DijkstraAlgorithm dijkstraAlgorithm = new DijkstraAlgorithm();
List<RoadNetworkEdge> blocked = new ArrayList<>();
for (RoadInformation roadInformation : actualKnownInformation) {
if (!blocked.contains(roadInformation.getEdge())) {
blocked.add(roadInformation.getEdge());
}
}
RoadNetworkRoute route = dijkstraAlgorithm.findRoute(RoadNetwork.CURRENT_ROAD_NETWORK, getVehicleInformation().getCurrentRoute().getStart(), getVehicleInformation().getCurrentRoute().getDestination(), Collections.emptyList(), blocked);
if (route != null) {
double oldCosts = 0;
for (RoadNetworkEdge edge : pInvestigatedRoute.getRoute()) {
oldCosts += edge.calculateStandardEdgeCosts();
if (knownInformation != null) {
for (RoadInformation roadInformation : actualKnownInformation) {
oldCosts += edge.calculateAdditionalCostIfKnown(roadInformation.getValue());
}
}
}
double newCosts = 0;
for (RoadNetworkEdge edge : route.getRoute()) {
newCosts += edge.calculateStandardEdgeCosts();
if (knownInformation != null) {
for (RoadInformation roadInformation : actualKnownInformation) {
newCosts += edge.calculateAdditionalCostIfKnown(roadInformation.getValue());
}
}
}
if (oldCosts > newCosts) {
return new BenefitBasedRoute(oldCosts - newCosts, route);
}
}
return new BenefitBasedRoute(0, pInvestigatedRoute);
}
return null;
}
}
...@@ -25,6 +25,7 @@ import java.util.Collections; ...@@ -25,6 +25,7 @@ import java.util.Collections;
import java.util.List; import java.util.List;
import de.tudarmstadt.maki.simonstrator.api.Host; import de.tudarmstadt.maki.simonstrator.api.Host;
import de.tudarmstadt.maki.simonstrator.api.component.sensor.environment.data.Environment;
import de.tudarmstadt.maki.simonstrator.api.component.sensor.environment.data.properties.RoadProperty; import de.tudarmstadt.maki.simonstrator.api.component.sensor.environment.data.properties.RoadProperty;
import de.tudarmstadt.maki.simonstrator.api.component.vehicular.information.RoadInformation; import de.tudarmstadt.maki.simonstrator.api.component.vehicular.information.RoadInformation;
import de.tudarmstadt.maki.simonstrator.api.component.vehicular.roadnetwork.RoadNetwork; import de.tudarmstadt.maki.simonstrator.api.component.vehicular.roadnetwork.RoadNetwork;
...@@ -39,24 +40,34 @@ public class VisionBasedVehicleDecisionComponent extends AbstractVehicleDecision ...@@ -39,24 +40,34 @@ public class VisionBasedVehicleDecisionComponent extends AbstractVehicleDecision
} }
@Override @Override
public BenefitBasedRoute getOptimalRoute(RoadNetworkRoute pInvestigatedRoute, List<RoadInformation> knownInformation) { public BenefitBasedRoute getOptimalRoute(RoadNetworkRoute pInvestigatedRoute,
List<RoadInformation> actualKnownInformation = new ArrayList<>(); List<RoadInformation> pKnownInformation) {
return new BenefitBasedRoute(0, pInvestigatedRoute);
}
@Override
public BenefitBasedRoute getOptimalRoute(RoadNetworkRoute pInvestigatedRoute, List<RoadInformation> knownInformation, Environment pEnvironment) {
List<RoadProperty> actualKnownInformation = new ArrayList<>();
if (getVehicleInformation().isValid() && knownInformation != null) { if (getVehicleInformation().isValid()) {
for (RoadInformation roadInformation : knownInformation) { if (knownInformation != null) {
RoadProperty property = roadInformation.getValue(); for (RoadInformation roadInformation : knownInformation) {
if (!property.getValue().equals(property.getDefaultProperty().getValue())) { RoadProperty property = roadInformation.getValue();
if (pInvestigatedRoute.getStart().getAccessibleEdges().contains(roadInformation.getEdge())) { if (!property.getValue().equals(property.getDefaultProperty().getValue())) {
actualKnownInformation.add(roadInformation); if (pInvestigatedRoute.getStart().getAccessibleEdges().contains(roadInformation.getEdge())) {
actualKnownInformation.add(roadInformation.getValue());
}
} }
} }
} }
actualKnownInformation.addAll(pEnvironment.getProperties(RoadProperty.class));
DijkstraAlgorithm dijkstraAlgorithm = new DijkstraAlgorithm(); DijkstraAlgorithm dijkstraAlgorithm = new DijkstraAlgorithm();
List<RoadNetworkEdge> blocked = new ArrayList<>(); List<RoadNetworkEdge> blocked = new ArrayList<>();
for (RoadInformation roadInformation : actualKnownInformation) { for (RoadProperty roadInformation : actualKnownInformation) {
if (!blocked.contains(roadInformation.getEdge())) { if (!blocked.contains(roadInformation.getEdge()) && roadInformation.getEdge().isActive()) {
blocked.add(roadInformation.getEdge()); blocked.add(roadInformation.getEdge());
} }
} }
...@@ -66,20 +77,16 @@ public class VisionBasedVehicleDecisionComponent extends AbstractVehicleDecision ...@@ -66,20 +77,16 @@ public class VisionBasedVehicleDecisionComponent extends AbstractVehicleDecision
double oldCosts = 0; double oldCosts = 0;
for (RoadNetworkEdge edge : pInvestigatedRoute.getRoute()) { for (RoadNetworkEdge edge : pInvestigatedRoute.getRoute()) {
oldCosts += edge.calculateStandardEdgeCosts(); oldCosts += edge.calculateStandardEdgeCosts();
if (knownInformation != null) { for (RoadProperty roadInformation : actualKnownInformation) {
for (RoadInformation roadInformation : actualKnownInformation) { oldCosts += edge.calculateAdditionalCostIfKnown(roadInformation);
oldCosts += edge.calculateAdditionalCostIfKnown(roadInformation.getValue());
}
} }
} }
double newCosts = 0; double newCosts = 0;
for (RoadNetworkEdge edge : route.getRoute()) { for (RoadNetworkEdge edge : route.getRoute()) {
newCosts += edge.calculateStandardEdgeCosts(); newCosts += edge.calculateStandardEdgeCosts();
if (knownInformation != null) { for (RoadProperty roadInformation : actualKnownInformation) {
for (RoadInformation roadInformation : actualKnownInformation) { newCosts += edge.calculateAdditionalCostIfKnown(roadInformation);
newCosts += edge.calculateAdditionalCostIfKnown(roadInformation.getValue());
}
} }
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment