2 * Reliable Multicast Transport (RMT)
3 * FEC Building Block dissector
4 * Copyright 2005, Stefano Pettini <spettini@users.sourceforge.net>
6 * Forward Error Correction (ALC):
7 * -------------------------------
9 * The goal of the FEC building block is to describe functionality
10 * directly related to FEC codes that is common to all reliable content
11 * delivery IP multicast protocols, and to leave out any additional
12 * functionality that is specific to particular protocols.
15 * RFC 3452, Forward Error Correction Building Block
16 * RFC 3695, Compact Forward Error Correction (FEC) Schemes
17 * Simple XOR, Reed-Solomon, and Parity Check Matrix-based FEC Schemes draft-peltotalo-rmt-bb-fec-supp-xor-pcm-rs-00
18 * IANA RMT FEC parameters (http://www.iana.org/assignments/rmt-fec-parameters)
20 * Wireshark - Network traffic analyzer
21 * By Gerald Combs <gerald@wireshark.org>
22 * Copyright 1998 Gerald Combs
24 * SPDX-License-Identifier: GPL-2.0-or-later
29 #include <epan/packet.h>
30 #include <epan/expert.h>
31 #include <epan/proto_data.h>
32 #include "packet-rmt-common.h"
34 void proto_register_rmt_fec(void);
36 static int proto_rmt_fec
;
38 static int hf_encoding_id
;
39 static int hf_instance_id
;
41 static int hf_sbn_with_mask
;
44 static int hf_esi_with_mask
;
45 static int hf_fti_transfer_length
;
46 static int hf_fti_encoding_symbol_length
;
47 static int hf_fti_max_source_block_length
;
48 static int hf_fti_max_number_encoding_symbols
;
49 static int hf_fti_num_blocks
;
50 static int hf_fti_num_subblocks
;
51 static int hf_fti_alignment
;
55 static expert_field ei_fec_encoding_id
;
57 typedef struct fec_packet_data
65 const value_string string_fec_encoding_id
[] =
67 { 0, "Compact No-Code" },
69 { 2, "Reed-Solomon Codes over GF(2^^m)" },
70 { 3, "LDPC Staircase Codes" },
71 { 4, "LDPC Triangle Codes" },
72 { 5, "Reed-Solomon Codes over GF(2^^8)" },
73 { 6, "RaptorQ Code" },
74 /* 7-127 Unassigned */
75 { 128, "Small Block, Large Block and Expandable FEC Codes" },
76 { 129, "Small Block Systematic FEC Codes" },
77 { 130, "Compact FEC Codes" },
78 /* 131-255 Unassigned */
85 /* Decode an EXT_FTI extension and fill FEC array */
86 void fec_decode_ext_fti(tvbuff_t
*tvb
, packet_info
*pinfo
, proto_tree
*tree
, int offset
, uint8_t encoding_id
)
88 uint64_t transfer_length
;
89 fec_packet_data_t
*fec_data
;
90 uint8_t instance_id
= 0;
93 if (encoding_id
== 6){
94 /* Raptor Q uses 40-bit transfer length */
95 transfer_length
= tvb_get_ntoh40(tvb
, offset
+2);
98 /* Decode 48-bit length field */
99 transfer_length
= tvb_get_ntoh48(tvb
, offset
+2);
102 if (encoding_id
>= 128)
104 instance_id
= (uint8_t) tvb_get_ntohs(tvb
, offset
+8);
106 /* Decode FEC Instance ID */
107 fec_data
= wmem_new0(wmem_file_scope(), fec_packet_data_t
);
108 fec_data
->instance_id
= instance_id
;
110 p_add_proto_data(wmem_file_scope(), pinfo
, proto_rmt_fec
, 0, fec_data
);
113 if (encoding_id
== 6){
114 /* Raptor Q uses 40-bit transfer length */
115 proto_tree_add_uint64(tree
, hf_fti_transfer_length
, tvb
, offset
+2, 5, transfer_length
);
118 proto_tree_add_uint64(tree
, hf_fti_transfer_length
, tvb
, offset
+2, 6, transfer_length
);
119 ti
= proto_tree_add_item(tree
, hf_instance_id
, tvb
, offset
+8, 2, ENC_BIG_ENDIAN
);
120 if ((encoding_id
< 128) && (encoding_id
!= 0)) {
121 expert_add_info(pinfo
, ti
, &ei_fec_encoding_id
);
128 proto_tree_add_item(tree
, hf_fti_encoding_symbol_length
, tvb
, offset
+10, 2, ENC_BIG_ENDIAN
);
129 proto_tree_add_item(tree
, hf_fti_num_blocks
, tvb
, offset
+12, 2, ENC_BIG_ENDIAN
);
130 proto_tree_add_item(tree
, hf_fti_num_subblocks
, tvb
, offset
+14, 1, ENC_BIG_ENDIAN
);
131 proto_tree_add_item(tree
, hf_fti_alignment
, tvb
, offset
+15, 1, ENC_BIG_ENDIAN
);
135 proto_tree_add_item(tree
, hf_fti_encoding_symbol_length
, tvb
, offset
+8, 2, ENC_BIG_ENDIAN
);
136 proto_tree_add_item(tree
, hf_fti_num_blocks
, tvb
, offset
+10, 1, ENC_BIG_ENDIAN
);
137 proto_tree_add_item(tree
, hf_fti_num_subblocks
, tvb
, offset
+11, 2, ENC_BIG_ENDIAN
);
138 proto_tree_add_item(tree
, hf_fti_alignment
, tvb
, offset
+13, 1, ENC_BIG_ENDIAN
);
145 proto_tree_add_item(tree
, hf_fti_encoding_symbol_length
, tvb
, offset
+10, 2, ENC_BIG_ENDIAN
);
146 proto_tree_add_item(tree
, hf_fti_max_source_block_length
, tvb
, offset
+12, 4, ENC_BIG_ENDIAN
);
150 proto_tree_add_item(tree
, hf_fti_encoding_symbol_length
, tvb
, offset
+10, 2, ENC_BIG_ENDIAN
);
151 proto_tree_add_item(tree
, hf_fti_max_source_block_length
, tvb
, offset
+12, 2, ENC_BIG_ENDIAN
);
152 proto_tree_add_item(tree
, hf_fti_max_number_encoding_symbols
, tvb
, offset
+14, 2, ENC_BIG_ENDIAN
);
156 proto_tree_add_item(tree
, hf_fti_encoding_symbol_length
, tvb
, offset
+10, 2, ENC_BIG_ENDIAN
);
157 proto_tree_add_item(tree
, hf_fti_max_source_block_length
, tvb
, offset
+12, 4, ENC_BIG_ENDIAN
);
158 proto_tree_add_item(tree
, hf_fti_max_number_encoding_symbols
, tvb
, offset
+16, 4, ENC_BIG_ENDIAN
);
163 /* Dissect a FEC header:
164 * fec - ptr to the logical FEC packet representation to fill
165 * hf - ptr to header fields array
166 * ett - ptr to ett array
167 * prefs - ptr to FEC prefs array
169 * pinfo - packet info
170 * tree - tree where to add FEC header subtree
171 * offset - ptr to offset to use and update
174 dissect_fec(tvbuff_t
*tvb
, packet_info
*pinfo
, proto_tree
*tree
, void *data
)
177 proto_tree
*fec_tree
;
179 fec_data_exchange_t
*fec
= (fec_data_exchange_t
*)data
;
180 uint8_t encoding_id
= 0;
181 fec_packet_data_t
*packet_data
= (fec_packet_data_t
*)p_get_proto_data(wmem_file_scope(), pinfo
, proto_rmt_fec
, 0);
185 encoding_id
= fec
->encoding_id
;
188 /* Create the FEC subtree */
189 ti
= proto_tree_add_item(tree
, proto_rmt_fec
, tvb
, offset
, -1, ENC_NA
);
190 fec_tree
= proto_item_add_subtree(ti
, ett_main
);
192 proto_tree_add_uint(fec_tree
, hf_encoding_id
, tvb
, offset
, 0, encoding_id
);
194 if (encoding_id
>= 128 && (packet_data
!= NULL
))
195 proto_tree_add_uint(fec_tree
, hf_instance_id
, tvb
, offset
, 0, packet_data
->instance_id
);
202 proto_tree_add_item(fec_tree
, hf_sbn
, tvb
, offset
, 2, ENC_BIG_ENDIAN
);
203 proto_tree_add_item(fec_tree
, hf_esi
, tvb
, offset
+2, 2, ENC_BIG_ENDIAN
);
205 col_append_sep_fstr(pinfo
->cinfo
, COL_INFO
, " ", "SBN: %u", tvb_get_ntohs(tvb
, offset
));
206 col_append_sep_fstr(pinfo
->cinfo
, COL_INFO
, " ", "ESI: 0x%X", tvb_get_ntohs(tvb
, offset
+2));
214 proto_tree_add_item(fec_tree
, hf_sbn
, tvb
, offset
, 4, ENC_BIG_ENDIAN
);
215 proto_tree_add_item(fec_tree
, hf_esi
, tvb
, offset
+4, 4, ENC_BIG_ENDIAN
);
217 col_append_sep_fstr(pinfo
->cinfo
, COL_INFO
, " ", "SBN: %u", tvb_get_ntohl(tvb
, offset
));
218 col_append_sep_fstr(pinfo
->cinfo
, COL_INFO
, " ", "ESI: 0x%X", tvb_get_ntohl(tvb
, offset
+4));
225 proto_tree_add_item(fec_tree
, hf_sbn_with_mask
, tvb
, offset
, 4, ENC_BIG_ENDIAN
);
226 proto_tree_add_item(fec_tree
, hf_esi_with_mask
, tvb
, offset
, 4, ENC_BIG_ENDIAN
);
228 col_append_sep_fstr(pinfo
->cinfo
, COL_INFO
, " ", "SBN: %u", tvb_get_ntohl(tvb
, offset
) >> 20);
229 col_append_sep_fstr(pinfo
->cinfo
, COL_INFO
, " ", "ESI: 0x%X", tvb_get_ntohl(tvb
, offset
) & 0xfffff);
235 proto_tree_add_item(fec_tree
, hf_sbn
, tvb
, offset
, 1, ENC_BIG_ENDIAN
);
236 proto_tree_add_item(fec_tree
, hf_esi
, tvb
, offset
+1, 3, ENC_BIG_ENDIAN
);
238 col_append_sep_fstr(pinfo
->cinfo
, COL_INFO
, " ", "SBN: %u", tvb_get_uint8(tvb
, offset
));
239 col_append_sep_fstr(pinfo
->cinfo
, COL_INFO
, " ", "ESI: 0x%X", tvb_get_ntoh24(tvb
, offset
+1));
245 proto_tree_add_item(fec_tree
, hf_sbn
, tvb
, offset
, 4, ENC_BIG_ENDIAN
);
246 proto_tree_add_item(fec_tree
, hf_sbl
, tvb
, offset
+4, 2, ENC_BIG_ENDIAN
);
247 proto_tree_add_item(fec_tree
, hf_esi
, tvb
, offset
+6, 2, ENC_BIG_ENDIAN
);
249 col_append_sep_fstr(pinfo
->cinfo
, COL_INFO
, " ", "SBN: %u", tvb_get_ntohl(tvb
, offset
));
250 col_append_sep_fstr(pinfo
->cinfo
, COL_INFO
, " ", "ESI: 0x%X", tvb_get_ntohs(tvb
, offset
+6));
259 void proto_register_rmt_fec(void)
261 static hf_register_info hf
[] = {
263 { "FEC Encoding ID", "rmt-fec.encoding_id",
264 FT_UINT8
, BASE_DEC
, VALS(string_fec_encoding_id
), 0x0,
268 { "FEC Instance ID", "rmt-fec.instance_id",
269 FT_UINT16
, BASE_DEC
, NULL
, 0x0,
273 { "Source Block Number", "rmt-fec.sbn",
274 FT_UINT32
, BASE_DEC
, NULL
, 0x0,
278 { "Source Block Number", "rmt-fec.sbn",
279 FT_UINT32
, BASE_DEC
, NULL
, 0xFFF00000,
283 { "Source Block Length", "rmt-fec.sbl",
284 FT_UINT32
, BASE_DEC
, NULL
, 0x0,
288 { "Encoding Symbol ID", "rmt-fec.esi",
289 FT_UINT32
, BASE_HEX
, NULL
, 0x0,
293 { "Encoding Symbol ID", "rmt-fec.esi",
294 FT_UINT32
, BASE_HEX
, NULL
, 0x000FFFFF,
297 { &hf_fti_transfer_length
,
298 { "Transfer Length", "rmt-fec.fti.transfer_length",
299 FT_UINT64
, BASE_DEC
, NULL
, 0x0,
302 { &hf_fti_encoding_symbol_length
,
303 { "Encoding Symbol Length", "rmt-fec.fti.encoding_symbol_length",
304 FT_UINT32
, BASE_DEC
, NULL
, 0x0,
307 { &hf_fti_max_source_block_length
,
308 { "Maximum Source Block Length", "rmt-fec.fti.max_source_block_length",
309 FT_UINT32
, BASE_DEC
, NULL
, 0x0,
312 { &hf_fti_max_number_encoding_symbols
,
313 { "Maximum Number of Encoding Symbols", "rmt-fec.fti.max_number_encoding_symbols",
314 FT_UINT32
, BASE_DEC
, NULL
, 0x0,
317 { &hf_fti_num_blocks
,
318 { "Number of Source Blocks", "rmt-fec.fti.num_blocks",
319 FT_UINT16
, BASE_DEC
, NULL
, 0x0,
322 { &hf_fti_num_subblocks
,
323 { "Number of Sub-Blocks", "rmt-fec.fti.num_subblocks",
324 FT_UINT16
, BASE_DEC
, NULL
, 0x0,
328 { "Symbol Alignment", "rmt-fec.fti.alignment",
329 FT_UINT8
, BASE_DEC
, NULL
, 0x0,
334 /* Setup protocol subtree array */
335 static int *ett
[] = {
339 static ei_register_info ei
[] = {
340 { &ei_fec_encoding_id
, { "rmt-fec.encoding_id.not0", PI_PROTOCOL
, PI_WARN
, "FEC Encoding ID < 128, should be zero", EXPFILL
}},
343 expert_module_t
* expert_rmt_fec
;
345 /* Register the protocol name and description */
346 proto_rmt_fec
= proto_register_protocol("Forward Error Correction (FEC)", "RMT-FEC", "rmt-fec");
347 register_dissector("rmt-fec", dissect_fec
, proto_rmt_fec
);
349 /* Required function calls to register the header fields and subtrees used */
350 proto_register_field_array(proto_rmt_fec
, hf
, array_length(hf
));
351 proto_register_subtree_array(ett
, array_length(ett
));
352 expert_rmt_fec
= expert_register_protocol(proto_rmt_fec
);
353 expert_register_field_array(expert_rmt_fec
, ei
, array_length(ei
));
357 * Editor modelines - https://www.wireshark.org/tools/modelines.html
362 * indent-tabs-mode: nil
365 * ex: set shiftwidth=4 tabstop=8 expandtab:
366 * :indentSize=4:tabSize=8:noTabs=true: