Commit eff5d429 authored by Julian Zobel's avatar Julian Zobel 🦄
Browse files

Merge branch 'master' into 'cherry-pick-7698d9d7'

# Conflicts:
#   src/de/tud/kom/p2psim/impl/analyzer/metric/output/MetricOutputDAO.java
#   src/de/tud/kom/p2psim/impl/util/db/dao/DAO.java
parents 1c7f20ec 37020b44
...@@ -23,7 +23,7 @@ package de.tud.kom.p2psim.impl.energy.configs; ...@@ -23,7 +23,7 @@ package de.tud.kom.p2psim.impl.energy.configs;
import de.tud.kom.p2psim.api.common.SimHost; import de.tud.kom.p2psim.api.common.SimHost;
import de.tud.kom.p2psim.api.energy.EnergyConfiguration; import de.tud.kom.p2psim.api.energy.EnergyConfiguration;
import de.tud.kom.p2psim.api.linklayer.mac.PhyType; import de.tud.kom.p2psim.api.linklayer.mac.PhyType;
import de.tud.kom.p2psim.impl.energy.SmartphoneCommunicationEnergyComponent; import de.tud.kom.p2psim.impl.energy.components.SmartphoneCommunicationEnergyComponent;
public class TimeBased implements public class TimeBased implements
EnergyConfiguration<SmartphoneCommunicationEnergyComponent> { EnergyConfiguration<SmartphoneCommunicationEnergyComponent> {
......
...@@ -23,7 +23,7 @@ package de.tud.kom.p2psim.impl.energy.configs; ...@@ -23,7 +23,7 @@ package de.tud.kom.p2psim.impl.energy.configs;
import de.tud.kom.p2psim.api.common.SimHost; import de.tud.kom.p2psim.api.common.SimHost;
import de.tud.kom.p2psim.api.energy.EnergyConfiguration; import de.tud.kom.p2psim.api.energy.EnergyConfiguration;
import de.tud.kom.p2psim.api.linklayer.mac.PhyType; import de.tud.kom.p2psim.api.linklayer.mac.PhyType;
import de.tud.kom.p2psim.impl.energy.StateEnergyCommunicationComponent; import de.tud.kom.p2psim.impl.energy.components.StateEnergyCommunicationComponent;
/** /**
* This class is a configuration for the * This class is a configuration for the
......
...@@ -18,7 +18,7 @@ ...@@ -18,7 +18,7 @@
* *
*/ */
package de.tud.kom.p2psim.impl.energy; package de.tud.kom.p2psim.impl.energy.models;
import java.util.List; import java.util.List;
import java.util.Set; import java.util.Set;
...@@ -26,15 +26,12 @@ import java.util.Vector; ...@@ -26,15 +26,12 @@ import java.util.Vector;
import de.tud.kom.p2psim.api.analyzer.EnergyAnalyzer; import de.tud.kom.p2psim.api.analyzer.EnergyAnalyzer;
import de.tud.kom.p2psim.api.common.SimHost; import de.tud.kom.p2psim.api.common.SimHost;
import de.tud.kom.p2psim.api.energy.Battery;
import de.tud.kom.p2psim.api.energy.ComponentType; import de.tud.kom.p2psim.api.energy.ComponentType;
import de.tud.kom.p2psim.api.energy.EnergyComponent; import de.tud.kom.p2psim.api.energy.EnergyComponent;
import de.tud.kom.p2psim.api.energy.EnergyEventListener;
import de.tud.kom.p2psim.api.energy.EnergyInfo; import de.tud.kom.p2psim.api.energy.EnergyInfo;
import de.tud.kom.p2psim.api.energy.EnergyModel; import de.tud.kom.p2psim.api.energy.EnergyModel;
import de.tud.kom.p2psim.api.energy.EnergyState;
import de.tud.kom.p2psim.api.network.SimNetInterface;
import de.tudarmstadt.maki.simonstrator.api.Monitor; import de.tudarmstadt.maki.simonstrator.api.Monitor;
import de.tudarmstadt.maki.simonstrator.api.Time;
import de.tudarmstadt.maki.simonstrator.api.common.graph.INodeID; import de.tudarmstadt.maki.simonstrator.api.common.graph.INodeID;
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;
...@@ -47,32 +44,25 @@ import de.tudarmstadt.maki.simonstrator.api.component.sis.exception.InformationN ...@@ -47,32 +44,25 @@ import de.tudarmstadt.maki.simonstrator.api.component.sis.exception.InformationN
import de.tudarmstadt.maki.simonstrator.api.component.sis.type.SiSTypes; import de.tudarmstadt.maki.simonstrator.api.component.sis.type.SiSTypes;
/** /**
* The default energy model that is composed of different * The default functionalities for energy models, composed of different
* {@link EnergyComponent}s and configured via the factory. In contrast to the * {@link EnergyComponent}s and configured via the factory.
* <i>old</i> EnergyModels these are Host components, ie. there is one instance
* for each host.
* *
* @author Bjoern Richerzhagen * @author Julian Zobel
* @version 1.0, 27.02.2012 * @version 1.0, 07.09.2018
*/ */
public class ModularEnergyModel implements EnergyModel, EnergyEventListener, public abstract class AbstractEnergyModel implements EnergyModel, BatterySensor, EnergyInfo {
EnergyInfo, BatterySensor {
protected SimHost host;
// private static Logger log = protected List<EnergyComponent> energyComponents;
// SimLogger.getLogger(ModularEnergyModel.class); protected Battery bat;
private SimHost host;
public AbstractEnergyModel(SimHost host, Battery bat) {
private List<EnergyComponent> energyComponents;
private Battery bat;
public ModularEnergyModel(SimHost host, Battery bat) {
energyComponents = new Vector<EnergyComponent>(); energyComponents = new Vector<EnergyComponent>();
this.bat = bat; this.bat = bat;
this.host = host; this.host = host;
} }
@Override @Override
public void initialize() { public void initialize() {
// //
...@@ -137,13 +127,7 @@ public class ModularEnergyModel implements EnergyModel, EnergyEventListener, ...@@ -137,13 +127,7 @@ public class ModularEnergyModel implements EnergyModel, EnergyEventListener,
// OK // OK
} }
} }
@Override
public void shutdown() {
throw new AssertionError(
"You are not supposed to shutdown this component.");
}
@Override @Override
public <T extends EnergyComponent> List<T> getComponents( public <T extends EnergyComponent> List<T> getComponents(
ComponentType type, Class<T> componentClass) { ComponentType type, Class<T> componentClass) {
...@@ -168,15 +152,15 @@ public class ModularEnergyModel implements EnergyModel, EnergyEventListener, ...@@ -168,15 +152,15 @@ public class ModularEnergyModel implements EnergyModel, EnergyEventListener,
} }
return null; return null;
} }
@Override @Override
public EnergyInfo getInfo() { public EnergyInfo getEnergyInfo() {
/* /*
* We export our status to interested applications via this interface * We export our status to interested applications via this interface
*/ */
return this; return this;
} }
@Override @Override
public Battery getBattery() { public Battery getBattery() {
return bat; return bat;
...@@ -189,68 +173,47 @@ public class ModularEnergyModel implements EnergyModel, EnergyEventListener, ...@@ -189,68 +173,47 @@ public class ModularEnergyModel implements EnergyModel, EnergyEventListener,
@Override @Override
public double getCurrentEnergyLevel() { public double getCurrentEnergyLevel() {
return bat.getCurrentEnergyLevel(); return bat.getCurrentEnergy();
} }
@Override @Override
public void registerComponent(EnergyComponent comp) { public SimHost getHost() {
comp.setEnergyEventListener(this); return host;
energyComponents.add(comp);
} }
@Override @Override
public void switchedState(EnergyComponent component, EnergyState oldState, public void shutdown() {
EnergyState newState, long timeSpentInOldState) { throw new AssertionError(
"You are not supposed to shutdown this component.");
if (!bat.isEmpty()) {
double consumedEnergy = oldState.getEnergyConsumption()
* (timeSpentInOldState / (double) Time.SECOND);
bat.consumeEnergy(consumedEnergy);
/*
* TODO Refactor the Energy-Analyzer to support EnergyComponents
* directly, rather than strings.
*/
try {
Monitor.get(EnergyAnalyzer.class).consumeEnergy(getHost(),
consumedEnergy, component);
} catch (AnalyzerNotAvailableException e1) {
//
}
// log.debug(component.toString() + " consumed " + consumedEnergy
// + " uJ in State " + oldState.getName() + " after spending "
// + (timeSpentInOldState/Simulator.SECOND_UNIT) + " sec there.");
if (bat.isEmpty()) {
/*
* Battery is now empty. Go offline.
*/
try {
Monitor.get(EnergyAnalyzer.class).batteryIsEmpty(getHost());
} catch (AnalyzerNotAvailableException e) {
//
}
for (SimNetInterface net : getHost().getNetworkComponent()
.getSimNetworkInterfaces()) {
net.goOffline();
}
}
}
} }
@Override @Override
public boolean turnOn(EnergyComponent component) { public void reset() {
return !bat.isEmpty(); throw new AssertionError(
"You are not supposed to reset this component.");
} }
@Override protected void monitorEnergyConsumation(EnergyComponent component, double consumedEnergy) {
public SimHost getHost() { /*
return host; * TODO Refactor the Energy-Analyzer to support EnergyComponents
* directly, rather than strings.
*/
try {
Monitor.get(EnergyAnalyzer.class).consumeEnergy(getHost(),
consumedEnergy, component);
} catch (AnalyzerNotAvailableException e1) {
//
}
} }
@Override protected void monitorEmptyBattery() {
public void reset() { /*
bat.reset(); * Battery is now empty.
*/
try {
Monitor.get(EnergyAnalyzer.class).batteryIsEmpty(getHost());
} catch (AnalyzerNotAvailableException e) {
//
}
} }
} }
/*
* 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.energy.models;
import de.tud.kom.p2psim.api.common.SimHost;
import de.tud.kom.p2psim.api.energy.Battery;
import de.tud.kom.p2psim.api.energy.EnergyComponent;
import de.tud.kom.p2psim.api.energy.EnergyEventListener;
import de.tud.kom.p2psim.api.network.SimNetInterface;
import de.tud.kom.p2psim.impl.energy.components.StatefulActuatorComponent;
/**
* Energy Model based on multiple exchangeable components. Each component states the amount of consumed energy,
* which the energy model than will remove from the battery.
*
* @author Julian Zobel
* @version 1.0, 11.09.2018
*/
public class ComponentBasedEnergyModel extends AbstractEnergyModel implements EnergyEventListener {
public ComponentBasedEnergyModel(SimHost host, Battery bat) {
super(host, bat);
}
@Override
public void registerComponent(EnergyComponent comp) {
energyComponents.add(comp);
comp.setEnergyEventListener(this);
}
@Override
public void componentConsumedEnergy(EnergyComponent component, double consumedEnergy) {
if (!bat.isEmpty()) {
bat.consumeEnergy(consumedEnergy);
monitorEnergyConsumation(component, consumedEnergy);
if (bat.isEmpty()) {
monitorEmptyBattery();
if(component instanceof StatefulActuatorComponent) {
((StatefulActuatorComponent) component).turnOff();
}
/*
* Battery is now empty. Go offline.
*/
for (SimNetInterface net : getHost().getNetworkComponent()
.getSimNetworkInterfaces()) {
net.goOffline();
}
}
}
}
@Override
public boolean componentCanBeActivated(EnergyComponent component) {
if(!bat.isEmpty()) {
return true;
}
return false;
}
}
...@@ -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) {
...@@ -873,21 +873,23 @@ public abstract class AbstractMacLayer implements MacLayer { ...@@ -873,21 +873,23 @@ public abstract class AbstractMacLayer implements MacLayer {
messageDropped(DropReason.QUEUE_FULL, message); messageDropped(DropReason.QUEUE_FULL, message);
// FIXME BR DEBUG Print it // FIXME BR DEBUG Print it
// int idx = 0; // System.out.println("[AbstractMacLayer] debug output");
// for (QueueEntry qe : queue) { // int idx = 0;
// Message msg = qe.getMessage(); // for (QueueEntry qe : queue) {
// while (msg.getPayload() != null) { // Message msg = qe.getMessage();
// msg = msg.getPayload(); // while (msg.getPayload() != null) {
// } // msg = msg.getPayload();
// System.out.println(idx + " " // }
// + msg.getClass().getSimpleName() + " " // System.out.println(idx + " "
// + msg.toString()); // + msg.getClass().getSimpleName() + " "
// idx++; // + msg.toString());
// } // idx++;
// }
} else { } else {
// still a spot in the queue, add message and notify MAC // still a spot in the queue, add message and notify MAC
queue.add(new QueueEntry(receiver, message)); queue.add(new QueueEntry(receiver, message));
handleNewQueueEntry(); handleNewQueueEntry();
} }
} }
} }
...@@ -896,7 +898,7 @@ public abstract class AbstractMacLayer implements MacLayer { ...@@ -896,7 +898,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 +928,7 @@ public abstract class AbstractMacLayer implements MacLayer { ...@@ -926,7 +928,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 +967,7 @@ public abstract class AbstractMacLayer implements MacLayer { ...@@ -965,7 +967,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
*/ */
...@@ -1011,8 +1013,9 @@ public abstract class AbstractMacLayer implements MacLayer { ...@@ -1011,8 +1013,9 @@ public abstract class AbstractMacLayer implements MacLayer {
} }
@Override @Override
public void turnOff() { public boolean turnOff() {
on = false; on = false;
return true;
} }
public boolean turnOn() { public boolean turnOn() {
...@@ -1028,14 +1031,14 @@ public abstract class AbstractMacLayer implements MacLayer { ...@@ -1028,14 +1031,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
*/ */
...@@ -1066,7 +1069,7 @@ public abstract class AbstractMacLayer implements MacLayer { ...@@ -1066,7 +1069,7 @@ public abstract class AbstractMacLayer implements MacLayer {
out.append(reason.toString()); out.append(reason.toString());
out.append(": "); out.append(": ");
out.append(_messageDropCounters[reason.ordinal()]); out.append(_messageDropCounters[reason.ordinal()]);
out.append("\n"); out.append(" | \n");
} }
return out.toString(); return out.toString();
} }
......
...@@ -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
......
...@@ -46,7 +46,7 @@ import de.tud.kom.p2psim.impl.linklayer.DefaultLinkMessageEvent; ...@@ -46,7 +46,7 @@ import de.tud.kom.p2psim.impl.linklayer.DefaultLinkMessageEvent;
import de.tud.kom.p2psim.impl.linklayer.mac.AbstractMacLayer; import de.tud.kom.p2psim.impl.linklayer.mac.AbstractMacLayer;
import de.tud.kom.p2psim.impl.linklayer.mac.wifi.AbstractRateManager.RateManagerTypes; import de.tud.kom.p2psim.impl.linklayer.mac.wifi.AbstractRateManager.RateManagerTypes;
import de.tud.kom.p2psim.impl.linklayer.mac.wifi.DcfManager.WifiState; import de.tud.kom.p2psim.impl.linklayer.mac.wifi.DcfManager.WifiState;
import de.tud.kom.p2psim.impl.topology.PositionVector; import de.tud.kom.p2psim.impl.topology.util.PositionVector;
import de.tud.kom.p2psim.impl.topology.views.wifi.WifiTopologyView; import de.tud.kom.p2psim.impl.topology.views.wifi.WifiTopologyView;
import de.tud.kom.p2psim.impl.util.LiveMonitoring; import de.tud.kom.p2psim.impl.util.LiveMonitoring;
import de.tud.kom.p2psim.impl.util.LiveMonitoring.ProgressValue; import de.tud.kom.p2psim.impl.util.LiveMonitoring.ProgressValue;
......
...@@ -34,7 +34,7 @@ import de.tud.kom.p2psim.impl.network.gnp.topology.PingErLookup; ...@@ -34,7 +34,7 @@ import de.tud.kom.p2psim.impl.network.gnp.topology.PingErLookup;
import de.tudarmstadt.maki.simonstrator.api.Randoms; import de.tudarmstadt.maki.simonstrator.api.Randoms;
import de.tudarmstadt.maki.simonstrator.api.Time; import de.tudarmstadt.maki.simonstrator.api.Time;
import de.tudarmstadt.maki.simonstrator.api.component.sensor.location.Location; import de.tudarmstadt.maki.simonstrator.api.component.sensor.location.Location;
import umontreal.iro.lecuyer.probdist.LognormalDist; import umontreal.ssj.probdist.LognormalDist;
public class GnpLatencyModel implements NetLatencyModel { public class GnpLatencyModel implements NetLatencyModel {
......
...@@ -23,7 +23,7 @@ package de.tud.kom.p2psim.impl.network.gnp.topology; ...@@ -23,7 +23,7 @@ package de.tud.kom.p2psim.impl.network.gnp.topology;
import de.tud.kom.p2psim.impl.topology.PositionVector; import de.tud.kom.p2psim.impl.topology.util.PositionVector;
import de.tudarmstadt.maki.simonstrator.api.component.sensor.location.Location; import de.tudarmstadt.maki.simonstrator.api.component.sensor.location.Location;
/** /**
......
...@@ -319,12 +319,12 @@ public class GnpPosition implements Location, Comparable<GnpPosition> { ...@@ -319,12 +319,12 @@ public class GnpPosition implements Location, Comparable<GnpPosition> {
} }
@Override @Override
public double getLatitude() { public double getLatitudeOrY() {
throw new UnsupportedOperationException(); throw new UnsupportedOperationException();
} }
@Override @Override
public double getLongitude() { public double getLongitudeOrX() {
throw new UnsupportedOperationException(); throw new UnsupportedOperationException();
} }
......
...@@ -35,7 +35,6 @@ import java.util.Set; ...@@ -35,7 +35,6 @@ import java.util.Set;
import org.dom4j.Element; import org.dom4j.Element;
import org.dom4j.tree.DefaultElement; import org.dom4j.tree.DefaultElement;
import umontreal.iro.lecuyer.probdist.LognormalDist;
import de.tud.kom.p2psim.impl.network.modular.db.NetMeasurementDB; import de.tud.kom.p2psim.impl.network.modular.db.NetMeasurementDB;
import de.tud.kom.p2psim.impl.network.modular.db.NetMeasurementDB.Country; import de.tud.kom.p2psim.impl.network.modular.db.NetMeasurementDB.Country;
import de.tud.kom.p2psim.impl.network.modular.db.NetMeasurementDB.GlobalSummaryRelation; import de.tud.kom.p2psim.impl.network.modular.db.NetMeasurementDB.GlobalSummaryRelation;
...@@ -44,6 +43,7 @@ import de.tud.kom.p2psim.impl.network.modular.db.NetMeasurementDB.RegionRegionSu ...@@ -44,6 +43,7 @@ import de.tud.kom.p2psim.impl.network.modular.db.NetMeasurementDB.RegionRegionSu
import de.tud.kom.p2psim.impl.network.modular.db.NetMeasurementDB.SummaryRelation; import de.tud.kom.p2psim.impl.network.modular.db.NetMeasurementDB.SummaryRelation;
import de.tudarmstadt.maki.simonstrator.api.Monitor; import de.tudarmstadt.maki.simonstrator.api.Monitor;
import de.tudarmstadt.maki.simonstrator.api.Monitor.Level; import de.tudarmstadt.maki.simonstrator.api.Monitor.Level;
import umontreal.ssj.probdist.LognormalDist;
/** /**
* This Class Implements a container for the PingER summary reports used as a * This Class Implements a container for the PingER summary reports used as a
......
...@@ -23,8 +23,7 @@ package de.tud.kom.p2psim.impl.network.modular.common; ...@@ -23,8 +23,7 @@ package de.tud.kom.p2psim.impl.network.modular.common;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections; import java.util.Collections;
import umontreal.ssj.probdist.LognormalDist;
import umontreal.iro.lecuyer.probdist.LognormalDist;
/** /**
* *
......
...@@ -36,7 +36,6 @@ import javax.xml.parsers.ParserConfigurationException; ...@@ -36,7 +36,6 @@ import javax.xml.parsers.ParserConfigurationException;
import org.xml.sax.SAXException; import org.xml.sax.SAXException;
import umontreal.iro.lecuyer.probdist.LognormalDist;
import de.tud.kom.p2psim.impl.network.IPv4NetID; import de.tud.kom.p2psim.impl.network.IPv4NetID;
import de.tud.kom.p2psim.impl.network.modular.common.PingErToolkit; import de.tud.kom.p2psim.impl.network.modular.common.PingErToolkit;
import de.tud.kom.p2psim.impl.util.BackToXMLWritable; import de.tud.kom.p2psim.impl.util.BackToXMLWritable;
...@@ -44,6 +43,7 @@ import de.tud.kom.p2psim.impl.util.SymmetricRelation; ...@@ -44,6 +43,7 @@ import de.tud.kom.p2psim.impl.util.SymmetricRelation;
import de.tud.kom.p2psim.impl.util.Tuple; import de.tud.kom.p2psim.impl.util.Tuple;
import de.tud.kom.p2psim.impl.util.db.relational.DBInstantiationException; import de.tud.kom.p2psim.impl.util.db.relational.DBInstantiationException;
import de.tud.kom.p2psim.impl.util.db.relational.RelationalDB; import de.tud.kom.p2psim.impl.util.db.relational.RelationalDB;
import umontreal.ssj.probdist.LognormalDist;
/** /**
* Database format for measurements of network characteristics for the Modular Network Layer. * Database format for measurements of network characteristics for the Modular Network Layer.
......
...@@ -22,8 +22,7 @@ ...@@ -22,8 +22,7 @@
package de.tud.kom.p2psim.impl.network.modular.st.jitter; package de.tud.kom.p2psim.impl.network.modular.st.jitter;
import java.util.Random; import java.util.Random;
import umontreal.ssj.probdist.LognormalDist;
import umontreal.iro.lecuyer.probdist.LognormalDist;
import de.tud.kom.p2psim.api.network.NetMessage; import de.tud.kom.p2psim.api.network.NetMessage;
import de.tud.kom.p2psim.impl.network.modular.ModularNetLayer; import de.tud.kom.p2psim.impl.network.modular.ModularNetLayer;
import de.tud.kom.p2psim.impl.network.modular.db.NetMeasurementDB; import de.tud.kom.p2psim.impl.network.modular.db.NetMeasurementDB;
......
...@@ -28,7 +28,7 @@ import de.tud.kom.p2psim.api.common.SimHost; ...@@ -28,7 +28,7 @@ import de.tud.kom.p2psim.api.common.SimHost;
import de.tud.kom.p2psim.impl.network.modular.common.GNPToolkit; import de.tud.kom.p2psim.impl.network.modular.common.GNPToolkit;
import de.tud.kom.p2psim.impl.network.modular.db.NetMeasurementDB; import de.tud.kom.p2psim.impl.network.modular.db.NetMeasurementDB;
import de.tud.kom.p2psim.impl.network.modular.st.PositioningStrategy; import de.tud.kom.p2psim.impl.network.modular.st.PositioningStrategy;
import de.tud.kom.p2psim.impl.topology.PositionVector; import de.tud.kom.p2psim.impl.topology.util.PositionVector;
import de.tudarmstadt.maki.simonstrator.api.component.sensor.location.Location; import de.tudarmstadt.maki.simonstrator.api.component.sensor.location.Location;
/** /**
......
...@@ -25,7 +25,7 @@ import de.tud.kom.p2psim.api.common.SimHost; ...@@ -25,7 +25,7 @@ import de.tud.kom.p2psim.api.common.SimHost;
import de.tud.kom.p2psim.impl.network.modular.common.GeoToolkit; import de.tud.kom.p2psim.impl.network.modular.common.GeoToolkit;
import de.tud.kom.p2psim.impl.network.modular.db.NetMeasurementDB; import de.tud.kom.p2psim.impl.network.modular.db.NetMeasurementDB;
import de.tud.kom.p2psim.impl.network.modular.st.PositioningStrategy; import de.tud.kom.p2psim.impl.network.modular.st.PositioningStrategy;
import de.tud.kom.p2psim.impl.topology.PositionVector; import de.tud.kom.p2psim.impl.topology.util.PositionVector;
import de.tudarmstadt.maki.simonstrator.api.component.sensor.location.Location; import de.tudarmstadt.maki.simonstrator.api.component.sensor.location.Location;
/** /**
......
...@@ -26,7 +26,7 @@ import de.tud.kom.p2psim.api.common.SimHost; ...@@ -26,7 +26,7 @@ import de.tud.kom.p2psim.api.common.SimHost;
import de.tud.kom.p2psim.impl.network.modular.db.NetMeasurementDB; import de.tud.kom.p2psim.impl.network.modular.db.NetMeasurementDB;
import de.tud.kom.p2psim.impl.network.modular.st.PositioningStrategy; import de.tud.kom.p2psim.impl.network.modular.st.PositioningStrategy;
import de.tud.kom.p2psim.impl.network.simple.SimpleSubnet; import de.tud.kom.p2psim.impl.network.simple.SimpleSubnet;
import de.tud.kom.p2psim.impl.topology.PositionVector; import de.tud.kom.p2psim.impl.topology.util.PositionVector;
import de.tudarmstadt.maki.simonstrator.api.Randoms; import de.tudarmstadt.maki.simonstrator.api.Randoms;
import de.tudarmstadt.maki.simonstrator.api.component.sensor.location.Location; import de.tudarmstadt.maki.simonstrator.api.component.sensor.location.Location;
......
...@@ -26,7 +26,7 @@ import java.util.Random; ...@@ -26,7 +26,7 @@ import java.util.Random;
import de.tud.kom.p2psim.api.common.SimHost; import de.tud.kom.p2psim.api.common.SimHost;
import de.tud.kom.p2psim.impl.network.modular.db.NetMeasurementDB; import de.tud.kom.p2psim.impl.network.modular.db.NetMeasurementDB;
import de.tud.kom.p2psim.impl.network.modular.st.PositioningStrategy; import de.tud.kom.p2psim.impl.network.modular.st.PositioningStrategy;
import de.tud.kom.p2psim.impl.topology.PositionVector; import de.tud.kom.p2psim.impl.topology.util.PositionVector;
import de.tudarmstadt.maki.simonstrator.api.Randoms; import de.tudarmstadt.maki.simonstrator.api.Randoms;
import de.tudarmstadt.maki.simonstrator.api.component.sensor.location.Location; import de.tudarmstadt.maki.simonstrator.api.component.sensor.location.Location;
......
...@@ -20,7 +20,9 @@ ...@@ -20,7 +20,9 @@
package de.tud.kom.p2psim.impl.scenario.simcfg2.utils; package de.tud.kom.p2psim.impl.scenario.simcfg2.utils;
import de.tud.kom.p2psim.impl.scenario.simcfg2.configuration.SimCfgConfiguration; import de.tud.kom.p2psim.impl.scenario.simcfg2.configuration.SimCfgConfiguration;
import org.apache.log4j.Logger;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import javax.script.*; import javax.script.*;
import java.util.Map; import java.util.Map;
...@@ -30,7 +32,7 @@ import java.util.Map; ...@@ -30,7 +32,7 @@ import java.util.Map;
* @version 1.0, 12.07.13 * @version 1.0, 12.07.13
*/ */
public class SimCfgExpressionExecutor { public class SimCfgExpressionExecutor {
private static final Logger log = Logger.getLogger(SimCfgExpressionExecutor.class); private static final Logger log = LogManager.getLogger(SimCfgExpressionExecutor.class);
private ScriptEngine javascriptEngine = null; private ScriptEngine javascriptEngine = null;
public SimCfgExpressionExecutor() { public SimCfgExpressionExecutor() {
......
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