3
sys.path.append(os.path.join('.','commonConfig'))
4
sys.path.append(os.path.join('..','commonConfig'))
9
import openwns.evaluation.default
10
import constanze.traffic
13
import ip.AddressResolver
14
from ip.VirtualARP import VirtualARPServer
15
from ip.VirtualDHCP import VirtualDHCPServer
16
from ip.VirtualDNS import VirtualDNSServer
18
import ofdmaphy.OFDMAPhy
21
from constanze.node import IPBinding, IPListenerBinding, Listener
22
from openwns.pyconfig import Frozen
23
from openwns.pyconfig import Sealed
27
import wimac.KeyBuilder as CIDKeyBuilder
28
import wimac.evaluation.default
30
from support.WiMACParameters import ParametersSystem, ParametersOFDM, ParametersMAC, ParametersPropagation, ParametersPropagation_NLOS
31
from support.scenarioSupport import setupRelayScenario
32
from support.scenarioSupport import calculateScenarioRadius, numberOfAccessPointsForHexagonalScenario
33
import support.PostProcessor as PostProcessor
41
####################################################
42
### Distinguished Simulation Settings #
43
####################################################
45
# Set basic WiMAX Parameters
46
parametersSystem = ParametersSystem
47
parametersPhy = ParametersOFDM
48
parametersMAC = ParametersMAC
49
parametersPropagation = ParametersPropagation
51
# WiMAC Layer2 forming
54
friendliness_dBm = "-85 dBm"
57
#only considered for mapsizes not synchronized with actual scheduling strategy
58
dlStrategy = "ProportionalFairDL"
59
ulStrategy = "ProportionalFairUL"
61
arrayLayout = "linear" #"circular"
63
positionErrorVariance = 0.0
66
packetSize = 3000 #in bit
67
trafficUL = 1000000 # bit/s per station
70
oldPFScheduler = False
74
nBSs = numberOfAccessPointsForHexagonalScenario(nCircles)
79
numberOfStations = nBSs * ( nRSs + nSSs + nRmSs * nRSs + 1 )
81
scenarioXSize = 2 * calculateScenarioRadius(parametersSystem.clusterOrder, nCircles, parametersSystem.cellRadius)
82
scenarioYSize = scenarioXSize
84
RSDistance = parametersSystem.cellRadius / 2.0
87
operationModeRelays = 'SDM' #'TDM' 'FDM'
90
####################################################
91
# General Simulation settings #
92
####################################################
94
# create an instance of the WNS configuration
95
# The variable must be called WNS!!!!
96
WNS = openwns.Simulator(simulationModel = openwns.node.NodeSimulationModel())
97
WNS.maxSimTime = 0.1 # seconds
100
WNS.masterLogger.backtrace.enabled = False
101
WNS.masterLogger.enabled = True
102
format = openwns.logger.Console()
103
format.colors = openwns.logger.ColorMode.Off
104
WNS.masterLogger.loggerChain = [ openwns.logger.FormatOutputPair( format, openwns.logger.File()) ]
105
WNS.outputStrategy = openwns.simulator.OutputStrategy.DELETE
108
WNS.statusWriteInterval = 30 # in seconds
109
WNS.probesWriteInterval = 36000 # in seconds
112
####################################################
113
### PHY (PHysical Layer) settings #
114
####################################################
115
riseConfig = WNS.modules.rise
116
riseConfig.debug.transmitter = False
117
riseConfig.debug.main = False
118
riseConfig.debug.antennas = False
120
# from ./modules/phy/OFDMAPhy--unstable--0.3/PyConfig/ofdmaphy/OFDMAPhy.py
121
#scenario = rise.scenario.Hexagonal.Hexagonal(config.clusterSize, config.center, config.numOfCircles, config.cellRadius, config.numRN, nUT, config.distanceBetweenBSs, config.distanceBetweenBSandRN, nSectorsBS=1, corrAngle=0.0, rnShiftAngle=config.RN_Shift_Angle, useWraparound = config.useWraparound)
122
ofdmaPhyConfig = WNS.modules.ofdmaPhy
123
ofdmaPhySystem = ofdmaphy.OFDMAPhy.OFDMASystem('ofdma')
124
#ofdmaPhySystem.Scenario = rise.Scenario.Scenario(Config.scenarioXSize, Config.scenarioYSize)
125
ofdmaPhySystem.Scenario = rise.Scenario.Scenario()
126
ofdmaPhyConfig.systems.append(ofdmaPhySystem)
128
####################################################
130
####################################################
132
WNS.modules.wimac.parametersPHY = Config.parametersPhy
134
####################################################
135
### Instantiating Nodes and setting Traffic #
136
####################################################
140
# BSs with some SSs each
148
stationIDs = stationID()
152
for i in xrange(Config.nBSs):
153
bs = Nodes.BaseStation(stationIDs.next(), Config)
154
bs.dll.logger.level = 2
155
accessPoints.append(bs)
157
WNS.simulationModel.nodes.append(bs)
159
# The RANG only has one IPListenerBinding that is attached
160
# to the listener. The listener is the only traffic sink
162
ipListenerBinding = IPListenerBinding(rang.nl.domainName)
163
listener = Listener(rang.nl.domainName + ".listener")
164
rang.load.addListener(ipListenerBinding, listener)
168
for bs in accessPoints:
169
for i in xrange(Config.nSSs):
170
ss = Nodes.SubscriberStation(stationIDs.next(), Config)
171
cbrDL = constanze.traffic.Poisson(offset = 0.05, throughput = Config.trafficDL, packetSize = Config.packetSize)
172
ipBinding = IPBinding(rang.nl.domainName, ss.nl.domainName)
173
rang.load.addTraffic(ipBinding, cbrDL)
175
cbrUL = constanze.traffic.Poisson(offset = 0.0, throughput = Config.trafficUL, packetSize = Config.packetSize)
176
ipBinding = IPBinding(ss.nl.domainName, rang.nl.domainName)
177
ss.load.addTraffic(ipBinding, cbrUL)
178
ipListenerBinding = IPListenerBinding(ss.nl.domainName)
179
listener = Listener(ss.nl.domainName + ".listener")
180
ss.load.addListener(ipListenerBinding, listener)
181
ss.dll.associate(bs.dll)
182
associations[bs].append(ss)
183
userTerminals.append(ss)
184
WNS.simulationModel.nodes.append(ss)
188
# each access point is connected to some fixed relay stations
191
for bs in accessPoints:
193
for i in xrange(Config.nRSs):
194
rs = Nodes.RelayStation(stationIDs.next(), Config)
195
rs.dll.associate(bs.dll)
197
associations[bs].append(rs)
198
relayStations.append(rs)
199
WNS.simulationModel.nodes.append(rs)
204
# each relay station is connected to some remote stations
207
for bs in accessPoints:
209
for rs in associations[bs]:
210
if rs.dll.stationType != 'FRS':
213
for i in xrange(Config.nRmSs):
214
ss = Nodes.SubscriberStation(stationIDs.next(), Config)
215
ss.dll.logger.level = 2
216
cbrDL = constanze.traffic.CBR(offset = 0.05, throughput = Config.trafficDL, packetSize = Config.packetSize)
217
ipBinding = IPBinding(rang.nl.domainName, ss.nl.domainName)
218
rang.load.addTraffic(ipBinding, cbrDL)
220
cbrUL = constanze.traffic.CBR(offset = 0.0, throughput = Config.trafficUL, packetSize = Config.packetSize)
221
ipBinding = IPBinding(ss.nl.domainName, rang.nl.domainName)
222
ss.load.addTraffic(ipBinding, cbrUL)
223
ipListenerBinding = IPListenerBinding(ss.nl.domainName)
224
listener = Listener(ss.nl.domainName + ".listener")
225
ss.load.addListener(ipListenerBinding, listener)
227
ss.dll.associate(rs.dll)
228
# 192.168.1.254 = "nl address of RANG" = rang.nl.address ?
229
associations[rs].append(ss)
230
remoteStations.append(ss)
231
WNS.simulationModel.nodes.append(ss)
235
WNS.simulationModel.nodes.append(rang)
237
# Positions of the stations are determined here
238
setupRelayScenario(Config, WNS.simulationModel.nodes, associations)
241
intracellMobility = False
243
if(intracellMobility):
245
for ss in userTerminals:
247
for bs in accessPoints:
248
if bs.dll.stationID == ss.dll.associateTo:
250
bsPos = associatedBS.mobility.mobility.getCoords()
252
if associatedBS == None:
253
print 'no associated BS found'
256
# too large, SS might be outside the hexagon
257
maxDistance_ = Config.parametersSystem.cellRadius
258
# too small, corners are not filled
259
# maxDistance_ = (math.sqrt(3.0)/2.0) * Config.parametersSystem.cellRadius
261
# maxDistance_ = math.sqrt( 3.0/2.0/math.pi*math.sqrt(3.0)) * Config.parametersSystem.cellRadius
262
ss.mobility.mobility = rise.Mobility.BrownianCirc(center=bsPos,
263
maxDistance = maxDistance_ )
265
bsPos = accessPoints[0].mobility.mobility.getCoords()
267
userTerminals[0].mobility.mobility.setCoords(bsPos + openwns.geometry.position.Position(10,0,0))
268
userTerminals[1].mobility.mobility.setCoords(bsPos + openwns.geometry.position.Position(1700,0,0))
269
#print "BSPos:" + str(bsPos)
270
#print "UT1Pos:" + str(userTerminals[0].mobility.mobility.getCoords())
271
#print "UT2Pos:" + str(userTerminals[1].mobility.mobility.getCoords())
273
# TODO: for multihop simulations: replicate the code for remote stations
278
# Here we specify the stations we want to probe.
279
# This is usually only the center cell with the BS and its associated stations.
280
loggingStationIDs = []
282
for st in associations[accessPoints[0]]:
283
if st.dll.stationType == 'FRS':
284
loggingStationIDs.append(st.dll.stationID)
285
for st2 in associations[st]:
286
if st2.dll.stationType == 'UT':
287
loggingStationIDs.append(st2.dll.stationID)
289
if st.dll.stationType == 'UT':
290
loggingStationIDs.append(st.dll.stationID)
292
wimac.evaluation.default.installEvaluation(WNS, [1], loggingStationIDs)
294
# sources = ["wimac.top.window.incoming.bitThroughput",
295
# "wimac.top.window.aggregated.bitThroughput",
297
# "wimac.top.packet.incoming.delay"]
299
# for src in sources:
301
# node = openwns.evaluation.createSourceNode(WNS, src)
302
# nodeBS = node.appendChildren(openwns.evaluation.generators.Accept(
303
# by = 'MAC.StationType', ifIn = [1], suffix = "BS"))
304
# #nodeRS = node.appendChildren(openwns.evaluation.generators.Accept(
305
# # by = 'MAC.StationType', ifIn = [2], suffix = "RS"))
306
# nodeUT = node.appendChildren(openwns.evaluation.generators.Accept(
307
# by = 'MAC.StationType', ifIn = [3], suffix = "UT"))
308
# nodeBS.appendChildren(openwns.evaluation.generators.Separate(
309
# by = 'MAC.Id', forAll = [1], format = "Id%d"))
310
# nodeUT.appendChildren(openwns.evaluation.generators.Separate(
311
# by = 'MAC.Id', forAll = loggingStationIDs, format = "Id%d"))
313
# if src == "wimac.cirSDMA":
314
# node.getLeafs().appendChildren(openwns.evaluation.generators.PDF(
317
# resolution = 2000))
318
# elif "window" in src:
319
# node.getLeafs().appendChildren(openwns.evaluation.generators.PDF(
321
# maxXValue = 120.0e+6,
322
# resolution = 1000))
324
# elif "packet" in src:
325
# node.getLeafs().appendChildren(openwns.evaluation.generators.PDF(
331
#symbolsInFrame = Config.parametersPhy.symbolsFrame
332
#wimac.evaluation.default.installOverFrameOffsetEvaluation(WNS, symbolsInFrame, [1], loggingStationIDs)
334
openwns.evaluation.default.installEvaluation(WNS)
336
# one Virtual ARP Zone
337
varp = VirtualARPServer("vARP", "WIMAXRAN")
338
WNS.simulationModel.nodes = [varp] + WNS.simulationModel.nodes
340
vdhcp = VirtualDHCPServer("vDHCP@",
342
"192.168.0.2", "192.168.254.253",
345
vdns = VirtualDNSServer("vDNS", "ip.DEFAULT.GLOBAL")
346
WNS.simulationModel.nodes.append(vdns)
348
WNS.simulationModel.nodes.append(vdhcp)
350
### PostProcessor ###
351
postProcessor = PostProcessor.WiMACPostProcessor()
352
postProcessor.Config = Config
353
postProcessor.accessPoints = accessPoints
354
postProcessor.relayStations = relayStations
355
postProcessor.userTerminals = userTerminals
356
postProcessor.remoteStations = remoteStations
357
WNS.addPostProcessing(postProcessor)
358
openwns.setSimulator(WNS)