aboutsummaryrefslogtreecommitdiffstats
path: root/library/RTP_Emulation.ttcn
diff options
context:
space:
mode:
Diffstat (limited to 'library/RTP_Emulation.ttcn')
-rw-r--r--library/RTP_Emulation.ttcn49
1 files changed, 43 insertions, 6 deletions
diff --git a/library/RTP_Emulation.ttcn b/library/RTP_Emulation.ttcn
index 20e4299c..475b4785 100644
--- a/library/RTP_Emulation.ttcn
+++ b/library/RTP_Emulation.ttcn
@@ -188,20 +188,57 @@ function f_rtpem_stats_get(RTPEM_CTRL_PT pt, boolean rtcp := false) return Rtpem
return stats;
}
-function f_rtpem_stats_compare(RtpemStats a, RtpemStats b) return boolean {
+function f_rtpem_stats_compare_value(integer a, integer b, integer tolerance := 0) return boolean {
+ var integer temp;
+
+ temp := (a - b)
+ if (temp < 0) {
+ temp := -temp;
+ }
+
+ if (temp > tolerance) {
+ return false;
+ }
+
+ return true;
+}
+
+/* Cross-compare two rtpem-statistics. The transmission statistics on the a side
+ * must match the reception statistics on the other side and vice versa. The
+ * user may also supply a tolerance value (number of packets) when deviations
+ * are acceptable */
+function f_rtpem_stats_compare(RtpemStats a, RtpemStats b, integer tolerance := 0) return boolean {
+ var integer plen;
+
log("stats A: ", a);
log("stats B: ", b);
+ log("tolerance: ", tolerance, " packets");
- if (a.num_pkts_tx != b.num_pkts_rx or
- a.num_pkts_rx != b.num_pkts_tx or
- a.bytes_payload_tx != b.bytes_payload_rx or
- a.bytes_payload_rx != b.bytes_payload_tx) {
+ if (f_rtpem_stats_compare_value(a.num_pkts_tx, b.num_pkts_rx, tolerance) == false) {
return false;
}
+
+ if (f_rtpem_stats_compare_value(a.num_pkts_rx, b.num_pkts_tx, tolerance) == false) {
+ return false;
+ }
+
+ if(a.num_pkts_tx > 0) {
+ plen := a.bytes_payload_tx / a.num_pkts_tx;
+ } else {
+ plen := 0;
+ }
+
+ if (f_rtpem_stats_compare_value(a.bytes_payload_tx, b.bytes_payload_rx, tolerance * plen) == false) {
+ return false;
+ }
+
+ if (f_rtpem_stats_compare_value(a.bytes_payload_rx, b.bytes_payload_tx, tolerance * plen) == false) {
+ return false;
+ }
+
return true;
}
-
template PDU_RTP ts_RTP(BIT32_BO_LAST ssrc, INT7b pt, LIN2_BO_LAST seq, uint32_t ts,
octetstring payload, BIT1 marker := '0'B) := {
version := 2,