-
Notifications
You must be signed in to change notification settings - Fork 1
/
XmlMessages.xml
246 lines (242 loc) · 11.2 KB
/
XmlMessages.xml
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
133
134
135
136
137
138
139
140
141
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
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
<?xml version="1.0" encoding="utf-8"?>
<Model xmlns="http://lab.tagroot.io/Schema/ComSim.xsd"
xmlns:xmpp="http://lab.tagroot.io/Schema/ComSim/XMPP.xsd"
xmlns:xmldsig="http://lab.tagroot.io/Schema/ComSim/XmlDSig.xsd"
xmlns:perf="http://lab.tagroot.io/Schema/ComSim/Performance.xsd"
timeBase="StartOfSimulation"
bucketTime="PT10S"
timeUnit="PT1S"
timeCycle="PT1M"
duration="PT10M">
<Meta>
<Title>XML Messages</Title>
<Introduction>Simulates XMPP Machine-to-Machine (M2M) messages being sent between participants. Some are signed, some are not.</Introduction>
<Description>
<![CDATA[
Simulates 100 XMPP clients over TCP exchanging signed and unsigned machine-readable XML messages randomly between each other
during 10 minutes, at a total frequency of 1000 messages per minute.
]]>
</Description>
<Preparation>
<![CDATA[
XMPP
------
The XMPP Client accounts are created automatically, if the broker being used supports
[XEP-0077: In-Band Registration](https://xmpp.org/extensions/xep-0077.html). The
account registration process can be protected using keys and secrets, if the broker supports
[XEP-0348: Signing Forms](https://xmpp.org/extensions/xep-0348.html).
Performance Counters
------------------------
For this simulation to work, the `Performance.ws` Web Service script available in the
[Examples](https://github.com/Trust-Anchor-Group/ComSim/tree/master/Examples) folder in the
[ComSim](https://github.com/Trust-Anchor-Group/ComSim) project, needs to be copied to the
`/Reports` web folder of the [TAG Neuron](https://lab.tagroot.io/Broker.md) or the
[IoT Gateway](https://waher.se/IoTGateway/Index.md) web server. For readability, the web service
script contais the following script, executed when the resource is accessed:
{
"cpuPercent":PerformanceCounterValue("Processor","_Total","% Processor Time"),
"networkBytesPerSec":PerformanceCounterValue("Network Interface","Microsoft Hyper-V Network Adapter","Bytes Total/sec"),
"memoryMBytesFree":PerformanceCounterValue("Memory","Available MBytes")
}
]]>
</Preparation>
<ModelScript>
<![CDATA[
GetBrokerPerformance():=Post("https://lab.tagroot.io/Reports/Performance.ws","","application/json");
]]>
</ModelScript>
</Meta>
<Assemblies>
<Assembly fileName="TAG.Simulator.Performance.dll"/>
<Assembly fileName="TAG.Simulator.XMPP.dll"/>
<Assembly fileName="TAG.Simulator.XMLDSIG.dll"/>
</Assemblies>
<Actors>
<Timer id="PerformanceTimer" N="1" period="PT2S">
<ExternalEvent name="Elapsed" event="MeasurePerformance"/>
</Timer>
<xmpp:XmppActorTcp domain="lab.tagroot.io" userName="XmppTcp" id="XmppTcp" N="100" apiKey="LabApiKey1" secret="LabSecret1" alwaysConnected="true">
<xmpp:MessageHandler name="Msg" namespace="http://lab.tagroot.io/Schema/Examples/XmlMessages.xsd" event="UnsignedMessageReceived" actorName="To" eventArgs="e"/>
<xmpp:MessageHandler name="SignedMsg" namespace="http://lab.tagroot.io/Schema/Examples/XmlMessages.xsd" event="SignedMessageReceived" actorName="To" eventArgs="e"/>
</xmpp:XmppActorTcp>
</Actors>
<Distributions>
<Uniform id="FiveHundredPerMinute" from="0" to="60" N="500"/>
</Distributions>
<Events>
<StochasticEvent distribution="FiveHundredPerMinute" activity="SendUnsignedMessage">
<Description>Sends an unsigned XML message from one random XMPP client to another, at a frequency of five hundred times per minute using a uniform distribution.</Description>
<ActorReference name="From" exclusive="true">
<FromPopulation actor="XmppTcp"/>
</ActorReference>
<ActorReference name="To" exclusive="false">
<FromPopulation actor="XmppTcp"/>
</ActorReference>
<SetVariable name="StartTime">
<Script>Now</Script>
</SetVariable>
</StochasticEvent>
<StochasticEvent distribution="FiveHundredPerMinute" activity="SendSignedMessage">
<Description>Sends a signed XML message from one random XMPP client to another, at a frequency of five hundred times per minute using a uniform distribution.</Description>
<ActorReference name="From" exclusive="true">
<FromPopulation actor="XmppTcp"/>
</ActorReference>
<ActorReference name="To" exclusive="false">
<FromPopulation actor="XmppTcp"/>
</ActorReference>
<SetVariable name="StartTime">
<Script>Now</Script>
</SetVariable>
</StochasticEvent>
<EventHandler id="UnsignedMessageReceived" activity="ProcessUnsignedMessage">
<Description>Event triggered when an unsigned message has been received.</Description>
</EventHandler>
<EventHandler id="SignedMessageReceived" activity="ProcessSignedMessage">
<Description>Event triggered when a signed message has been received.</Description>
</EventHandler>
<EventHandler id="MeasurePerformance" activity="ReadPerformanceCounters">
<Description>Server and Simulator performance is measured regularly during the simulation, and shown in the final report.</Description>
</EventHandler>
</Events>
<Activities>
<Activity id="ReadPerformanceCounters">
<Description>This activity measures the performance of the broker, as well as the machine performing the simulation.</Description>
<Start/>
<Parallel>
<Thread>
<Group title="Performance at Broker">
<Eval>M:=GetBrokerPerformance()</Eval>
<Sample name="Broker CPU (%)">
<Script>M.cpuPercent</Script>
</Sample>
<Sample name="Broker Network (kB/s)">
<Script>M.networkBytesPerSec/1024</Script>
</Sample>
<Sample name="Broker Free Memory (GB)">
<Script>M.memoryMBytesFree/1024</Script>
</Sample>
</Group>
</Thread>
<Thread>
<Group title="Performance at Simulator Machine">
<!-- NOTE: Performance counter names, instance names and category names depends on configuration and locale of operating system of the machine running the simulator. Might have to be changed. -->
<Sample name="Simulator CPU (%)">
<!-- Swedish: -->
<perf:Performance category="Processor" instance="_Total" counter="% Processor Time"/>
<!-- English:
<perf:Performance category="Processor" instance="_Total" counter="% Processor Time"/> -->
</Sample>
<Sample name="Simulator Network (kB/s)">
<!-- Swedish: -->
<perf:Performance category="Nätverksgränssnitt" instance="Intel[R] Wireless-AC 9560 160MHz" counter="Totalt antal byte/s" divider="1024"/>
<!-- English:
<perf:Performance category="Network Interface" instance="Microsoft Hyper-V Network Adapter" counter="Bytes Total/sec" divider="1024"/> -->
</Sample>
<Sample name="Simulator Free Memory (GB)">
<!-- Swedish: -->
<perf:Performance category="Minne" counter="Tillgängliga megabyte" divider="1024"/>
<!-- English:
<perf:Performance category="Memory" counter="Available MBytes" divider="1024"/>-->
</Sample>
</Group>
</Thread>
</Parallel>
<Stop/>
</Activity>
<Activity id="SendUnsignedMessage">
<Description>This activity sends an unsigned XML message to a random recipient.</Description>
<Start/>
<xmpp:SendMessage actor="From" to="{To.FullJID}">
<Xml>
<Msg xmlns="http://lab.tagroot.io/Schema/Examples/XmlMessages.xsd">
<StartTime>{StartTime.ToString("yyyy-MM-ddTHH:mm:ss.ffffff")}</StartTime>
</Msg>
</Xml>
</xmpp:SendMessage>
<Count counter="UnsignedSent"/>
<Stop/>
</Activity>
<Activity id="ProcessUnsignedMessage">
<Description>Processes a received unsigned message.</Description>
<Start/>
<Count counter="UnsignedReceived"/>
<Eval>
<![CDATA[
StartTime:=DateTime(e.Content["StartTime"].InnerText);
Elapsed:=Now.Subtract(StartTime).TotalMilliseconds
]]>
</Eval>
<Sample name="Unsigned Roundtrip">
<Script>Elapsed ms</Script>
</Sample>
<Stop/>
</Activity>
<Activity id="SendSignedMessage">
<Description>This activity sends a signed XML message to a random recipient. The XML message is signed using 4096-bit RSA keys using the [XMLDSIG](https://www.w3.org/TR/xmldsig-core/) standard.</Description>
<Start/>
<xmpp:SendMessage actor="From" to="{To.FullJID}">
<xmldsig:Sign rsaKeyName="{From.BareJID}" rsaKeySize="4096">
<Xml>
<SignedMsg xmlns="http://lab.tagroot.io/Schema/Examples/XmlMessages.xsd">
<StartTime>{StartTime.ToString("yyyy-MM-ddTHH:mm:ss.ffffff")}</StartTime>
</SignedMsg>
</Xml>
</xmldsig:Sign>
</xmpp:SendMessage>
<Count counter="SignedSent"/>
<Stop/>
</Activity>
<Activity id="ProcessSignedMessage">
<Description>Processes a received signed message.</Description>
<Start/>
<Count counter="SignedReceived"/>
<xmldsig:Verify rsaKeyName="{e.FromBareJID}">
<Script>e.Content</Script>
</xmldsig:Verify>
<Eval>
<![CDATA[
StartTime:=DateTime(e.Content["StartTime"].InnerText);
Elapsed:=Now.Subtract(StartTime).TotalMilliseconds
]]>
</Eval>
<Sample name="Signed Roundtrip">
<Script>Elapsed ms</Script>
</Sample>
<Stop/>
</Activity>
</Activities>
<Graphs>
<CombinedExecutionsGraph title="Nr Messages sent" legend="true" header="Send messages">
<Source ref="SendUnsignedMessage"/>
<Source ref="SendSignedMessage"/>
</CombinedExecutionsGraph>
<CombinedExecutionTimeGraph title="Time sending Messages" legend="false">
<Source ref="SendUnsignedMessage"/>
<Source ref="SendSignedMessage"/>
</CombinedExecutionTimeGraph>
<CombinedExecutionsGraph title="Nr Messages processed" legend="true" header="Received messages">
<Source ref="ProcessUnsignedMessage"/>
<Source ref="ProcessSignedMessage"/>
</CombinedExecutionsGraph>
<CombinedExecutionTimeGraph title="Time processing Messages" legend="false">
<Source ref="ProcessUnsignedMessage"/>
<Source ref="ProcessSignedMessage"/>
</CombinedExecutionTimeGraph>
<CombinedSampleGraph title="Message roundtrip" legend="true" header="Performance">
<Source ref="Unsigned Roundtrip"/>
<Source ref="Signed Roundtrip"/>
</CombinedSampleGraph>
<CombinedSampleGraph title="CPU %" legend="true">
<Source ref="Broker CPU (%)"/>
<Source ref="Simulator CPU (%)"/>
</CombinedSampleGraph>
<CombinedSampleGraph title="Free Memory (GB)" legend="true">
<Source ref="Broker Free Memory (GB)"/>
<Source ref="Simulator Free Memory (GB)"/>
</CombinedSampleGraph>
<CombinedSampleGraph title="Network (kB/s)" legend="true">
<Source ref="Broker Network (kB/s)"/>
<Source ref="Simulator Network (kB/s)"/>
</CombinedSampleGraph>
</Graphs>
</Model>