~comnets/openwns-systemtest-wimac/systemtest-wimac--main--1.0

« back to all changes in this revision

Viewing changes to configBypass/config.py

  • Committer: Karsten Klagges
  • Date: 2009-08-24 15:56:23 UTC
  • mfrom: (27.1.2 WiMAC-Tests--main--1.2)
  • Revision ID: kks@comnets.rwth-aachen.de-20090824155623-1uqr7za3xjd1u8ko
new bypass queue test

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
import os
 
2
import sys
 
3
sys.path.append(os.path.join('.','commonConfig'))
 
4
sys.path.append(os.path.join('..','commonConfig'))
 
5
 
 
6
import rise
 
7
import openwns.node
 
8
import openwns
 
9
import openwns.evaluation.default
 
10
import constanze.traffic
 
11
import openwns.logger
 
12
import ip.IP
 
13
import ip.AddressResolver
 
14
from ip.VirtualARP import VirtualARPServer
 
15
from ip.VirtualDHCP import VirtualDHCPServer
 
16
from ip.VirtualDNS import VirtualDNSServer
 
17
 
 
18
import ofdmaphy.OFDMAPhy
 
19
import rise.Scenario
 
20
import rise.Mobility
 
21
from constanze.node import IPBinding, IPListenerBinding, Listener
 
22
from openwns.pyconfig import Frozen
 
23
from openwns.pyconfig import Sealed
 
24
 
 
25
import Nodes
 
26
import Layer2
 
27
import wimac.KeyBuilder as CIDKeyBuilder
 
28
import wimac.evaluation.default
 
29
 
 
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
 
34
 
 
35
import random
 
36
random.seed(7)
 
37
 
 
38
 
 
39
associations = {}
 
40
 
 
41
####################################################
 
42
###  Distinguished Simulation Settings             #
 
43
####################################################
 
44
class Config(Frozen):
 
45
    # Set basic WiMAX Parameters
 
46
    parametersSystem      = ParametersSystem
 
47
    parametersPhy         = ParametersOFDM
 
48
    parametersMAC         = ParametersMAC
 
49
    parametersPropagation = ParametersPropagation
 
50
 
 
51
    # WiMAC Layer2 forming
 
52
    beamforming = False
 
53
    maxBeams = 1
 
54
    friendliness_dBm = "-85 dBm"
 
55
    maxBursts = 20
 
56
 
 
57
    #only considered for mapsizes not synchronized with actual scheduling strategy
 
58
    dlStrategy = "ProportionalFairDL"
 
59
    ulStrategy = "ProportionalFairUL"
 
60
 
 
61
    arrayLayout = "linear" #"circular"
 
62
    eirpLimited = False
 
63
    positionErrorVariance = 0.0
 
64
 
 
65
 
 
66
    packetSize = 3000 #in bit
 
67
    trafficUL = 1000000 # bit/s per station
 
68
    trafficDL = 1000000
 
69
 
 
70
    oldPFScheduler = False
 
71
 
 
72
    nSectors = 1
 
73
    nCircles = 0
 
74
    nBSs = numberOfAccessPointsForHexagonalScenario(nCircles)
 
75
    nRSs = 0
 
76
    nSSs = 2
 
77
    nRmSs = 0
 
78
 
 
79
    numberOfStations =  nBSs * ( nRSs + nSSs + nRmSs * nRSs + 1 )
 
80
 
 
81
    scenarioXSize = 2 * calculateScenarioRadius(parametersSystem.clusterOrder, nCircles, parametersSystem.cellRadius)
 
82
    scenarioYSize = scenarioXSize
 
83
 
 
84
    RSDistance = parametersSystem.cellRadius / 2.0
 
85
 
 
86
    writeOutput = True
 
87
    operationModeRelays = 'SDM' #'TDM' 'FDM'
 
88
 
 
89
#config = Config()
 
90
####################################################
 
91
# General Simulation settings                      #
 
92
####################################################
 
93
 
 
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
 
98
 
 
99
# Logger settings
 
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
 
106
 
 
107
# Probe settings
 
108
WNS.statusWriteInterval = 30 # in seconds
 
109
WNS.probesWriteInterval = 36000 # in seconds
 
110
 
 
111
 
 
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
 
119
 
 
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)
 
127
 
 
128
####################################################
 
129
### WiMAC settings                                 #
 
130
####################################################
 
131
 
 
132
WNS.modules.wimac.parametersPHY = Config.parametersPhy
 
133
 
 
134
####################################################
 
135
### Instantiating Nodes and setting Traffic        #
 
136
####################################################
 
137
# one RANG
 
138
rang = Nodes.RANG()
 
139
 
 
140
# BSs with some SSs each
 
141
 
 
142
def stationID():
 
143
    id = 1
 
144
    while (True):
 
145
        yield id
 
146
        id += 1
 
147
 
 
148
stationIDs = stationID()
 
149
 
 
150
accessPoints = []
 
151
 
 
152
for i in xrange(Config.nBSs):
 
153
    bs = Nodes.BaseStation(stationIDs.next(), Config)
 
154
    bs.dll.logger.level = 2
 
155
    accessPoints.append(bs)
 
156
    associations[bs]=[]
 
157
    WNS.simulationModel.nodes.append(bs)
 
158
 
 
159
# The RANG only has one IPListenerBinding that is attached
 
160
# to the listener. The listener is the only traffic sink
 
161
# within the RANG
 
162
ipListenerBinding = IPListenerBinding(rang.nl.domainName)
 
163
listener = Listener(rang.nl.domainName + ".listener")
 
164
rang.load.addListener(ipListenerBinding, listener)
 
165
 
 
166
userTerminals = []
 
167
k = 0
 
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)
 
174
 
 
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)
 
185
    rang.dll.addAP(bs)
 
186
    k += 1
 
187
 
 
188
# each access point is connected to some fixed relay stations
 
189
k = 0
 
190
relayStations = []
 
191
for bs in accessPoints:
 
192
    l = 0
 
193
    for i in xrange(Config.nRSs):
 
194
        rs = Nodes.RelayStation(stationIDs.next(), Config)
 
195
        rs.dll.associate(bs.dll)
 
196
        associations[rs]=[]
 
197
        associations[bs].append(rs)
 
198
        relayStations.append(rs)
 
199
        WNS.simulationModel.nodes.append(rs)
 
200
 
 
201
        l += 1
 
202
    k += 1
 
203
 
 
204
# each relay station is connected to some remote stations
 
205
remoteStations = []
 
206
k = 0
 
207
for bs in accessPoints:
 
208
    l = 0
 
209
    for rs in associations[bs]:
 
210
        if rs.dll.stationType != 'FRS':
 
211
            continue
 
212
        i = 0
 
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)
 
219
 
 
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)
 
226
 
 
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)
 
232
        l += 1
 
233
    k += 1
 
234
 
 
235
WNS.simulationModel.nodes.append(rang)
 
236
 
 
237
# Positions of the stations are determined here
 
238
setupRelayScenario(Config, WNS.simulationModel.nodes, associations)
 
239
 
 
240
#set mobility
 
241
intracellMobility = False
 
242
 
 
243
if(intracellMobility):
 
244
 
 
245
    for ss in userTerminals:
 
246
        associatedBS = None
 
247
        for bs in accessPoints:
 
248
            if bs.dll.stationID == ss.dll.associateTo:
 
249
                associatedBS = bs
 
250
                bsPos = associatedBS.mobility.mobility.getCoords()
 
251
                break
 
252
        if associatedBS == None:
 
253
            print 'no associated BS found'
 
254
            exit(1)
 
255
 
 
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
 
260
        # equal area
 
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_ )
 
264
 
 
265
bsPos =  accessPoints[0].mobility.mobility.getCoords()
 
266
 
 
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())
 
272
 
 
273
# TODO: for multihop simulations: replicate the code for remote stations
 
274
 
 
275
#plotStations.plot()
 
276
 
 
277
 
 
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 = []
 
281
 
 
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)
 
288
 
 
289
    if st.dll.stationType == 'UT':
 
290
        loggingStationIDs.append(st.dll.stationID)
 
291
 
 
292
wimac.evaluation.default.installEvaluation(WNS, [1], loggingStationIDs)
 
293
 
 
294
# sources = ["wimac.top.window.incoming.bitThroughput", 
 
295
#             "wimac.top.window.aggregated.bitThroughput", 
 
296
#             "wimac.cirSDMA",
 
297
#             "wimac.top.packet.incoming.delay"]
 
298
 
 
299
# for src in sources:
 
300
    
 
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"))
 
312
                        
 
313
#     if src == "wimac.cirSDMA":
 
314
#         node.getLeafs().appendChildren(openwns.evaluation.generators.PDF(
 
315
#                                                     minXValue = -100,
 
316
#                                                     maxXValue = 100,
 
317
#                                                     resolution =  2000))
 
318
#     elif "window" in src:                          
 
319
#         node.getLeafs().appendChildren(openwns.evaluation.generators.PDF(
 
320
#                                                     minXValue = 0.0,
 
321
#                                                     maxXValue = 120.0e+6,
 
322
#                                                     resolution =  1000))
 
323
                                        
 
324
#     elif "packet" in src:                          
 
325
#         node.getLeafs().appendChildren(openwns.evaluation.generators.PDF(
 
326
#                                                     minXValue = 0.0,
 
327
#                                                     maxXValue = 1.0,
 
328
#                                                     resolution =  100))
 
329
 
 
330
 
 
331
#symbolsInFrame = Config.parametersPhy.symbolsFrame
 
332
#wimac.evaluation.default.installOverFrameOffsetEvaluation(WNS, symbolsInFrame, [1], loggingStationIDs)
 
333
 
 
334
openwns.evaluation.default.installEvaluation(WNS)
 
335
 
 
336
# one Virtual ARP Zone
 
337
varp = VirtualARPServer("vARP", "WIMAXRAN")
 
338
WNS.simulationModel.nodes = [varp] + WNS.simulationModel.nodes
 
339
 
 
340
vdhcp = VirtualDHCPServer("vDHCP@",
 
341
                          "WIMAXRAN",
 
342
                          "192.168.0.2", "192.168.254.253",
 
343
                          "255.255.0.0")
 
344
 
 
345
vdns = VirtualDNSServer("vDNS", "ip.DEFAULT.GLOBAL")
 
346
WNS.simulationModel.nodes.append(vdns)
 
347
 
 
348
WNS.simulationModel.nodes.append(vdhcp)
 
349
 
 
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)