1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
|
### constanzeTestsSimpleTL
# Constanze over UDP and SimpleTL
import openwns
import openwns.node
# import other modules to be loaded
import simpleTL.Component
import openwns.distribution
import constanze.distribution.CDFTables
import constanze
import constanze.traffic
import constanze.node
import constanze.evaluation.default
simulator = openwns.Simulator(simulationModel = openwns.node.NodeSimulationModel())
simulator.maxSimTime = 1.0
numberOfClients = 1
numberOfServers = 1
numberOfStations = numberOfClients
speed = 1E9
meanPacketSize = 1500 * 8
loadFactor = 0.1
throughputPerStation = speed * loadFactor / numberOfStations
simulator.modules.simpletl.channel.capacity = speed
simulator.outputStrategy = openwns.simulator.OutputStrategy.DELETE
class ClientNode(openwns.node.Node):
tl = None
#applications = None
load = None
logger = None
def __init__(self, id):
super(ClientNode, self).__init__("client"+str(id))
self.logger = openwns.logger.Logger("CONST", "client"+str(id), True) # used for ConstanzeComponent
self.tl = simpleTL.Component.Component(self, "ClientTL", "127.0.0."+str(id+1))
self.load = constanze.node.ConstanzeComponent(self, "constanze",self.logger)
class ServerNode(openwns.node.Node):
tl = None
#applications = None
load = None
logger = None
def __init__(self, id):
super(ServerNode, self).__init__("server"+str(id))
self.logger = openwns.logger.Logger("CONST", "server"+str(id), True) # used for ConstanzeComponent
self.tl = simpleTL.Component.Component(self, "ServerTL", "137.226.4."+str(id+1))
self.load = constanze.node.ConstanzeComponent(self, "constanze",self.logger)
for i in xrange(numberOfServers):
node = ServerNode(i)
logger = node.logger
udpListenerBinding = constanze.node.UDPListenerBinding(777, logger)
udpListenerBinding.udpService = node.tl.udpServiceName
listener = constanze.node.Listener("listener",logger);
node.load.addListener(udpListenerBinding, listener)
simulator.simulationModel.nodes.append(node)
serverNode = ServerNode(0)
for i in xrange(numberOfClients):
node = ClientNode(i+numberOfServers)
logger = node.logger
startTime = 0.01
startindex = 0
trafficVariants = 4
phaseDuration = simulator.maxSimTime / trafficVariants
duration = phaseDuration - startTime
for trafficindexOffset in xrange(trafficVariants):
trafficindex = (trafficindexOffset + startindex) % trafficVariants
if ( trafficindex == 0 ):
traffic = constanze.traffic.CBR(
startTime,
throughputPerStation,
meanPacketSize,
duration = duration,
parentLogger = logger)
elif ( trafficindex == 1 ):
traffic = constanze.traffic.Poisson(
startTime,
throughputPerStation,
meanPacketSize,
duration = duration,
parentLogger = logger)
elif ( trafficindex == 2 ):
iatDistribution = openwns.distribution.Fixed(meanPacketSize / throughputPerStation)
packetSizeDistribution = openwns.distribution.Uniform(2 * meanPacketSize, 8)
traffic = constanze.traffic.ABR(
iatDistribution,
packetSizeDistribution,
offset = startTime,
duration = duration,
parentLogger = logger)
elif ( trafficindex == 3 ):
IPmeanPacketSize = 2056.84 # Bits
iatDistribution = openwns.distribution.NegExp(IPmeanPacketSize / throughputPerStation)
packetSizeDistribution = constanze.distribution.CDFTables.IPPacketSizeDataTraffic()
traffic = constanze.traffic.ABR(
iatDistribution,
packetSizeDistribution,
offset = startTime,
duration=duration,
parentLogger = logger)
else:
assert "invalid traffic choice"
startTime += phaseDuration
udpBinding = constanze.node.UDPBinding(_domainName = node.tl.domainName,
_destinationDomainName = serverNode.tl.domainName,
_destionationPort = 777,
qosClass = openwns.qos.undefinedQosClass,
parentLogger = logger)
udpBinding.udpService = node.tl.udpServiceName
node.load.addTraffic(udpBinding, traffic)
simulator.simulationModel.nodes.append(node)
constanze.evaluation.default.installEvaluation(simulator,
maxPacketDelay = 0.0001,
maxPacketSize = 16000,
maxBitThroughput = 2* throughputPerStation,
maxPacketThroughput = 2 * throughputPerStation/meanPacketSize,
delayResolution = 1000,
sizeResolution = 2000,
throughputResolution = 10000)
openwns.setSimulator(simulator)
|