blob: fcb158bd258bf80b7c2255ae64bf5e2158195c0e [file] [log] [blame]
Harald Welte067d66e2017-12-13 17:24:03 +01001module RTP_Emulation {
2
3/* Functionalities that we want this module to imeplement:
4 * * act as a RTP source that generates a RTP Stream
5 * * act asaa RTP sink that consumes a RTP Stream
6 *
7 * for all of the above, we want to be able to
8 * * specify the payload type
9 * * specify the interval / sample rate
10 * * create drop-outs in the stream
11 * * detect reordered or lost frames
12 * * validate if the size of the frames matches epectations
13 * * play back real audio (at least some tones?)
14 * * enable/disable generation/verification of RTCP
15 */
16
Harald Weltea4ca4462018-02-09 00:17:14 +010017/* Ideas:
18
19* each component consists of transmitter and receiver
20* transmitters and receivers can be operated as tuple?
21* high-level operation
22** set-up config at transmitter + receiver
23** transmit sequence of payloads
24** verify receiption of those payloads
25* can operate full-duplex/bi-directional as needed
26
27* transmitter
28** trigger transmission of n number of packets
29** transmit them at normal ptime interval
30** payload size configurable
31** payload contents PRBS or the like
32
33* receiver
34** count number of related packets at receiver
35** check received payload type
36** check received timestamp increments
37** check received seq_nr increments
38** (optionally) check for SSRC
39** (optionally) check for payload size
40** (optionally) check for payload contents
41
42* later
43** how to test transcoding?
44** how to test pure play-out endpoints (rx only)?
45** how to test "Rx from wrong IP/port" scenarios?
46** how to test RTCP?
47** maybe keep ports un-connected to show wrong src -lrt
48
49*/
50
51
52
53
Harald Welte067d66e2017-12-13 17:24:03 +010054import from General_Types all;
55import from Osmocom_Types all;
56import from IPL4asp_Types all;
57import from RTP_Types all;
58import from RTP_CodecPort all;
59import from RTP_CodecPort_CtrlFunct all;
60
Harald Welte80981642017-12-24 23:59:47 +010061import from IuUP_Types all;
62import from IuUP_Emulation all;
63
Harald Welte067d66e2017-12-13 17:24:03 +010064type component RTP_Emulation_CT {
65 /* down-facing ports for RTP and RTCP codec ports on top of IPL4asp */
66 port RTP_CODEC_PT RTP;
67 var integer g_rtp_conn_id := -1;
68 port RTP_CODEC_PT RTCP;
69 var integer g_rtcp_conn_id := -1;
70
71 /* user-facing port for controlling the binding */
72 port RTPEM_CTRL_PT CTRL;
73
74 /* configurable by user, should be fixed */
Harald Welte80981642017-12-24 23:59:47 +010075 var RtpemConfig g_cfg := c_RtpemDefaultCfg;
Harald Welte067d66e2017-12-13 17:24:03 +010076
Harald Weltecb8b4272018-03-28 19:57:58 +020077 /* statistics */
78 var RtpemStats g_stats_rtp := c_RtpemStatsReset;
79 var RtpemStats g_stats_rtcp := c_RtpemStatsReset;
80
Harald Welte067d66e2017-12-13 17:24:03 +010081 var HostName g_remote_host;
82 var PortNumber g_remote_port;
83 var HostName g_local_host;
84 var PortNumber g_local_port;
85
86 /* state variables, change over time */
87 var boolean g_rx_enabled := false;
88 var LIN2_BO_LAST g_tx_next_seq := 0;
89 var uint32_t g_tx_next_ts := 0;
90
91 var INT7b g_rx_payload_type := 0;
92 var LIN2_BO_LAST g_rx_last_seq;
93 var uint32_t g_rx_last_ts;
Harald Welte80981642017-12-24 23:59:47 +010094
95 var IuUP_Entity g_iuup_ent; // := valueof(t_IuUP_Entity(1));
Harald Welte067d66e2017-12-13 17:24:03 +010096}
97
98type enumerated RtpemMode {
99 RTPEM_MODE_NONE,
100 RTPEM_MODE_TXONLY,
101 RTPEM_MODE_RXONLY,
102 RTPEM_MODE_BIDIR
103};
104
Harald Weltecb8b4272018-03-28 19:57:58 +0200105type record RtpemStats {
106 /* number of packets transmitted */
107 integer num_pkts_tx,
108 /* number of RTP payload bytes transmitted */
109 integer bytes_payload_tx,
110
111 /* number of packets received */
112 integer num_pkts_rx,
113 /* number of RTP payload bytes received */
114 integer bytes_payload_rx,
115 /* number of packets received out-of-sequence */
116 integer num_pkts_rx_err_seq,
117 /* number of packets received wrong timestamp */
118 integer num_pkts_rx_err_ts,
Philipp Maierc290d722018-07-24 18:51:36 +0200119 /* number of packets received wrong payload type */
120 integer num_pkts_rx_err_pt,
Harald Weltecb8b4272018-03-28 19:57:58 +0200121 /* number of packets received during Rx disable */
122 integer num_pkts_rx_err_disabled
123}
124
125const RtpemStats c_RtpemStatsReset := {
126 num_pkts_tx := 0,
127 bytes_payload_tx := 0,
128 num_pkts_rx := 0,
129 bytes_payload_rx := 0,
130 num_pkts_rx_err_seq := 0,
131 num_pkts_rx_err_ts := 0,
Philipp Maierc290d722018-07-24 18:51:36 +0200132 num_pkts_rx_err_pt := 0,
Harald Weltecb8b4272018-03-28 19:57:58 +0200133 num_pkts_rx_err_disabled := 0
134}
135
Harald Welte3f6f48f2017-12-24 21:48:33 +0100136type record RtpemConfig {
137 INT7b tx_payload_type,
138 integer tx_samplerate_hz,
139 integer tx_duration_ms,
140 BIT32_BO_LAST tx_ssrc,
Harald Welte80981642017-12-24 23:59:47 +0100141 octetstring tx_fixed_payload optional,
142 boolean iuup_mode,
143 boolean iuup_tx_init
Harald Welte3f6f48f2017-12-24 21:48:33 +0100144};
145
Harald Welte80981642017-12-24 23:59:47 +0100146const RtpemConfig c_RtpemDefaultCfg := {
Harald Welte3f6f48f2017-12-24 21:48:33 +0100147 tx_payload_type := 0,
148 tx_samplerate_hz := 8000,
149 tx_duration_ms := 20,
150 tx_ssrc := '11011110101011011011111011101111'B,
Harald Welte80981642017-12-24 23:59:47 +0100151 tx_fixed_payload := '01020304'O,
152 iuup_mode := false,
153 iuup_tx_init := true
Harald Welte3f6f48f2017-12-24 21:48:33 +0100154}
155
Harald Welte067d66e2017-12-13 17:24:03 +0100156signature RTPEM_bind(in HostName local_host, inout PortNumber local_port);
157signature RTPEM_connect(in HostName remote_host, in PortNumber remote_port);
158signature RTPEM_mode(in RtpemMode mode);
Harald Welte3f6f48f2017-12-24 21:48:33 +0100159signature RTPEM_configure(in RtpemConfig cfg);
Harald Weltecb8b4272018-03-28 19:57:58 +0200160signature RTPEM_stats_get(out RtpemStats stats, in boolean rtcp);
Harald Welte067d66e2017-12-13 17:24:03 +0100161
162type port RTPEM_CTRL_PT procedure {
Harald Weltecb8b4272018-03-28 19:57:58 +0200163 inout RTPEM_bind, RTPEM_connect, RTPEM_mode, RTPEM_configure, RTPEM_stats_get;
Harald Welte067d66e2017-12-13 17:24:03 +0100164} with { extension "internal" };
165
Harald Welte1af40332018-03-29 08:50:33 +0200166function f_rtpem_bind(RTPEM_CTRL_PT pt, in HostName local_host, inout PortNumber local_port) {
167 pt.call(RTPEM_bind:{local_host, local_port}) {
168 [] pt.getreply(RTPEM_bind:{local_host, ?}) -> param (local_port) {};
169 }
170}
171function f_rtpem_connect(RTPEM_CTRL_PT pt, in HostName remote_host, in PortNumber remote_port) {
172 pt.call(RTPEM_connect:{remote_host, remote_port}) {
173 [] pt.getreply(RTPEM_connect:{remote_host, remote_port}) {};
174 }
175}
176function f_rtpem_mode(RTPEM_CTRL_PT pt, in RtpemMode mode) {
177 pt.call(RTPEM_mode:{mode}) {
178 [] pt.getreply(RTPEM_mode:{mode}) {};
179 }
180}
181function f_rtpem_configure(RTPEM_CTRL_PT pt, in RtpemConfig cfg) {
182 pt.call(RTPEM_configure:{cfg}) {
183 [] pt.getreply(RTPEM_configure:{cfg}) {};
184 }
185}
186function f_rtpem_stats_get(RTPEM_CTRL_PT pt, boolean rtcp := false) return RtpemStats {
187 var RtpemStats stats;
188 pt.call(RTPEM_stats_get:{-, rtcp}) {
189 [] pt.getreply(RTPEM_stats_get:{?, rtcp}) -> param(stats) {};
190 }
191 return stats;
192}
193
Philipp Maier2321ef92018-06-27 17:52:04 +0200194function f_rtpem_stats_compare_value(integer a, integer b, integer tolerance := 0) return boolean {
195 var integer temp;
Harald Welte5c49ba42018-03-29 08:51:20 +0200196
Philipp Maier2321ef92018-06-27 17:52:04 +0200197 temp := (a - b)
198 if (temp < 0) {
199 temp := -temp;
200 }
201
202 if (temp > tolerance) {
Harald Welte5c49ba42018-03-29 08:51:20 +0200203 return false;
204 }
Philipp Maier2321ef92018-06-27 17:52:04 +0200205
Harald Welte5c49ba42018-03-29 08:51:20 +0200206 return true;
207}
Harald Welte1af40332018-03-29 08:50:33 +0200208
Philipp Maier2321ef92018-06-27 17:52:04 +0200209/* Cross-compare two rtpem-statistics. The transmission statistics on the a side
210 * must match the reception statistics on the other side and vice versa. The
211 * user may also supply a tolerance value (number of packets) when deviations
212 * are acceptable */
213function f_rtpem_stats_compare(RtpemStats a, RtpemStats b, integer tolerance := 0) return boolean {
214 var integer plen;
215
216 log("stats A: ", a);
217 log("stats B: ", b);
218 log("tolerance: ", tolerance, " packets");
219
220 if (f_rtpem_stats_compare_value(a.num_pkts_tx, b.num_pkts_rx, tolerance) == false) {
221 return false;
222 }
223
224 if (f_rtpem_stats_compare_value(a.num_pkts_rx, b.num_pkts_tx, tolerance) == false) {
225 return false;
226 }
227
228 if(a.num_pkts_tx > 0) {
229 plen := a.bytes_payload_tx / a.num_pkts_tx;
230 } else {
231 plen := 0;
232 }
233
234 if (f_rtpem_stats_compare_value(a.bytes_payload_tx, b.bytes_payload_rx, tolerance * plen) == false) {
235 return false;
236 }
237
238 if (f_rtpem_stats_compare_value(a.bytes_payload_rx, b.bytes_payload_tx, tolerance * plen) == false) {
239 return false;
240 }
241
242 return true;
243}
Harald Welte1af40332018-03-29 08:50:33 +0200244
Philipp Maier36291392018-07-25 09:40:44 +0200245/* Check the statistics for general signs of errors. This is a basic general
246 * check that will fit most situations and is intended to be executed by
247 * the testcases as as needed. */
248function f_rtpem_stats_err_check(RtpemStats s) {
249 log("stats: ", s);
250
251 /* Check if there was some activity at either on the RX or on the
252 * TX side, but complete silence would indicate some problem */
253 if (s.num_pkts_tx < 1 and s.num_pkts_rx < 1) {
254 setverdict(fail, "no RTP packet activity detected (packets)");
255 mtc.stop;
256 }
257 if (s.bytes_payload_tx < 1 and s.bytes_payload_rx < 1) {
258 setverdict(fail, "no RTP packet activity detected (bytes)");
259 mtc.stop;
260 }
261
262 /* Check error counters */
263 if (s.num_pkts_rx_err_seq != 0) {
264 setverdict(fail, "RTP packet sequence number errors occurred");
265 mtc.stop;
266 }
267 if (s.num_pkts_rx_err_ts != 0) {
268 setverdict(fail, "RTP packet timestamp errors occurred");
269 mtc.stop;
270 }
271 if (s.num_pkts_rx_err_pt != 0) {
272 setverdict(fail, "RTP packet payload type errors occurred");
273 mtc.stop;
274 }
275 if (s.num_pkts_rx_err_disabled != 0) {
276 setverdict(fail, "RTP packets received while RX was disabled");
277 mtc.stop;
278 }
279}
280
Harald Welte067d66e2017-12-13 17:24:03 +0100281template PDU_RTP ts_RTP(BIT32_BO_LAST ssrc, INT7b pt, LIN2_BO_LAST seq, uint32_t ts,
282 octetstring payload, BIT1 marker := '0'B) := {
283 version := 2,
284 padding_ind := '0'B,
285 extension_ind := '0'B,
286 CSRC_count := 0,
287 marker_bit := marker,
288 payload_type := pt,
289 sequence_number := seq,
Harald Welte8a4d3952017-12-24 21:30:23 +0100290 time_stamp := int2bit(ts, 32),
Harald Welte067d66e2017-12-13 17:24:03 +0100291 SSRC_id := ssrc,
292 CSRCs := omit,
293 ext_header := omit,
294 data := payload
295}
296
297private function f_tx_rtp(octetstring payload, BIT1 marker := '0'B) runs on RTP_Emulation_CT {
Harald Welte80981642017-12-24 23:59:47 +0100298 if (g_cfg.iuup_mode) {
299 payload := f_IuUP_Em_tx_encap(g_iuup_ent, payload);
300 }
Harald Welte3f6f48f2017-12-24 21:48:33 +0100301 var PDU_RTP rtp := valueof(ts_RTP(g_cfg.tx_ssrc, g_cfg.tx_payload_type, g_tx_next_seq,
Harald Welte067d66e2017-12-13 17:24:03 +0100302 g_tx_next_ts, payload, marker));
303 RTP.send(t_RTP_Send(g_rtp_conn_id, RTP_messages_union:{rtp:=rtp}));
304 /* increment sequence + timestamp for next transmit */
305 g_tx_next_seq := g_tx_next_seq + 1;
Harald Welte3f6f48f2017-12-24 21:48:33 +0100306 g_tx_next_ts := g_tx_next_ts + (g_cfg.tx_samplerate_hz / (1000 / g_cfg.tx_duration_ms));
Harald Welte067d66e2017-12-13 17:24:03 +0100307}
308
309function f_main() runs on RTP_Emulation_CT
310{
311 var Result res;
Harald Weltecb8b4272018-03-28 19:57:58 +0200312 var boolean is_rtcp
Harald Welte067d66e2017-12-13 17:24:03 +0100313
Harald Welte3f6f48f2017-12-24 21:48:33 +0100314 timer T_transmit := int2float(g_cfg.tx_duration_ms)/1000.0;
Harald Welte067d66e2017-12-13 17:24:03 +0100315 var RTP_RecvFrom rx_rtp;
Harald Welte3f6f48f2017-12-24 21:48:33 +0100316 var RtpemConfig cfg;
Harald Welte067d66e2017-12-13 17:24:03 +0100317 var template RTP_RecvFrom tr := {
318 connId := ?,
319 remName := ?,
320 remPort := ?,
321 locName := ?,
322 locPort := ?,
323 msg := ?
324 };
325 var template RTP_RecvFrom tr_rtp := tr;
326 var template RTP_RecvFrom tr_rtcp := tr;
Harald Welte067d66e2017-12-13 17:24:03 +0100327 tr_rtp.msg := { rtp := ? };
Harald Welte067d66e2017-12-13 17:24:03 +0100328 tr_rtcp.msg := { rtcp := ? };
329
Harald Welte80981642017-12-24 23:59:47 +0100330 g_iuup_ent := valueof(t_IuUP_Entity(g_cfg.iuup_tx_init));
331
Harald Welte067d66e2017-12-13 17:24:03 +0100332 while (true) {
333 alt {
334 /* control procedures (calls) from the user */
335 [] CTRL.getcall(RTPEM_bind:{?,?}) -> param(g_local_host, g_local_port) {
336 if (g_local_port rem 2 == 1) {
337 //CTRL.raise(RTPEM_bind, "Local Port is not an even port number!");
338 log("Local Port is not an even port number!");
339 continue;
340 }
341 res := RTP_CodecPort_CtrlFunct.f_IPL4_listen(RTP, g_local_host,
342 g_local_port, {udp:={}});
Harald Welte9220f632018-05-23 20:27:02 +0200343 if (not ispresent(res.connId)) {
344 setverdict(fail, "Could not listen on RTP socket, check your configuration");
Daniel Willmanne4ff5372018-07-05 17:35:03 +0200345 mtc.stop;
Harald Welte9220f632018-05-23 20:27:02 +0200346 }
Harald Welte067d66e2017-12-13 17:24:03 +0100347 g_rtp_conn_id := res.connId;
Harald Welte9774e7a2018-03-29 08:49:38 +0200348 tr_rtp.connId := g_rtp_conn_id;
Harald Welte98eb1bf2018-04-02 18:18:44 +0200349 res := RTP_CodecPort_CtrlFunct.f_IPL4_listen(RTCP, g_local_host,
Harald Welte067d66e2017-12-13 17:24:03 +0100350 g_local_port+1, {udp:={}});
Harald Welte9220f632018-05-23 20:27:02 +0200351 if (not ispresent(res.connId)) {
352 setverdict(fail, "Could not listen on RTCP socket, check your configuration");
Daniel Willmanne4ff5372018-07-05 17:35:03 +0200353 mtc.stop;
Harald Welte9220f632018-05-23 20:27:02 +0200354 }
Harald Welte067d66e2017-12-13 17:24:03 +0100355 g_rtcp_conn_id := res.connId;
Harald Welte9774e7a2018-03-29 08:49:38 +0200356 tr_rtcp.connId := g_rtcp_conn_id;
Harald Welte067d66e2017-12-13 17:24:03 +0100357 CTRL.reply(RTPEM_bind:{g_local_host, g_local_port});
358 }
359 [] CTRL.getcall(RTPEM_connect:{?,?}) -> param (g_remote_host, g_remote_port) {
360 if (g_remote_port rem 2 == 1) {
361 //CTRL.raise(RTPEM_connect, "Remote Port is not an even number!");
362 log("Remote Port is not an even number!");
363 continue;
364 }
365 res := RTP_CodecPort_CtrlFunct.f_IPL4_connect(RTP, g_remote_host,
366 g_remote_port,
367 g_local_host, g_local_port,
368 g_rtp_conn_id, {udp:={}});
Harald Welte9220f632018-05-23 20:27:02 +0200369 if (not ispresent(res.connId)) {
370 setverdict(fail, "Could not connect to RTP socket, check your configuration");
Daniel Willmanne4ff5372018-07-05 17:35:03 +0200371 mtc.stop;
Harald Welte9220f632018-05-23 20:27:02 +0200372 }
Harald Welte067d66e2017-12-13 17:24:03 +0100373 res := RTP_CodecPort_CtrlFunct.f_IPL4_connect(RTCP, g_remote_host,
374 g_remote_port+1,
375 g_local_host, g_local_port+1,
376 g_rtcp_conn_id, {udp:={}});
Harald Welte9220f632018-05-23 20:27:02 +0200377 if (not ispresent(res.connId)) {
378 setverdict(fail, "Could not connect to RTCP socket, check your configuration");
Daniel Willmanne4ff5372018-07-05 17:35:03 +0200379 mtc.stop;
Harald Welte9220f632018-05-23 20:27:02 +0200380 }
Harald Welte067d66e2017-12-13 17:24:03 +0100381 CTRL.reply(RTPEM_connect:{g_remote_host, g_remote_port});
382 }
383 [] CTRL.getcall(RTPEM_mode:{RTPEM_MODE_NONE}) {
384 T_transmit.stop;
385 g_rx_enabled := false;
Harald Welte80981642017-12-24 23:59:47 +0100386 CTRL.reply(RTPEM_mode:{RTPEM_MODE_NONE});
Harald Welte067d66e2017-12-13 17:24:03 +0100387 }
388 [] CTRL.getcall(RTPEM_mode:{RTPEM_MODE_TXONLY}) {
389 /* start transmit timer */
390 T_transmit.start;
391 g_rx_enabled := false;
Harald Welte80981642017-12-24 23:59:47 +0100392 CTRL.reply(RTPEM_mode:{RTPEM_MODE_TXONLY});
Harald Welte067d66e2017-12-13 17:24:03 +0100393 }
394 [] CTRL.getcall(RTPEM_mode:{RTPEM_MODE_RXONLY}) {
395
396 T_transmit.stop;
397 if (g_rx_enabled == false) {
398 /* flush queues */
399 RTP.clear;
400 RTCP.clear;
401 g_rx_enabled := true;
402 }
Harald Welte80981642017-12-24 23:59:47 +0100403 CTRL.reply(RTPEM_mode:{RTPEM_MODE_RXONLY});
Harald Welte067d66e2017-12-13 17:24:03 +0100404 }
405 [] CTRL.getcall(RTPEM_mode:{RTPEM_MODE_BIDIR}) {
406 T_transmit.start;
407 if (g_rx_enabled == false) {
408 /* flush queues */
409 RTP.clear;
410 RTCP.clear;
411 g_rx_enabled := true;
412 }
Harald Welte80981642017-12-24 23:59:47 +0100413 CTRL.reply(RTPEM_mode:{RTPEM_MODE_BIDIR});
Harald Welte067d66e2017-12-13 17:24:03 +0100414 }
Harald Welte3f6f48f2017-12-24 21:48:33 +0100415 [] CTRL.getcall(RTPEM_configure:{?}) -> param (cfg) {
416 g_cfg := cfg;
Harald Welte80981642017-12-24 23:59:47 +0100417 g_iuup_ent.cfg.active_init := g_cfg.iuup_tx_init;
418 CTRL.reply(RTPEM_configure:{cfg});
Harald Welte3f6f48f2017-12-24 21:48:33 +0100419 }
Harald Weltecb8b4272018-03-28 19:57:58 +0200420 [] CTRL.getcall(RTPEM_stats_get:{?, ?}) -> param (is_rtcp) {
421 if (is_rtcp) {
422 CTRL.reply(RTPEM_stats_get:{g_stats_rtcp, is_rtcp});
423 } else {
424 CTRL.reply(RTPEM_stats_get:{g_stats_rtp, is_rtcp});
425 }
426 }
Harald Welte067d66e2017-12-13 17:24:03 +0100427
Harald Weltecb8b4272018-03-28 19:57:58 +0200428
429
430 /* simply ignore any RTTP/RTP if receiver not enabled */
431 [g_rx_enabled==false] RTP.receive(tr_rtp) {
432 g_stats_rtp.num_pkts_rx_err_disabled := g_stats_rtp.num_pkts_rx_err_disabled+1;
433 }
Harald Welte98eb1bf2018-04-02 18:18:44 +0200434 [g_rx_enabled==false] RTCP.receive(tr_rtcp) {
Harald Weltecb8b4272018-03-28 19:57:58 +0200435 g_stats_rtcp.num_pkts_rx_err_disabled := g_stats_rtcp.num_pkts_rx_err_disabled+1;
436 }
Harald Welte067d66e2017-12-13 17:24:03 +0100437
438 /* process received RTCP/RTP if receiver enabled */
439 [g_rx_enabled] RTP.receive(tr_rtp) -> value rx_rtp {
Harald Welte8d3ea0e2018-03-29 08:50:18 +0200440 //log("RX RTP: ", rx_rtp);
Philipp Maierc290d722018-07-24 18:51:36 +0200441
Harald Weltecb8b4272018-03-28 19:57:58 +0200442 /* increment counters */
Philipp Maierc290d722018-07-24 18:51:36 +0200443 if (rx_rtp.msg.rtp.payload_type != g_cfg.tx_payload_type) {
444 g_stats_rtp.num_pkts_rx_err_pt := g_stats_rtp.num_pkts_rx_err_pt+1;
445 }
Harald Weltecb8b4272018-03-28 19:57:58 +0200446 g_stats_rtp.num_pkts_rx := g_stats_rtp.num_pkts_rx+1;
447 g_stats_rtp.bytes_payload_rx := g_stats_rtp.bytes_payload_rx +
448 lengthof(rx_rtp.msg.rtp.data);
Harald Welte80981642017-12-24 23:59:47 +0100449 if (g_cfg.iuup_mode) {
450 rx_rtp.msg.rtp.data := f_IuUP_Em_rx_decaps(g_iuup_ent, rx_rtp.msg.rtp.data);
451 }
Harald Welte067d66e2017-12-13 17:24:03 +0100452 }
453 [g_rx_enabled] RTCP.receive(tr_rtcp) -> value rx_rtp {
Harald Welte8d3ea0e2018-03-29 08:50:18 +0200454 //log("RX RTCP: ", rx_rtp);
Harald Weltecb8b4272018-03-28 19:57:58 +0200455 g_stats_rtcp.num_pkts_rx := g_stats_rtcp.num_pkts_rx+1;
Harald Welte067d66e2017-12-13 17:24:03 +0100456 }
457
458 /* transmit if timer has expired */
459 [] T_transmit.timeout {
460 /* send one RTP frame, re-start timer */
Harald Welte3f6f48f2017-12-24 21:48:33 +0100461 f_tx_rtp(g_cfg.tx_fixed_payload);
Harald Welte067d66e2017-12-13 17:24:03 +0100462 T_transmit.start;
Harald Weltecb8b4272018-03-28 19:57:58 +0200463 /* update counters */
464 g_stats_rtp.num_pkts_tx := g_stats_rtp.num_pkts_tx+1;
465 g_stats_rtp.bytes_payload_tx := g_stats_rtp.bytes_payload_tx +
466 lengthof(g_cfg.tx_fixed_payload);
Harald Welte067d66e2017-12-13 17:24:03 +0100467 }
468
469 /* fail on any unexpected messages */
470 [] RTP.receive {
471 setverdict(fail, "Received unexpected type from RTP");
Daniel Willmanne4ff5372018-07-05 17:35:03 +0200472 mtc.stop;
Harald Welte067d66e2017-12-13 17:24:03 +0100473 }
474 [] RTCP.receive {
475 setverdict(fail, "Received unexpected type from RTCP");
Daniel Willmanne4ff5372018-07-05 17:35:03 +0200476 mtc.stop;
Harald Welte067d66e2017-12-13 17:24:03 +0100477 }
478 }
479 }
480}
481
482
483}