diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-10 20:34:10 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-10 20:34:10 +0000 |
commit | e4ba6dbc3f1e76890b22773807ea37fe8fa2b1bc (patch) | |
tree | 68cb5ef9081156392f1dd62a00c6ccc1451b93df /test/suite_dissectors | |
parent | Initial commit. (diff) | |
download | wireshark-e4ba6dbc3f1e76890b22773807ea37fe8fa2b1bc.tar.xz wireshark-e4ba6dbc3f1e76890b22773807ea37fe8fa2b1bc.zip |
Adding upstream version 4.2.2.upstream/4.2.2
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'test/suite_dissectors')
-rw-r--r-- | test/suite_dissectors/dissectorstest.py | 116 | ||||
-rw-r--r-- | test/suite_dissectors/group_asterix.py | 3875 | ||||
-rw-r--r-- | test/suite_dissectors/group_netperfmeter.py | 430 |
3 files changed, 4421 insertions, 0 deletions
diff --git a/test/suite_dissectors/dissectorstest.py b/test/suite_dissectors/dissectorstest.py new file mode 100644 index 00000000..899df596 --- /dev/null +++ b/test/suite_dissectors/dissectorstest.py @@ -0,0 +1,116 @@ +# +# Wireshark dissector tests +# By Atli Guðmundsson <atli@tern.is> +# +# SPDX-License-Identifier: GPL-2.0-or-later + +import inspect +import json +import subprocess +import pytest + + +class _dissection_validator_real: + ''' + Collects a set of byte bundles, matching json objects and a protocol + name and verifies that a byte bundle converts into the matching json + object using the following execution chain: + + byte bundle -> text2pcap -> tshark <protocol> -> json + + Note: The idea for this approach came about when it was realized that + calling text2pcap and tshark for each byte bundle resulted in + unacceptable overhead during execution of the unittests. + ''' + + def __init__(self, protocol, request, cmd_tshark, cmd_text2pcap, result_file, env): + self.dissection_list = [] + self.protocol = protocol + self.cmd_tshark = cmd_tshark + self.cmd_text2pcap = cmd_text2pcap + self.test_case = request.instance + self.result_file = result_file + self.env = env + + def add_dissection(self, byte_list, expected_result, line_no=None): + '''Adds a byte bundle and an expected result to the set of byte + bundles to verify. + + byte bundles must be iterable.''' + + hex_string = ' '.join('{:02x}'.format(ele) for ele in bytes(byte_list)) + + if line_no is None: + caller = inspect.getframeinfo(inspect.stack()[1][0]) + line_no = caller.lineno + + self.dissection_list.append((line_no, hex_string, expected_result)) + +# Uncomment the following lines to record in a text file all the dissector byte +# bundles, in the order they are presented: +# +# with open("full.txt", 'a') as f: +# f.write("0 {}\n".format(hex_string)) + +# Then use the following command to convert full.txt into a pcap file, +# replacing <port> with the default port of your protocol: +# # text2pcap -u <port>,<port> full.txt out.pcap + + def check_dissections(self): + '''Processes and verifies all added byte bundles and their expected + results. At the end of processing the current set is emptied.''' + + text_file = self.result_file('txt') + pcap_file = self.result_file('pcap') + + # create our text file of hex encoded messages + with open(text_file, 'w') as f: + for line_no, hex_string, expected_result in self.dissection_list: + f.write("0 {}\n".format(hex_string)) + + # generate our pcap file by feeding the messages to text2pcap + subprocess.check_call(( + self.cmd_text2pcap, + '-u', '1234,1234', + text_file, pcap_file + ), env=self.env) + + # generate our dissection from our pcap file + tshark_stdout = subprocess.check_output(( + self.cmd_tshark, + '-r', pcap_file, + '-T', 'json', + '-d', 'udp.port==1234,{}'.format(self.protocol), + '-J', self.protocol + ), encoding='utf-8', env=self.env) + + dissections = json.loads(tshark_stdout) + for (line_no, hex_string, expected_result), dissection in zip(self.dissection_list, dissections): + + # strip away everything except the protocol + result = dissection['_source']['layers'] + assert self.protocol in result + result = result[self.protocol] + + # verify that the dissection is as expected + assert expected_result == result, \ + "expected != result, while dissecting [{}] from line {}.".format(hex_string, line_no) + + # cleanup for next test + self.dissection_list = [] + + +@pytest.fixture +def dissection_validator(request, cmd_tshark, cmd_text2pcap, result_file, test_env): + + def generate_validator(protocol): + retval = _dissection_validator_real( + protocol, + request, + cmd_tshark, + cmd_text2pcap, + result_file, + test_env) + return retval + + return generate_validator diff --git a/test/suite_dissectors/group_asterix.py b/test/suite_dissectors/group_asterix.py new file mode 100644 index 00000000..b5b1b4fd --- /dev/null +++ b/test/suite_dissectors/group_asterix.py @@ -0,0 +1,3875 @@ +# +# Wireshark ASTERIX dissector tests +# By Atli Guðmundsson <atli@tern.is> +# +# SPDX-License-Identifier: GPL-2.0-or-later +# +'''ASTERIX dissector tests''' + +import inspect +import pytest + +# Wireshark modules +from suite_dissectors.dissectorstest import * + + +class TestAsterix: + + def test_for_asterix(self, dissection_validator): + '''Verifies that the asterix dissector is installed and accessible''' + + tester = dissection_validator('asterix') + tester.add_dissection( + [0x13, 0x00, 0x03], + { + "asterix.category": "19", + "asterix.length": "3" + } + ) + tester.check_dissections() + + +class _asterix_validator_real: + + def __init__(self, category, dissection_validator): + self.category = category + self.validator = dissection_validator("asterix") + + def add_dissection(self, byte_list, field, expected_message, line_no=None): + '''pre-wrap asterix category messages with proper asterix structure''' + + total_length = len(byte_list) + 3 + byte_list = [ + self.category, + (total_length // 256) % 256, + total_length % 256 + ] + byte_list + expected_result = { + "asterix.category": "{}".format(self.category), + "asterix.length": "{}".format(total_length), + "asterix.message": + { + "asterix.fspec": "", + field: expected_message + } + } + if line_no is None: + caller = inspect.getframeinfo(inspect.stack()[1][0]) + line_no = caller.lineno + self.validator.add_dissection(byte_list, expected_result, line_no) + + def check_dissections(self): + self.validator.check_dissections() + + +@pytest.fixture +def asterix_validator(dissection_validator): + + def generate_asterix_validator(category): + retval = _asterix_validator_real(category, dissection_validator) + return retval + + return generate_asterix_validator + + +class _asterix_re_validator_real(_asterix_validator_real): + + def __init__(self, category, re_byte_list, dissection_validator): + super().__init__(category, dissection_validator) + self.re_byte_list = re_byte_list + + def add_re_dissection(self, byte_list, field, expected_message, line_no=None): + '''pre-wrap asterix RE messages with proper asterix RE structure''' + + re_length = len(byte_list) + 1 + byte_list = self.re_byte_list + [ + re_length % 256 + ] + byte_list + expected_result = { + "asterix.re_field_len": "{}".format(re_length), + "asterix.fspec": "", + "asterix.{:03}_RE_{}".format(self.category, field): expected_message + } + if line_no is None: + caller = inspect.getframeinfo(inspect.stack()[1][0]) + line_no = caller.lineno + self.add_dissection(byte_list, "asterix.{:03}_RE".format( + self.category), expected_result, line_no) + + +@pytest.fixture +def asterix_re_validator(dissection_validator): + + def generate_re_asterix_validator(category, re_byte_list): + retval = _asterix_re_validator_real( + category, re_byte_list, dissection_validator) + return retval + + return generate_re_asterix_validator + + +def fspec_local(key, idx, value): + result = { + "asterix.fspec": "", + "asterix.{}".format(key): + { + "asterix.{}_{}".format(key, idx): value + } + } + return result + + +def fspec_global(key, idx, value): + result = { + "asterix.fspec": "", + "asterix.{}".format(key): + { + "asterix.{}".format(idx): value + } + } + return result + + +def dict_local(vmap, key, idx, value): + result = vmap.copy() + result["asterix.{}_{}".format(key, idx)] = value + return result + + +def dict_global(vmap, key, value): + result = vmap.copy() + result["asterix.{}".format(key)] = value + return result + + +def dict_fspec_local(vmap, key, idx, value): + result = { + "asterix.fspec": "", + "asterix.{}".format(key): dict_local(vmap, key, idx, value) + } + return result + + +def dict_fspec_global(vmap, key, idx, value): + result = { + "asterix.fspec": "", + "asterix.{}".format(key): dict_global(vmap, idx, value) + } + return result + + +def counter_local(vmap, counter, key, idx, value): + result = { + "asterix.fspec": "", + "asterix.{}".format(key): + { + "asterix.counter": counter, + "asterix.{}".format(key): dict_local(vmap, key, idx, value) + } + } + return result + + +class TestCategory019: + ''' + Unittest case for ASTERIX Category 019 + + Online specification: + https://www.eurocontrol.int/publications/cat019-multilateration-system-status-messages-part-18 + + Part 18 : Category 019 (1.3) + Multilateration System + Status Messages + + Standard User Application Profile + + FRN Data Item Information Length + 1 I019/010 Data Source Identifier 2 + 2 I019/000 Message Type 1 + 3 I019/140 Time of Day 3 + 4 I019/550 System Status 1 + 5 I019/551 Tracking Processor Detailed Status 1 + 6 I019/552 Remote Sensor Detailed Status 1+ + 7 I019/553 Reference Transponder Detailed Status 1+ + FX - Field Extension Indicator - + 8 I019/600 Position of the MLT System Reference point 8 + 9 I019/610 Height of the MLT System Reference point 2 + 10 I019/620 WGS-84 Undulation 1 + 11 - Spare - + 12 - Spare - + 13 RE Reserved Expansion Field - + 14 SP Special Purpose Field - + FX - Field Extension Indicator - + ''' + + def test_for_fields(self, asterix_validator): + '''verifies existence of all fields and their maximum value''' + + validator = asterix_validator(19) + + validator.add_dissection( + [0x80, 0xff, 0x00], + "asterix.019_010", + { + "asterix.019_010_SAC": "0xff", + "asterix.019_010_SIC": "0x00" + } + ) + validator.add_dissection( + [0x80, 0x00, 0xff], + "asterix.019_010", + { + "asterix.019_010_SAC": "0x00", + "asterix.019_010_SIC": "0xff" + } + ) + validator.add_dissection( + [0x40, 0x03], + "asterix.019_000", + { + "asterix.019_000_VALUE": "3" + } + ) + validator.add_dissection( + [0x20, 0xa8, 0xbf, 0xff], + "asterix.019_140", + { + "asterix.019_140_VALUE": "86399.9921875" + } + ) + validator.add_dissection( + [0x10, 0xc0], + "asterix.019_550", + { + "asterix.019_550_NOGO": "3", + "asterix.019_550_OVL": "0", + "asterix.019_550_TSV": "0", + "asterix.019_550_TTF": "0" + } + ) + validator.add_dissection( + [0x10, 0x20], + "asterix.019_550", + { + "asterix.019_550_NOGO": "0", + "asterix.019_550_OVL": "1", + "asterix.019_550_TSV": "0", + "asterix.019_550_TTF": "0" + } + ) + validator.add_dissection( + [0x10, 0x10], + "asterix.019_550", + { + "asterix.019_550_NOGO": "0", + "asterix.019_550_OVL": "0", + "asterix.019_550_TSV": "1", + "asterix.019_550_TTF": "0" + } + ) + validator.add_dissection( + [0x10, 0x08], + "asterix.019_550", + { + "asterix.019_550_NOGO": "0", + "asterix.019_550_OVL": "0", + "asterix.019_550_TSV": "0", + "asterix.019_550_TTF": "1" + } + ) + validator.add_dissection( + [0x08, 0x80], + "asterix.019_551", + { + "asterix.019_551_TP1A": "1", + "asterix.019_551_TP1B": "0", + "asterix.019_551_TP2A": "0", + "asterix.019_551_TP2B": "0", + "asterix.019_551_TP3A": "0", + "asterix.019_551_TP3B": "0", + "asterix.019_551_TP4A": "0", + "asterix.019_551_TP4B": "0" + } + ) + validator.add_dissection( + [0x08, 0x40], + "asterix.019_551", + { + "asterix.019_551_TP1A": "0", + "asterix.019_551_TP1B": "1", + "asterix.019_551_TP2A": "0", + "asterix.019_551_TP2B": "0", + "asterix.019_551_TP3A": "0", + "asterix.019_551_TP3B": "0", + "asterix.019_551_TP4A": "0", + "asterix.019_551_TP4B": "0" + } + ) + validator.add_dissection( + [0x08, 0x20], + "asterix.019_551", + { + "asterix.019_551_TP1A": "0", + "asterix.019_551_TP1B": "0", + "asterix.019_551_TP2A": "1", + "asterix.019_551_TP2B": "0", + "asterix.019_551_TP3A": "0", + "asterix.019_551_TP3B": "0", + "asterix.019_551_TP4A": "0", + "asterix.019_551_TP4B": "0" + } + ) + validator.add_dissection( + [0x08, 0x10], + "asterix.019_551", + { + "asterix.019_551_TP1A": "0", + "asterix.019_551_TP1B": "0", + "asterix.019_551_TP2A": "0", + "asterix.019_551_TP2B": "1", + "asterix.019_551_TP3A": "0", + "asterix.019_551_TP3B": "0", + "asterix.019_551_TP4A": "0", + "asterix.019_551_TP4B": "0" + } + ) + validator.add_dissection( + [0x08, 0x08], + "asterix.019_551", + { + "asterix.019_551_TP1A": "0", + "asterix.019_551_TP1B": "0", + "asterix.019_551_TP2A": "0", + "asterix.019_551_TP2B": "0", + "asterix.019_551_TP3A": "1", + "asterix.019_551_TP3B": "0", + "asterix.019_551_TP4A": "0", + "asterix.019_551_TP4B": "0" + } + ) + validator.add_dissection( + [0x08, 0x04], + "asterix.019_551", + { + "asterix.019_551_TP1A": "0", + "asterix.019_551_TP1B": "0", + "asterix.019_551_TP2A": "0", + "asterix.019_551_TP2B": "0", + "asterix.019_551_TP3A": "0", + "asterix.019_551_TP3B": "1", + "asterix.019_551_TP4A": "0", + "asterix.019_551_TP4B": "0" + } + ) + validator.add_dissection( + [0x08, 0x02], + "asterix.019_551", + { + "asterix.019_551_TP1A": "0", + "asterix.019_551_TP1B": "0", + "asterix.019_551_TP2A": "0", + "asterix.019_551_TP2B": "0", + "asterix.019_551_TP3A": "0", + "asterix.019_551_TP3B": "0", + "asterix.019_551_TP4A": "1", + "asterix.019_551_TP4B": "0" + } + ) + validator.add_dissection( + [0x08, 0x01], + "asterix.019_551", + { + "asterix.019_551_TP1A": "0", + "asterix.019_551_TP1B": "0", + "asterix.019_551_TP2A": "0", + "asterix.019_551_TP2B": "0", + "asterix.019_551_TP3A": "0", + "asterix.019_551_TP3B": "0", + "asterix.019_551_TP4A": "0", + "asterix.019_551_TP4B": "1" + } + ) + validator.add_dissection( + [0x04, 0x00], + "asterix.019_552", + { + "asterix.counter": "0" + } + ) + validator.add_dissection( + [0x04, 0x01, 0xff, 0x00], + "asterix.019_552", + { + "asterix.counter": "1", + "asterix.019_552": + { + "asterix.019_552_RSI": "0xff", + "asterix.019_552_RS1090": "0", + "asterix.019_552_TX1030": "0", + "asterix.019_552_TX1090": "0", + "asterix.019_552_RSS": "0", + "asterix.019_552_RSO": "0" + } + } + ) + validator.add_dissection( + [0x04, 0x01, 0x00, 0x40], + "asterix.019_552", + { + "asterix.counter": "1", + "asterix.019_552": + { + "asterix.019_552_RSI": "0x00", + "asterix.019_552_RS1090": "1", + "asterix.019_552_TX1030": "0", + "asterix.019_552_TX1090": "0", + "asterix.019_552_RSS": "0", + "asterix.019_552_RSO": "0" + } + } + ) + validator.add_dissection( + [0x04, 0x01, 0x00, 0x20], + "asterix.019_552", + { + "asterix.counter": "1", + "asterix.019_552": + { + "asterix.019_552_RSI": "0x00", + "asterix.019_552_RS1090": "0", + "asterix.019_552_TX1030": "1", + "asterix.019_552_TX1090": "0", + "asterix.019_552_RSS": "0", + "asterix.019_552_RSO": "0" + } + } + ) + validator.add_dissection( + [0x04, 0x01, 0x00, 0x10], + "asterix.019_552", + { + "asterix.counter": "1", + "asterix.019_552": + { + "asterix.019_552_RSI": "0x00", + "asterix.019_552_RS1090": "0", + "asterix.019_552_TX1030": "0", + "asterix.019_552_TX1090": "1", + "asterix.019_552_RSS": "0", + "asterix.019_552_RSO": "0" + } + } + ) + validator.add_dissection( + [0x04, 0x01, 0x00, 0x08], + "asterix.019_552", + { + "asterix.counter": "1", + "asterix.019_552": + { + "asterix.019_552_RSI": "0x00", + "asterix.019_552_RS1090": "0", + "asterix.019_552_TX1030": "0", + "asterix.019_552_TX1090": "0", + "asterix.019_552_RSS": "1", + "asterix.019_552_RSO": "0" + } + } + ) + validator.add_dissection( + [0x04, 0x01, 0x00, 0x04], + "asterix.019_552", + { + "asterix.counter": "1", + "asterix.019_552": + { + "asterix.019_552_RSI": "0x00", + "asterix.019_552_RS1090": "0", + "asterix.019_552_TX1030": "0", + "asterix.019_552_TX1090": "0", + "asterix.019_552_RSS": "0", + "asterix.019_552_RSO": "1" + } + } + ) + validator.add_dissection( + [0x04, 0x03, 0x12, 0x34, 0x56, 0x78, 0x9a, 0x0c], + "asterix.019_552", + { + "asterix.counter": "3", + "asterix.019_552": + { + "asterix.019_552_RSI": "18", + "asterix.019_552_RS1090": "0", + "asterix.019_552_TX1030": "1", + "asterix.019_552_TX1090": "1", + "asterix.019_552_RSS": "0", + "asterix.019_552_RSO": "1" + }, + "asterix.019_552": + { + "asterix.019_552_RSI": "86", + "asterix.019_552_RS1090": "1", + "asterix.019_552_TX1030": "1", + "asterix.019_552_TX1090": "1", + "asterix.019_552_RSS": "1", + "asterix.019_552_RSO": "0" + }, + "asterix.019_552": + { + "asterix.019_552_RSI": "0x9a", + "asterix.019_552_RS1090": "0", + "asterix.019_552_TX1030": "0", + "asterix.019_552_TX1090": "0", + "asterix.019_552_RSS": "1", + "asterix.019_552_RSO": "1" + } + } + ) + validator.add_dissection( + [0x02, 0xc0], + "asterix.019_553", + { + "asterix.019_553_REFTR1": "3", + "asterix.019_553_REFTR2": "0", + "asterix.FX": "0" + } + ) + validator.add_dissection( + [0x02, 0x0c], + "asterix.019_553", + { + "asterix.019_553_REFTR1": "0", + "asterix.019_553_REFTR2": "3", + "asterix.FX": "0" + } + ) + '''TODO: check this testcase, it has too many subitems + validator.add_dissection( + [0x02, 0x01, 0x01, 0x0c], + "asterix.019_553", + { + "asterix.019_553_Ref_Trans_1_Status": "0", + "asterix.019_553_Ref_Trans_2_Status": "0", + "asterix.019_553_Ref_Trans_3_Status": "0", + "asterix.019_553_Ref_Trans_4_Status": "0", + "asterix.019_553_Ref_Trans_5_Status": "0", + "asterix.019_553_Ref_Trans_6_Status": "3", + "asterix.FX": "0" + } + ) + ''' + validator.add_dissection( + [0x01, 0x80, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], + "asterix.019_600", + { + "asterix.019_600_LAT": "90", + "asterix.019_600_LON": "0" + } + ) + validator.add_dissection( + [0x01, 0x80, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], + "asterix.019_600", + { + "asterix.019_600_LAT": "-90", + "asterix.019_600_LON": "0" + } + ) + validator.add_dissection( + [0x01, 0x80, 0x00, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00], + "asterix.019_600", + { + "asterix.019_600_LAT": "0", + "asterix.019_600_LON": "180" + } + ) + validator.add_dissection( + [0x01, 0x80, 0x00, 0x00, 0x00, 0x00, 0xc0, 0x00, 0x00, 0x00], + "asterix.019_600", + { + "asterix.019_600_LAT": "0", + "asterix.019_600_LON": "-180" + } + ) + validator.add_dissection( + [0x01, 0x40, 0x7f, 0xff], + "asterix.019_610", + { + "asterix.019_610_VALUE": "8191.75" + } + ) + validator.add_dissection( + [0x01, 0x40, 0x80, 0x00], + "asterix.019_610", + { + "asterix.019_610_VALUE": "-8192" + } + ) + validator.add_dissection( + [0x01, 0x20, 0x7f], + "asterix.019_620", + { + "asterix.019_620_VALUE": "127" + } + ) + validator.add_dissection( + [0x01, 0x20, 0x81], + "asterix.019_620", + { + "asterix.019_620_VALUE": "-127" + } + ) + + validator.check_dissections() + + def test_undefined_value_handling(self, asterix_validator): + '''verifies that the dissector can dissect undefined field values by setting + the maximum value of bits or by setting all undefined bits''' + + validator = asterix_validator(19) + + validator.add_dissection( + [0x40, 0xff], + "asterix.019_000", + { + "asterix.019_000_VALUE": "255" + } + ) + validator.add_dissection( + [0x20, 0xff, 0xff, 0xff], + "asterix.019_140", + { + "asterix.019_140_VALUE": "131071.9921875" + } + ) + validator.add_dissection( + [0x10, 0x07], + "asterix.019_550", + { + "asterix.019_550_NOGO": "0", + "asterix.019_550_OVL": "0", + "asterix.019_550_TSV": "0", + "asterix.019_550_TTF": "0" + } + ) + validator.add_dissection( + [0x04, 0x01, 0x00, 0x83], + "asterix.019_552", + { + "asterix.counter": "1", + "asterix.019_552": + { + "asterix.019_552_RSI": "0x00", + "asterix.019_552_RS1090": "0", + "asterix.019_552_TX1030": "0", + "asterix.019_552_TX1090": "0", + "asterix.019_552_RSS": "0", + "asterix.019_552_RSO": "0" + } + } + ) + validator.add_dissection( + [0x02, 0x32], + "asterix.019_553", + { + "asterix.019_553_REFTR1": "0", + "asterix.019_553_REFTR2": "0", + "asterix.FX": "0" + } + ) + '''TODO: check this testcase, it has too many subitems + validator.add_dissection( + [0x02, 0x33, 0x33, 0x32], + "asterix.019_553", + { + "asterix.019_553_REFTR1": "0", + "asterix.019_553_REFTR2": "0", + "asterix.019_553_REFTR3": "0", + "asterix.019_553_REFTR4": "0", + "asterix.019_553_Ref_Trans_5_Status": "0", + "asterix.019_553_Ref_Trans_6_Status": "0", + "asterix.FX": "0" + } + ) + ''' + validator.add_dissection( + [0x01, 0x80, 0x7f, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00], + "asterix.019_600", + { + "asterix.019_600_LAT": "359.999999832362", + "asterix.019_600_LON": "0" + } + ) + validator.add_dissection( + [0x01, 0x80, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], + "asterix.019_600", + { + "asterix.019_600_LAT": "-360", + "asterix.019_600_LON": "0" + } + ) + validator.add_dissection( + [0x01, 0x80, 0x00, 0x00, 0x00, 0x00, 0x7f, 0xff, 0xff, 0xff], + "asterix.019_600", + { + "asterix.019_600_LAT": "0", + "asterix.019_600_LON": "359.999999832362" + } + ) + validator.add_dissection( + [0x01, 0x80, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00], + "asterix.019_600", + { + "asterix.019_600_LAT": "0", + "asterix.019_600_LON": "-360" + } + ) + validator.add_dissection( + [0x01, 0x20, 0x80], + "asterix.019_620", + { + "asterix.019_620_VALUE": "-128" + } + ) + validator.add_dissection( + [0x01, 0x10], + "asterix.spare", + "" + ) + validator.add_dissection( + [0x01, 0x08], + "asterix.spare", + "" + ) + '''TODO: re-enable RE and SP tests when implemented + validator.add_dissection( + [0x01, 0x04, 0x02, 0x00], + "asterix.019_RE", + { + "asterix.re_field_len": "2", + "asterix.fspec": "" + } + ) + validator.add_dissection( + [0x01, 0x04, 0x10, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, + 0x99, 0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff], + "asterix.019_RE", + { + "asterix.fspec": "", + "asterix.re_field_len": "16" + } + ) + validator.add_dissection( + [0x01, 0x02, 0x01], + "asterix.019_SP", + "" + ) + validator.add_dissection( + [0x01, 0x02, 0x10, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, + 0x99, 0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff], + "asterix.019_SP", + "" + ) + ''' + + validator.check_dissections() + + +class TestCategory034: + ''' + Unittest case for ASTERIX Category 034 + + Online specification: + https://www.eurocontrol.int/publications/cat034-monoradar-service-messages-part-2b-next-version-cat-002 + + Part 2b + Transmission of Monoradar Service Messages + + Standard User Application Profile + + FRN Data Item Information Length + 1 I034/010 Data Source Identifier 2 + 2 I034/000 Message Type 1 + 3 I034/030 Time-of-Day 3 + 4 I034/020 Sector Number 1 + 5 I034/041 Antenna Rotation Period 2 + 6 I034/050 System Configuration and Status 1+ + 7 I034/060 System Processing Mode 1+ + FX N/A. Field Extension Indicator N/A. + 8 I034/070 Message Count Values (1+2*N) + 9 I034/100 Generic Polar Window 8 + 10 I034/110 Data Filter 1 + 11 I034/120 3D-Position of Data Source 8 + 12 I034/090 Collimation Error 2 + 13 RE-Data Item Reserved Expansion Field 1+1+ + 14 SP-Data Item Special Purpose Field 1+1+ + FX N/A. Field Extension Indicator n.a. + ''' + + def test_for_fields(self, asterix_validator): + '''verifies existence of all fields and their maximum value''' + + validator = asterix_validator(34) + + validator.add_dissection( + [0x80, 0xff, 0x00], + "asterix.034_010", + { + "asterix.034_010_SAC": "0xff", + "asterix.034_010_SIC": "0x00" + } + ) + validator.add_dissection( + [0x80, 0x00, 0xff], + "asterix.034_010", + { + "asterix.034_010_SAC": "0x00", + "asterix.034_010_SIC": "0xff" + } + ) + validator.add_dissection( + [0x40, 0x04], + "asterix.034_000", + { + "asterix.034_000_VALUE": "4" + } + ) + validator.add_dissection( + [0x20, 0xa8, 0xbf, 0xff], + "asterix.034_030", + { + "asterix.034_030_VALUE": "86399.9921875" + } + ) + validator.add_dissection( + [0x10, 0xff], + "asterix.034_020", + { + "asterix.034_020_VALUE": "358.59375" + } + ) + validator.add_dissection( + [0x08, 0xff, 0xff], + "asterix.034_041", + { + "asterix.034_041_VALUE": "511.9921875" + } + ) + x_050_COM = { + "asterix.034_050_COM_NOGO": "0", + "asterix.034_050_COM_RDPC": "0", + "asterix.034_050_COM_RDPR": "0", + "asterix.034_050_COM_OVLRDP": "0", + "asterix.034_050_COM_OVLXMT": "0", + "asterix.034_050_COM_MSC": "0", + "asterix.034_050_COM_TSV": "0" + } + validator.add_dissection( + [0x04, 0x80, 0x80], + "asterix.034_050", + dict_fspec_local(x_050_COM, "034_050_COM", "NOGO", "1") + ) + validator.add_dissection( + [0x04, 0x80, 0x40], + "asterix.034_050", + dict_fspec_local(x_050_COM, "034_050_COM", "RDPC", "1") + ) + validator.add_dissection( + [0x04, 0x80, 0x20], + "asterix.034_050", + dict_fspec_local(x_050_COM, "034_050_COM", "RDPR", "1") + ) + validator.add_dissection( + [0x04, 0x80, 0x10], + "asterix.034_050", + dict_fspec_local(x_050_COM, "034_050_COM", "OVLRDP", "1") + ) + validator.add_dissection( + [0x04, 0x80, 0x08], + "asterix.034_050", + dict_fspec_local(x_050_COM, "034_050_COM", "OVLXMT", "1") + ) + validator.add_dissection( + [0x04, 0x80, 0x04], + "asterix.034_050", + dict_fspec_local(x_050_COM, "034_050_COM", "MSC", "1") + ) + validator.add_dissection( + [0x04, 0x80, 0x02], + "asterix.034_050", + dict_fspec_local(x_050_COM, "034_050_COM", "TSV", "1") + ) + x_050_PSR = { + "asterix.034_050_PSR_ANT": "0", + "asterix.034_050_PSR_CHAB": "0", + "asterix.034_050_PSR_OVL": "0", + "asterix.034_050_PSR_MSC": "0" + } + validator.add_dissection( + [0x04, 0x10, 0x80], + "asterix.034_050", + dict_fspec_local(x_050_PSR, "034_050_PSR", "ANT", "1") + ) + validator.add_dissection( + [0x04, 0x10, 0x60], + "asterix.034_050", + dict_fspec_local(x_050_PSR, "034_050_PSR", "CHAB", "3") + ) + validator.add_dissection( + [0x04, 0x10, 0x10], + "asterix.034_050", + dict_fspec_local(x_050_PSR, "034_050_PSR", "OVL", "1") + ) + validator.add_dissection( + [0x04, 0x10, 0x08], + "asterix.034_050", + dict_fspec_local(x_050_PSR, "034_050_PSR", "MSC", "1") + ) + x_050_SSR = { + "asterix.034_050_SSR_ANT": "0", + "asterix.034_050_SSR_CHAB": "0", + "asterix.034_050_SSR_OVL": "0", + "asterix.034_050_SSR_MSC": "0" + } + validator.add_dissection( + [0x04, 0x08, 0x80], + "asterix.034_050", + dict_fspec_local(x_050_SSR, "034_050_SSR", "ANT", "1") + ) + validator.add_dissection( + [0x04, 0x08, 0x60], + "asterix.034_050", + dict_fspec_local(x_050_SSR, "034_050_SSR", "CHAB", "3") + ) + validator.add_dissection( + [0x04, 0x08, 0x10], + "asterix.034_050", + dict_fspec_local(x_050_SSR, "034_050_SSR", "OVL", "1") + ) + validator.add_dissection( + [0x04, 0x08, 0x08], + "asterix.034_050", + dict_fspec_local(x_050_SSR, "034_050_SSR", "MSC", "1") + ) + x_050_MDS = { + "asterix.034_050_MDS_ANT": "0", + "asterix.034_050_MDS_CHAB": "0", + "asterix.034_050_MDS_OVLSUR": "0", + "asterix.034_050_MDS_MSC": "0", + "asterix.034_050_MDS_SCF": "0", + "asterix.034_050_MDS_DLF": "0", + "asterix.034_050_MDS_OVLSCF": "0", + "asterix.034_050_MDS_OVLDLF": "0" + } + validator.add_dissection( + [0x04, 0x04, 0x80, 0x00], + "asterix.034_050", + dict_fspec_local(x_050_MDS, "034_050_MDS", "ANT", "1") + ) + validator.add_dissection( + [0x04, 0x04, 0x60, 0x00], + "asterix.034_050", + dict_fspec_local(x_050_MDS, "034_050_MDS", "CHAB", "3") + ) + validator.add_dissection( + [0x04, 0x04, 0x10, 0x00], + "asterix.034_050", + dict_fspec_local(x_050_MDS, "034_050_MDS", "OVLSUR", "1") + ) + validator.add_dissection( + [0x04, 0x04, 0x08, 0x00], + "asterix.034_050", + dict_fspec_local(x_050_MDS, "034_050_MDS", "MSC", "1") + ) + validator.add_dissection( + [0x04, 0x04, 0x04, 0x00], + "asterix.034_050", + dict_fspec_local(x_050_MDS, "034_050_MDS", "SCF", "1") + ) + validator.add_dissection( + [0x04, 0x04, 0x02, 0x00], + "asterix.034_050", + dict_fspec_local(x_050_MDS, "034_050_MDS", "DLF", "1") + ) + validator.add_dissection( + [0x04, 0x04, 0x01, 0x00], + "asterix.034_050", + dict_fspec_local(x_050_MDS, "034_050_MDS", "OVLSCF", "1") + ) + validator.add_dissection( + [0x04, 0x04, 0x00, 0x80], + "asterix.034_050", + dict_fspec_local(x_050_MDS, "034_050_MDS", "OVLDLF", "1") + ) + x_060_COM = { + "asterix.034_060_COM_REDRDP": "0", + "asterix.034_060_COM_REDXMT": "0" + } + validator.add_dissection( + [0x02, 0x80, 0x70], + "asterix.034_060", + dict_fspec_local(x_060_COM, "034_060_COM", "REDRDP", "7") + ) + validator.add_dissection( + [0x02, 0x80, 0x0e], + "asterix.034_060", + dict_fspec_local(x_060_COM, "034_060_COM", "REDXMT", "7") + ) + x_060_PSR = { + "asterix.034_060_PSR_POL": "0", + "asterix.034_060_PSR_REDRAD": "0", + "asterix.034_060_PSR_STC": "0" + } + validator.add_dissection( + [0x02, 0x10, 0x80], + "asterix.034_060", + dict_fspec_local(x_060_PSR, "034_060_PSR", "POL", "1") + ) + validator.add_dissection( + [0x02, 0x10, 0x70], + "asterix.034_060", + dict_fspec_local(x_060_PSR, "034_060_PSR", "REDRAD", "7") + ) + validator.add_dissection( + [0x02, 0x10, 0x0c], + "asterix.034_060", + dict_fspec_local(x_060_PSR, "034_060_PSR", "STC", "3") + ) + validator.add_dissection( + [0x02, 0x08, 0xe0], + "asterix.034_060", + fspec_local("034_060_SSR", "REDRAD", "7") + ) + x_060_06 = { + "asterix.034_060_MDS_REDRAD": "0", + "asterix.034_060_MDS_CLU": "0" + } + validator.add_dissection( + [0x02, 0x04, 0xe0], + "asterix.034_060", + dict_fspec_local(x_060_06, "034_060_MDS", "REDRAD", "7") + ) + validator.add_dissection( + [0x02, 0x04, 0x10], + "asterix.034_060", + dict_fspec_local(x_060_06, "034_060_MDS", "CLU", "1") + ) + x_070 = { + "asterix.034_070_TYP": "0", + "asterix.034_070_COUNT": "0" + } + validator.add_dissection( + [0x01, 0x80, 0x01, 0x80, 0x00], + "asterix.034_070", + { + "asterix.counter": "1", + "asterix.034_070": + dict_local(x_070, "034_070", "TYP", "16") + } + ) + validator.add_dissection( + [0x01, 0x80, 0x03, 0x80, 0x00, 0x87, 0xff, 0x07, 0xff], + "asterix.034_070", + { + "asterix.counter": "3", + "asterix.034_070": + dict_local(x_070, "034_070", "TYPE", "16"), + "asterix.034_070": + { + "asterix.034_070_TYP": "16", + "asterix.034_070_COUNT": "2047" + }, + "asterix.034_070": + dict_local(x_070, "034_070", "COUNT", "2047"), + } + ) + x_100 = { + "asterix.034_100_RHOST": "0", + "asterix.034_100_RHOEND": "0", + "asterix.034_100_THETAST": "0", + "asterix.034_100_THETAEND": "0" + } + validator.add_dissection( + [0x01, 0x40, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], + "asterix.034_100", + dict_local(x_100, "034_100", "RHOST", "255.99609375") + ) + validator.add_dissection( + [0x01, 0x40, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00], + "asterix.034_100", + dict_local(x_100, "034_100", "RHOEND", "255.99609375") + ) + validator.add_dissection( + [0x01, 0x40, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00], + "asterix.034_100", + dict_local(x_100, "034_100", "THETAST", "359.994506835938") + ) + validator.add_dissection( + [0x01, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff], + "asterix.034_100", + dict_local(x_100, "034_100", "THETAEND", "359.994506835938") + ) + validator.add_dissection( + [0x01, 0x20, 0x09], + "asterix.034_110", + { + "asterix.034_110_VALUE": "9" + } + ) + x_120 = { + "asterix.034_120_HGT": "0", + "asterix.034_120_LAT": "0", + "asterix.034_120_LON": "0" + } + validator.add_dissection( + [0x01, 0x10, 0x7f, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], + "asterix.034_120", + dict_local(x_120, "034_120", "HGT", "32767") + ) + validator.add_dissection( + [0x01, 0x10, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], + "asterix.034_120", + dict_local(x_120, "034_120", "HGT", "32768") + ) + validator.add_dissection( + [0x01, 0x10, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00], + "asterix.034_120", + dict_local(x_120, "034_120", "LAT", "90") + ) + validator.add_dissection( + [0x01, 0x10, 0x00, 0x00, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00], + "asterix.034_120", + dict_local(x_120, "034_120", "LAT", "-90") + ) + validator.add_dissection( + [0x01, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7f, 0xff, 0xff], + "asterix.034_120", + dict_local(x_120, "034_120", "LON", "179.999978542328") + ) + validator.add_dissection( + [0x01, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00], + "asterix.034_120", + dict_local(x_120, "034_120", "LON", "-180") + ) + '''TODO: re-enable RE and SP tests when implemented + x_090 = { + "asterix.034_090_RE": "0", + "asterix.034_090_AE": "0" + } + validator.add_dissection( + [0x01, 0x08, 0x7f, 0x00], + "asterix.034_090", + dict_local(x_090, "034_090", "RE", "0.9921875") + ) + validator.add_dissection( + [0x01, 0x08, 0x80, 0x00], + "asterix.034_090", + dict_local(x_090, "034_090", "RE", "-1") + ) + validator.add_dissection( + [0x01, 0x08, 0x00, 0x80], + "asterix.034_090", + dict_local(x_090, "034_090", "AE", "-2.8125") + ) + ''' + + validator.check_dissections() + + def test_undefined_value_handling(self, asterix_validator): + '''verifies that the dissector can dissect undefined field values by setting + the maximum value of bits or by setting all undefined bits''' + + validator = asterix_validator(34) + + validator.add_dissection( + [0x40, 0xff], + "asterix.034_000", + { + "asterix.034_000_VALUE": "255" + } + ) + validator.add_dissection( + [0x20, 0xff, 0xff, 0xff], + "asterix.034_030", + { + "asterix.034_030_VALUE": "131071.9921875" + } + ) + validator.add_dissection( + [0x04, 0x63, 0x00], + "asterix.034_050", + { + "asterix.fspec": "", + "asterix.spare": "" + } + ) + validator.add_dissection( + [0x04, 0x80, 0x01], + "asterix.034_050", + { + "asterix.fspec": "", + "asterix.034_050_COM": + { + "asterix.034_050_COM_NOGO": "0", + "asterix.034_050_COM_RDPC": "0", + "asterix.034_050_COM_RDPR": "0", + "asterix.034_050_COM_OVLRDP": "0", + "asterix.034_050_COM_OVLXMT": "0", + "asterix.034_050_COM_MSC": "0", + "asterix.034_050_COM_TSV": "0" + } + } + ) + validator.add_dissection( + [0x04, 0x10, 0x07], + "asterix.034_050", + { + "asterix.fspec": "", + "asterix.034_050_PSR": + { + "asterix.034_050_PSR_ANT": "0", + "asterix.034_050_PSR_CHAB": "0", + "asterix.034_050_PSR_OVL": "0", + "asterix.034_050_PSR_MSC": "0" + } + } + ) + validator.add_dissection( + [0x04, 0x08, 0x07], + "asterix.034_050", + { + "asterix.fspec": "", + "asterix.034_050_SSR": + { + "asterix.034_050_SSR_ANT": "0", + "asterix.034_050_SSR_CHAB": "0", + "asterix.034_050_SSR_OVL": "0", + "asterix.034_050_SSR_MSC": "0" + } + } + ) + validator.add_dissection( + [0x04, 0x04, 0x00, 0x7f], + "asterix.034_050", + { + "asterix.fspec": "", + "asterix.034_050_MDS": + { + "asterix.034_050_MDS_ANT": "0", + "asterix.034_050_MDS_CHAB": "0", + "asterix.034_050_MDS_OVLSUR": "0", + "asterix.034_050_MDS_MSC": "0", + "asterix.034_050_MDS_SCF": "0", + "asterix.034_050_MDS_DLF": "0", + "asterix.034_050_MDS_OVLSCF": "0", + "asterix.034_050_MDS_OVLDLF": "0" + } + } + ) + validator.add_dissection( + [0x02, 0x63, 0x00], + "asterix.034_060", + { + "asterix.fspec": "", + "asterix.spare": "" + } + ) + validator.add_dissection( + [0x02, 0x80, 0x81], + "asterix.034_060", + { + "asterix.fspec": "", + "asterix.034_060_COM": + { + "asterix.034_060_COM_REDRDP": "0", + "asterix.034_060_COM_REDXMT": "0" + } + } + ) + validator.add_dissection( + [0x02, 0x10, 0x03], + "asterix.034_060", + { + "asterix.fspec": "", + "asterix.034_060_PSR": + { + "asterix.034_060_PSR_POL": "0", + "asterix.034_060_PSR_REDRAD": "0", + "asterix.034_060_PSR_STC": "0" + } + } + ) + validator.add_dissection( + [0x02, 0x08, 0x1f], + "asterix.034_060", + fspec_local("034_060_SSR", "REDRAD", "0") + ) + validator.add_dissection( + [0x02, 0x04, 0x0f], + "asterix.034_060", + { + "asterix.fspec": "", + "asterix.034_060_MDS": + { + "asterix.034_060_MDS_REDRAD": "0", + "asterix.034_060_MDS_CLU": "0" + } + } + ) + x_070 = { + "asterix.034_070_TYP": "0", + "asterix.034_070_COUNT": "0" + } + validator.add_dissection( + [0x01, 0x80, 0x01, 0xf8, 0x00], + "asterix.034_070", + { + "asterix.counter": "1", + "asterix.034_070": + dict_local(x_070, "034_070", "TYP", "31") + } + ) + validator.add_dissection( + [0x01, 0x20, 0xff], + "asterix.034_110", + { + "asterix.034_110_VALUE": "255" + } + ) + '''TODO: re-enable RE and SP tests when implemented + validator.add_dissection( + [0x01, 0x04, 0x02, 0xfe], + "asterix.034_RE", + { + "asterix.re_field_len": "2", + "asterix.fspec": "" + } + ) + validator.add_dissection( + [0x01, 0x02, 0x01], + "asterix.034_SP", + "" + ) + validator.add_dissection( + [0x01, 0x02, 0x11, 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, + 0x88, 0x99, 0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff], + "asterix.034_SP", + "" + ) + ''' + + validator.check_dissections() + + +class TestCategory048: + ''' + Unittest case for ASTERIX Category 048 + + Online specification: + https://www.eurocontrol.int/publications/cat048-monoradar-target-reports-part-4-next-version-cat-001 + https://www.eurocontrol.int/publications/cat048-reserved-expansion-field-part-4-appendix + + Part 4 Category 048 + Monoradar Target Reports + + Standard User Application Profile + + FRN Data Item Information Length + 1 I048/010 Data Source Identifier 2 + 2 I048/140 Time-of-Day 3 + 3 I048/020 Target Report Descriptor 1+ + 4 I048/040 Measured Position in Slant Polar Coordinates 4 + 5 I048/070 Mode-3/A Code in Octal Representation 2 + 6 I048/090 Flight Level in Binary Representation 2 + 7 I048/130 Radar Plot Characteristics 1+1+ + FX n.a. Field Extension Indicator n.a. + 8 I048/220 Aircraft Address 3 + 9 I048/240 Aircraft Identification 6 + 10 I048/250 Mode S MB Data 1+8*n + 11 I048/161 Track Number 2 + 12 I048/042 Calculated Position in Cartesian Coordinates 4 + 13 I048/200 Calculated Track Velocity in Polar Representation 4 + 14 I048/170 Track Status 1+ + FX n.a. Field Extension Indicator n.a. + 15 I048/210 Track Quality 4 + 16 I048/030 Warning/Error Conditions 1+ + 17 I048/080 Mode-3/A Code Confidence Indicator 2 + 18 I048/100 Mode-C Code and Confidence Indicator 4 + 19 I048/110 Height Measured by 3D Radar 2 + 20 I048/120 Radial Doppler Speed 1+ + 21 I048/230 Communications / ACAS Capability and Flight Status 2 + FX n.a. Field Extension Indicator n.a. + 22 I048/260 ACAS Resolution Advisory Report 7 + 23 I048/055 Mode-1 Code in Octal Representation 1 + 24 I048/050 Mode-2 Code in Octal Representation 2 + 25 I048/065 Mode-1 Code Confidence Indicator 1 + 26 I048/060 Mode-2 Code Confidence Indicator 2 + 27 SP-Data Item Special Purpose Field 1+1+ + 28 RE-Data Item Reserved Expansion Field 1+1+ + FX n.a. Field Extension Indicator n.a. + ''' + + def test_for_fields(self, asterix_re_validator): + '''verifies existence of all fields and their maximum value''' + + validator = asterix_re_validator(48, [0x01, 0x01, 0x01, 0x02]) + + validator.add_dissection( + [0x80, 0xff, 0x00], + "asterix.048_010", + { + "asterix.048_010_SAC": "0xff", + "asterix.048_010_SIC": "0x00" + } + ) + validator.add_dissection( + [0x80, 0x00, 0xff], + "asterix.048_010", + { + "asterix.048_010_SAC": "0x00", + "asterix.048_010_SIC": "0xff" + } + ) + validator.add_dissection( + [0x40, 0xa8, 0xbf, 0xff], + "asterix.048_140", + { + "asterix.048_140_VALUE": "86399.9921875" + } + ) + x_020 = { + "asterix.048_020_TYP": "0", + "asterix.048_020_SIM": "0", + "asterix.048_020_RDP": "0", + "asterix.048_020_SPI": "0", + "asterix.048_020_RAB": "0", + "asterix.FX": "0" + } + validator.add_dissection( + [0x20, 0xe0], + "asterix.048_020", + dict_local(x_020, "048_020", "TYP", "7") + ) + validator.add_dissection( + [0x20, 0x08], + "asterix.048_020", + dict_local(x_020, "048_020", "RDP", "1") + ) + validator.add_dissection( + [0x20, 0x04], + "asterix.048_020", + dict_local(x_020, "048_020", "SPI", "1") + ) + validator.add_dissection( + [0x20, 0x02], + "asterix.048_020", + dict_local(x_020, "048_020", "RAB", "1") + ) + x_020.update({ + "asterix.048_020_TST": "0", + "asterix.048_020_ERR": "0", + "asterix.048_020_XPP": "0", + "asterix.048_020_ME": "0", + "asterix.048_020_MI": "0", + "asterix.048_020_FOEFRI": "0" + }) + validator.add_dissection( + [0x20, 0x01, 0x80], + "asterix.048_020", + dict_local(x_020, "048_020", "TST", "1") + ) + validator.add_dissection( + [0x20, 0x01, 0x40], + "asterix.048_020", + dict_local(x_020, "048_020", "ERR", "1") + ) + validator.add_dissection( + [0x20, 0x01, 0x20], + "asterix.048_020", + dict_local(x_020, "048_020", "XPP", "1") + ) + validator.add_dissection( + [0x20, 0x01, 0x10], + "asterix.048_020", + dict_local(x_020, "048_020", "ME", "1") + ) + validator.add_dissection( + [0x20, 0x01, 0x08], + "asterix.048_020", + dict_local(x_020, "048_020", "MI", "1") + ) + validator.add_dissection( + [0x20, 0x01, 0x06], + "asterix.048_020", + dict_local(x_020, "048_020", "FOEFRI", "3") + ) + x_040 = { + "asterix.048_040_RHO": "0", + "asterix.048_040_THETA": "0" + } + validator.add_dissection( + [0x10, 0xff, 0xff, 0x00, 0x00], + "asterix.048_040", + dict_local(x_040, "048_040", "RHO", "255.99609375") + ) + validator.add_dissection( + [0x10, 0x00, 0x00, 0xff, 0xff], + "asterix.048_040", + dict_local(x_040, "048_040", "THETA", "359.994506835938") + ) + x_070 = { + "asterix.048_070_V": "0", + "asterix.048_070_G": "0", + "asterix.048_070_L": "0", + "asterix.048_070_MODE3A": "0" + } + validator.add_dissection( + [0x08, 0x80, 0x00], + "asterix.048_070", + dict_local(x_070, "048_070", "V", "1") + ) + validator.add_dissection( + [0x08, 0x40, 0x00], + "asterix.048_070", + dict_local(x_070, "048_070", "G", "1") + ) + validator.add_dissection( + [0x08, 0x20, 0x00], + "asterix.048_070", + dict_local(x_070, "048_070", "L", "1") + ) + validator.add_dissection( + [0x08, 0x0e, 0x00], + "asterix.048_070", + dict_local(x_070, "048_070", "MODE3A", "3584") # 07000 + ) + validator.add_dissection( + [0x08, 0x01, 0xc0], + "asterix.048_070", + dict_local(x_070, "048_070", "MODE3A", "448") # 0700 + ) + validator.add_dissection( + [0x08, 0x00, 0x38], + "asterix.048_070", + dict_local(x_070, "048_070", "MODE3A", "56") # 070 + ) + validator.add_dissection( + [0x08, 0x00, 0x07], + "asterix.048_070", + dict_local(x_070, "048_070", "MODE3A", "7") # 07 + ) + x_090 = { + "asterix.048_090_V": "0", + "asterix.048_090_G": "0", + "asterix.048_090_FL": "0" + } + validator.add_dissection( + [0x04, 0x80, 0x00], + "asterix.048_090", + dict_local(x_090, "048_090", "V", "1") + ) + validator.add_dissection( + [0x04, 0x40, 0x00], + "asterix.048_090", + dict_local(x_090, "048_090", "G", "1") + ) + validator.add_dissection( + [0x04, 0x1f, 0xff], + "asterix.048_090", + dict_local(x_090, "048_090", "FL", "2047.75") + ) + validator.add_dissection( + [0x04, 0x20, 0x00], + "asterix.048_090", + dict_local(x_090, "048_090", "FL", "2048") + ) + validator.add_dissection( + [0x02, 0x80, 0xff], + "asterix.048_130", + fspec_local("048_130_SRL", "VALUE", "11.2060546875") + ) + validator.add_dissection( + [0x02, 0x40, 0xff], + "asterix.048_130", + fspec_local("048_130_SRR", "VALUE", "255") + ) + validator.add_dissection( + [0x02, 0x20, 0x7f], + "asterix.048_130", + fspec_local("048_130_SAM", "VALUE", "127") + ) + validator.add_dissection( + [0x02, 0x20, 0x80], + "asterix.048_130", + fspec_local("048_130_SAM", "VALUE", "-128") + ) + validator.add_dissection( + [0x02, 0x10, 0xff], + "asterix.048_130", + fspec_local("048_130_PRL", "VALUE", "11.2060546875") + ) + validator.add_dissection( + [0x02, 0x08, 0x7f], + "asterix.048_130", + fspec_local("048_130_PAM", "VALUE", "127") + ) + validator.add_dissection( + [0x02, 0x08, 0x80], + "asterix.048_130", + fspec_local("048_130_PAM", "VALUE", "-128") + ) + validator.add_dissection( + [0x02, 0x04, 0x7f], + "asterix.048_130", + fspec_local("048_130_RPD", "VALUE", "0.49609375") + ) + validator.add_dissection( + [0x02, 0x04, 0x80], + "asterix.048_130", + fspec_local("048_130_RPD", "VALUE", "-0.5") + ) + validator.add_dissection( + [0x02, 0x02, 0x7f], + "asterix.048_130", + fspec_local("048_130_APD", "VALUE", "2.79052734375") + ) + validator.add_dissection( + [0x02, 0x02, 0x80], + "asterix.048_130", + fspec_local("048_130_APD", "VALUE", "-2.8125") + ) + validator.add_dissection( + [0x01, 0x80, 0xff, 0xff, 0xff], + "asterix.048_220", + { + "asterix.048_220_VALUE": '0xffffff' + } + ) + validator.add_dissection( + [0x01, 0x80, 0xff, 0xff, 0xff], + "asterix.048_220", + { + "asterix.048_220_VALUE": '0xffffff' + } + ) + validator.add_dissection( + [0x01, 0x40, 0x04, 0x20, 0xda, 0x83, 0x0c, 0x79], + "asterix.048_240", + { + "asterix.048_240_VALUE": "ABCZ 019" + } + ) + x_250 = { + "asterix.048_250_MBDATA": "00:00:00:00:00:00:00", + "asterix.048_250_BDS1": "0", + "asterix.048_250_BDS2": "0" + } + validator.add_dissection( + [0x01, 0x20, + 0x01, + 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, + 0x00], + "asterix.048_250", + { + "asterix.counter": "1", + "asterix.048_250": + dict_global(x_250, "048_250_MBDATA", '0x0011223344556677'), + } + ) + '''TODO: result seems correct, check dict format + validator.add_dissection( + [0x01, 0x20, + 0x01, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0xf0], + "asterix.048_250", + { + "asterix.counter": "1", + "asterix.048_250": + dict_global(x_250, "048_250_BDS1", "15"), + } + ) + validator.add_dissection( + [0x01, 0x20, + 0x01, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x0f], + "asterix.048_250", + { + "asterix.counter": "1", + "asterix.048_250": + dict_global(x_250, "BDS2", "15"), + } + ) + validator.add_dissection( + [0x01, 0x20, + 0x03, + 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, + 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0xf0, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x0f], + "asterix.048_250", + { + "asterix.counter": "3", + "asterix.048_250": + dict_global(x_250, "048_250_MBDATA", '0x0011223344556677'), + "asterix.048_250": + dict_global(x_250, "048_250_BDS1", "15"), + "asterix.048_250": + dict_global(x_250, "048_250_BDS2", "15"), + } + ) + ''' + validator.add_dissection( + [0x01, 0x10, 0x0f, 0xff], + "asterix.048_161", + { + "asterix.048_161_TRN": "4095" + } + ) + x_042 = { + "asterix.048_042_X": "0", + "asterix.048_042_Y": "0" + } + validator.add_dissection( + [0x01, 0x08, 0x7f, 0xff, 0x00, 0x00], + "asterix.048_042", + dict_local(x_042, "048_042", "X", "255.9921875") + ) + validator.add_dissection( + [0x01, 0x08, 0x80, 0x00, 0x00, 0x00], + "asterix.048_042", + dict_local(x_042, "048_042", "X", "-256") + ) + validator.add_dissection( + [0x01, 0x08, 0x00, 0x0, 0x7f, 0xff], + "asterix.048_042", + dict_local(x_042, "048_042", "Y", "255.9921875") + ) + validator.add_dissection( + [0x01, 0x08, 0x00, 0x0, 0x80, 0x00], + "asterix.048_042", + dict_local(x_042, "048_042", "Y", "-256") + ) + x_200 = { + "asterix.048_200_GSP": "0", + "asterix.048_200_HDG": "0" + } + validator.add_dissection( + [0x01, 0x04, 0xff, 0xff, 0x00, 0x00], + "asterix.048_200", + dict_local(x_200, "048_200", "GSP", "3.99993896484375") + ) + validator.add_dissection( + [0x01, 0x04, 0x00, 0x00, 0xff, 0xff], + "asterix.048_200", + dict_local(x_200, "048_200", "HDG", "359.994506835938") + ) + x_170 = { + "asterix.048_170_CNF": "0", + "asterix.048_170_RAD": "0", + "asterix.048_170_DOU": "0", + "asterix.048_170_MAH": "0", + "asterix.048_170_CDM": "0", + "asterix.FX": "0" + } + validator.add_dissection( + [0x01, 0x02, 0x80], + "asterix.048_170", + dict_local(x_170, "048_170", "CNF", "1") + ) + validator.add_dissection( + [0x01, 0x02, 0x60], + "asterix.048_170", + dict_local(x_170, "048_170", "RAD", "3") + ) + validator.add_dissection( + [0x01, 0x02, 0x10], + "asterix.048_170", + dict_local(x_170, "048_170", "DOU", "1") + ) + validator.add_dissection( + [0x01, 0x02, 0x08], + "asterix.048_170", + dict_local(x_170, "048_170", "MAH", "1") + ) + validator.add_dissection( + [0x01, 0x02, 0x06], + "asterix.048_170", + dict_local(x_170, "048_170", "CDM", "3") + ) + x_170.update({ + "asterix.048_170_TRE": "0", + "asterix.048_170_GHO": "0", + "asterix.048_170_SUP": "0", + "asterix.048_170_TCC": "0" + }) + validator.add_dissection( + [0x01, 0x02, 0x01, 0x80], + "asterix.048_170", + dict_local(x_170, "048_170", "TRE", "1") + ) + validator.add_dissection( + [0x01, 0x02, 0x01, 0x40], + "asterix.048_170", + dict_local(x_170, "048_170", "GHO", "1") + ) + validator.add_dissection( + [0x01, 0x02, 0x01, 0x20], + "asterix.048_170", + dict_local(x_170, "048_170", "SUP", "1") + ) + validator.add_dissection( + [0x01, 0x02, 0x01, 0x10], + "asterix.048_170", + dict_local(x_170, "048_170", "TCC", "1") + ) + x_210 = { + "asterix.048_210_SIGX": "0", + "asterix.048_210_SIGY": "0", + "asterix.048_210_SIGV": "0", + "asterix.048_210_SIGH": "0" + } + validator.add_dissection( + [0x01, 0x01, 0x80, 0xff, 0x00, 0x00, 0x00], + "asterix.048_210", + dict_local(x_210, "048_210", "SIGX", "1.9921875") + ) + validator.add_dissection( + [0x01, 0x01, 0x80, 0x00, 0xff, 0x00, 0x00], + "asterix.048_210", + dict_local(x_210, "048_210", "SIGY", "1.9921875") + ) + validator.add_dissection( + [0x01, 0x01, 0x80, 0x00, 0x00, 0xff, 0x00], + "asterix.048_210", + dict_local(x_210, "048_210", "SIGV", "0.01556396484375") + ) + validator.add_dissection( + [0x01, 0x01, 0x80, 0x00, 0x00, 0x00, 0xff], + "asterix.048_210", + dict_local(x_210, "048_210", "SIGH", "22.412109375") + ) + validator.add_dissection( + [0x01, 0x01, 0x40, 0x2e], + "asterix.048_030", + { + "asterix.048_030_Subitem": "23", + "asterix.FX": "0" + } + ) + '''TODO: check this test, not according to the specs + validator.add_dissection( + [0x01, 0x01, 0x40, 0x2f, 0x03, 0x05, 0x06], + "asterix.048_030", + { + "asterix.048_030_WE": "23", + "asterix.048_030_1_WE": "1", + "asterix.048_030_2_WE": "2", + "asterix.048_030_3_WE": "3", + "asterix.FX": "0" + } + ) + ''' + x_080 = { + "asterix.048_080_QA4": "0", + "asterix.048_080_QA2": "0", + "asterix.048_080_QA1": "0", + "asterix.048_080_QB4": "0", + "asterix.048_080_QB2": "0", + "asterix.048_080_QB1": "0", + "asterix.048_080_QC4": "0", + "asterix.048_080_QC2": "0", + "asterix.048_080_QC1": "0", + "asterix.048_080_QD4": "0", + "asterix.048_080_QD2": "0", + "asterix.048_080_QD1": "0" + } + validator.add_dissection( + [0x01, 0x01, 0x20, 0x08, 0x00], + "asterix.048_080", + dict_local(x_080, "048_080", "QA4", "1") + ) + validator.add_dissection( + [0x01, 0x01, 0x20, 0x04, 0x00], + "asterix.048_080", + dict_local(x_080, "048_080", "QA2", "1") + ) + validator.add_dissection( + [0x01, 0x01, 0x20, 0x02, 0x00], + "asterix.048_080", + dict_local(x_080, "048_080", "QA1", "1") + ) + validator.add_dissection( + [0x01, 0x01, 0x20, 0x01, 0x00], + "asterix.048_080", + dict_local(x_080, "048_080", "QB4", "1") + ) + validator.add_dissection( + [0x01, 0x01, 0x20, 0x00, 0x80], + "asterix.048_080", + dict_local(x_080, "048_080", "QB2", "1") + ) + validator.add_dissection( + [0x01, 0x01, 0x20, 0x00, 0x40], + "asterix.048_080", + dict_local(x_080, "048_080", "QB1", "1") + ) + validator.add_dissection( + [0x01, 0x01, 0x20, 0x00, 0x20], + "asterix.048_080", + dict_local(x_080, "048_080", "QC4", "1") + ) + validator.add_dissection( + [0x01, 0x01, 0x20, 0x00, 0x10], + "asterix.048_080", + dict_local(x_080, "048_080", "QC2", "1") + ) + validator.add_dissection( + [0x01, 0x01, 0x20, 0x00, 0x08], + "asterix.048_080", + dict_local(x_080, "048_080", "QC1", "1") + ) + validator.add_dissection( + [0x01, 0x01, 0x20, 0x00, 0x04], + "asterix.048_080", + dict_local(x_080, "048_080", "QD4", "1") + ) + validator.add_dissection( + [0x01, 0x01, 0x20, 0x00, 0x02], + "asterix.048_080", + dict_local(x_080, "048_080", "QD2", "1") + ) + validator.add_dissection( + [0x01, 0x01, 0x20, 0x00, 0x01], + "asterix.048_080", + dict_local(x_080, "048_080", "QD1", "1") + ) + '''TODO: A,B,C,D values need to go to single subitem 'MODEC' + x_100 = { + "asterix.048_100_V": "0", + "asterix.048_100_G": "0", + "asterix.048_100_C1": "0", + "asterix.048_100_A1": "0", + "asterix.048_100_C2": "0", + "asterix.048_100_A2": "0", + "asterix.048_100_C4": "0", + "asterix.048_100_A4": "0", + "asterix.048_100_B1": "0", + "asterix.048_100_D1": "0", + "asterix.048_100_B2": "0", + "asterix.048_100_D2": "0", + "asterix.048_100_B4": "0", + "asterix.048_100_D4": "0", + "asterix.048_100_QC1": "0", + "asterix.048_100_QA1": "0", + "asterix.048_100_QC2": "0", + "asterix.048_100_QA2": "0", + "asterix.048_100_QC4": "0", + "asterix.048_100_QA4": "0", + "asterix.048_100_QB1": "0", + "asterix.048_100_QD1": "0", + "asterix.048_100_QB2": "0", + "asterix.048_100_QD2": "0", + "asterix.048_100_QB4": "0", + "asterix.048_100_QD4": "0" + } + validator.add_dissection( + [0x01, 0x01, 0x10, 0x80, 0x00, 0x00, 0x00], + "asterix.048_100", + dict_local(x_100, "048_100", "V", "1") + ) + validator.add_dissection( + [0x01, 0x01, 0x10, 0x40, 0x00, 0x00, 0x00], + "asterix.048_100", + dict_local(x_100, "048_100", "G", "1") + ) + validator.add_dissection( + [0x01, 0x01, 0x10, 0x08, 0x00, 0x00, 0x00], + "asterix.048_100", + dict_local(x_100, "048_100", "C1", "1") + ) + validator.add_dissection( + [0x01, 0x01, 0x10, 0x04, 0x00, 0x00, 0x00], + "asterix.048_100", + dict_local(x_100, "048_100", "A1", "1") + ) + validator.add_dissection( + [0x01, 0x01, 0x10, 0x02, 0x00, 0x00, 0x00], + "asterix.048_100", + dict_local(x_100, "048_100", "C2", "1") + ) + validator.add_dissection( + [0x01, 0x01, 0x10, 0x01, 0x00, 0x00, 0x00], + "asterix.048_100", + dict_local(x_100, "048_100", "A2", "1") + ) + validator.add_dissection( + [0x01, 0x01, 0x10, 0x00, 0x80, 0x00, 0x00], + "asterix.048_100", + dict_local(x_100, "048_100", "C4", "1") + ) + validator.add_dissection( + [0x01, 0x01, 0x10, 0x00, 0x40, 0x00, 0x00], + "asterix.048_100", + dict_local(x_100, "048_100", "A4", "1") + ) + validator.add_dissection( + [0x01, 0x01, 0x10, 0x00, 0x20, 0x00, 0x00], + "asterix.048_100", + dict_local(x_100, "048_100", "B1", "1") + ) + validator.add_dissection( + [0x01, 0x01, 0x10, 0x00, 0x10, 0x00, 0x00], + "asterix.048_100", + dict_local(x_100, "048_100", "D1", "1") + ) + validator.add_dissection( + [0x01, 0x01, 0x10, 0x00, 0x08, 0x00, 0x00], + "asterix.048_100", + dict_local(x_100, "048_100", "B2", "1") + ) + validator.add_dissection( + [0x01, 0x01, 0x10, 0x00, 0x04, 0x00, 0x00], + "asterix.048_100", + dict_local(x_100, "048_100", "D2", "1") + ) + validator.add_dissection( + [0x01, 0x01, 0x10, 0x00, 0x02, 0x00, 0x00], + "asterix.048_100", + dict_local(x_100, "048_100", "B4", "1") + ) + validator.add_dissection( + [0x01, 0x01, 0x10, 0x00, 0x01, 0x00, 0x00], + "asterix.048_100", + dict_local(x_100, "048_100", "D4", "1") + ) + validator.add_dissection( + [0x01, 0x01, 0x10, 0x00, 0x00, 0x08, 0x00], + "asterix.048_100", + dict_local(x_100, "048_100", "QC1", "1") + ) + validator.add_dissection( + [0x01, 0x01, 0x10, 0x00, 0x00, 0x04, 0x00], + "asterix.048_100", + dict_local(x_100, "048_100", "QA1", "1") + ) + validator.add_dissection( + [0x01, 0x01, 0x10, 0x00, 0x00, 0x02, 0x00], + "asterix.048_100", + dict_local(x_100, "048_100", "QC2", "1") + ) + validator.add_dissection( + [0x01, 0x01, 0x10, 0x00, 0x00, 0x01, 0x00], + "asterix.048_100", + dict_local(x_100, "048_100", "QA2", "1") + ) + validator.add_dissection( + [0x01, 0x01, 0x10, 0x00, 0x00, 0x00, 0x80], + "asterix.048_100", + dict_local(x_100, "048_100", "QC4", "1") + ) + validator.add_dissection( + [0x01, 0x01, 0x10, 0x00, 0x00, 0x00, 0x40], + "asterix.048_100", + dict_local(x_100, "048_100", "QA4", "1") + ) + validator.add_dissection( + [0x01, 0x01, 0x10, 0x00, 0x00, 0x00, 0x20], + "asterix.048_100", + dict_local(x_100, "048_100", "QB1", "1") + ) + validator.add_dissection( + [0x01, 0x01, 0x10, 0x00, 0x00, 0x00, 0x10], + "asterix.048_100", + dict_local(x_100, "048_100", "QD1", "1") + ) + validator.add_dissection( + [0x01, 0x01, 0x10, 0x00, 0x00, 0x00, 0x08], + "asterix.048_100", + dict_local(x_100, "048_100", "QB2", "1") + ) + validator.add_dissection( + [0x01, 0x01, 0x10, 0x00, 0x00, 0x00, 0x04], + "asterix.048_100", + dict_local(x_100, "048_100", "QD2", "1") + ) + validator.add_dissection( + [0x01, 0x01, 0x10, 0x00, 0x00, 0x00, 0x02], + "asterix.048_100", + dict_local(x_100, "048_100", "QB4", "1") + ) + validator.add_dissection( + [0x01, 0x01, 0x10, 0x00, 0x00, 0x00, 0x01], + "asterix.048_100", + dict_local(x_100, "048_100", "QD4", "1") + ) + ''' + validator.add_dissection( + [0x01, 0x01, 0x08, 0x1f, 0xff], + "asterix.048_110", + { + "asterix.048_110_3DH": "204775" + } + ) + validator.add_dissection( + [0x01, 0x01, 0x08, 0x20, 0x00], + "asterix.048_110", + { + "asterix.048_110_3DH": "-204800" + } + ) + x_120_01 = { + "asterix.048_120_CAL_D": "0", + "asterix.048_120_CAL_CAL": "0" + } + validator.add_dissection( + [0x01, 0x01, 0x04, 0x80, 0x80, 0x00], + "asterix.048_120", + dict_fspec_local(x_120_01, "048_120_CAL", "D", "1") + ) + validator.add_dissection( + [0x01, 0x01, 0x04, 0x80, 0x01, 0xff], + "asterix.048_120", + dict_fspec_local(x_120_01, "048_120_CAL", "CAL", "511") + ) + validator.add_dissection( + [0x01, 0x01, 0x04, 0x80, 0x02, 0x00], + "asterix.048_120", + dict_fspec_local(x_120_01, "048_120_CAL", "CAL", "-512") + ) + x_120_RDS = { + "asterix.048_120_RDS_DOP": "0", + "asterix.048_120_RDS_AMB": "0", + "asterix.048_120_RDS_FRQ": "0" + } + validator.add_dissection( + [0x01, 0x01, 0x04, 0x40, 0x01, 0x7f, 0xff, 0x00, 0x00, 0x00, 0x00], + "asterix.048_120", + counter_local(x_120_RDS, "1", "048_120_RDS", "DOP", "32767") + ) + validator.add_dissection( + [0x01, 0x01, 0x04, 0x40, 0x01, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00], + "asterix.048_120", + counter_local(x_120_RDS, "1", "048_120_RDS", "DOP", "32768") + ) + validator.add_dissection( + [0x01, 0x01, 0x04, 0x40, 0x01, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00], + "asterix.048_120", + counter_local(x_120_RDS, "1", "048_120_RDS", "AMB", "65535") + ) + validator.add_dissection( + [0x01, 0x01, 0x04, 0x40, 0x01, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff], + "asterix.048_120", + counter_local(x_120_RDS, "1", "048_120_RDS", "FRQ", "65535") + ) + validator.add_dissection( + [0x01, 0x01, 0x04, 0x40, 0x03, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, + 0xff], + "asterix.048_120", + { + "asterix.fspec": "", + "asterix.048_120_RDS": + { + "asterix.counter": "3", + "asterix.048_120_RDS": + dict_local(x_120_RDS, "048_120_RDS", "DOP", "-32768"), + "asterix.048_120_RDS": + dict_local(x_120_RDS, "048_120_RDS", "AMB", "65535"), + "asterix.048_120_RDS": + dict_local(x_120_RDS, "048_120_RDS", "FRQ", "65535") + } + } + ) + x_230 = { + "asterix.048_230_COM": "0", + "asterix.048_230_STAT": "0", + "asterix.048_230_SI": "0", + "asterix.048_230_MSSC": "0", + "asterix.048_230_ARC": "0", + "asterix.048_230_AIC": "0", + "asterix.048_230_B1A": "0", + "asterix.048_230_B1B": "0" + } + validator.add_dissection( + [0x01, 0x01, 0x02, 0xe0, 0x00], + "asterix.048_230", + dict_local(x_230, "048_230", "COM", "7") + ) + validator.add_dissection( + [0x01, 0x01, 0x02, 0x1c, 0x00], + "asterix.048_230", + dict_local(x_230, "048_230", "STAT", "7") + ) + validator.add_dissection( + [0x01, 0x01, 0x02, 0x02, 0x00], + "asterix.048_230", + dict_local(x_230, "048_230", "SI", "1") + ) + validator.add_dissection( + [0x01, 0x01, 0x02, 0x00, 0x80], + "asterix.048_230", + dict_local(x_230, "048_230", "MSSC", "1") + ) + validator.add_dissection( + [0x01, 0x01, 0x02, 0x00, 0x40], + "asterix.048_230", + dict_local(x_230, "048_230", "ARC", "1") + ) + validator.add_dissection( + [0x01, 0x01, 0x02, 0x00, 0x20], + "asterix.048_230", + dict_local(x_230, "048_230", "AIC", "1") + ) + validator.add_dissection( + [0x01, 0x01, 0x02, 0x00, 0x10], + "asterix.048_230", + dict_local(x_230, "048_230", "B1A", "1") + ) + validator.add_dissection( + [0x01, 0x01, 0x02, 0x00, 0x0f], + "asterix.048_230", + dict_local(x_230, "048_230", "B1B", "15") + ) + validator.add_dissection( + [0x01, 0x01, 0x01, 0x80, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77], + "asterix.048_260", + { + "asterix.048_260_VALUE": '0x0011223344556677' + } + ) + x_055 = { + "asterix.048_055_V": "0", + "asterix.048_055_G": "0", + "asterix.048_055_L": "0", + "asterix.048_055_MODE1": "0" + } + validator.add_dissection( + [0x01, 0x01, 0x01, 0x40, 0x80], + "asterix.048_055", + dict_local(x_055, "048_055", "V", "1") + ) + validator.add_dissection( + [0x01, 0x01, 0x01, 0x40, 0x40], + "asterix.048_055", + dict_local(x_055, "048_055", "G", "1") + ) + validator.add_dissection( + [0x01, 0x01, 0x01, 0x40, 0x20], + "asterix.048_055", + dict_local(x_055, "048_055", "L", "1") + ) + validator.add_dissection( + [0x01, 0x01, 0x01, 0x40, 0x1f], + "asterix.048_055", + dict_local(x_055, "048_055", "MODE1", "31") + ) + x_050 = { + "asterix.048_050_V": "0", + "asterix.048_050_G": "0", + "asterix.048_050_L": "0", + "asterix.048_050_MODE2": "0" + } + validator.add_dissection( + [0x01, 0x01, 0x01, 0x20, 0x80, 0x00], + "asterix.048_050", + dict_local(x_050, "048_050", "V", "1") + ) + validator.add_dissection( + [0x01, 0x01, 0x01, 0x20, 0x40, 0x00], + "asterix.048_050", + dict_local(x_050, "048_050", "G", "1") + ) + validator.add_dissection( + [0x01, 0x01, 0x01, 0x20, 0x20, 0x00], + "asterix.048_050", + dict_local(x_050, "048_050", "L", "1") + ) + validator.add_dissection( + [0x01, 0x01, 0x01, 0x20, 0x0f, 0xff], + "asterix.048_050", + dict_local(x_050, "048_050", "MODE2", "4095") + ) + x_065 = { + "asterix.048_065_QA4": "0", + "asterix.048_065_QA2": "0", + "asterix.048_065_QA1": "0", + "asterix.048_065_QB2": "0", + "asterix.048_065_QB1": "0" + } + validator.add_dissection( + [0x01, 0x01, 0x01, 0x10, 0x10], + "asterix.048_065", + dict_local(x_065, "048_065", "QA4", "1") + ) + validator.add_dissection( + [0x01, 0x01, 0x01, 0x10, 0x08], + "asterix.048_065", + dict_local(x_065, "048_065", "QA2", "1") + ) + validator.add_dissection( + [0x01, 0x01, 0x01, 0x10, 0x04], + "asterix.048_065", + dict_local(x_065, "048_065", "QA1", "1") + ) + validator.add_dissection( + [0x01, 0x01, 0x01, 0x10, 0x02], + "asterix.048_065", + dict_local(x_065, "048_065", "QB2", "1") + ) + validator.add_dissection( + [0x01, 0x01, 0x01, 0x10, 0x01], + "asterix.048_065", + dict_local(x_065, "048_065", "QB1", "1") + ) + x_060 = { + "asterix.048_060_QA4": "0", + "asterix.048_060_QA2": "0", + "asterix.048_060_QA1": "0", + "asterix.048_060_QB4": "0", + "asterix.048_060_QB2": "0", + "asterix.048_060_QB1": "0", + "asterix.048_060_QC4": "0", + "asterix.048_060_QC2": "0", + "asterix.048_060_QC1": "0", + "asterix.048_060_QD4": "0", + "asterix.048_060_QD2": "0", + "asterix.048_060_QD1": "0" + } + validator.add_dissection( + [0x01, 0x01, 0x01, 0x08, 0x08, 0x00], + "asterix.048_060", + dict_local(x_060, "048_060", "QA4", "1") + ) + validator.add_dissection( + [0x01, 0x01, 0x01, 0x08, 0x04, 0x00], + "asterix.048_060", + dict_local(x_060, "048_060", "QA2", "1") + ) + validator.add_dissection( + [0x01, 0x01, 0x01, 0x08, 0x02, 0x00], + "asterix.048_060", + dict_local(x_060, "048_060", "QA1", "1") + ) + validator.add_dissection( + [0x01, 0x01, 0x01, 0x08, 0x01, 0x00], + "asterix.048_060", + dict_local(x_060, "048_060", "QB4", "1") + ) + validator.add_dissection( + [0x01, 0x01, 0x01, 0x08, 0x00, 0x80], + "asterix.048_060", + dict_local(x_060, "048_060", "QB2", "1") + ) + validator.add_dissection( + [0x01, 0x01, 0x01, 0x08, 0x00, 0x40], + "asterix.048_060", + dict_local(x_060, "048_060", "QB1", "1") + ) + validator.add_dissection( + [0x01, 0x01, 0x01, 0x08, 0x00, 0x20], + "asterix.048_060", + dict_local(x_060, "048_060", "QC4", "1") + ) + validator.add_dissection( + [0x01, 0x01, 0x01, 0x08, 0x00, 0x10], + "asterix.048_060", + dict_local(x_060, "048_060", "QC2", "1") + ) + validator.add_dissection( + [0x01, 0x01, 0x01, 0x08, 0x00, 0x08], + "asterix.048_060", + dict_local(x_060, "048_060", "QC1", "1") + ) + validator.add_dissection( + [0x01, 0x01, 0x01, 0x08, 0x00, 0x04], + "asterix.048_060", + dict_local(x_060, "048_060", "QD4", "1") + ) + validator.add_dissection( + [0x01, 0x01, 0x01, 0x08, 0x00, 0x02], + "asterix.048_060", + dict_local(x_060, "048_060", "QD2", "1") + ) + validator.add_dissection( + [0x01, 0x01, 0x01, 0x08, 0x00, 0x01], + "asterix.048_060", + dict_local(x_060, "048_060", "QD1", "1") + ) + validator.add_dissection( + [0x01, 0x01, 0x01, 0x04, 0x01], + "asterix.048_SP", + "" + ) + validator.add_dissection( + [0x01, 0x01, 0x01, 0x04, 0x10, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, + 0x77, 0x88, 0x99, 0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff], + "asterix.048_SP", + "" + ) + '''TODO: re-enable RE and SP tests when implemented + x_re_md5 = { + "asterix.048_RE_MD5_01_M5": "0", + "asterix.048_RE_MD5_01_ID": "0", + "asterix.048_RE_MD5_01_DA": "0", + "asterix.048_RE_MD5_01_M1": "0", + "asterix.048_RE_MD5_01_M2": "0", + "asterix.048_RE_MD5_01_M3": "0", + "asterix.048_RE_MD5_01_MC": "0" + } + validator.add_re_dissection( + [0x80, 0x80, 0x80], + "MD5", + dict_fspec_local(x_re_md5, "048_RE_MD5_01", "M5", "1") + ) + validator.add_re_dissection( + [0x80, 0x80, 0x40], + "MD5", + dict_fspec_local(x_re_md5, "048_RE_MD5_01", "ID", "1") + ) + validator.add_re_dissection( + [0x80, 0x80, 0x20], + "MD5", + dict_fspec_local(x_re_md5, "048_RE_MD5_01", "DA", "1") + ) + validator.add_re_dissection( + [0x80, 0x80, 0x10], + "MD5", + dict_fspec_local(x_re_md5, "048_RE_MD5_01", "M1", "1") + ) + validator.add_re_dissection( + [0x80, 0x80, 0x08], + "MD5", + dict_fspec_local(x_re_md5, "048_RE_MD5_01", "M2", "1") + ) + validator.add_re_dissection( + [0x80, 0x80, 0x04], + "MD5", + dict_fspec_local(x_re_md5, "048_RE_MD5_01", "M3", "1") + ) + validator.add_re_dissection( + [0x80, 0x80, 0x02], + "MD5", + dict_fspec_local(x_re_md5, "048_RE_MD5_01", "MC", "1") + ) + x_re_pmn = { + "asterix.048_RE_MD5_02_PIN": "0", + "asterix.048_RE_MD5_02_NAV": "0", + "asterix.048_RE_MD5_02_NAT": "0", + "asterix.048_RE_MD5_02_MIS": "0" + } + validator.add_re_dissection( + [0x80, 0x40, 0x3f, 0xff, 0x00, 0x00], + "MD5", + dict_fspec_local(x_re_pmn, "048_RE_MD5_02", "PIN", "16383") + ) + validator.add_re_dissection( + [0x80, 0x40, 0x00, 0x00, 0x20, 0x00], + "MD5", + dict_fspec_local(x_re_pmn, "048_RE_MD5_02", "NAV", "1") + ) + validator.add_re_dissection( + [0x80, 0x40, 0x00, 0x00, 0x1f, 0x00], + "MD5", + dict_fspec_local(x_re_pmn, "048_RE_MD5_02", "NAT", "31") + ) + validator.add_re_dissection( + [0x80, 0x40, 0x00, 0x00, 0x00, 0x3f], + "MD5", + dict_fspec_local(x_re_pmn, "048_RE_MD5_02", "MIS", "63") + ) + x_re_pos = { + "asterix.048_RE_MD5_03_LAT": "0", + "asterix.048_RE_MD5_03_LON": "0" + } + validator.add_re_dissection( + [0x80, 0x20, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00], + "MD5", + dict_fspec_local(x_re_pos, "048_RE_MD5_03", "LAT", "90") + ) + validator.add_re_dissection( + [0x80, 0x20, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00], + "MD5", + dict_fspec_local(x_re_pos, "048_RE_MD5_03", "LAT", "-90") + ) + validator.add_re_dissection( + [0x80, 0x20, 0x00, 0x00, 0x00, 0x7f, 0xff, 0xff], + "MD5", + dict_fspec_local(x_re_pos, "048_RE_MD5_03", + "LON", "179.999978542328") + ) + validator.add_re_dissection( + [0x80, 0x20, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00], + "MD5", + dict_fspec_local(x_re_pos, "048_RE_MD5_03", "LON", "-180") + ) + x_re_ga = { + "asterix.048_RE_MD5_04_RES": "0", + "asterix.048_RE_MD5_04_GA": "0" + } + validator.add_re_dissection( + [0x80, 0x10, 0x40, 0x00], + "MD5", + dict_fspec_local(x_re_ga, "048_RE_MD5_04", "RES", "1") + ) + validator.add_re_dissection( + [0x80, 0x10, 0x1f, 0xff], + "MD5", + dict_fspec_local(x_re_ga, "048_RE_MD5_04", "GA", "204775") + ) + validator.add_re_dissection( + [0x80, 0x10, 0x20, 0x00], + "MD5", + dict_fspec_local(x_re_ga, "048_RE_MD5_04", "GA", "-204800") + ) + x_re_em1 = { + "asterix.048_RE_MD5_05_V": "0", + "asterix.048_RE_MD5_05_G": "0", + "asterix.048_RE_MD5_05_L": "0", + "asterix.048_RE_MD5_05_MODE3A": "0" + } + validator.add_re_dissection( + [0x80, 0x08, 0x80, 0x00], + "MD5", + dict_fspec_local(x_re_em1, "048_RE_MD5_05", "V", "1") + ) + validator.add_re_dissection( + [0x80, 0x08, 0x40, 0x00], + "MD5", + dict_fspec_local(x_re_em1, "048_RE_MD5_05", "G", "1") + ) + validator.add_re_dissection( + [0x80, 0x08, 0x20, 0x00], + "MD5", + dict_fspec_local(x_re_em1, "048_RE_MD5_05", "L", "1") + ) + validator.add_re_dissection( + [0x80, 0x08, 0x0f, 0xff], + "MD5", + dict_fspec_local(x_re_em1, "048_RE_MD5_05", "MODE3A", "4095") + ) + validator.add_re_dissection( + [0x80, 0x04, 0x7f], + "MD5", + fspec_local("048_RE_MD5_06", "TOS", "0.9921875") + ) + validator.add_re_dissection( + [0x80, 0x04, 0x80], + "MD5", + fspec_local("048_RE_MD5_06", "TOS", "-1") + ) + x_re_xp = { + "asterix.048_RE_MD5_07_XP": "0", + "asterix.048_RE_MD5_07_X5": "0", + "asterix.048_RE_MD5_07_XC": "0", + "asterix.048_RE_MD5_07_X3": "0", + "asterix.048_RE_MD5_07_X2": "0", + "asterix.048_RE_MD5_07_X1": "0" + } + validator.add_re_dissection( + [0x80, 0x02, 0x20], + "MD5", + dict_fspec_local(x_re_xp, "048_RE_MD5_07", "XP", "1") + ) + validator.add_re_dissection( + [0x80, 0x02, 0x10], + "MD5", + dict_fspec_local(x_re_xp, "048_RE_MD5_07", "X5", "1") + ) + validator.add_re_dissection( + [0x80, 0x02, 0x08], + "MD5", + dict_fspec_local(x_re_xp, "048_RE_MD5_07", "XC", "1") + ) + validator.add_re_dissection( + [0x80, 0x02, 0x04], + "MD5", + dict_fspec_local(x_re_xp, "048_RE_MD5_07", "X3", "1") + ) + validator.add_re_dissection( + [0x80, 0x02, 0x02], + "MD5", + dict_fspec_local(x_re_xp, "048_RE_MD5_07", "X2", "1") + ) + validator.add_re_dissection( + [0x80, 0x02, 0x01], + "MD5", + dict_fspec_local(x_re_xp, "048_RE_MD5_07", "X1", "1") + ) + x_re_md5 = { + "asterix.048_RE_M5N_01_M5": "0", + "asterix.048_RE_M5N_01_ID": "0", + "asterix.048_RE_M5N_01_DA": "0", + "asterix.048_RE_M5N_01_M1": "0", + "asterix.048_RE_M5N_01_M2": "0", + "asterix.048_RE_M5N_01_M3": "0", + "asterix.048_RE_M5N_01_MC": "0" + } + validator.add_re_dissection( + [0x40, 0x80, 0x80], + "M5N", + dict_fspec_local(x_re_md5, "048_RE_M5N_01", "M5", "1") + ) + validator.add_re_dissection( + [0x40, 0x80, 0x40], + "M5N", + dict_fspec_local(x_re_md5, "048_RE_M5N_01", "ID", "1") + ) + validator.add_re_dissection( + [0x40, 0x80, 0x20], + "M5N", + dict_fspec_local(x_re_md5, "048_RE_M5N_01", "DA", "1") + ) + validator.add_re_dissection( + [0x40, 0x80, 0x10], + "M5N", + dict_fspec_local(x_re_md5, "048_RE_M5N_01", "M1", "1") + ) + validator.add_re_dissection( + [0x40, 0x80, 0x08], + "M5N", + dict_fspec_local(x_re_md5, "048_RE_M5N_01", "M2", "1") + ) + validator.add_re_dissection( + [0x40, 0x80, 0x04], + "M5N", + dict_fspec_local(x_re_md5, "048_RE_M5N_01", "M3", "1") + ) + validator.add_re_dissection( + [0x40, 0x80, 0x02], + "M5N", + dict_fspec_local(x_re_md5, "048_RE_M5N_01", "MC", "1") + ) + x_re_pmn = { + "asterix.048_RE_M5N_02_PIN": "0", + "asterix.048_RE_M5N_02_NOV": "0", + "asterix.048_RE_M5N_02_NO": "0" + } + validator.add_re_dissection( + [0x40, 0x40, 0x3f, 0xff, 0x00, 0x00], + "M5N", + dict_fspec_local(x_re_pmn, "048_RE_M5N_02", "PIN", "16383") + ) + validator.add_re_dissection( + [0x40, 0x40, 0x00, 0x00, 0x08, 0x00], + "M5N", + dict_fspec_local(x_re_pmn, "048_RE_M5N_02", "NOV", "1") + ) + validator.add_re_dissection( + [0x40, 0x40, 0x00, 0x00, 0x07, 0xff], + "M5N", + dict_fspec_local(x_re_pmn, "048_RE_M5N_02", "NO", "2047") + ) + x_re_pos = { + "asterix.048_RE_M5N_03_LAT": "0", + "asterix.048_RE_M5N_03_LON": "0" + } + validator.add_re_dissection( + [0x40, 0x20, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00], + "M5N", + dict_fspec_local(x_re_pos, "048_RE_M5N_03", "LAT", "90") + ) + validator.add_re_dissection( + [0x40, 0x20, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00], + "M5N", + dict_fspec_local(x_re_pos, "048_RE_M5N_03", "LAT", "-90") + ) + validator.add_re_dissection( + [0x40, 0x20, 0x00, 0x00, 0x00, 0x7f, 0xff, 0xff], + "M5N", + dict_fspec_local(x_re_pos, "048_RE_M5N_03", + "LON", "179.999978542328") + ) + validator.add_re_dissection( + [0x40, 0x20, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00], + "M5N", + dict_fspec_local(x_re_pos, "048_RE_M5N_03", "LON", "-180") + ) + x_re_ga = { + "asterix.048_RE_M5N_04_RES": "0", + "asterix.048_RE_M5N_04_GA": "0" + } + validator.add_re_dissection( + [0x40, 0x10, 0x40, 0x00], + "M5N", + dict_fspec_local(x_re_ga, "048_RE_M5N_04", "RES", "1") + ) + validator.add_re_dissection( + [0x40, 0x10, 0x1f, 0xff], + "M5N", + dict_fspec_local(x_re_ga, "048_RE_M5N_04", "GA", "204775") + ) + validator.add_re_dissection( + [0x40, 0x10, 0x20, 0x00], + "M5N", + dict_fspec_local(x_re_ga, "048_RE_M5N_04", "GA", "-204800") + ) + x_re_em1 = { + "asterix.048_RE_M5N_05_V": "0", + "asterix.048_RE_M5N_05_G": "0", + "asterix.048_RE_M5N_05_L": "0", + "asterix.048_RE_M5N_05_MODE3A": "0" + } + validator.add_re_dissection( + [0x40, 0x08, 0x80, 0x00], + "M5N", + dict_fspec_local(x_re_em1, "048_RE_M5N_05", "V", "1") + ) + validator.add_re_dissection( + [0x40, 0x08, 0x40, 0x00], + "M5N", + dict_fspec_local(x_re_em1, "048_RE_M5N_05", "G", "1") + ) + validator.add_re_dissection( + [0x40, 0x08, 0x20, 0x00], + "M5N", + dict_fspec_local(x_re_em1, "048_RE_M5N_05", "L", "1") + ) + validator.add_re_dissection( + [0x40, 0x08, 0x0f, 0xff], + "M5N", + dict_fspec_local(x_re_em1, "048_RE_M5N_05", "MODE3A", "4095") + ) + validator.add_re_dissection( + [0x40, 0x04, 0x7f], + "M5N", + fspec_local("048_RE_M5N_06", "TOS", "0.9921875") + ) + validator.add_re_dissection( + [0x40, 0x04, 0x80], + "M5N", + fspec_local("048_RE_M5N_06", "TOS", "-1") + ) + x_re_xp = { + "asterix.048_RE_M5N_07_XP": "0", + "asterix.048_RE_M5N_07_X5": "0", + "asterix.048_RE_M5N_07_XC": "0", + "asterix.048_RE_M5N_07_X3": "0", + "asterix.048_RE_M5N_07_X2": "0", + "asterix.048_RE_M5N_07_X1": "0" + } + validator.add_re_dissection( + [0x40, 0x02, 0x20], + "M5N", + dict_fspec_local(x_re_xp, "048_RE_M5N_07", "XP", "1") + ) + validator.add_re_dissection( + [0x40, 0x02, 0x10], + "M5N", + dict_fspec_local(x_re_xp, "048_RE_M5N_07", "X5", "1") + ) + validator.add_re_dissection( + [0x40, 0x02, 0x08], + "M5N", + dict_fspec_local(x_re_xp, "048_RE_M5N_07", "XC", "1") + ) + validator.add_re_dissection( + [0x40, 0x02, 0x04], + "M5N", + dict_fspec_local(x_re_xp, "048_RE_M5N_07", "X3", "1") + ) + validator.add_re_dissection( + [0x40, 0x02, 0x02], + "M5N", + dict_fspec_local(x_re_xp, "048_RE_M5N_07", "X2", "1") + ) + validator.add_re_dissection( + [0x40, 0x02, 0x01], + "M5N", + dict_fspec_local(x_re_xp, "048_RE_M5N_07", "X1", "1") + ) + validator.add_re_dissection( + [0x40, 0x01, 0x80, 0x1f], + "M5N", + fspec_local("048_RE_M5N_08", "FOM", "31") + ) + validator.add_re_dissection( + [0x20, 0x06], + "M4E", + { + "asterix.048_RE_M4E_FOE_FRI": "3", + "asterix.FX": "0" + } + ) + validator.add_re_dissection( + [0x10, 0x80, 0xff], + "RPC", + fspec_local("048_RE_RPC_01", "SCO", "255") + ) + validator.add_re_dissection( + [0x10, 0x40, 0xff, 0xff], + "RPC", + fspec_local("048_RE_RPC_02", "SCR", "6553.5") + ) + validator.add_re_dissection( + [0x10, 0x20, 0xff, 0xff], + "RPC", + fspec_local("048_RE_RPC_03", "RW", "255.99609375") + ) + validator.add_re_dissection( + [0x10, 0x10, 0xff, 0xff], + "RPC", + fspec_local("048_RE_RPC_04", "AR", "255.99609375") + ) + validator.add_re_dissection( + [0x08, 0xff, 0xff, 0xff], + "ERR", + { + "asterix.048_RE_ERR_RHO": "65535.99609375" + } + ) + ''' + + validator.check_dissections() + + def test_undefined_value_handling(self, asterix_re_validator): + '''verifies that the dissector can dissect undefined field values by + setting the maximum value of bits or by setting all undefined bits''' + + validator = asterix_re_validator(48, [0x01, 0x01, 0x01, 0x02]) + + validator.add_dissection( + [0x08, 0x10, 0x00], + "asterix.048_070", + { + "asterix.048_070_V": "0", + "asterix.048_070_G": "0", + "asterix.048_070_L": "0", + "asterix.048_070_MODE3A": "0" + } + ) + validator.add_dissection( + [0x01, 0x10, 0xf0, 0x00], + "asterix.048_161", + { + "asterix.048_161_TRN": "0" + } + ) + validator.add_dissection( + [0x01, 0x02, 0x01, 0x0e], + "asterix.048_170", + { + "asterix.048_170_CNF": "0", + "asterix.048_170_RAD": "0", + "asterix.048_170_DOU": "0", + "asterix.048_170_MAH": "0", + "asterix.048_170_CDM": "0", + "asterix.048_170_TRE": "0", + "asterix.048_170_GHO": "0", + "asterix.048_170_SUP": "0", + "asterix.048_170_TCC": "0", + "asterix.FX": "0" + } + ) + validator.add_dissection( + [0x01, 0x01, 0x40, 0xfe], + "asterix.048_030", + { + "asterix.048_030_Subitem": "127", + "asterix.FX": "0" + } + ) + validator.add_dissection( + [0x01, 0x01, 0x20, 0xf0, 0x00], + "asterix.048_080", + { + "asterix.048_080_QA4": "0", + "asterix.048_080_QA2": "0", + "asterix.048_080_QA1": "0", + "asterix.048_080_QB4": "0", + "asterix.048_080_QB2": "0", + "asterix.048_080_QB1": "0", + "asterix.048_080_QC4": "0", + "asterix.048_080_QC2": "0", + "asterix.048_080_QC1": "0", + "asterix.048_080_QD4": "0", + "asterix.048_080_QD2": "0", + "asterix.048_080_QD1": "0" + } + ) + '''TODO: A,B,C,D values need to go to single subitem 'MODEC' + validator.add_dissection( + [0x01, 0x01, 0x10, 0x30, 0x00, 0xf0, 0x00], + "asterix.048_100", + { + "asterix.048_100_V": "0", + "asterix.048_100_G": "0", + "asterix.048_100_A1": "0", + "asterix.048_100_C2": "0", + "asterix.048_100_A2": "0", + "asterix.048_100_C4": "0", + "asterix.048_100_A4": "0", + "asterix.048_100_B1": "0", + "asterix.048_100_D1": "0", + "asterix.048_100_B2": "0", + "asterix.048_100_D2": "0", + "asterix.048_100_B4": "0", + "asterix.048_100_D4": "0", + "asterix.048_100_QC1": "0", + "asterix.048_100_QA1": "0", + "asterix.048_100_QC2": "0", + "asterix.048_100_QA2": "0", + "asterix.048_100_QC4": "0", + "asterix.048_100_QA4": "0", + "asterix.048_100_QB1": "0", + "asterix.048_100_QD1": "0", + "asterix.048_100_QB2": "0", + "asterix.048_100_QD2": "0", + "asterix.048_100_QB4": "0", + "asterix.048_100_QD4": "0" + } + ) + validator.add_dissection( + [0x01, 0x01, 0x04, 0x80, 0x7c, 0x00], + "asterix.048_120", + { + "asterix.fspec": "", + "asterix.048_120_01": + { + "asterix.048_120_01_D": "0", + "asterix.048_120_01_CAL": "0" + } + } + ) + ''' + validator.add_dissection( + [0x01, 0x01, 0x04, 0x3e], + "asterix.048_120", + { + "asterix.fspec": "" + } + ) + validator.add_dissection( + [0x01, 0x01, 0x02, 0x01, 0x00], + "asterix.048_230", + { + "asterix.048_230_COM": "0", + "asterix.048_230_STAT": "0", + "asterix.048_230_SI": "0", + "asterix.048_230_MSSC": "0", + "asterix.048_230_ARC": "0", + "asterix.048_230_AIC": "0", + "asterix.048_230_B1A": "0", + "asterix.048_230_B1B": "0" + } + ) + validator.add_dissection( + [0x01, 0x01, 0x01, 0x20, 0x10, 0x00], + "asterix.048_050", + { + "asterix.048_050_V": "0", + "asterix.048_050_G": "0", + "asterix.048_050_L": "0", + "asterix.048_050_MODE2": "0" + } + ) + validator.add_dissection( + [0x01, 0x01, 0x01, 0x10, 0xe0], + "asterix.048_065", + { + "asterix.048_065_QA4": "0", + "asterix.048_065_QA2": "0", + "asterix.048_065_QA1": "0", + "asterix.048_065_QB2": "0", + "asterix.048_065_QB1": "0" + } + ) + '''TODO: re-enable RE and SP tests when implemented + x_re_md5 = { + "asterix.048_RE_MD5_01_M5": "0", + "asterix.048_RE_MD5_01_ID": "0", + "asterix.048_RE_MD5_01_DA": "0", + "asterix.048_RE_MD5_01_M1": "0", + "asterix.048_RE_MD5_01_M2": "0", + "asterix.048_RE_MD5_01_M3": "0", + "asterix.048_RE_MD5_01_MC": "0" + } + validator.add_re_dissection( + [0x80, 0x80, 0x01, 0x00], + "MD5", + dict_fspec_local(x_re_md5, "048_RE_MD5_01", "M5", "0") + ) + x_re_pmn = { + "asterix.048_RE_MD5_02_PIN": "0", + "asterix.048_RE_MD5_02_NAV": "0", + "asterix.048_RE_MD5_02_NAT": "0", + "asterix.048_RE_MD5_02_MIS": "0" + } + validator.add_re_dissection( + [0x80, 0x40, 0xc0, 0x00, 0xc0, 0xc0], + "MD5", + dict_fspec_local(x_re_pmn, "048_RE_MD5_02", "PIN", "0") + ) + x_re_em1 = { + "asterix.048_RE_MD5_05_V": "0", + "asterix.048_RE_MD5_05_G": "0", + "asterix.048_RE_MD5_05_L": "0", + "asterix.048_RE_MD5_05_MODE3A": "0" + } + validator.add_re_dissection( + [0x80, 0x08, 0x10, 0x00], + "MD5", + dict_fspec_local(x_re_em1, "048_RE_MD5_05", "V", "0") + ) + x_re_md5 = { + "asterix.048_RE_M5N_01_M5": "0", + "asterix.048_RE_M5N_01_ID": "0", + "asterix.048_RE_M5N_01_DA": "0", + "asterix.048_RE_M5N_01_M1": "0", + "asterix.048_RE_M5N_01_M2": "0", + "asterix.048_RE_M5N_01_M3": "0", + "asterix.048_RE_M5N_01_MC": "0" + } + validator.add_re_dissection( + [0x40, 0x80, 0x01, 0x00], + "M5N", + dict_fspec_local(x_re_md5, "048_RE_M5N_01", "M5", "0") + ) + x_re_pmn = { + "asterix.048_RE_M5N_02_PIN": "0", + "asterix.048_RE_M5N_02_NOV": "0", + "asterix.048_RE_M5N_02_NO": "0" + } + validator.add_re_dissection( + [0x40, 0x40, 0xc0, 0x00, 0xf0, 0x00], + "M5N", + dict_fspec_local(x_re_pmn, "048_RE_M5N_02", "PIN", "0") + ) + x_re_em1 = { + "asterix.048_RE_M5N_05_V": "0", + "asterix.048_RE_M5N_05_G": "0", + "asterix.048_RE_M5N_05_L": "0", + "asterix.048_RE_M5N_05_MODE3A": "0" + } + validator.add_re_dissection( + [0x40, 0x08, 0x10, 0x00], + "M5N", + dict_fspec_local(x_re_em1, "048_RE_M5N_05", "V", "0") + ) + validator.add_re_dissection( + [0x40, 0x01, 0x80, 0xe0], + "M5N", + fspec_local("048_RE_M5N_08", "FOM", "0") + ) + validator.add_re_dissection( + [0x20, 0xf8], + "M4E", + { + "asterix.048_RE_M4E_FOE_FRI": "0", + "asterix.FX": "0" + } + ) + validator.add_re_dissection( + [0x20, 0x01, 0x00], + "M4E", + { + "asterix.048_RE_M4E_FOE_FRI": "0", + "asterix.FX": "1" + } + ) + ''' + + validator.check_dissections() + + +class TestCategory063: + ''' + Unittest case for ASTERIX Category 063 + + Online specification: + https://www.eurocontrol.int/publications/cat063-sensor-status-messages-part-10 + + Part 10: Category 63 (1.4) + Sensor Status Messages + + Standard User Application Profile + + FRN Data Item Information Length + 1 I063/010 Data Source Identifier 2 + 2 I063/015 Service Identification 1 + 3 I063/030 Time of Message 3 + 4 I063/050 Sensor Identifier 2 + 5 I063/060 Sensor Configuration and Status 1+1 + 6 I063/070 Time Stamping Bias 2 + 7 I063/080 SSR/Mode S Range Gain and Bias 4 + FX - Field extension indicator - + 8 I063/081 SSR/Mode S Azimuth Bias 2 + 9 I063/090 PSR Range Gain and Bias 4 + 10 I063/091 PSR Azimuth Bias 2 + 11 I063/092 PSR Elevation Bias 2 + 12 - spare - + 13 RE Reserved Expansion Field 1+1+ + 14 SP Special Purpose Field 1+1+ + FX - Field extension indicator - + ''' + + def test_for_fields(self, asterix_validator): + '''verifies existence of all fields and their maximum value''' + + validator = asterix_validator(63) + + validator.add_dissection( + [0x80, 0xff, 0x00], + "asterix.063_010", + { + "asterix.063_010_SAC": "0xff", + "asterix.063_010_SIC": "0x00" + } + ) + validator.add_dissection( + [0x80, 0x00, 0xff], + "asterix.063_010", + { + "asterix.063_010_SAC": "0x00", + "asterix.063_010_SIC": "0xff" + } + ) + validator.add_dissection( + [0x40, 0xff], + "asterix.063_015", + { + "asterix.063_015_VALUE": "0xff" + } + ) + validator.add_dissection( + [0x20, 0xa8, 0xbf, 0xff], + "asterix.063_030", + { + "asterix.063_030_VALUE": "86399.9921875" + } + ) + validator.add_dissection( + [0x10, 0xff, 0x00], + "asterix.063_050", + { + "asterix.063_050_SAC": "0xff", + "asterix.063_050_SIC": "0x00" + } + ) + validator.add_dissection( + [0x10, 0x00, 0xff], + "asterix.063_050", + { + "asterix.063_050_SAC": "0x00", + "asterix.063_050_SIC": "0xff" + } + ) + validator.add_dissection( + [0x08, 0xc0], + "asterix.063_060", + { + "asterix.063_060_CON": "3", + "asterix.063_060_PSR": "0", + "asterix.063_060_SSR": "0", + "asterix.063_060_MDS": "0", + "asterix.063_060_ADS": "0", + "asterix.063_060_MLT": "0", + "asterix.FX": "0" + } + ) + validator.add_dissection( + [0x08, 0x20], + "asterix.063_060", + { + "asterix.063_060_CON": "0", + "asterix.063_060_PSR": "1", + "asterix.063_060_SSR": "0", + "asterix.063_060_MDS": "0", + "asterix.063_060_ADS": "0", + "asterix.063_060_MLT": "0", + "asterix.FX": "0" + } + ) + validator.add_dissection( + [0x08, 0x10], + "asterix.063_060", + { + "asterix.063_060_CON": "0", + "asterix.063_060_PSR": "0", + "asterix.063_060_SSR": "1", + "asterix.063_060_MDS": "0", + "asterix.063_060_ADS": "0", + "asterix.063_060_MLT": "0", + "asterix.FX": "0" + } + ) + validator.add_dissection( + [0x08, 0x08], + "asterix.063_060", + { + "asterix.063_060_CON": "0", + "asterix.063_060_PSR": "0", + "asterix.063_060_SSR": "0", + "asterix.063_060_MDS": "1", + "asterix.063_060_ADS": "0", + "asterix.063_060_MLT": "0", + "asterix.FX": "0" + } + ) + validator.add_dissection( + [0x08, 0x04], + "asterix.063_060", + { + "asterix.063_060_CON": "0", + "asterix.063_060_PSR": "0", + "asterix.063_060_SSR": "0", + "asterix.063_060_MDS": "0", + "asterix.063_060_ADS": "1", + "asterix.063_060_MLT": "0", + "asterix.FX": "0" + } + ) + validator.add_dissection( + [0x08, 0x02], + "asterix.063_060", + { + "asterix.063_060_CON": "0", + "asterix.063_060_PSR": "0", + "asterix.063_060_SSR": "0", + "asterix.063_060_MDS": "0", + "asterix.063_060_ADS": "0", + "asterix.063_060_MLT": "1", + "asterix.FX": "0" + } + ) + validator.add_dissection( + [0x08, 0x01, 0x80], + "asterix.063_060", + { + "asterix.063_060_CON": "0", + "asterix.063_060_PSR": "0", + "asterix.063_060_SSR": "0", + "asterix.063_060_MDS": "0", + "asterix.063_060_ADS": "0", + "asterix.063_060_MLT": "0", + "asterix.063_060_OPS": "1", + "asterix.063_060_ODP": "0", + "asterix.063_060_OXT": "0", + "asterix.063_060_MSC": "0", + "asterix.063_060_TSV": "0", + "asterix.063_060_NPW": "0", + "asterix.FX": "0" + } + ) + validator.add_dissection( + [0x08, 0x01, 0x40], + "asterix.063_060", + { + "asterix.063_060_CON": "0", + "asterix.063_060_PSR": "0", + "asterix.063_060_SSR": "0", + "asterix.063_060_MDS": "0", + "asterix.063_060_ADS": "0", + "asterix.063_060_MLT": "0", + "asterix.063_060_OPS": "0", + "asterix.063_060_ODP": "1", + "asterix.063_060_OXT": "0", + "asterix.063_060_MSC": "0", + "asterix.063_060_TSV": "0", + "asterix.063_060_NPW": "0", + "asterix.FX": "0" + } + ) + validator.add_dissection( + [0x08, 0x01, 0x20], + "asterix.063_060", + { + "asterix.063_060_CON": "0", + "asterix.063_060_PSR": "0", + "asterix.063_060_SSR": "0", + "asterix.063_060_MDS": "0", + "asterix.063_060_ADS": "0", + "asterix.063_060_MLT": "0", + "asterix.063_060_OPS": "0", + "asterix.063_060_ODP": "0", + "asterix.063_060_OXT": "1", + "asterix.063_060_MSC": "0", + "asterix.063_060_TSV": "0", + "asterix.063_060_NPW": "0", + "asterix.FX": "0" + } + ) + validator.add_dissection( + [0x08, 0x01, 0x10], + "asterix.063_060", + { + "asterix.063_060_CON": "0", + "asterix.063_060_PSR": "0", + "asterix.063_060_SSR": "0", + "asterix.063_060_MDS": "0", + "asterix.063_060_ADS": "0", + "asterix.063_060_MLT": "0", + "asterix.063_060_OPS": "0", + "asterix.063_060_ODP": "0", + "asterix.063_060_OXT": "0", + "asterix.063_060_MSC": "1", + "asterix.063_060_TSV": "0", + "asterix.063_060_NPW": "0", + "asterix.FX": "0" + } + ) + validator.add_dissection( + [0x08, 0x01, 0x08], + "asterix.063_060", + { + "asterix.063_060_CON": "0", + "asterix.063_060_PSR": "0", + "asterix.063_060_SSR": "0", + "asterix.063_060_MDS": "0", + "asterix.063_060_ADS": "0", + "asterix.063_060_MLT": "0", + "asterix.063_060_OPS": "0", + "asterix.063_060_ODP": "0", + "asterix.063_060_OXT": "0", + "asterix.063_060_MSC": "0", + "asterix.063_060_TSV": "1", + "asterix.063_060_NPW": "0", + "asterix.FX": "0" + } + ) + validator.add_dissection( + [0x08, 0x01, 0x04], + "asterix.063_060", + { + "asterix.063_060_CON": "0", + "asterix.063_060_PSR": "0", + "asterix.063_060_SSR": "0", + "asterix.063_060_MDS": "0", + "asterix.063_060_ADS": "0", + "asterix.063_060_MLT": "0", + "asterix.063_060_OPS": "0", + "asterix.063_060_ODP": "0", + "asterix.063_060_OXT": "0", + "asterix.063_060_MSC": "0", + "asterix.063_060_TSV": "0", + "asterix.063_060_NPW": "1", + "asterix.FX": "0" + } + ) + validator.add_dissection( + [0x04, 0xff, 0xff], + "asterix.063_070", + { + "asterix.063_070_VALUE": "-1" + } + ) + validator.add_dissection( + [0x02, 0x7f, 0xff, 0x00, 0x00], + "asterix.063_080", + { + "asterix.063_080_SRG": "0.32767", + "asterix.063_080_SRB": "0" + } + ) + validator.add_dissection( + [0x02, 0x80, 0x00, 0x00, 0x00], + "asterix.063_080", + { + "asterix.063_080_SRG": "-0.32768", + "asterix.063_080_SRB": "0" + } + ) + validator.add_dissection( + [0x02, 0x00, 0x00, 0x7f, 0xff], + "asterix.063_080", + { + "asterix.063_080_SRG": "0", + "asterix.063_080_SRB": "255.9921875" + } + ) + validator.add_dissection( + [0x02, 0x00, 0x00, 0x80, 0x00], + "asterix.063_080", + { + "asterix.063_080_SRG": "0", + "asterix.063_080_SRB": "-256" + } + ) + validator.add_dissection( + [0x01, 0x80, 0x7f, 0xff], + "asterix.063_081", + { + "asterix.063_081_VALUE": "179.994506835938" + } + ) + validator.add_dissection( + [0x01, 0x80, 0x80, 0x00], + "asterix.063_081", + { + "asterix.063_081_VALUE": "-180" + } + ) + validator.add_dissection( + [0x01, 0x40, 0x7f, 0xff, 0x00, 0x00], + "asterix.063_090", + { + "asterix.063_090_PRG": "0.32767", + "asterix.063_090_PRB": "0" + } + ) + validator.add_dissection( + [0x01, 0x40, 0x80, 0x00, 0x00, 0x00], + "asterix.063_090", + { + "asterix.063_090_PRG": "-0.32768", + "asterix.063_090_PRB": "0" + } + ) + validator.add_dissection( + [0x01, 0x40, 0x00, 0x00, 0x7f, 0xff], + "asterix.063_090", + { + "asterix.063_090_PRG": "0", + "asterix.063_090_PRB": "255.9921875" + } + ) + validator.add_dissection( + [0x01, 0x40, 0x00, 0x00, 0x80, 0x00], + "asterix.063_090", + { + "asterix.063_090_PRG": "0", + "asterix.063_090_PRB": "-256" + } + ) + validator.add_dissection( + [0x01, 0x20, 0x7f, 0xff], + "asterix.063_091", + { + "asterix.063_091_VALUE": "179.994506835938" + } + ) + validator.add_dissection( + [0x01, 0x20, 0x80, 0x00], + "asterix.063_091", + { + "asterix.063_091_VALUE": "-180" + } + ) + validator.add_dissection( + [0x01, 0x10, 0x7f, 0xff], + "asterix.063_092", + { + "asterix.063_092_VALUE": "179.994506835938" + } + ) + validator.add_dissection( + [0x01, 0x10, 0x80, 0x00], + "asterix.063_092", + { + "asterix.063_092_VALUE": "-180" + } + ) + + validator.check_dissections() + + def test_undefined_value_handling(self, asterix_validator): + '''verifies that the dissector can dissect undefined field values by + setting the maximum value of bits or by setting all undefined bits''' + + validator = asterix_validator(63) + + validator.add_dissection( + [0x01, 0x08], + "asterix.spare", + "" + ) + '''TODO: re-enable RE and SP tests when implemented + validator.add_dissection( + [0x01, 0x04, 0x02, 0x00], + "asterix.063_RE", + { + "asterix.re_field_len": "2", + "asterix.fspec": "" + } + ) + validator.add_dissection( + [0x01, 0x04, 0x10, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, + 0x99, 0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff], + "asterix.063_RE", + { + "asterix.fspec": "", + "asterix.re_field_len": "16" + } + ) + validator.add_dissection( + [0x01, 0x02, 0x01], + "asterix.063_SP", + "" + ) + validator.add_dissection( + [0x01, 0x02, 0x10, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, + 0x99, 0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff], + "asterix.063_SP", + "" + ) + ''' + + validator.check_dissections() + + +class TestCategory065: + ''' + Unittest case for ASTERIX Category 065 + + Online specification: + https://www.eurocontrol.int/publications/cat065-surveillance-data-processing-system-sdps-service-status-messages-part-15 + https://www.eurocontrol.int/publications/cat065-coding-rules-reserved-expansion-field-part-15-appendix + + Part 15 Category 65 (1.4) + SDPS Service Status Reports + + Standard User Application Profile + + FRN Data Item Information Length + 1 I065/010 Data Source Identifier 2 + 2 I065/000 Message Type 1 + 3 I065/015 Service Identification 1 + 4 I065/030 Time of Message 3 + 5 I065/020 Batch Number 1 + 6 I065/040 SDPS Configuration and Status 1 + 7 I065/050 Service Status Report 1 + FX - Field extension indicator - + 8 - Spare - + 9 - Spare - + 10 - Spare - + 11 - Spare - + 12 - Spare - + 13 RE Reserved Expansion Field 1+1+ + 14 SP Special Purpose Field 1+1+ + FX - Field extension indicator - + ''' + + def test_for_fields(self, asterix_validator): + '''verifies existence of all fields and their maximum value''' + + validator = asterix_validator(65) + + validator.add_dissection( + [0x80, 0xff, 0x00], + "asterix.065_010", + { + "asterix.065_010_SAC": "0xff", + "asterix.065_010_SIC": "0x00" + } + ) + validator.add_dissection( + [0x80, 0x00, 0xff], + "asterix.065_010", + { + "asterix.065_010_SAC": "0x00", + "asterix.065_010_SIC": "0xff" + } + ) + validator.add_dissection( + [0x40, 0x03], + "asterix.065_000", + { + "asterix.065_000_VALUE": "3" + } + ) + validator.add_dissection( + [0x20, 0xff], + "asterix.065_015", + { + "asterix.065_015_VALUE": "0xff" + } + ) + validator.add_dissection( + [0x10, 0xa8, 0xbf, 0xff], + "asterix.065_030", + { + "asterix.065_030_VALUE": "86399.9921875" + } + ) + validator.add_dissection( + [0x08, 0xff], + "asterix.065_020", + { + "asterix.065_020_VALUE": "255" + } + ) + validator.add_dissection( + [0x04, 0xc0], + "asterix.065_040", + { + "asterix.065_040_NOGO": "3", + "asterix.065_040_OVL": "0", + "asterix.065_040_TSV": "0", + "asterix.065_040_PSS": "0", + "asterix.065_040_STTN": "0" + } + ) + validator.add_dissection( + [0x04, 0x20], + "asterix.065_040", + { + "asterix.065_040_NOGO": "0", + "asterix.065_040_OVL": "1", + "asterix.065_040_TSV": "0", + "asterix.065_040_PSS": "0", + "asterix.065_040_STTN": "0" + } + ) + validator.add_dissection( + [0x04, 0x10], + "asterix.065_040", + { + "asterix.065_040_NOGO": "0", + "asterix.065_040_OVL": "0", + "asterix.065_040_TSV": "1", + "asterix.065_040_PSS": "0", + "asterix.065_040_STTN": "0" + } + ) + validator.add_dissection( + [0x04, 0x0c], + "asterix.065_040", + { + "asterix.065_040_NOGO": "0", + "asterix.065_040_OVL": "0", + "asterix.065_040_TSV": "0", + "asterix.065_040_PSS": "3", + "asterix.065_040_STTN": "0" + } + ) + validator.add_dissection( + [0x04, 0x02], + "asterix.065_040", + { + "asterix.065_040_NOGO": "0", + "asterix.065_040_OVL": "0", + "asterix.065_040_TSV": "0", + "asterix.065_040_PSS": "0", + "asterix.065_040_STTN": "1" + } + ) + validator.add_dissection( + [0x02, 0xff], + "asterix.065_050", + { + "asterix.065_050_VALUE": "255" + } + ) + '''TODO: re-enable RE and SP tests when implemented + validator.add_dissection( + [0x01, 0x04, 0x02, 0x00], + "asterix.065_RE", + { + "asterix.re_field_len": "2", + "asterix.fspec": "" + } + ) + validator.add_dissection( + [0x01, 0x04, 0x0a, 0x80, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00], + "asterix.065_RE", + { + "asterix.re_field_len": "10", + "asterix.fspec": "", + "asterix.065_RE_SRP": + { + "asterix.065_RE_SRP_Latitude": "90", + "asterix.065_RE_SRP_Longitude": "0" + } + } + ) + validator.add_dissection( + [0x01, 0x04, 0x0a, 0x80, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00], + "asterix.065_RE", + { + "asterix.re_field_len": "10", + "asterix.fspec": "", + "asterix.065_RE_SRP": + { + "asterix.065_RE_SRP_Latitude": "-90", + "asterix.065_RE_SRP_Longitude": "0" + } + } + ) + validator.add_dissection( + [0x01, 0x04, 0x0a, 0x80, 0x00, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, + 0x00], + "asterix.065_RE", + { + "asterix.re_field_len": "10", + "asterix.fspec": "", + "asterix.065_RE_SRP": + { + "asterix.065_RE_SRP_Latitude": "0", + "asterix.065_RE_SRP_Longitude": "180" + } + } + ) + validator.add_dissection( + [0x01, 0x04, 0x0a, 0x80, 0x00, 0x00, 0x00, 0x00, 0xc0, 0x00, 0x00, + 0x00], + "asterix.065_RE", + { + "asterix.re_field_len": "10", + "asterix.fspec": "", + "asterix.065_RE_SRP": + { + "asterix.065_RE_SRP_Latitude": "0", + "asterix.065_RE_SRP_Longitude": "-180" + } + } + ) + validator.add_dissection( + [0x01, 0x04, 0x04, 0x40, 0xff, 0xfc], + "asterix.065_RE", + { + "asterix.re_field_len": "4", + "asterix.fspec": "", + "asterix.065_RE_ARL": + { + "asterix.065_RE_ARL_ARL": "65532" + } + } + ) + ''' + + validator.check_dissections() + + def test_undefined_value_handling(self, asterix_validator): + '''verifies that the dissector can dissect undefined field values by + setting the maximum value of bits or by setting all undefined bits''' + + validator = asterix_validator(65) + + validator.add_dissection( + [0x40, 0xff], + "asterix.065_000", + { + "asterix.065_000_VALUE": "255" + } + ) + validator.add_dissection( + [0x10, 0xff, 0xff, 0xff], + "asterix.065_030", + { + "asterix.065_030_VALUE": "131071.9921875" + } + ) + validator.add_dissection( + [0x04, 0x01], + "asterix.065_040", + { + "asterix.065_040_NOGO": "0", + "asterix.065_040_OVL": "0", + "asterix.065_040_TSV": "0", + "asterix.065_040_PSS": "0", + "asterix.065_040_STTN": "0" + } + ) + validator.add_dissection( + [0x01, 0x80], + "asterix.spare", + "" + ) + validator.add_dissection( + [0x01, 0x40], + "asterix.spare", + "" + ) + validator.add_dissection( + [0x01, 0x20], + "asterix.spare", + "" + ) + validator.add_dissection( + [0x01, 0x10], + "asterix.spare", + "" + ) + validator.add_dissection( + [0x01, 0x08], + "asterix.spare", + "" + ) + '''TODO: re-enable RE and SP tests when implemented + validator.add_dissection( + [0x01, 0x04, 0x0a, 0x80, 0x7f, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, + 0x00], + "asterix.065_RE", + { + "asterix.re_field_len": "10", + "asterix.fspec": "", + "asterix.065_RE_SRP": + { + "asterix.065_RE_SRP_Latitude": "359.999999832362", + "asterix.065_RE_SRP_Longitude": "0" + } + } + ) + validator.add_dissection( + [0x01, 0x04, 0x0a, 0x80, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00], + "asterix.065_RE", + { + "asterix.re_field_len": "10", + "asterix.fspec": "", + "asterix.065_RE_SRP": + { + "asterix.065_RE_SRP_Latitude": "-360", + "asterix.065_RE_SRP_Longitude": "0" + } + } + ) + validator.add_dissection( + [0x01, 0x04, 0x0a, 0x80, 0x00, 0x00, 0x00, 0x00, 0x7f, 0xff, 0xff, + 0xff], + "asterix.065_RE", + { + "asterix.re_field_len": "10", + "asterix.fspec": "", + "asterix.065_RE_SRP": + { + "asterix.065_RE_SRP_Latitude": "0", + "asterix.065_RE_SRP_Longitude": "359.999999832362" + } + } + ) + validator.add_dissection( + [0x01, 0x04, 0x0a, 0x80, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, + 0x00], + "asterix.065_RE", + { + "asterix.re_field_len": "10", + "asterix.fspec": "", + "asterix.065_RE_SRP": + { + "asterix.065_RE_SRP_Latitude": "0", + "asterix.065_RE_SRP_Longitude": "-360" + } + } + ) + validator.add_dissection( + [0x01, 0x04, 0x04, 0x40, 0xff, 0xff], + "asterix.065_RE", + { + "asterix.re_field_len": "4", + "asterix.fspec": "", + "asterix.065_RE_ARL": + { + "asterix.065_RE_ARL_ARL": "65535" + } + } + ) + validator.add_dissection( + [0x01, 0x02, 0x01], + "asterix.065_SP", + "" + ) + validator.add_dissection( + [0x01, 0x02, 0x10, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, + 0x99, 0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff], + "asterix.065_SP", + "" + ) + ''' + + validator.check_dissections() diff --git a/test/suite_dissectors/group_netperfmeter.py b/test/suite_dissectors/group_netperfmeter.py new file mode 100644 index 00000000..04b5aeb6 --- /dev/null +++ b/test/suite_dissectors/group_netperfmeter.py @@ -0,0 +1,430 @@ +# +# Wireshark tests +# +# Copyright 2021 by Thomas Dreibholz <dreibh [AT] simula.no> +# +# SPDX-License-Identifier: GPL-2.0-or-later +# +'''NetPerfMeter tests''' + +import subprocess +import pytest + + +class TestNetperfmeter: + + def test_netperfmeter_test_control(self, cmd_tshark, capture_file, test_env): + '''Checks whether the NetPerfMeter dissector correctly handles NetPerfMeter Control via SCTP.''' + + # Test: Identify and decode NetPerfMeter Control via SCTP + stdout = subprocess.check_output((cmd_tshark, + '-r', capture_file('netperfmeter.pcapng.gz'), + '-Y', 'sctp && netperfmeter && ((netperfmeter.message_type != 5) && (netperfmeter.message_type != 4))' + ), + encoding='utf-8', env=test_env) + + result = ''.join([x.strip()+"\n" for x in stdout.splitlines()]) + + assert """\ +8 0.019316433 192.168.0.20 → 192.168.0.27 SCTP, NetPerfMeter 260 NetPerfMeter Add Flow +10 0.038537718 192.168.0.27 → 192.168.0.20 SCTP, NetPerfMeter 88 NetPerfMeter Acknowledge +14 0.326752277 192.168.0.27 → 192.168.0.20 SCTP, NetPerfMeter 88 NetPerfMeter Acknowledge +18 0.333703948 192.168.0.20 → 192.168.0.27 SCTP, NetPerfMeter 276 SACK (Ack=1, Arwnd=106496) NetPerfMeter Add Flow +19 0.340092259 192.168.0.27 → 192.168.0.20 SCTP, NetPerfMeter 104 SACK (Ack=1, Arwnd=106496) NetPerfMeter Acknowledge +23 0.547510935 192.168.0.27 → 192.168.0.20 SCTP, NetPerfMeter 88 NetPerfMeter Acknowledge +24 0.548336846 192.168.0.20 → 192.168.0.27 SCTP, NetPerfMeter 276 SACK (Ack=3, Arwnd=106496) NetPerfMeter Add Flow +25 0.556582544 192.168.0.27 → 192.168.0.20 SCTP, NetPerfMeter 104 SACK (Ack=2, Arwnd=106496) NetPerfMeter Acknowledge +28 0.768799828 192.168.0.27 → 192.168.0.20 SCTP, NetPerfMeter 88 NetPerfMeter Acknowledge +29 0.769562835 192.168.0.20 → 192.168.0.27 SCTP, NetPerfMeter 276 SACK (Ack=5, Arwnd=106496) NetPerfMeter Add Flow +30 0.777872331 192.168.0.27 → 192.168.0.20 SCTP, NetPerfMeter 104 SACK (Ack=3, Arwnd=106496) NetPerfMeter Acknowledge +33 0.986925179 192.168.0.27 → 192.168.0.20 SCTP, NetPerfMeter 88 NetPerfMeter Acknowledge +37 0.992962317 192.168.0.20 → 192.168.0.27 SCTP, NetPerfMeter 276 SACK (Ack=7, Arwnd=106496) NetPerfMeter Add Flow +38 1.000163511 192.168.0.27 → 192.168.0.20 SCTP, NetPerfMeter 104 SACK (Ack=4, Arwnd=106496) NetPerfMeter Acknowledge +41 1.245101828 192.168.0.27 → 192.168.0.20 SCTP, NetPerfMeter 88 NetPerfMeter Acknowledge +45 1.248598897 192.168.0.20 → 192.168.0.27 SCTP, NetPerfMeter 276 SACK (Ack=9, Arwnd=106496) NetPerfMeter Add Flow +46 1.257101874 192.168.0.27 → 192.168.0.20 SCTP, NetPerfMeter 104 SACK (Ack=5, Arwnd=106496) NetPerfMeter Acknowledge +49 1.502117462 192.168.0.27 → 192.168.0.20 SCTP, NetPerfMeter 88 NetPerfMeter Acknowledge +53 1.509411259 192.168.0.20 → 192.168.0.27 SCTP, NetPerfMeter 276 SACK (Ack=11, Arwnd=106496) NetPerfMeter Add Flow +54 1.518356124 192.168.0.27 → 192.168.0.20 SCTP, NetPerfMeter 104 SACK (Ack=6, Arwnd=106496) NetPerfMeter Acknowledge +57 1.762124577 192.168.0.27 → 192.168.0.20 SCTP, NetPerfMeter 88 NetPerfMeter Acknowledge +61 1.768546288 192.168.0.20 → 192.168.0.27 SCTP, NetPerfMeter 276 SACK (Ack=13, Arwnd=106496) NetPerfMeter Add Flow +62 1.776275446 192.168.0.27 → 192.168.0.20 SCTP, NetPerfMeter 104 SACK (Ack=7, Arwnd=106496) NetPerfMeter Acknowledge +65 1.996204594 192.168.0.27 → 192.168.0.20 SCTP, NetPerfMeter 88 NetPerfMeter Acknowledge +69 2.003084950 192.168.0.20 → 192.168.0.27 SCTP, NetPerfMeter 276 SACK (Ack=15, Arwnd=106496) NetPerfMeter Add Flow +70 2.012723649 192.168.0.27 → 192.168.0.20 SCTP, NetPerfMeter 104 SACK (Ack=8, Arwnd=106496) NetPerfMeter Acknowledge +73 2.253277911 192.168.0.27 → 192.168.0.20 SCTP, NetPerfMeter 88 NetPerfMeter Acknowledge +77 2.259089003 192.168.0.20 → 192.168.0.27 SCTP, NetPerfMeter 276 SACK (Ack=17, Arwnd=106496) NetPerfMeter Add Flow +78 2.267758027 192.168.0.27 → 192.168.0.20 SCTP, NetPerfMeter 104 SACK (Ack=9, Arwnd=106496) NetPerfMeter Acknowledge +81 2.513148441 192.168.0.27 → 192.168.0.20 SCTP, NetPerfMeter 88 NetPerfMeter Acknowledge +85 2.519444777 192.168.0.20 → 192.168.0.27 SCTP, NetPerfMeter 276 SACK (Ack=19, Arwnd=106496) NetPerfMeter Add Flow +86 2.526479512 192.168.0.27 → 192.168.0.20 SCTP, NetPerfMeter 104 SACK (Ack=10, Arwnd=106496) NetPerfMeter Acknowledge +89 2.772395957 192.168.0.27 → 192.168.0.20 SCTP, NetPerfMeter 88 NetPerfMeter Acknowledge +93 2.781575331 192.168.0.20 → 192.168.0.27 SCTP, NetPerfMeter 276 SACK (Ack=21, Arwnd=106496) NetPerfMeter Add Flow +94 2.789065601 192.168.0.27 → 192.168.0.20 SCTP, NetPerfMeter 104 SACK (Ack=11, Arwnd=106496) NetPerfMeter Acknowledge +97 2.998736571 192.168.0.27 → 192.168.0.20 SCTP, NetPerfMeter 88 NetPerfMeter Acknowledge +101 3.005046187 192.168.0.20 → 192.168.0.27 SCTP, NetPerfMeter 276 SACK (Ack=23, Arwnd=106496) NetPerfMeter Add Flow +102 3.011025634 192.168.0.27 → 192.168.0.20 SCTP, NetPerfMeter 104 SACK (Ack=12, Arwnd=106496) NetPerfMeter Acknowledge +105 3.255120658 192.168.0.27 → 192.168.0.20 SCTP, NetPerfMeter 88 NetPerfMeter Acknowledge +109 3.262979723 192.168.0.20 → 192.168.0.27 SCTP, NetPerfMeter 276 SACK (Ack=25, Arwnd=106496) NetPerfMeter Add Flow +110 3.270638348 192.168.0.27 → 192.168.0.20 SCTP, NetPerfMeter 104 SACK (Ack=13, Arwnd=106496) NetPerfMeter Acknowledge +113 3.518145868 192.168.0.27 → 192.168.0.20 SCTP, NetPerfMeter 88 NetPerfMeter Acknowledge +118 3.536880998 192.168.0.20 → 192.168.0.27 SCTP, NetPerfMeter 276 SACK (Ack=27, Arwnd=106496) NetPerfMeter Add Flow +119 3.541489068 192.168.0.27 → 192.168.0.20 SCTP, NetPerfMeter 104 SACK (Ack=14, Arwnd=106496) NetPerfMeter Acknowledge +123 3.776536632 192.168.0.27 → 192.168.0.20 SCTP, NetPerfMeter 88 NetPerfMeter Acknowledge +124 3.777268092 192.168.0.20 → 192.168.0.27 SCTP, NetPerfMeter 276 SACK (Ack=29, Arwnd=106496) NetPerfMeter Add Flow +125 3.784200653 192.168.0.27 → 192.168.0.20 SCTP, NetPerfMeter 104 SACK (Ack=15, Arwnd=106496) NetPerfMeter Acknowledge +128 3.995220129 192.168.0.27 → 192.168.0.20 SCTP, NetPerfMeter 88 NetPerfMeter Acknowledge +129 3.995907203 192.168.0.20 → 192.168.0.27 SCTP, NetPerfMeter 276 SACK (Ack=31, Arwnd=106496) NetPerfMeter Add Flow +131 4.006264635 192.168.0.27 → 192.168.0.20 SCTP, NetPerfMeter 104 SACK (Ack=16, Arwnd=106496) NetPerfMeter Acknowledge +135 4.215292054 192.168.0.27 → 192.168.0.20 SCTP, NetPerfMeter 88 NetPerfMeter Acknowledge +136 4.216018889 192.168.0.20 → 192.168.0.27 SCTP, NetPerfMeter 276 SACK (Ack=33, Arwnd=106496) NetPerfMeter Add Flow +137 4.222906817 192.168.0.27 → 192.168.0.20 SCTP, NetPerfMeter 104 SACK (Ack=17, Arwnd=106496) NetPerfMeter Acknowledge +141 4.430858169 192.168.0.27 → 192.168.0.20 SCTP, NetPerfMeter 88 NetPerfMeter Acknowledge +142 4.431619137 192.168.0.20 → 192.168.0.27 SCTP, NetPerfMeter 276 SACK (Ack=35, Arwnd=106496) NetPerfMeter Add Flow +143 4.439186831 192.168.0.27 → 192.168.0.20 SCTP, NetPerfMeter 104 SACK (Ack=18, Arwnd=106496) NetPerfMeter Acknowledge +147 4.647960736 192.168.0.27 → 192.168.0.20 SCTP, NetPerfMeter 88 NetPerfMeter Acknowledge +148 4.648753903 192.168.0.20 → 192.168.0.27 SCTP, NetPerfMeter 276 SACK (Ack=37, Arwnd=106496) NetPerfMeter Add Flow +149 4.654062259 192.168.0.27 → 192.168.0.20 SCTP, NetPerfMeter 104 SACK (Ack=19, Arwnd=106496) NetPerfMeter Acknowledge +153 4.861696359 192.168.0.27 → 192.168.0.20 SCTP, NetPerfMeter 88 NetPerfMeter Acknowledge +158 4.881874024 192.168.0.20 → 192.168.0.27 SCTP, NetPerfMeter 276 SACK (Ack=39, Arwnd=106496) NetPerfMeter Add Flow +159 4.886932549 192.168.0.27 → 192.168.0.20 SCTP, NetPerfMeter 104 SACK (Ack=20, Arwnd=106496) NetPerfMeter Acknowledge +163 5.095411239 192.168.0.27 → 192.168.0.20 SCTP, NetPerfMeter 88 NetPerfMeter Acknowledge +184 5.101147570 192.168.0.20 → 192.168.0.27 SCTP, NetPerfMeter 96 SACK (Ack=41, Arwnd=106496) NetPerfMeter Start Measurement +227 5.315482367 192.168.0.27 → 192.168.0.20 SCTP, NetPerfMeter 88 NetPerfMeter Acknowledge +2084 15.615367349 192.168.0.20 → 192.168.0.27 SCTP, NetPerfMeter 80 NetPerfMeter Stop Measurement +2086 16.091680420 192.168.0.27 → 192.168.0.20 SCTP, NetPerfMeter 88 NetPerfMeter Acknowledge +2087 16.092542043 192.168.0.27 → 192.168.0.20 SCTP, NetPerfMeter 1468 NetPerfMeter Results +2088 16.092542469 192.168.0.27 → 192.168.0.20 SCTP, NetPerfMeter 1468 NetPerfMeter Results +2089 16.092542579 192.168.0.27 → 192.168.0.20 SCTP, NetPerfMeter 1468 NetPerfMeter Results +2090 16.092542691 192.168.0.27 → 192.168.0.20 SCTP, NetPerfMeter 1468 NetPerfMeter Results +2093 16.098744445 192.168.0.27 → 192.168.0.20 SCTP, NetPerfMeter 1468 NetPerfMeter Results +2095 16.099492702 192.168.0.27 → 192.168.0.20 SCTP, NetPerfMeter 1468 NetPerfMeter Results +2096 16.099493075 192.168.0.27 → 192.168.0.20 SCTP, NetPerfMeter 1468 NetPerfMeter Results +2097 16.099493204 192.168.0.27 → 192.168.0.20 SCTP, NetPerfMeter 1468 NetPerfMeter Results +2098 16.099493337 192.168.0.27 → 192.168.0.20 SCTP, NetPerfMeter 1468 NetPerfMeter Results +2101 16.108240278 192.168.0.27 → 192.168.0.20 SCTP, NetPerfMeter 1468 NetPerfMeter Results +2102 16.109665125 192.168.0.27 → 192.168.0.20 SCTP, NetPerfMeter 1468 NetPerfMeter Results +2103 16.109665219 192.168.0.27 → 192.168.0.20 SCTP, NetPerfMeter 1468 NetPerfMeter Results +2104 16.109665258 192.168.0.27 → 192.168.0.20 SCTP, NetPerfMeter 1468 NetPerfMeter Results +2105 16.109665298 192.168.0.27 → 192.168.0.20 SCTP, NetPerfMeter 1468 NetPerfMeter Results +2106 16.109665335 192.168.0.27 → 192.168.0.20 SCTP, NetPerfMeter 1468 NetPerfMeter Results +2107 16.109665374 192.168.0.27 → 192.168.0.20 SCTP, NetPerfMeter 1468 NetPerfMeter Results +2108 16.109665413 192.168.0.27 → 192.168.0.20 SCTP, NetPerfMeter 1468 NetPerfMeter Results +2109 16.109665451 192.168.0.27 → 192.168.0.20 SCTP, NetPerfMeter 1468 NetPerfMeter Results +2114 16.115534573 192.168.0.27 → 192.168.0.20 SCTP, NetPerfMeter 1468 NetPerfMeter Results +2116 16.117085522 192.168.0.27 → 192.168.0.20 SCTP, NetPerfMeter 1468 NetPerfMeter Results +2117 16.117085740 192.168.0.27 → 192.168.0.20 SCTP, NetPerfMeter 1468 NetPerfMeter Results +2118 16.117085774 192.168.0.27 → 192.168.0.20 SCTP, NetPerfMeter 1468 NetPerfMeter Results +2119 16.117085808 192.168.0.27 → 192.168.0.20 SCTP, NetPerfMeter 1468 NetPerfMeter Results +2120 16.117085841 192.168.0.27 → 192.168.0.20 SCTP, NetPerfMeter 1468 NetPerfMeter Results +2121 16.117085874 192.168.0.27 → 192.168.0.20 SCTP, NetPerfMeter 1468 NetPerfMeter Results +2122 16.117085906 192.168.0.27 → 192.168.0.20 SCTP, NetPerfMeter 1468 NetPerfMeter Results +2123 16.117085940 192.168.0.27 → 192.168.0.20 SCTP, NetPerfMeter 1468 NetPerfMeter Results +2125 16.117208639 192.168.0.27 → 192.168.0.20 SCTP, NetPerfMeter 1468 NetPerfMeter Results +2129 16.117847682 192.168.0.27 → 192.168.0.20 SCTP, NetPerfMeter 1468 NetPerfMeter Results +2131 16.120936939 192.168.0.27 → 192.168.0.20 SCTP, NetPerfMeter 1468 NetPerfMeter Results +2132 16.121564917 192.168.0.27 → 192.168.0.20 SCTP, NetPerfMeter 1468 NetPerfMeter Results +2134 16.124001266 192.168.0.27 → 192.168.0.20 SCTP, NetPerfMeter 1468 NetPerfMeter Results +2135 16.126359615 192.168.0.27 → 192.168.0.20 SCTP, NetPerfMeter 1468 NetPerfMeter Results +2136 16.126359784 192.168.0.27 → 192.168.0.20 SCTP, NetPerfMeter 1468 NetPerfMeter Results +2137 16.126359829 192.168.0.27 → 192.168.0.20 SCTP, NetPerfMeter 1468 NetPerfMeter Results +2138 16.126359875 192.168.0.27 → 192.168.0.20 SCTP, NetPerfMeter 1468 NetPerfMeter Results +2139 16.126359923 192.168.0.27 → 192.168.0.20 SCTP, NetPerfMeter 1468 NetPerfMeter Results +2140 16.126359972 192.168.0.27 → 192.168.0.20 SCTP, NetPerfMeter 1468 NetPerfMeter Results +2141 16.126360016 192.168.0.27 → 192.168.0.20 SCTP, NetPerfMeter 1468 NetPerfMeter Results +2142 16.126360065 192.168.0.27 → 192.168.0.20 SCTP, NetPerfMeter 1468 NetPerfMeter Results +2144 16.126516782 192.168.0.27 → 192.168.0.20 SCTP, NetPerfMeter 1468 NetPerfMeter Results +2145 16.126516838 192.168.0.27 → 192.168.0.20 SCTP, NetPerfMeter 1468 NetPerfMeter Results +2150 16.126568776 192.168.0.27 → 192.168.0.20 SCTP, NetPerfMeter 1468 NetPerfMeter Results +2151 16.126568857 192.168.0.27 → 192.168.0.20 SCTP, NetPerfMeter 1468 NetPerfMeter Results +2152 16.126568903 192.168.0.27 → 192.168.0.20 SCTP, NetPerfMeter 1468 NetPerfMeter Results +2153 16.126568947 192.168.0.27 → 192.168.0.20 SCTP, NetPerfMeter 1088 NetPerfMeter Results +2154 16.126568990 192.168.0.27 → 192.168.0.20 SCTP, NetPerfMeter 1468 NetPerfMeter Results +2155 16.126569037 192.168.0.27 → 192.168.0.20 SCTP, NetPerfMeter 1468 NetPerfMeter Results +2156 16.126569084 192.168.0.27 → 192.168.0.20 SCTP, NetPerfMeter 1468 NetPerfMeter Results +2162 16.128296076 192.168.0.27 → 192.168.0.20 SCTP, NetPerfMeter 1468 NetPerfMeter Results +2163 16.128991998 192.168.0.27 → 192.168.0.20 SCTP, NetPerfMeter 1468 NetPerfMeter Results +2164 16.128992266 192.168.0.27 → 192.168.0.20 SCTP, NetPerfMeter 1468 NetPerfMeter Results +2166 16.132186659 192.168.0.27 → 192.168.0.20 SCTP, NetPerfMeter 1468 NetPerfMeter Results +2168 16.133696852 192.168.0.27 → 192.168.0.20 SCTP, NetPerfMeter 1468 NetPerfMeter Results +2169 16.133697204 192.168.0.27 → 192.168.0.20 SCTP, NetPerfMeter 1468 NetPerfMeter Results +2170 16.133697304 192.168.0.27 → 192.168.0.20 SCTP, NetPerfMeter 1468 NetPerfMeter Results +2171 16.133697400 192.168.0.27 → 192.168.0.20 SCTP, NetPerfMeter 1468 NetPerfMeter Results +2172 16.133697505 192.168.0.27 → 192.168.0.20 SCTP, NetPerfMeter 1468 NetPerfMeter Results +2175 16.136109923 192.168.0.27 → 192.168.0.20 SCTP, NetPerfMeter 1468 NetPerfMeter Results +2177 16.138000289 192.168.0.27 → 192.168.0.20 SCTP, NetPerfMeter 1468 NetPerfMeter Results +2178 16.138000795 192.168.0.27 → 192.168.0.20 SCTP, NetPerfMeter 1468 NetPerfMeter Results +2179 16.138000952 192.168.0.27 → 192.168.0.20 SCTP, NetPerfMeter 1468 NetPerfMeter Results +2180 16.138001087 192.168.0.27 → 192.168.0.20 SCTP, NetPerfMeter 1468 NetPerfMeter Results +2181 16.138001222 192.168.0.27 → 192.168.0.20 SCTP, NetPerfMeter 1468 NetPerfMeter Results +2182 16.138001355 192.168.0.27 → 192.168.0.20 SCTP, NetPerfMeter 1468 NetPerfMeter Results +2183 16.138001497 192.168.0.27 → 192.168.0.20 SCTP, NetPerfMeter 1468 NetPerfMeter Results +2184 16.138001654 192.168.0.27 → 192.168.0.20 SCTP, NetPerfMeter 1468 NetPerfMeter Results +2189 16.138407582 192.168.0.27 → 192.168.0.20 SCTP, NetPerfMeter 1468 NetPerfMeter Results +2190 16.138407852 192.168.0.27 → 192.168.0.20 SCTP, NetPerfMeter 1468 NetPerfMeter Results +2191 16.138407948 192.168.0.27 → 192.168.0.20 SCTP, NetPerfMeter 1360 NetPerfMeter Results +2193 16.138949169 192.168.0.20 → 192.168.0.27 SCTP, NetPerfMeter 100 SACK (Ack=113, Arwnd=106496) NetPerfMeter Remove Flow +2194 16.147965640 192.168.0.27 → 192.168.0.20 SCTP, NetPerfMeter 104 SACK (Ack=23, Arwnd=106496) NetPerfMeter Acknowledge +2195 16.149160472 192.168.0.27 → 192.168.0.20 SCTP, NetPerfMeter 1468 NetPerfMeter Results +2197 16.149694877 192.168.0.27 → 192.168.0.20 SCTP, NetPerfMeter 1468 NetPerfMeter Results +2199 16.359112863 192.168.0.27 → 192.168.0.20 SCTP, NetPerfMeter 400 NetPerfMeter Results +2200 16.360439472 192.168.0.20 → 192.168.0.27 SCTP, NetPerfMeter 100 SACK (Ack=117, Arwnd=106496) NetPerfMeter Remove Flow +2201 16.367838301 192.168.0.27 → 192.168.0.20 SCTP, NetPerfMeter 104 SACK (Ack=24, Arwnd=106496) NetPerfMeter Acknowledge +2202 16.369999711 192.168.0.27 → 192.168.0.20 SCTP, NetPerfMeter 1468 NetPerfMeter Results +2204 16.370249698 192.168.0.27 → 192.168.0.20 SCTP, NetPerfMeter 252 NetPerfMeter Results +2205 16.371333521 192.168.0.20 → 192.168.0.27 SCTP, NetPerfMeter 100 SACK (Ack=120, Arwnd=106496) NetPerfMeter Remove Flow +2206 16.377931209 192.168.0.27 → 192.168.0.20 SCTP, NetPerfMeter 104 SACK (Ack=25, Arwnd=106496) NetPerfMeter Acknowledge +2207 16.379416052 192.168.0.27 → 192.168.0.20 SCTP, NetPerfMeter 1468 NetPerfMeter Results +2209 16.379921676 192.168.0.27 → 192.168.0.20 SCTP, NetPerfMeter 1468 NetPerfMeter Results +2211 16.586758032 192.168.0.27 → 192.168.0.20 SCTP, NetPerfMeter 460 NetPerfMeter Results +2212 16.588004878 192.168.0.20 → 192.168.0.27 SCTP, NetPerfMeter 100 SACK (Ack=124, Arwnd=106496) NetPerfMeter Remove Flow +2213 16.596287178 192.168.0.27 → 192.168.0.20 SCTP, NetPerfMeter 104 SACK (Ack=26, Arwnd=106496) NetPerfMeter Acknowledge +2214 16.600862615 192.168.0.27 → 192.168.0.20 SCTP, NetPerfMeter 1468 NetPerfMeter Results +2216 16.601572074 192.168.0.27 → 192.168.0.20 SCTP, NetPerfMeter 256 NetPerfMeter Results +2217 16.602770488 192.168.0.20 → 192.168.0.27 SCTP, NetPerfMeter 100 SACK (Ack=127, Arwnd=106496) NetPerfMeter Remove Flow +2218 16.608528578 192.168.0.27 → 192.168.0.20 SCTP, NetPerfMeter 104 SACK (Ack=27, Arwnd=106496) NetPerfMeter Acknowledge +2219 16.610851595 192.168.0.27 → 192.168.0.20 SCTP, NetPerfMeter 1468 NetPerfMeter Results +2221 16.611228721 192.168.0.27 → 192.168.0.20 SCTP, NetPerfMeter 1468 NetPerfMeter Results +2224 16.820428495 192.168.0.27 → 192.168.0.20 SCTP, NetPerfMeter 368 NetPerfMeter Results +2226 16.821725312 192.168.0.20 → 192.168.0.27 SCTP, NetPerfMeter 100 SACK (Ack=131, Arwnd=106496) NetPerfMeter Remove Flow +2227 16.829665670 192.168.0.27 → 192.168.0.20 SCTP, NetPerfMeter 104 SACK (Ack=28, Arwnd=106496) NetPerfMeter Acknowledge +2228 16.831477557 192.168.0.27 → 192.168.0.20 SCTP, NetPerfMeter 1468 NetPerfMeter Results +2230 16.831711400 192.168.0.27 → 192.168.0.20 SCTP, NetPerfMeter 276 NetPerfMeter Results +2233 16.832859448 192.168.0.20 → 192.168.0.27 SCTP, NetPerfMeter 100 SACK (Ack=134, Arwnd=106496) NetPerfMeter Remove Flow +2235 16.838963861 192.168.0.27 → 192.168.0.20 SCTP, NetPerfMeter 104 SACK (Ack=29, Arwnd=106496) NetPerfMeter Acknowledge +2236 16.839917250 192.168.0.27 → 192.168.0.20 SCTP, NetPerfMeter 1468 NetPerfMeter Results +2238 16.841055807 192.168.0.27 → 192.168.0.20 SCTP, NetPerfMeter 236 NetPerfMeter Results +2241 16.842312060 192.168.0.20 → 192.168.0.27 SCTP, NetPerfMeter 100 SACK (Ack=137, Arwnd=106496) NetPerfMeter Remove Flow +2243 16.847748197 192.168.0.27 → 192.168.0.20 SCTP, NetPerfMeter 104 SACK (Ack=30, Arwnd=106496) NetPerfMeter Acknowledge +2244 16.848933463 192.168.0.27 → 192.168.0.20 SCTP, NetPerfMeter 1468 NetPerfMeter Results +2246 16.849525492 192.168.0.27 → 192.168.0.20 SCTP, NetPerfMeter 236 NetPerfMeter Results +2249 16.850661714 192.168.0.20 → 192.168.0.27 SCTP, NetPerfMeter 100 SACK (Ack=140, Arwnd=106496) NetPerfMeter Remove Flow +2251 16.857615760 192.168.0.27 → 192.168.0.20 SCTP, NetPerfMeter 104 SACK (Ack=31, Arwnd=106496) NetPerfMeter Acknowledge +2252 16.859140443 192.168.0.27 → 192.168.0.20 SCTP, NetPerfMeter 1468 NetPerfMeter Results +2254 16.859653107 192.168.0.27 → 192.168.0.20 SCTP, NetPerfMeter 976 NetPerfMeter Results +2257 16.860923512 192.168.0.20 → 192.168.0.27 SCTP, NetPerfMeter 100 SACK (Ack=143, Arwnd=106496) NetPerfMeter Remove Flow +2259 16.866293943 192.168.0.27 → 192.168.0.20 SCTP, NetPerfMeter 104 SACK (Ack=32, Arwnd=106496) NetPerfMeter Acknowledge +2260 16.867822941 192.168.0.27 → 192.168.0.20 SCTP, NetPerfMeter 1468 NetPerfMeter Results +2262 16.868668201 192.168.0.27 → 192.168.0.20 SCTP, NetPerfMeter 1468 NetPerfMeter Results +2265 17.079265007 192.168.0.27 → 192.168.0.20 SCTP, NetPerfMeter 368 NetPerfMeter Results +2267 17.080555093 192.168.0.20 → 192.168.0.27 SCTP, NetPerfMeter 100 SACK (Ack=147, Arwnd=106496) NetPerfMeter Remove Flow +2268 17.089928582 192.168.0.27 → 192.168.0.20 SCTP, NetPerfMeter 104 SACK (Ack=33, Arwnd=106496) NetPerfMeter Acknowledge +2269 17.091479195 192.168.0.27 → 192.168.0.20 SCTP, NetPerfMeter 1468 NetPerfMeter Results +2271 17.092073003 192.168.0.27 → 192.168.0.20 SCTP, NetPerfMeter 272 NetPerfMeter Results +2274 17.093044526 192.168.0.20 → 192.168.0.27 SCTP, NetPerfMeter 100 SACK (Ack=150, Arwnd=106496) NetPerfMeter Remove Flow +2276 17.099098185 192.168.0.27 → 192.168.0.20 SCTP, NetPerfMeter 104 SACK (Ack=34, Arwnd=106496) NetPerfMeter Acknowledge +2277 17.100201203 192.168.0.27 → 192.168.0.20 SCTP, NetPerfMeter 1468 NetPerfMeter Results +2279 17.100852674 192.168.0.27 → 192.168.0.20 SCTP, NetPerfMeter 244 NetPerfMeter Results +2282 17.101916382 192.168.0.20 → 192.168.0.27 SCTP, NetPerfMeter 100 SACK (Ack=153, Arwnd=106496) NetPerfMeter Remove Flow +2284 17.109026614 192.168.0.27 → 192.168.0.20 SCTP, NetPerfMeter 104 SACK (Ack=35, Arwnd=106496) NetPerfMeter Acknowledge +2285 17.112907819 192.168.0.27 → 192.168.0.20 SCTP, NetPerfMeter 1468 NetPerfMeter Results +2287 17.115302865 192.168.0.27 → 192.168.0.20 SCTP, NetPerfMeter 244 NetPerfMeter Results +2290 17.116443045 192.168.0.20 → 192.168.0.27 SCTP, NetPerfMeter 100 SACK (Ack=156, Arwnd=106496) NetPerfMeter Remove Flow +2292 17.122058351 192.168.0.27 → 192.168.0.20 SCTP, NetPerfMeter 104 SACK (Ack=36, Arwnd=106496) NetPerfMeter Acknowledge +2293 17.125840461 192.168.0.27 → 192.168.0.20 SCTP, NetPerfMeter 1468 NetPerfMeter Results +2295 17.126459769 192.168.0.27 → 192.168.0.20 SCTP, NetPerfMeter 976 NetPerfMeter Results +2297 17.126760188 192.168.0.20 → 192.168.0.27 SCTP, NetPerfMeter 100 SACK (Ack=159, Arwnd=106496) NetPerfMeter Remove Flow +2300 17.132579296 192.168.0.27 → 192.168.0.20 SCTP, NetPerfMeter 104 SACK (Ack=37, Arwnd=106496) NetPerfMeter Acknowledge +2301 17.133301477 192.168.0.27 → 192.168.0.20 SCTP, NetPerfMeter 1468 NetPerfMeter Results +2302 17.133302153 192.168.0.27 → 192.168.0.20 SCTP, NetPerfMeter 284 NetPerfMeter Results +2304 17.133706810 192.168.0.20 → 192.168.0.27 SCTP, NetPerfMeter 100 SACK (Ack=162, Arwnd=106496) NetPerfMeter Remove Flow +2305 17.138731552 192.168.0.27 → 192.168.0.20 SCTP, NetPerfMeter 104 SACK (Ack=38, Arwnd=106496) NetPerfMeter Acknowledge +2306 17.139818471 192.168.0.27 → 192.168.0.20 SCTP, NetPerfMeter 1468 NetPerfMeter Results +2308 17.140335127 192.168.0.27 → 192.168.0.20 SCTP, NetPerfMeter 288 NetPerfMeter Results +2309 17.140830809 192.168.0.20 → 192.168.0.27 SCTP, NetPerfMeter 100 SACK (Ack=165, Arwnd=106496) NetPerfMeter Remove Flow +2310 17.145622016 192.168.0.27 → 192.168.0.20 SCTP, NetPerfMeter 104 SACK (Ack=39, Arwnd=106496) NetPerfMeter Acknowledge +2311 17.147059541 192.168.0.27 → 192.168.0.20 SCTP, NetPerfMeter 1468 NetPerfMeter Results +2313 17.148571671 192.168.0.27 → 192.168.0.20 SCTP, NetPerfMeter 1468 NetPerfMeter Results +2314 17.149475099 192.168.0.27 → 192.168.0.20 SCTP, NetPerfMeter 1468 NetPerfMeter Results +2316 17.150223037 192.168.0.27 → 192.168.0.20 SCTP, NetPerfMeter 1468 NetPerfMeter Results +2318 17.359940788 192.168.0.27 → 192.168.0.20 SCTP, NetPerfMeter 740 NetPerfMeter Results +2319 17.361102522 192.168.0.20 → 192.168.0.27 SCTP, NetPerfMeter 100 SACK (Ack=171, Arwnd=106496) NetPerfMeter Remove Flow +2320 17.368203507 192.168.0.27 → 192.168.0.20 SCTP, NetPerfMeter 104 SACK (Ack=40, Arwnd=106496) NetPerfMeter Acknowledge +2321 17.370823736 192.168.0.27 → 192.168.0.20 SCTP, NetPerfMeter 1468 NetPerfMeter Results +2323 17.371236232 192.168.0.27 → 192.168.0.20 SCTP, NetPerfMeter 280 NetPerfMeter Results +2324 17.372205596 192.168.0.20 → 192.168.0.27 SCTP, NetPerfMeter 100 SACK (Ack=174, Arwnd=106496) NetPerfMeter Remove Flow +2325 17.378113171 192.168.0.27 → 192.168.0.20 SCTP, NetPerfMeter 104 SACK (Ack=41, Arwnd=106496) NetPerfMeter Acknowledge +2326 17.379408121 192.168.0.27 → 192.168.0.20 SCTP, NetPerfMeter 1468 NetPerfMeter Results +2328 17.379940226 192.168.0.27 → 192.168.0.20 SCTP, NetPerfMeter 284 NetPerfMeter Results +2329 17.380772832 192.168.0.20 → 192.168.0.27 SCTP, NetPerfMeter 100 SACK (Ack=177, Arwnd=106496) NetPerfMeter Remove Flow +2330 17.389000119 192.168.0.27 → 192.168.0.20 SCTP, NetPerfMeter 104 SACK (Ack=42, Arwnd=106496) NetPerfMeter Acknowledge +2331 17.389893116 192.168.0.27 → 192.168.0.20 SCTP, NetPerfMeter 1468 NetPerfMeter Results +2332 17.389893325 192.168.0.27 → 192.168.0.20 SCTP, NetPerfMeter 380 NetPerfMeter Results +2334 17.390667295 192.168.0.20 → 192.168.0.27 SCTP, NetPerfMeter 100 SACK (Ack=180, Arwnd=106496) NetPerfMeter Remove Flow +2335 17.395701306 192.168.0.27 → 192.168.0.20 SCTP, NetPerfMeter 104 SACK (Ack=43, Arwnd=106496) NetPerfMeter Acknowledge +2336 17.397791412 192.168.0.27 → 192.168.0.20 SCTP, NetPerfMeter 1468 NetPerfMeter Results +2338 17.398332887 192.168.0.27 → 192.168.0.20 SCTP, NetPerfMeter 284 NetPerfMeter Results +""".replace("\r\n", "\n") in result + + def test_netperfmeter_test_udp(self, cmd_tshark, capture_file, test_env): + '''Checks whether the NetPerfMeter dissector correctly handles NetPerfMeter Data via UDP.''' + + # Test: Identify and decode NetPerfMeter Data via UDP + stdout = subprocess.check_output((cmd_tshark, + '-r', capture_file('netperfmeter.pcapng.gz'), + '-Y', 'frame.number >= 1 && frame.number <= 512 && udp && netperfmeter' + ), + encoding='utf-8', env=test_env) + + result = ''.join([x.strip()+"\n" for x in stdout.splitlines()]) + + assert """\ +26 0.556893098 192.168.0.20 → 192.168.0.27 UDP, NetPerfMeter 70 NetPerfMeter Identify Flow +31 0.778199411 192.168.0.20 → 192.168.0.27 UDP, NetPerfMeter 70 NetPerfMeter Identify Flow +166 5.097058561 192.168.0.20 → 192.168.0.27 UDP, NetPerfMeter 1068 NetPerfMeter Data +167 5.097156368 192.168.0.20 → 192.168.0.27 UDP, NetPerfMeter 556 NetPerfMeter Data +203 5.188581678 192.168.0.27 → 192.168.0.20 UDP, NetPerfMeter 1068 NetPerfMeter Data +204 5.198869201 192.168.0.27 → 192.168.0.20 UDP, NetPerfMeter 556 NetPerfMeter Data +229 5.347412858 192.168.0.20 → 192.168.0.27 UDP, NetPerfMeter 1068 NetPerfMeter Data +248 5.521667162 192.168.0.27 → 192.168.0.20 UDP, NetPerfMeter 1068 NetPerfMeter Data +249 5.529727434 192.168.0.27 → 192.168.0.20 UDP, NetPerfMeter 556 NetPerfMeter Data +251 5.597939044 192.168.0.20 → 192.168.0.27 UDP, NetPerfMeter 1068 NetPerfMeter Data +252 5.597979296 192.168.0.20 → 192.168.0.27 UDP, NetPerfMeter 556 NetPerfMeter Data +315 5.848599107 192.168.0.20 → 192.168.0.27 UDP, NetPerfMeter 1068 NetPerfMeter Data +326 5.869626418 192.168.0.27 → 192.168.0.20 UDP, NetPerfMeter 1068 NetPerfMeter Data +327 5.870477253 192.168.0.27 → 192.168.0.20 UDP, NetPerfMeter 556 NetPerfMeter Data +336 6.099006262 192.168.0.20 → 192.168.0.27 UDP, NetPerfMeter 1068 NetPerfMeter Data +337 6.099035694 192.168.0.20 → 192.168.0.27 UDP, NetPerfMeter 556 NetPerfMeter Data +374 6.239221234 192.168.0.27 → 192.168.0.20 UDP, NetPerfMeter 1068 NetPerfMeter Data +375 6.240243736 192.168.0.27 → 192.168.0.20 UDP, NetPerfMeter 556 NetPerfMeter Data +406 6.349592731 192.168.0.20 → 192.168.0.27 UDP, NetPerfMeter 1068 NetPerfMeter Data +429 6.538916191 192.168.0.27 → 192.168.0.20 UDP, NetPerfMeter 1068 NetPerfMeter Data +430 6.540208385 192.168.0.27 → 192.168.0.20 UDP, NetPerfMeter 556 NetPerfMeter Data +438 6.600112279 192.168.0.20 → 192.168.0.27 UDP, NetPerfMeter 556 NetPerfMeter Data +439 6.600127896 192.168.0.20 → 192.168.0.27 UDP, NetPerfMeter 1068 NetPerfMeter Data +499 6.850796522 192.168.0.20 → 192.168.0.27 UDP, NetPerfMeter 1068 NetPerfMeter Data +509 6.874579699 192.168.0.27 → 192.168.0.20 UDP, NetPerfMeter 1068 NetPerfMeter Data +510 6.875289205 192.168.0.27 → 192.168.0.20 UDP, NetPerfMeter 556 NetPerfMeter Data +""".replace("\r\n", "\n") in result + + def test_netperfmeter_test_dccp(self, cmd_tshark, capture_file, test_env): + '''Checks whether the NetPerfMeter dissector correctly handles NetPerfMeter Data via DCCP.''' + + # Test: Identify and decode NetPerfMeter Data via DCCP + stdout = subprocess.check_output((cmd_tshark, + '-r', capture_file('netperfmeter.pcapng.gz'), + '-Y', 'frame.number >= 1 && frame.number <= 256 && dccp && netperfmeter' + ), + encoding='utf-8', env=test_env) + + result = ''.join([x.strip()+"\n" for x in stdout.splitlines()]) + + assert """\ +39 1.000448305 192.168.0.20 → 192.168.0.27 DCCP, NetPerfMeter 106 NetPerfMeter Identify Flow +47 1.257376250 192.168.0.20 → 192.168.0.27 DCCP, NetPerfMeter 106 NetPerfMeter Identify Flow +55 1.518626642 192.168.0.20 → 192.168.0.27 DCCP, NetPerfMeter 106 NetPerfMeter Identify Flow +63 1.776552210 192.168.0.20 → 192.168.0.27 DCCP, NetPerfMeter 106 NetPerfMeter Identify Flow +71 2.013038051 192.168.0.20 → 192.168.0.27 DCCP, NetPerfMeter 106 NetPerfMeter Identify Flow +79 2.268029558 192.168.0.20 → 192.168.0.27 DCCP, NetPerfMeter 106 NetPerfMeter Identify Flow +87 2.526765502 192.168.0.20 → 192.168.0.27 DCCP, NetPerfMeter 106 NetPerfMeter Identify Flow +95 2.789401573 192.168.0.20 → 192.168.0.27 DCCP, NetPerfMeter 106 NetPerfMeter Identify Flow +103 3.011188128 192.168.0.20 → 192.168.0.27 DCCP, NetPerfMeter 106 NetPerfMeter Identify Flow +111 3.270945041 192.168.0.20 → 192.168.0.27 DCCP, NetPerfMeter 106 NetPerfMeter Identify Flow +168 5.097388740 192.168.0.20 → 192.168.0.27 DCCP, NetPerfMeter 1112 NetPerfMeter Data +169 5.097563303 192.168.0.20 → 192.168.0.27 DCCP, NetPerfMeter 1112 NetPerfMeter Data +170 5.097680252 192.168.0.20 → 192.168.0.27 DCCP, NetPerfMeter 600 NetPerfMeter Data +171 5.097804675 192.168.0.20 → 192.168.0.27 DCCP, NetPerfMeter 600 NetPerfMeter Data +172 5.097860862 192.168.0.20 → 192.168.0.27 DCCP, NetPerfMeter 336 NetPerfMeter Data +173 5.097960425 192.168.0.20 → 192.168.0.27 DCCP, NetPerfMeter 1104 NetPerfMeter Data +174 5.098168605 192.168.0.20 → 192.168.0.27 DCCP, NetPerfMeter 1104 NetPerfMeter Data +175 5.098268064 192.168.0.20 → 192.168.0.27 DCCP, NetPerfMeter 592 NetPerfMeter Data +176 5.098379939 192.168.0.20 → 192.168.0.27 DCCP, NetPerfMeter 592 NetPerfMeter Data +177 5.098474409 192.168.0.20 → 192.168.0.27 DCCP, NetPerfMeter 336 NetPerfMeter Data +205 5.203489906 192.168.0.27 → 192.168.0.20 DCCP, NetPerfMeter 1088 NetPerfMeter Data +206 5.208120579 192.168.0.27 → 192.168.0.20 DCCP, NetPerfMeter 1088 NetPerfMeter Data +207 5.211621270 192.168.0.27 → 192.168.0.20 DCCP, NetPerfMeter 576 NetPerfMeter Data +208 5.216629302 192.168.0.27 → 192.168.0.20 DCCP, NetPerfMeter 576 NetPerfMeter Data +209 5.218637208 192.168.0.27 → 192.168.0.20 DCCP, NetPerfMeter 320 NetPerfMeter Data +210 5.220923234 192.168.0.27 → 192.168.0.20 DCCP, NetPerfMeter 1088 NetPerfMeter Data +211 5.224470647 192.168.0.27 → 192.168.0.20 DCCP, NetPerfMeter 1088 NetPerfMeter Data +212 5.228633904 192.168.0.27 → 192.168.0.20 DCCP, NetPerfMeter 576 NetPerfMeter Data +213 5.235096316 192.168.0.27 → 192.168.0.20 DCCP, NetPerfMeter 576 NetPerfMeter Data +214 5.235387030 192.168.0.27 → 192.168.0.20 DCCP, NetPerfMeter 320 NetPerfMeter Data +230 5.347723929 192.168.0.20 → 192.168.0.27 DCCP, NetPerfMeter 1088 NetPerfMeter Data +231 5.348299245 192.168.0.20 → 192.168.0.27 DCCP, NetPerfMeter 1088 NetPerfMeter Data +236 5.432621676 192.168.0.20 → 192.168.0.27 DCCP, NetPerfMeter 320 NetPerfMeter Data +237 5.433090508 192.168.0.20 → 192.168.0.27 DCCP, NetPerfMeter 320 NetPerfMeter Data +238 5.458215001 192.168.0.27 → 192.168.0.20 DCCP, NetPerfMeter 1104 NetPerfMeter Data +240 5.472252869 192.168.0.27 → 192.168.0.20 DCCP, NetPerfMeter 1104 NetPerfMeter Data +250 5.597889485 192.168.0.20 → 192.168.0.27 DCCP, NetPerfMeter 1096 NetPerfMeter Data +255 5.598126766 192.168.0.20 → 192.168.0.27 DCCP, NetPerfMeter 1088 NetPerfMeter Data +256 5.598378615 192.168.0.20 → 192.168.0.27 DCCP, NetPerfMeter 576 NetPerfMeter Data +""".replace("\r\n", "\n") in result + + def test_netperfmeter_test_tcp(self, cmd_tshark, capture_file, test_env): + '''Checks whether the NetPerfMeter dissector correctly handles NetPerfMeter Data via TCP.''' + + # Test: Identify and decode NetPerfMeter Data via TCP + stdout = subprocess.check_output((cmd_tshark, + '-r', capture_file('netperfmeter.pcapng.gz'), + '-Y', 'frame.number >= 1 && frame.number <= 512 && tcp && netperfmeter' + ), + encoding='utf-8', env=test_env) + + result = ''.join([x.strip()+"\n" for x in stdout.splitlines()]) + + assert """\ +12 0.038833197 192.168.0.20 → 192.168.0.27 TCP, NetPerfMeter 94 NetPerfMeter Identify Flow +20 0.340423798 192.168.0.20 → 192.168.0.27 TCP, NetPerfMeter 94 NetPerfMeter Identify Flow +164 5.096822593 192.168.0.20 → 192.168.0.27 TCP, NetPerfMeter 1092 NetPerfMeter Data +165 5.096933125 192.168.0.20 → 192.168.0.27 TCP, NetPerfMeter 580 NetPerfMeter Data +199 5.180197902 192.168.0.27 → 192.168.0.20 TCP, NetPerfMeter 1092 NetPerfMeter Data +201 5.183618768 192.168.0.27 → 192.168.0.20 TCP, NetPerfMeter 580 NetPerfMeter Data +228 5.347212980 192.168.0.20 → 192.168.0.27 TCP, NetPerfMeter 1092 NetPerfMeter Data +243 5.510843364 192.168.0.27 → 192.168.0.20 TCP, NetPerfMeter 1092 NetPerfMeter Data +246 5.518285725 192.168.0.27 → 192.168.0.20 TCP, NetPerfMeter 580 NetPerfMeter Data +253 5.598004664 192.168.0.20 → 192.168.0.27 TCP, NetPerfMeter 580 NetPerfMeter Data +254 5.598037007 192.168.0.20 → 192.168.0.27 TCP, NetPerfMeter 1092 NetPerfMeter Data +313 5.843608886 192.168.0.27 → 192.168.0.20 TCP, NetPerfMeter 1092 NetPerfMeter Data +316 5.848649435 192.168.0.20 → 192.168.0.27 TCP, NetPerfMeter 1092 NetPerfMeter Data +320 5.852294838 192.168.0.27 → 192.168.0.20 TCP, NetPerfMeter 580 NetPerfMeter Data +335 6.098962324 192.168.0.20 → 192.168.0.27 TCP, NetPerfMeter 580 NetPerfMeter Data +342 6.099194942 192.168.0.20 → 192.168.0.27 TCP, NetPerfMeter 1092 NetPerfMeter Data +370 6.178557080 192.168.0.27 → 192.168.0.20 TCP, NetPerfMeter 1092 NetPerfMeter Data +372 6.186668259 192.168.0.27 → 192.168.0.20 TCP, NetPerfMeter 580 NetPerfMeter Data +408 6.349677977 192.168.0.20 → 192.168.0.27 TCP, NetPerfMeter 1092 NetPerfMeter Data +425 6.512522597 192.168.0.27 → 192.168.0.20 TCP, NetPerfMeter 1092 NetPerfMeter Data +427 6.521373219 192.168.0.27 → 192.168.0.20 TCP, NetPerfMeter 580 NetPerfMeter Data +436 6.600056667 192.168.0.20 → 192.168.0.27 TCP, NetPerfMeter 580 NetPerfMeter Data +441 6.600170332 192.168.0.20 → 192.168.0.27 TCP, NetPerfMeter 1092 NetPerfMeter Data +497 6.846781911 192.168.0.27 → 192.168.0.20 TCP, NetPerfMeter 1092 NetPerfMeter Data +502 6.850917051 192.168.0.20 → 192.168.0.27 TCP, NetPerfMeter 1092 NetPerfMeter Data +507 6.857231771 192.168.0.27 → 192.168.0.20 TCP, NetPerfMeter 580 NetPerfMeter Data +""".replace("\r\n", "\n") in result + + def test_netperfmeter_test_sctp(self, cmd_tshark, capture_file, test_env): + '''Checks whether the NetPerfMeter dissector correctly handles NetPerfMeter Data via SCTP.''' + + # Test: Identify and decode NetPerfMeter Data via SCTP + stdout = subprocess.check_output((cmd_tshark, + '-r', capture_file('netperfmeter.pcapng.gz'), + '-Y', 'frame.number >= 1 && frame.number <= 256 && sctp && netperfmeter && ((netperfmeter.message_type == 5) || (netperfmeter.message_type == 4))' + ), + encoding='utf-8', env=test_env) + + result = ''.join([x.strip()+"\n" for x in stdout.splitlines()]) + + assert """\ +120 3.541753666 192.168.0.20 → 192.168.0.27 SCTP, NetPerfMeter 92 NetPerfMeter Identify Flow +126 3.784578040 192.168.0.20 → 192.168.0.27 SCTP, NetPerfMeter 92 NetPerfMeter Identify Flow +132 4.006622016 192.168.0.20 → 192.168.0.27 SCTP, NetPerfMeter 92 NetPerfMeter Identify Flow +138 4.223204664 192.168.0.20 → 192.168.0.27 SCTP, NetPerfMeter 92 NetPerfMeter Identify Flow +144 4.439513544 192.168.0.20 → 192.168.0.27 SCTP, NetPerfMeter 92 NetPerfMeter Identify Flow +150 4.654398275 192.168.0.20 → 192.168.0.27 SCTP, NetPerfMeter 92 NetPerfMeter Identify Flow +160 4.887196553 192.168.0.20 → 192.168.0.27 SCTP, NetPerfMeter 92 NetPerfMeter Identify Flow +178 5.098706269 192.168.0.20 → 192.168.0.27 SCTP, NetPerfMeter 1088 NetPerfMeter Data +180 5.098939899 192.168.0.20 → 192.168.0.27 SCTP, NetPerfMeter 660 NetPerfMeter Data +181 5.099244178 192.168.0.20 → 192.168.0.27 SCTP, NetPerfMeter, NetPerfMeter 1232 NetPerfMeter Data NetPerfMeter Data +182 5.099428646 192.168.0.20 → 192.168.0.27 SCTP, NetPerfMeter 1088 NetPerfMeter Data +183 5.099642887 192.168.0.20 → 192.168.0.27 SCTP, NetPerfMeter 1088 NetPerfMeter Data +215 5.242589734 192.168.0.27 → 192.168.0.20 SCTP, NetPerfMeter 1104 SACK (Ack=11, Arwnd=106496) NetPerfMeter Data +216 5.242748399 192.168.0.20 → 192.168.0.27 SCTP, NetPerfMeter, NetPerfMeter 1248 SACK (Ack=0, Arwnd=211968) NetPerfMeter Data NetPerfMeter Data +218 5.247412901 192.168.0.27 → 192.168.0.20 SCTP, NetPerfMeter 680 NetPerfMeter Data +220 5.252114400 192.168.0.27 → 192.168.0.20 SCTP, NetPerfMeter 208 SACK (Ack=13, Arwnd=105344) NetPerfMeter Data +221 5.266387026 192.168.0.27 → 192.168.0.20 SCTP, NetPerfMeter 1088 NetPerfMeter Data +223 5.266637245 192.168.0.27 → 192.168.0.20 SCTP, NetPerfMeter 1088 NetPerfMeter Data +224 5.273527654 192.168.0.27 → 192.168.0.20 SCTP, NetPerfMeter 1104 SACK (Ack=1, Arwnd=106496) NetPerfMeter Data +232 5.349726358 192.168.0.20 → 192.168.0.27 SCTP, NetPerfMeter 208 SACK (Ack=5, Arwnd=212992) NetPerfMeter Data +235 5.355361743 192.168.0.27 → 192.168.0.20 SCTP, NetPerfMeter 1104 SACK (Ack=14, Arwnd=106368) NetPerfMeter Data +242 5.475302128 192.168.0.20 → 192.168.0.27 SCTP, NetPerfMeter 208 SACK (Ack=6, Arwnd=212992) NetPerfMeter Data +""".replace("\r\n", "\n") in result |