• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# RTCP unit tests
2# run with:
3#   test/run_tests  -P "load_contrib('rtcp')" -t test/contrib/rtcp.uts -F
4
5% RTCP regression tests for Scapy
6
7############
8# RTCP
9############
10
11+ RTCP Sender Report tests
12
13= test sender report parse
14
15raw = b'\x80\xc8\x00\x06\x9c\xe9\xc6\x48\xe5\x61\xe4\x4b\x63\x8a\x19\xc9\x98\x64\xea\x2e\x00\x00\x00\x49\x00\x00\x09\x69'
16parsed = RTCP(raw)
17assert parsed.version == 2
18assert parsed.padding == 0
19assert parsed.count == 0
20assert parsed.packet_type == 200
21assert parsed.length == 6
22assert parsed.sourcesync == 0x9ce9c648
23assert parsed.sender_info.ntp_timestamp == 0xe561e44b638a19c9
24assert parsed.sender_info.rtp_timestamp == 2556750382
25assert parsed.sender_info.sender_packet_count == 73
26assert parsed.sender_info.sender_octet_count == 2409
27
28+ RTCP Receiver Report tests
29
30= test receiver report parse
31
32raw = b'\x81\xc9\x00\x07\xa2\xdf\x02\x72\x49\x6e\x93\xbd\x00\xff\xff\xff\x00\x00\x59\x47\x00\x00\x00\x00\xe4\x8f\xb9\x3a\x00\x03\x3f\x1b'
33parsed = RTCP(raw)
34assert parsed.version == 2
35assert parsed.padding == 0
36assert parsed.count == 1
37assert parsed.packet_type == 201
38assert parsed.length == 7
39assert parsed.sourcesync == 0xa2df0272
40assert parsed.report_blocks[0].sourcesync == 0x496e93bd
41assert parsed.report_blocks[0].fraction_lost == 0
42assert parsed.report_blocks[0].cumulative_lost == 0xffffff
43assert parsed.report_blocks[0].highest_seqnum_recv == 22855
44assert parsed.report_blocks[0].interarrival_jitter == 0
45assert parsed.report_blocks[0].last_SR_timestamp == 0xe48fb93a
46assert parsed.report_blocks[0].delay_since_last_SR == 212763
47
48+ RTCP Source Description tests
49
50= test source description report parse
51
52raw = b"\x81\xca\x00\x0c\xa2\xdf\x02\x72\x01\x1c\x75\x73\x65\x72\x31\x35" \
53      b"\x30\x33\x34\x38\x38\x39\x30\x31\x40\x68\x6f\x73\x74\x2d\x65\x37" \
54      b"\x32\x64\x62\x34\x33\x64\x06\x09\x47\x53\x74\x72\x65\x61\x6d\x65" \
55      b"\x72\x00\x00\x00"
56parsed = RTCP(raw)
57assert parsed.version == 2
58assert parsed.padding == 0
59assert parsed.count == 1
60assert parsed.packet_type == 202
61assert parsed.length == 12
62assert parsed.sdes_chunks[0].sourcesync == 0xa2df0272
63assert parsed.sdes_chunks[0].items[0].chunk_type == 1
64assert parsed.sdes_chunks[0].items[0].length == 28
65assert parsed.sdes_chunks[0].items[0].value == b'user1503488901@host-e72db43d'
66assert parsed.sdes_chunks[0].items[1].chunk_type == 6
67assert parsed.sdes_chunks[0].items[1].length == 9
68assert parsed.sdes_chunks[0].items[1].value == b'GStreamer'
69
70+ RTCP parsing tests
71
72= test parse SR and SDES stacked
73raw = b"\x81\xc9\x00\x07\xa2\xdf\x02\x72\x49\x6e\x93\xbd\x00\xff\xff\xff" \
74      b"\x00\x00\x59\x47\x00\x00\x00\x00\xe4\x8f\xb9\x3a\x00\x03\x3f\x1b" \
75      b"\x81\xca\x00\x0c\xa2\xdf\x02\x72\x01\x1c\x75\x73\x65\x72\x31\x35" \
76      b"\x30\x33\x34\x38\x38\x39\x30\x31\x40\x68\x6f\x73\x74\x2d\x65\x37" \
77      b"\x32\x64\x62\x34\x33\x64\x06\x09\x47\x53\x74\x72\x65\x61\x6d\x65" \
78      b"\x72\x00\x00\x00"
79
80= format SR + 2xRR and parse back
81
82rtcp = RTCP()
83rtcp.packet_type = 200
84rtcp.sourcesync = 0x01010101
85rtcp.sender_info.rtp_timestamp = 0x03030303
86rtcp.count = 2
87rtcp.report_blocks.append(ReceptionReport(sourcesync=0x04040404))
88rtcp.report_blocks.append(ReceptionReport(sourcesync=0x05050505))
89b = bytes(rtcp)
90rtcp2 = RTCP(b)
91assert rtcp2.count == 2
92assert rtcp2.length == 18
93assert rtcp2.sourcesync == 0x01010101
94assert rtcp2.sender_info.rtp_timestamp == 0x03030303
95assert len(rtcp2.sender_info.payload) == 0
96assert rtcp2.report_blocks[0].sourcesync == 0x04040404
97assert len(rtcp2.report_blocks[0].payload) == 0
98assert rtcp2.report_blocks[1].sourcesync == 0x05050505
99