Author Topic: YATE SS7 patch for Digium cards users, and not only for them  (Read 1328 times)

Pavel.S

  • Newbie
  • *
  • Posts: 2
    • View Profile
YATE SS7 patch for Digium cards users, and not only for them
« on: April 04, 2016, 02:31:02 AM »
Based on my experiences with SS7 YATE using Digium cards, I have prepared this patch, which includes:

modules/server/zapcard.cpp:
- Support for mtp2 dahdi channel, which is commonly used in Libss7 and Chan_SS7 implementations.
- Changing the default errormask to 1 to avoid counting DAHDI_ABORT_EVENT between errors.

libs/ysig/layer2.cpp:
- Reducing the time between two packets from 20 to 1 ms, new variable "fillIntervalMs". I have not found any negative effect in the system load.
- Bug fix in MTP2 error correction. Yate generate retransmission request by toggling the BIB's value, when FSN of 2 following MSUs differ in more than 1. However it is very late, because the time difference between MSUs could be several tens of seconds and after the T7_MTP2 timer expires  (1 sec) on the opposite side,  alignment is initiated. Now generates retransmission request already when FSN of FISU differs from the previous packet. Correction of error is made in a few milliseconds without a new alignment.

Pavel

******************** yate-5.5.0-1_dahdi_mtp2.patch ***************************

--- ./yate/conf.d/ysigchan.conf.sample   2014-02-05 11:49:51.000000000 +0100
+++ ./yate/conf.d/ysigchan.conf.sample   2016-04-01 23:39:51.000000000 +0200
@@ -643,6 +643,9 @@
 ;  sending FISU or LSSU packets
 ;filllink=yes
 
+ ; fillIntervalMs: int: Interval in ms between two packets
+;fillIntervalMs=1
+
 ; maxerrors: int: Number of consecutive errors that cause realignment
 ; This parameter is constrained between 8 and 256
 ; When in proving interval this setting is ignored and realignment occurs at
--- ./yate/conf.d/zapcard.conf.sample   2011-05-13 17:13:46.000000000 +0200
+++ ./yate/conf.d/zapcard.conf.sample   2016-04-01 23:35:22.000000000 +0200
@@ -38,12 +38,12 @@
 ;buflen=160
 
 ; errormask: integer: Value to AND with the received error byte on E1/T1 interface
-; The errors controlled by this mask are 1: RX buffer overrun 2: HDLC Align error
+; The errors controlled by this mask are 1: RX buffer overrun 2: HDLC Abort
 ; Maximum value 255
 ; Defaults to 255 if missing or invalid
 ; Ignored if type is not E1, T1 or BRI
 ; This option can be overriden in span sections
-;errormask=255
+;errormask=1
 
 ; priority: keyword: Default priority of the data service threads (read data and
 ;  events from Zaptel devices)
--- ./yate/libs/ysig/engine.cpp   2014-08-12 13:48:59.000000000 +0200
+++ ./yate/libs/ysig/engine.cpp   2016-04-01 23:11:18.000000000 +0200
@@ -30,7 +30,7 @@
 #endif
 
 #define MIN_TICK_SLEEP 500
-#define DEF_TICK_SLEEP 5000
+#define DEF_TICK_SLEEP 1000
 #define MAX_TICK_SLEEP 50000
 
 namespace TelEngine {
--- ./yate/libs/ysig/layer2.cpp   2014-02-05 11:49:52.000000000 +0100
+++ ./yate/libs/ysig/layer2.cpp   2016-04-01 23:23:49.000000000 +0200
@@ -293,7 +293,7 @@
       m_interval(0), m_resend(0), m_abort(0), m_fillTime(0), m_congestion(false),
       m_bsn(127), m_fsn(127), m_bib(true), m_fib(true),
       m_lastFsn(128), m_lastBsn(127), m_lastBib(true), m_errors(0), m_maxErrors(64),
-      m_resendMs(250), m_abortMs(5000), m_fillIntervalMs(20), m_fillLink(true),
+      m_resendMs(250), m_abortMs(5000), m_fillIntervalMs(1), m_fillLink(true),
       m_autostart(false), m_flushMsus(true)
 {
 #ifdef DEBUG
@@ -311,6 +311,7 @@
     else if (m_maxErrors > 256)
    m_maxErrors = 256;
     setDumper(params.getValue(YSTRING("layer2dump")));
+    m_fillIntervalMs = params.getIntValue(YSTRING("fillIntervalMs"),1);
 }
 
 SS7MTP2::~SS7MTP2()
@@ -457,7 +458,7 @@
        control(Resume);
        break;
    default:
-       XDebug(this,DebugMild,"Got error %u: %s [%p]",
+       Debug(this,DebugMild,"Got error %u: %s [%p]",
       event,lookup(event,SignallingInterface::s_notifName),this);
        {
       unsigned int err = (m_errors += 256) >> 8;
@@ -697,11 +698,11 @@
     XDebug(this,DebugAll,"got bsn=%u/%d fsn=%u/%d local bsn=%u/%d fsn=%u/%d diff=%u len=%u [%p]",
    bsn,bib,fsn,fib,m_bsn,m_bib,m_fsn,m_fib,diff,len,this);
     if (aligned()) {
-   // received FSN should be only 1 ahead of last we handled
-   if (diff > 1) {
+   // received FSN should be only 1 ahead of last we handled or 0 for FISU
+   if ((diff > 1) || ((diff > 0) && (len == 0))) {
        if (diff < 64)
-      Debug(this,DebugMild,"We lost %u packets, remote fsn=%u local bsn=%u [%p]",
-          (diff - 1),fsn,m_bsn,this);
+      Debug(this,DebugNote,"We lost MSU, remote fsn=%u local bsn=%u, requested resend [%p]",
+          fsn,m_bsn,this);
        if (fsn != m_lastFsn) {
       m_lastFsn = fsn;
       // toggle BIB to request immediate retransmission
--- ./yate/modules/server/zapcard.cpp   2014-02-19 12:45:17.000000000 +0100
+++ ./yate/modules/server/zapcard.cpp   2016-04-01 23:31:28.000000000 +0200
@@ -151,6 +151,7 @@
 #define DAHDI_SIG_EM_E1      ZT_SIG_EM_E1
 #define DAHDI_SIG_DACS_RBS   ZT_SIG_DACS_RBS
 #define DAHDI_SIG_HARDHDLC   ZT_SIG_HARDHDLC
+#define DAHDI_SIG_MTP2   ZT_SIG_MTP2
 
 // tonedetect
 #define DAHDI_TONEDETECT_ON   ZT_TONEDETECT_ON
@@ -892,6 +893,7 @@
     {"EM_E1",    DAHDI_SIG_EM_E1},          // E1 E&M Variation
     {"DACS_RBS", DAHDI_SIG_DACS_RBS},       // Cross connect w/ RBS
     {"HARDHDLC", DAHDI_SIG_HARDHDLC},
+    {"MTP2",     DAHDI_SIG_MTP2},
     {0,0}
 };
 
@@ -1119,7 +1121,7 @@
 
    // Open for an interface
    // Check channel mode
-   if (par.sigtype != DAHDI_SIG_HDLCFCS && par.sigtype != DAHDI_SIG_HARDHDLC) {
+   if (par.sigtype != DAHDI_SIG_HDLCFCS && par.sigtype != DAHDI_SIG_HARDHDLC && par.sigtype != DAHDI_SIG_MTP2) {
        Debug(m_owner,DebugWarn,"Channel %u is not in '%s' or '%s' mode [%p]",
       m_channel,lookup(DAHDI_SIG_HDLCFCS,s_zaptelSig),
       lookup(DAHDI_SIG_HARDHDLC,s_zaptelSig),m_owner);
@@ -1671,7 +1673,7 @@
     : SignallingComponent(params,&params,"tdm"),
       m_device(ZapDevice::DChan,this,0,0),
       m_priority(Thread::Normal),
-      m_errorMask(255),
+      m_errorMask(1),
       m_numbufs(16), m_bufsize(1024), m_buffer(0),
       m_readOnly(false), m_sendReadOnly(false),
       m_notify(0),
@@ -1800,8 +1802,8 @@
     int rx = params.getIntValue("rxunderrun");
     if (rx > 0)
    m_timerRxUnder.interval(rx);
-    int i = params.getIntValue("errormask",config.getIntValue("errormask",255));
-    m_errorMask = ((i >= 0 && i < 256) ? i : 255);
+    int i = params.getIntValue("errormask",config.getIntValue("errormask",1));
+    m_errorMask = ((i >= 0 && i < 256) ? i : 1);
     if (debugAt(DebugInfo)) {
    String s;
    s << "driver=" << plugin.debugName();
*****************************************************************************