PhyType.java 5.17 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
/*
 * 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.api.linklayer.mac;

import de.tud.kom.p2psim.api.linklayer.LinkLayer;
import de.tud.kom.p2psim.impl.simengine.Simulator;
25
import de.tudarmstadt.maki.simonstrator.api.Rate;
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
import de.tudarmstadt.maki.simonstrator.api.Time;
import de.tudarmstadt.maki.simonstrator.api.component.network.NetworkComponent.NetInterfaceName;

/**
 * This is a physical medium (PHY-Layer). It is implemented as an enum, because
 * 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
 * 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
 * be used inside the MacLayer or as part of a {@link Link}
 * 
 * @author Bjoern Richerzhagen
 * @version 1.0, 25.02.2012
 */
public enum PhyType {

	/**
	 * Direct wireless connections between adjacent hosts or AP-based (decided
45
	 * by the MAC/TopologyView used). Based on
46
47
48
49
50
51
	 * "WiFi in Ad Hoc Mode: A Meaurement Study" by Anastasi et al. (2004),
	 * 
	 * Assuming the following defaults: 1% drop-rate of LinkLayer-Packets
	 * (LinkLayer might add retransmission behavior as in 802.11), 5MBit/s netto
	 * (802.11b) BW, 500us latency, 2,2kB MTU, Broadcast
	 */
52
	WIFI(NetInterfaceName.WIFI, 0.01, 5 * Rate.Mbit_s, 500 * Time.MICROSECOND,
53
54
55
56
57
58
59
			2334, true),
	/**
	 * A wired connection based on a TopologyView
	 * 
	 * Assuming the following defaults: 0.1% link-layer loss, 100 Mbit/s, 1ms
	 * Link-Latency, 1,5kB MTU
	 */
60
	ETHERNET(NetInterfaceName.ETHERNET, 0.001, 100 * Rate.Mbit_s,
61
62
			1 * Time.MILLISECOND, 1500, false),

63
64
65
66
67
68
69
	/**
	 * A centrally scheduled wireless connection connecting a host to at most
	 * one base-station. No direct communication between hosts.
	 *
	 * Assuming the following defaults: zero link-layer packet loss due to
	 * scheduling, 384kBit/s, 500us latency, 1,4 kByte MTU
	 */
70
	UMTS(NetInterfaceName.MOBILE, 0, 384 * Rate.kbit_s,
71
			500 * Simulator.MICROSECOND_UNIT, 1472, false),
72
73
74
75
76
77
78
79

	/**
	 * 
	 * Bluetooth, short-ranged wireless transmissions between adjacent hosts
	 *
	 * Assuming the following defaults: zero link-layer packet loss, 3Mbit/s BW,
	 * 500us latency, 1kByte MTU
	 */
80
	BLUETOOTH(NetInterfaceName.BLUETOOTH, 0.0, 3 * Rate.Mbit_s,
Julian Zobel's avatar
Julian Zobel committed
81
82
83
84
85
86
87
			500 * Simulator.MICROSECOND_UNIT, 1024, true),
	
	/**
	 * WiFi for UAV communication
	 */
	WIFI_UAV_NET(NetInterfaceName.WIFI_UAV_NET, 0.01, 5 * Rate.Mbit_s,
			500 * Time.MICROSECOND, 2334, true);
88
89
90
91
92

	private double defaultDropProbability;

	/**
	 * Default bw of a link in this PHY (a link is unidirectional, therefore
93
	 * this is just one value) in bit/s
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
	 */
	private long defaultRawBW;

	private long defaultLatency;

	private int defaultMTU;

	private boolean isBroadcastMedium;

	/**
	 * FIXME we lateron want to get rid of the "PHY"-Definition and rely on
	 * NetInterfaceNames instead.
	 */
	private NetInterfaceName netInterfaceName;

	/**
	 * 
	 * @param defaultDropProbability
	 * @param defaultRawBW
113
	 *            bw in bit/s
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
	 * @param defaultLatency
	 * @param defaultMTU
	 */
	private PhyType(NetInterfaceName netName, double defaultDropProbability,
			long defaultRawBW, long defaultLatency, int defaultMTU,
			boolean isBroadcastMedium) {
		this.defaultDropProbability = defaultDropProbability;
		this.defaultRawBW = defaultRawBW;
		this.defaultLatency = defaultLatency;
		this.defaultMTU = defaultMTU;
		this.isBroadcastMedium = isBroadcastMedium;
		this.netInterfaceName = netName;
	}

	public double getDefaultDropProbability() {
		return defaultDropProbability;
	}

	public long getDefaultLatency() {
		return defaultLatency;
	}

	public int getDefaultMTU() {
		return defaultMTU;
	}

	/**
141
	 * The Default BW of a link (unidirectional) in bit/s
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
	 * 
	 * @return
	 */
	public long getDefaultBW() {
		return defaultRawBW;
	}

	/**
	 * 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
	 * the medium supports Multiplexing such as UMTS, set this to false.
	 * 
	 * @return
	 */
	public boolean isBroadcastMedium() {
		return isBroadcastMedium;
	}

	/**
	 * Long-term replacement of PHY
	 * 
	 * @return
	 */
	public NetInterfaceName getNetInterfaceName() {
		return netInterfaceName;
	}

	public static String printTypes() {
		PhyType[] types = values();
		String out = "";
		for (int i = 0; i < types.length; i++) {
			if (i > 0) {
				out += ", ";
			}
			out += types[i].name();
		}
		return out;
	}

}