-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathpackettest.js
More file actions
144 lines (112 loc) · 6.65 KB
/
Copy pathpackettest.js
File metadata and controls
144 lines (112 loc) · 6.65 KB
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
var packet = require('./packet').packet;
var dgram = require('dgram');
var client = dgram.createSocket("udp4");
client.bind(19135);
type = new Buffer(process.argv['2'], 'hex').readUInt8(0);
switch (type)
{
case 0x02:
hex='02000000000000191c00ffff00fefefefefdfdfdfd12345678';
break;
case 0x1c:
hex= '1c000000000019d3f01718612f9080423b00ffff00fefefefefdfdfdfd12345678002e4d434350503b44656d6f3b50485020536572766572205b5320302f32305d20202054686973206973206120576f72';
break;
case 0x05:
hex = '0500ffff00fefefefefdfdfdfd1234567805000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000';
break;
case 0x06:
hex = '0600ffff00fefefefefdfdfdfd123456781718612f9080423b0005b8';
break;
case 0x07:
hex = '0700ffff00fefefefefdfdfdfd12345678043f57fe6d4abe05d4ffffffffec9e1144';
break;
case 0x08:
hex = '0800ffff00fefefefefdfdfdfd123456781718612f9080423bbcbc05b800';
break;
case 0xc0:
if (process.argv['3'] == 'multiple')
{
//Multiple ACKS
hex = 'c00001001f0200220200';
}
else
{
hex = 'c0000101000000';
}
break;
//Add NACK
case checkData(type):
dataType = new Buffer(process.argv['3'], 'hex').readUInt8(0);
switch(dataType)
{
case 0x82:
hex = '840300004000900200008200074272616e646f6e0000000800000008';
break;
case 0x83:
hex = '800100000000288300000000';
break;
case 0x84:
hex = '840a00004000100500008401';
break;
case 0x85:
hex = '843800000000c085001557656c636f6d6520746f2050485020536572766572';
break;
case 0x86:
hex = '844100000000288600001022';
break;
case 0x87:
hex = '840200000000e887c70f83e100000000000000010000000242fd09e242900000430682cc';
break;
case 0x88:
hex = '88f616004000e8707802880000465e00000020437e80004290000042a50000f8000000212c017f';
break;
case 0x89:
hex = '802613000001a88900000000b009ffbd00074272616e646f6e0000002c0000000000000000000000002000000000c00000000000000000000000007f';
break;
case 0x8a:
hex = '84071e00400068c6ec028a000051b9ffffffffb92744b4';
break;
case 0x8c:
hex = '800809004000e058f7008c00010ccb504206a52342953135432f4ad9000107d9fdfae891d7af';
break;
case 0x8d:
hex = '80290a004000285611018d00010ccc';
break;
case 0x8e:
hex = '883d13004000c8dc00028e00010cdb002501000042db96d742ae6d6c433d511afa19fb';
break;
case 0x8f:
hex = '809304004000487a46008f0000001900000018';
break;
//No example for 0x90
case 0x93:
hex = '841b00004000c8040000930000000142c90ed1427b5f8e41cbe91ec38037c100000000';
break;
case 0x94:
hex = '841900004000c809000094000000184300800042820000430080000000000000000000';
break;
//No example for 0x95
case 0x96:
hex = '806a0301400070a2df1e960000004d00000096000000a640';
break;
case 0x97:
hex = '80690301600060a1df1ebb0700009700000096000000a6400000';
break;
}
break;
}
msg = new Buffer(hex, 'hex');
console.log(packet.decode(new Buffer(hex, 'hex')));
client.send(msg, 0, msg.length, 19135, '192.168.1.141');
setTimeout(function()
{
client.close();
}, 10)
function checkData(type)
{
if (type >= 0x80 && type <= 0x8f)
{
return type;
}
return false;
}