packet_via_dmem 0.0.1 → 0.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 8440c5a60e199124adc3d0324bf38437174fb6a3
4
- data.tar.gz: 73eebe8936d415da89dbf6e61c1c2086d8fa050b
3
+ metadata.gz: 53ecfd612ff435c2479e2ad5e4248237426126ff
4
+ data.tar.gz: c6c57f9a6236e43b0d75d3f3ff8f0fbab3c4aa0d
5
5
  SHA512:
6
- metadata.gz: 16e295f2ce92ffba8b559bba2aaf92b7df0bc2e2754a72736e47b9ae3418c54b5695a74f7bc149123ab733af600d087d0e30d64e66d135c5d16066007da40097
7
- data.tar.gz: b3180ed9bac4472230ca4b0bd421bd79043f5dbe321d0501431fe0f9df588d8a3862aaed6f538c7854e0797417ca6694363b22f8b366f8480cc429bf01594ed4
6
+ metadata.gz: 0fac3c202a90560476a5dc846af13161016dde8a08949dd7b9de5fa2c4b283649d4ccdf472f26bdb8800a7ed9fa1edd1998e90360849d8553b39daa341e3347e
7
+ data.tar.gz: d2a122ab2e01fe44e8fdecfdbd27303eb217acc2c719227feed78c34188c3fff7a93f56e2ed569870d58b8914321cccfb0651b0065805794d8796d1187aedc0c
data/README.md CHANGED
@@ -70,11 +70,55 @@ To capture say packets with IP address 10.11.12.13
70
70
 
71
71
 
72
72
  ## Header format
73
- Potentially first is type
74
- * 00 ?? ?? ?? source ??
75
- * 10 ?? ?? ?? ?? ?? source ??
73
+ ### Received header
74
+
75
+ * First byte is type of header?
76
+ * 00 'lu packet' (i.e. whole packet was sent for lookup, i.e. small packet)
77
+ * 10 'lu packet head' (i.e. only head of packet was sent for lookup, i.e. large packet)
78
+
79
+ * Second and third byte appear to tell nothing about where packet came from,
80
+ but more when it came from. Timing? Counter? Randomness?
81
+
82
+ * Fourth byte is 0xf0 on MX80, tendency for last nibble to be 0. Perhaps src fabric stream?
83
+ * Fifth byte appears to be source port?
84
+
85
+ * Sixth byte is perhaps source NPU?
86
+
87
+ * 00 (22) (33) (44) \<src\> (66)
88
+ * 10 (22) (33) (44) \<si\> \<ze\> \<src\> (66)
89
+
90
+ Example from MX960
91
+
92
+ 00 00 c0 30 80 08
93
+ 00 03 40 30 80 08
94
+ 00 03 c0 70 81 08
95
+ 00 06 c0 30 80 08
96
+ 00 07 c0 70 81 08
97
+ 00 0a 40 30 80 08
98
+ 00 01 c0 70 81 08
99
+ 00 02 40 70 81 08
100
+ 10 01 40 70 05 c0 81 08
101
+ 00 05 40 70 81 08
102
+ 00 08 c0 30 80 08
103
+ 00 0a c0 70 81 08
104
+ 10 0b 40 20 05 28 40 08
105
+ 00 0d c0 30 80 08
106
+ 10 00 c0 30 05 8c 80 08
107
+ 00 03 c0 30 80 08
108
+ 10 03 40 30 05 8c 80 08
109
+ 10 06 40 30 05 8c 80 08
110
+ 10 06 c0 30 05 f0 80 08
111
+ 00 07 40 70 81 08
112
+ 00 07 80 40 42 20
113
+ 00 09 00 98 42 20
114
+ 00 0a 00 48 42 20
115
+ 10 09 c0 30 05 8c 80 08
116
+ 00 02 40 70 81 08
117
+ 10 0b 80 48 05 ce 42 20
118
+ 10 01 c0 30 05 8c 80 08
119
+
120
+ Example from MX480
76
121
 
77
- Example receive headers, MX480
78
122
  00 0b 40 60 41 08
79
123
  00 01 c0 70 81 08
80
124
  00 02 40 70 81 08
@@ -104,7 +148,8 @@ Example receive headers, MX480
104
148
  00 02 40 60 41 08
105
149
  00 07 c7 f0 b0 80
106
150
 
107
- Example receive headers, MX80
151
+ Example from MX80
152
+
108
153
  00 08 00 f0 81 08
109
154
  10 08 80 f0 05 b4 81 08
110
155
  10 09 00 f0 05 b4 81 08
@@ -122,18 +167,99 @@ Example receive headers, MX80
122
167
  10 07 80 f0 05 b4 81 08
123
168
  10 0b 00 f0 02 28 81 08
124
169
 
125
- TAZ-TBB-0(X vty)# show ixchip ifd
126
-
127
- IFD IFD IX WAN Ing Queue Egr Queue
128
- Index Name Id Port Rt/Ct/Be H/L
129
- ====== ========== ====== ====== ============== ======
130
- 148 ge-1/0/0 2 0 0/32/64 0/32
131
- 149 ge-1/0/1 2 1 1/33/65 1/33
132
- 166 ge-1/1/8 2 18 18/50/82 18/50
133
-
134
170
  For this box, second to last byte, divmod 64, returns these ports, which are
135
171
  correct port for source.
136
172
 
173
+ TAZ-TBB-0(X vty)# show ixchip ifd
174
+ IFD IFD IX WAN Ing Queue Egr Queue
175
+ Index Name Id Port Rt/Ct/Be H/L
176
+ ====== ========== ====== ====== ============== ======
177
+ 148 ge-1/0/0 2 0 0/32/64 0/32
178
+ 149 ge-1/0/1 2 1 1/33/65 1/33
179
+ 166 ge-1/1/8 2 18 18/50/82 18/50
180
+
181
+ ### Sent header
182
+ I'm really not sure about sent headers, need more data to figure out what is
183
+ our type. For all my examples, when we sent frame without L2 headers for
184
+ fabric, it was MPLS, but almost certainly it can be IPv4, IPv6, ARP etc too.
185
+ Need data to know which header tells that. So we are going to pop wrong amount
186
+ of bytes in many sent cases.
187
+
188
+ * first byte is output
189
+ * 0x00 == to fabric
190
+ * 0x08 == to wan
191
+
192
+ * byte 6, 7, 9, 11 or 21 probably defines type (different if we sent layer2 to fabric or if we don't)
193
+
194
+ Example from MX960
195
+
196
+ 00 bf e0 0d 71 f0 00 04 42 20 01 44 03 01 00 81 00 00 00 00 00 00 07 e9
197
+ 00 bf e0 0f 71 f0 00 09 42 20 01 44 03 01 01 21 00 00 00 00 00 00 16 65
198
+ 00 bf e0 14 11 f0 00 04 42 20 01 44 00 01 00 81 00 00 00 00 00 00 0b ad
199
+ 00 bf e0 03 71 f0 00 04 42 20 01 44 03 01 00 81 00 00 00 00 00 00 04 06
200
+ 00 bf e0 04 71 f0 00 00 42 20 01 44 03 01 00 01 00 00 00 00 00 00 24 42
201
+ 00 bf e0 0a 71 f0 00 04 42 20 01 44 03 01 00 81 00 00 00 00 00 00 18 a4
202
+ 00 a0 00 02 71 f0 00 04 42 20 01 44 03 01 00 81 00 00 00 00 00 00 0a 8f
203
+ 00 bf e0 11 11 f0 00 04 42 20 01 44 00 01 00 81 00 00 00 00 00 00 04 00
204
+ 00 bf e0 15 71 f0 00 04 42 20 01 44 03 01 00 81 00 00 00 00 00 00 1c 69
205
+ 00 bf e0 1b 11 f0 00 04 42 20 01 44 00 01 00 81 00 00 00 00 00 00 0b ad
206
+ 00 a0 00 16 71 f0 00 04 42 20 01 44 03 01 00 81 00 00 00 00 00 00 05 ec
207
+ 00 bf e0 07 11 f0 00 04 42 20 01 44 00 01 00 81 00 00 00 00 00 00 0b ad
208
+ 00 a0 00 01 11 f0 00 04 42 20 01 44 00 01 00 81 00 00 00 00 00 00 08 0a
209
+ 00 a0 00 06 11 f0 00 04 42 20 01 44 00 01 00 81 00 00 00 00 00 00 08 0a
210
+ 00 a0 00 0c 11 f0 00 04 42 20 01 44 00 01 00 81 00 00 00 00 00 00 08 0a
211
+ 00 a0 00 0d 71 f0 00 00 42 20 01 44 03 01 00 01 00 00 00 00 00 00 24 06
212
+ 08 bf e0 0f 70 00 00 08 b0 0e 80 03 0a
213
+ 00 bf e0 0e 11 f0 00 04 42 20 01 44 00 01 00 81 00 00 00 00 00 00 06 6b
214
+ 08 bf e0 12 10 00 00 08 b0 0e 80 03 0a
215
+ 08 bf e0 14 10 00 00 08 b0 0e 80 03 0a
216
+ 00 bf e0 04 71 f0 00 09 42 20 01 44 03 01 01 21 00 00 00 00 00 00 16 65
217
+
218
+ Example from MX480
219
+
220
+ 00 bf e0 16 10 00 03 f9 20 00 20 03 02 b0 03 7a 00 0e 00 42 80 00 00 20 0e 00 00 10 00 0c 00 00 00
221
+ 00 bf e0 03 10 00 03 f8 20 40 20 00 20 10 03 7a 00 12 00 46 80 00 00 20 12 00 00 18 00 00 00 00 00
222
+ 00 bf e0 04 10 00 03 f8 20 40 20 00 20 10 03 7a 00 12 00 46 80 00 00 20 12 00 00 18 00 00 00 00 00
223
+ 08 bf e0 05 14 00 00 10 20 12 80 5a 28
224
+ 08 a0 00 06 14 00 00 10 b0 12 80 5a 28
225
+ 08 bf e0 07 14 00 00 10 20 12 80 5a 28
226
+ 08 bf e0 0c 14 00 00 10 b0 12 80 5a 28
227
+ 08 bf e0 0f 14 00 00 10 20 12 80 5a 28
228
+ 08 bf e0 10 14 00 00 0b 20 12 80 33 2a
229
+ 08 bf e0 12 14 00 00 0b 20 0e 80 33 2c
230
+ 08 bf e0 13 14 00 00 08 00 00 80 00 be
231
+ 08 bf e0 17 14 00 00 10 20 12 80 5a 28
232
+ 08 bf e0 01 14 00 00 10 b0 12 80 5a 28
233
+ 08 bf e0 02 14 00 00 08 00 00 80 00 be
234
+ 08 a0 00 09 14 00 00 10 a0 12 80 5a 28
235
+ 08 bf e0 0a 14 00 00 10 20 12 80 5a 28
236
+ 08 bf e0 0b 14 00 00 10 a0 12 80 5a 28
237
+ 08 bf e0 0d 14 00 00 0b 00 0e 80 33 2c
238
+ 08 bf e0 11 14 00 00 10 b0 12 80 5a 28
239
+ 08 bf e0 14 14 00 00 10 b0 12 80 5a 28
240
+ 08 bf e0 15 14 00 00 10 20 12 80 5a 28
241
+ 08 bf e0 16 14 00 00 0b 20 0e 80 33 2c
242
+
243
+ Example from MX80
244
+
245
+ 08 bf e0 10 11 00 00 00 70 0e 80 0a 1e
246
+ 08 a0 00 11 11 00 00 00 70 0e 80 0a 1e
247
+ 08 a0 00 12 11 00 00 00 70 0e 80 0a 1e
248
+ 08 a0 00 13 11 00 00 00 10 0e 80 0a 1e
249
+ 08 bf e0 14 11 00 00 00 70 12 80 0a 1e
250
+ 08 a0 00 15 11 00 00 00 70 0e 80 0a 1e
251
+ 08 bf e0 08 11 00 00 00 70 0e 80 0a 1e
252
+ 08 a0 00 06 11 00 00 00 70 0e 80 0a 1e
253
+ 08 a0 00 09 11 00 00 00 70 0e 80 0a 1e
254
+ 08 a0 00 0a 11 00 00 00 70 0e 80 0a 1e
255
+ 08 a0 00 0b 11 00 00 00 70 0e 80 0a 1e
256
+ 08 bf e0 0c 11 00 00 00 70 0e 80 0a 1e
257
+ 08 a0 00 0d 11 00 00 00 70 0e 80 0a 1e
258
+ 08 bf e0 0e 71 00 00 08 10 0e 80 0a 32
259
+ 08 a0 00 0f 11 00 00 00 70 0e 80 0a 1e
260
+ 08 a0 00 16 11 00 00 00 70 0e 80 0a 1e
261
+
137
262
  ## Todo
138
- 1. correctly discover how many bytes need to be popped, perhaps by finding valid ethernet headers and ignore anything before?
139
- 1. reverse engineer header/cookie, at least figuring out which fabric stream (And hence egress NPU) is going to be used should be trivial
263
+ 1. reverse engineer sent headers (so we can pop them correctly)
264
+ 1. reverse engineer cookie
265
+ 1. more research on received headers source fabric, port, npu
@@ -2,9 +2,14 @@ require 'strscan'
2
2
 
3
3
  class PacketViaDMEM
4
4
  PACKET = /^(Received|Sent) \d+ byte parcel:.*\n/
5
+ FAKE = {
6
+ :dmac => %w( 22 22 22 22 22 22 ),
7
+ :smac => %w( 66 66 66 66 66 66 ),
8
+ :etype => %w( 88 47 ),
9
+ }
5
10
  HEADER_SIZE = {
6
11
  :received => 6,
7
- :sent => 33, # FIXME: it's variable, we're dumb
12
+ :sent => 13,
8
13
  }
9
14
  class Error < StandardError; end
10
15
 
@@ -30,11 +35,11 @@ class PacketViaDMEM
30
35
  pkt << @sc.scan_until(/\n/).strip
31
36
  end
32
37
  pkt = parse_packet pkt
33
- pop = get_pop(type, pkt)
38
+ pop, push = get_pop_push(type, pkt)
34
39
  header = pkt[0..pop-1]
35
40
  pkt = pkt[pop..-1]
36
41
  if pkt
37
- packets << '000000 ' + pkt.join(' ')
42
+ packets << '000000 ' + [push, pkt].flatten.join(' ')
38
43
  headers << header.join(' ')
39
44
  end
40
45
  end
@@ -43,16 +48,29 @@ class PacketViaDMEM
43
48
 
44
49
  private
45
50
 
46
- def get_pop type, pkt
47
- if type == :sent
48
- @sent
51
+ def get_pop_push type, pkt
52
+ push = []
53
+ pop = if type == :sent
54
+ case pkt.first.to_i(16)
55
+ when 0x00 # we're sending to fabric
56
+ # we may send MAC to fabric,byte 6, 7, 9, 11, 21?
57
+ if pkt[5].to_i(16) == 0xf0 # we don't send MAC to fabric
58
+ push = FAKE[:dmac] + FAKE[:smac] + FAKE[:etype]
59
+ 24
60
+ else # we send MAC to fabric
61
+ 33
62
+ end
63
+ when 0x08 then 13
64
+ else @sent
65
+ end
49
66
  else
50
67
  case pkt.first.to_i(16)
51
- when 0x0 then 6 #1,2,3,4,5,6
68
+ when 0x00 then 6 #1,2,3,4,5,6
52
69
  when 0x10 then 8 #1,2,3,4,7,8,5,6
53
70
  else @received
54
71
  end
55
72
  end
73
+ [pop, push]
56
74
  end
57
75
 
58
76
  def parse_packet pkt
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'packet_via_dmem'
3
- s.version = '0.0.1'
3
+ s.version = '0.0.2'
4
4
  s.licenses = %w( Apache-2.0 )
5
5
  s.platform = Gem::Platform::RUBY
6
6
  s.authors = [ 'Saku Ytti' ]
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: packet_via_dmem
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Saku Ytti
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-02-26 00:00:00.000000000 Z
11
+ date: 2015-02-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: slop