Commit 5922b411 authored by Björn Richerzhagen's avatar Björn Richerzhagen
Browse files

Fixes in the TopologyView and Enqueuing Mac

- configuration of whether receiver-queue is taken into account is now
based on the selected TopologyView
- fixed min-time for dropped msgs to be 1 us instead of 1 ms.
- deleted obsolete (unused) CollisionAwareMac. Use 80211 instead.
parent b1ae37ae
......@@ -134,4 +134,13 @@ public interface TopologyView
*/
public double getDistance(MacAddress addressA, MacAddress addressB);
/**
* Denotes whether this {@link TopologyView} has a real link layer (i.e.,
* hosts within this view act as Layer 2 elements, connected by a layer 2
* link). In "Internet-wide" topology views, this is usually NOT the case.
*
* @return
*/
public boolean hasRealLinkLayer();
}
......@@ -572,7 +572,7 @@ public abstract class AbstractMacLayer implements MacLayer {
* We have no neighbors!
*/
eventInfo.arrivedAt(this, true);
timeToSend = 1 * Time.MILLISECOND;
timeToSend = 1 * Time.MICROSECOND;
}
return timeToSend;
}
......
/*
* 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.linklayer.mac;
import de.tud.kom.p2psim.api.common.SimHost;
import de.tud.kom.p2psim.api.linklayer.mac.MacAddress;
import de.tud.kom.p2psim.api.linklayer.mac.MacLayer;
import de.tud.kom.p2psim.api.linklayer.mac.PhyType;
import de.tud.kom.p2psim.api.network.BandwidthImpl;
import de.tudarmstadt.maki.simonstrator.api.Message;
/**
* This MAC provides an outgoing queue and schedules messages in a shared
* Medium. It is ensured that no MAC sends while another MAC within range is
* sending. Of course, this only makes sense in a Broadcast-Medium.
*
* @author Bjoern Richerzhagen
* @version 1.0, 27.03.2012
*/
public class CollisionAwareMac extends EnqueuingMac {
/**
* Create a new MAC for a broadcast-medium that avoids collisions
*
* @param ownMacAddress
* @param phy
* @param maxQueueLength
* @param maxTimeInQueue
* @param maxRetransmissions
* @param bandwidth
* the maximum BW of this MAC (i.e. the BW that would be achieved
* if messages are not queued)
*/
public CollisionAwareMac(SimHost host, MacAddress ownMacAddress,
PhyType phy,
int maxQueueLength, long maxTimeInQueue, int maxRetransmissions,
BandwidthImpl bandwidth) {
super(host, ownMacAddress, phy, maxQueueLength, maxTimeInQueue,
maxRetransmissions, bandwidth);
if (!phy.isBroadcastMedium()) {
throw new AssertionError(
"The CollisionAwareMac requires a Broadcast-PHY such as WIFI or BLUETOOTH");
}
}
/*
*
* TODO
*/
/**
* The EventInfo-Object that is used by this MAC to track blocking of MACs
*
* @author Bjoern Richerzhagen
* @version 1.0, 27.03.2012
*/
protected class CollisionAwareMacEventInfo extends
DefaultMacEventInformation {
public CollisionAwareMacEventInfo(Message msg, EnqueuingMac sender,
MacAddress receiver, long timeInQueue) {
super(msg, sender.getMacAddress(), receiver, timeInQueue);
}
@Override
public void arrivedAt(MacLayer receiver, boolean wasDropped) {
super.arrivedAt(receiver, wasDropped);
}
}
}
......@@ -29,7 +29,6 @@ import de.tud.kom.p2psim.api.linklayer.mac.PhyType;
import de.tud.kom.p2psim.api.network.BandwidthImpl;
import de.tud.kom.p2psim.api.scenario.ConfigurationException;
import de.tud.kom.p2psim.impl.linklayer.DefaultLinkMessageEvent;
import de.tud.kom.p2psim.impl.topology.views.CloudTopologyView;
import de.tudarmstadt.maki.simonstrator.api.Event;
import de.tudarmstadt.maki.simonstrator.api.Time;
......@@ -53,8 +52,11 @@ public class EnqueuingMac extends AbstractMacLayer {
private long nextRcvTime = 0;
/**
* This will simulate the incoming queue at the receiver as well. Does only
* make sense in a scenario where there is no
* This will simulate the incoming queue at the receiver as well. This does
* only make sense in topologyViews that consider real link layers (e.g.,
* Wi-Fi). For all Internet-scale scenarios, where we use links as a concept
* for a connection between end hosts and not in the sense of a real link
* layer, this HAS TO BE false.
*/
private boolean simulateReceiverQueue = true;
......@@ -82,15 +84,7 @@ public class EnqueuingMac extends AbstractMacLayer {
@Override
public void initialize() throws ConfigurationException {
super.initialize();
if (getTopologyView() instanceof CloudTopologyView) {
/*
* In this case, we do not have a "real" Linklayer, i.e. messages
* will travel over multiple hops that are not simulated. Therefore,
* we do not wait until the message can be received by the other
* MAC, before we send the next one.
*/
simulateReceiverQueue = false;
}
this.simulateReceiverQueue = getTopologyView().hasRealLinkLayer();
}
@Override
......
......@@ -104,6 +104,12 @@ public abstract class AbstractTopologyView<L extends DefaultLink> implements
*/
private boolean movementSupported = false;
/**
* Indicating, that this view is targeted towards the simulations of real
* link layers. See {@link TopologyView}.
*/
private boolean hasRealLinkLayer = false;
/**
* Basic TopologyView, does not support movement
*
......@@ -484,4 +490,19 @@ public abstract class AbstractTopologyView<L extends DefaultLink> implements
return getCachedPosition(addressA)
.distanceTo(getCachedPosition(addressB));
}
@Override
public boolean hasRealLinkLayer() {
return hasRealLinkLayer;
}
/**
* Mark that this {@link TopologyView} has a real link layer (latencies and
* drop rates are Layer 2 measurements!)
*
* @param hasRealLinkLayer
*/
public void setHasRealLinkLayer(boolean hasRealLinkLayer) {
this.hasRealLinkLayer = hasRealLinkLayer;
}
}
......@@ -51,6 +51,7 @@ public class CloudTopologyView extends AbstractTopologyView<DefaultLink> {
public CloudTopologyView(PhyType phy) {
super(phy);
setHasRealLinkLayer(false);
}
@XMLConfigurableConstructor({ "phy" })
......
......@@ -119,6 +119,7 @@ public class FiveGTopologyView extends AbstractTopologyView<CellLink> {
*/
public FiveGTopologyView(PhyType phy) {
super(phy, true);
setHasRealLinkLayer(false);
}
@XMLConfigurableConstructor({ "phy" })
......
......@@ -100,7 +100,7 @@ public class RangedTopologyView extends AbstractTopologyView<RangedLink> {
public RangedTopologyView(PhyType phy, double range) {
super(phy, true);
this.range = range;
setHasRealLinkLayer(true);
LiveMonitoring.addProgressValueIfNotThere(new DijkstraMonitor());
}
......
......@@ -680,4 +680,9 @@ public class VisualizationTopologyView extends JFrame implements TopologyView,
throw new NotSupportedException();
}
@Override
public boolean hasRealLinkLayer() {
throw new NotSupportedException();
}
}
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