This repository has been archived by the owner on Oct 6, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
118 lines (81 loc) · 3.63 KB
/
index.html
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
<!DOCTYPE html >
<html>
<head>
<meta charset="utf-8">
<title>DDD - Dennis Dolle Demo</title>
<link rel="stylesheet" media="screen" href="bootstrap.css">
<script type="text/javascript" src="jquery-1.9.1.js"></script>
<script type="text/javascript" src="bootstrap.js"></script>
</head>
<body>
<script type="text/javascript" src="app.js"></script>
<script type="text/javascript" src="wiseml.js"></script>
<script type="text/javascript">
var lastTag = 0;
function sendPacket(userScript, srcNodeUrn, dstNodeUrn, demoIteration) {
if (demoIteration % 5 == 0) {
lastTag = (lastTag +1) % Number.MAX_VALUE;
}
/*
var packetBytes = [ 0x6c, 0x21, 0x40, 0x21, 0x24, 0x0, 0x0, 0x0, 0x42, 0x6f, 0x0, 0x5, 0x0, 0xe, 0x20, 0x1, 0x63, 0x80, 0x70, 0xa0, 0xb0, 0x69, 0x2, 0x0, 0x0, 0x0, 0x0, 0x0, 0x21, 0x40, 0x20, 0x1, 0x63, 0x80, 0x70, 0xa0, 0xb0, 0x69, 0x2, 0x0, 0x0, 0x0, 0x0, 0x0, 0x21, 0x30, 0xf1, 0x0, 0x0, 0xb0, 0x74, 0xe1, 0x54, 0x68, 0x69, 0x73, 0x20, 0x69, 0x73, 0x20, 0x61, 0x20, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x20, 0x58, 0x58, 0x58, 0x58, 0x0];
var packet = PTPacket.parse(packetBytes);
console.log(packet.getSource().toString(16));
console.log(packet.getDestination().toString(16));
console.log(packet.getPayload());
var lowpanPacket = SixLowPanPacket.parse(packet.getPayload());
console.log(lowpanPacket.toString());
*/
var payload = [ 0x6f, 0x0, 0x5, 0x0, 0xe, 0x20, 0x1, 0x63, 0x80, 0x70, 0xa0, 0xb0, 0x69, 0x2, 0x0, 0x0, 0x0, 0x0, 0x0, 0x21, 0x40, 0x20, 0x1, 0x63, 0x80, 0x70, 0xa0, 0xb0, 0x69, 0x2, 0x0, 0x0, 0x0, 0x0, 0x0, 0x21, 0x30, 0xf1, 0x0, 0x0, 0xb0, 0x74, 0xe1, 0x54, 0x68, 0x69, 0x73, 0x20, 0x69, 0x73, 0x20, 0x61, 0x20, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x20, 0x58, 0x58, 0x58, 0x58, 0x0];
var lowpanPacket = SixLowPanPacket.parse(payload);
lowpanPacket.setFlowLabel(lastTag);
var packet = PTPacket.create(srcNodeUrn.getMac(), dstNodeUrn.getMac(), lowpanPacket.buffer);
//console.log(packet.toString());
var base64EncodedPacket = btoa(String.fromCharCode.apply(null, packet.buffer));
var message = {
payloadBase64 : base64EncodedPacket,
sourceNodeUrn : srcNodeUrn.nodeUrnString,
timestamp : new Date().toISOString(),
type : "upstream"
}
userScript.onmessage([message]);
}
function startPacketGenerator(userScript) {
var isense48Nodes = wiseml.setup.node.filter(function(node) { return node.nodeType == "isense48"; });
var experimentNodes = isense48Nodes.slice(0, isense48Nodes.length);
var experimentNodesUrns = experimentNodes.map(function(node) { return new NodeUrn(node.id); });
var totalNumberOfPackets = 3000;
var delay = 500;
var i=0, j=0, k=0;
var schedule;
schedule = window.setInterval(function() {
i = (i == Number.MAX_VALUE) ? 0 : i+1;
j = i % experimentNodesUrns.length;
k = (i + 1) % experimentNodesUrns.length;
sendPacket(userScript, experimentNodesUrns[j], experimentNodesUrns[k], i);
$('#DivPacketCount').html(" # " + i + " ");
if (i == totalNumberOfPackets) {
window.clearInterval(schedule);
userScript.stop();
}
}, delay);
}
$(function() {
var env = {
testbedId : 1,
experimentId : 2,
outputDiv : $("#DemoCanvas")
};
var userScript = new WiseGuiUserScript();
userScript.start(env);
var startSchedule = window.setInterval(function() {
if (userScript.ready()) {
window.clearInterval(startSchedule);
startPacketGenerator(userScript);
}
}, 1000);
})
</script>
<div id="DemoCanvas" class="DemoCanvas"></div>
<div id="DivPacketCount" class="DivPacketCount"></div>
</body>
</html>