comparison pcap/rtp-cont-check.c @ 171:75607bc26f57

rtp-cont-check design change: print time deltas instead of checking against arbitrary thresholds
author Mychaela Falconia <falcon@freecalypso.org>
date Mon, 26 Dec 2022 21:35:09 +0000
parents b9af126bfddb
children 693a0958a303
comparison
equal deleted inserted replaced
170:b9af126bfddb 171:75607bc26f57
1 /* 1 /*
2 * This program reads a pcap file, extracts packets belonging to a 2 * This program reads a pcap file, extracts packets belonging to a
3 * particular RTP stream as identified by a source or destination 3 * particular RTP stream as identified by a source or destination
4 * IP:port, and checks its continuity: verifies that all sequence 4 * IP:port, and checks its continuity: verifies that the sequence
5 * numbers and timestamps increase monotonously without breaks, 5 * number always increments by 1 and that the timestamp always
6 * and that the time delta between each consecutive pair of packets 6 * increments by 160 units. Finally, this program prints out
7 * is within GSM TCH multiframe jitter bounds of 20 ms. 7 * the Rx time delta of each stream packet (the capture time of
8 * the current packet minus the capture time of the previous packet)
9 * on stdout, allowing visual timing analysis.
8 * 10 *
9 * The codec can be anything, and this program can also be used to 11 * The codec can be anything, and this program can also be used to
10 * check continuity of RTP streams coming from PSTN/SIP, but the 12 * check continuity of RTP streams coming from PSTN/SIP, but the
11 * core assumption is that packets must arrive every 20 ms, with 13 * core assumption is that packets must arrive every 20 ms, with
12 * the timestamp field incrementing by 160 units each time. 14 * the timestamp field incrementing by 160 units each time.
29 static unsigned iphdr_addr_offset, udphdr_port_offset; 31 static unsigned iphdr_addr_offset, udphdr_port_offset;
30 static unsigned link_hdr_len, ethertype_offset; 32 static unsigned link_hdr_len, ethertype_offset;
31 static int stream_init_flag; 33 static int stream_init_flag;
32 static unsigned last_seq, last_tstamp, stream_ssrc; 34 static unsigned last_seq, last_tstamp, stream_ssrc;
33 static struct timeval last_pkt_time; 35 static struct timeval last_pkt_time;
34
35 /* usec jitter thresholds around 20 ms ideal */
36 #define DELTAT_MIN 18450
37 #define DELTAT_MAX 23090
38 36
39 static void 37 static void
40 check_dl_type() 38 check_dl_type()
41 { 39 {
42 int dltype; 40 int dltype;
105 fprintf(stderr, 103 fprintf(stderr,
106 "packet #%u timing error: Rx time gap >= 1 s\n", 104 "packet #%u timing error: Rx time gap >= 1 s\n",
107 pkt_idx); 105 pkt_idx);
108 exit(1); 106 exit(1);
109 } 107 }
110 if (deltat.tv_usec > DELTAT_MAX) { 108 printf("Packet #%u: time delta %u us\n", pkt_idx,
111 fprintf(stderr, 109 (unsigned) deltat.tv_usec);
112 "packet #%u timing error: Rx time delta of %u us is above max threshold\n",
113 pkt_idx, (unsigned) deltat.tv_usec);
114 exit(1);
115 }
116 if (deltat.tv_usec < DELTAT_MIN) {
117 fprintf(stderr,
118 "packet #%u timing error: Rx time delta of %u us is below min threshold\n",
119 pkt_idx, (unsigned) deltat.tv_usec);
120 exit(1);
121 }
122 } else { 110 } else {
123 stream_init_flag = 1; 111 stream_init_flag = 1;
124 stream_ssrc = cur_ssrc; 112 stream_ssrc = cur_ssrc;
125 } 113 }
126 last_seq = cur_seq; 114 last_seq = cur_seq;