From d4a0e0edc713a2c6d49ff98f9f6231c80e509f97 Mon Sep 17 00:00:00 2001 From: Simon Date: Sat, 8 Jan 2022 11:49:38 +0000 Subject: [PATCH 01/46] Move append for CRCs --- bridge_master.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/bridge_master.py b/bridge_master.py index a9ac24d..8e81b3b 100644 --- a/bridge_master.py +++ b/bridge_master.py @@ -1625,7 +1625,6 @@ class routerOBP(OPENBRIDGE): } - self.STATUS[_stream_id][crcs].append(_pkt_crc) # If we can, use the LC from the voice header as to keep all options intact if _frame_type == HBPF_DATA_SYNC and _dtype_vseq == HBPF_SLT_VHEAD: @@ -1724,7 +1723,9 @@ class routerOBP(OPENBRIDGE): self.STATUS[_stream_id]['lastData'] = _data - + + self.STATUS[_stream_id][crcs].append(_pkt_crc) + self.STATUS[_stream_id]['LAST'] = pkt_time From e2b31c271be84c85a4d3469ecd6429dfb3f7e195 Mon Sep 17 00:00:00 2001 From: Simon Date: Sat, 8 Jan 2022 11:55:46 +0000 Subject: [PATCH 02/46] crcs --- bridge_master.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/bridge_master.py b/bridge_master.py index 8e81b3b..c64de38 100644 --- a/bridge_master.py +++ b/bridge_master.py @@ -1699,13 +1699,15 @@ class routerOBP(OPENBRIDGE): #Duplicate handling# #Handle inbound duplicates - if _seq and _seq == self.STATUS[_stream_id]['lastSeq']: - logger.warning("(%s) *PacketControl* Duplicate sequence number %s, disgarding. Stream ID:, %s TGID: %s",self._system,_seq,int_id(_stream_id),int_id(_dst_id)) - return #Duplicate complete packet if self.STATUS[_stream_id]['lastData'] and self.STATUS[_stream_id]['lastData'] == _data and _seq > 1: logger.warning("(%s) *PacketControl* last packet is a complete duplicate of the previous one, disgarding. Stream ID:, %s TGID: %s",self._system,int_id(_stream_id),int_id(_dst_id)) return + #Duplicate SEQ number + if _seq and _seq == self.STATUS[_stream_id]['lastSeq']: + logger.warning("(%s) *PacketControl* Duplicate sequence number %s, disgarding. Stream ID:, %s TGID: %s",self._system,_seq,int_id(_stream_id),int_id(_dst_id)) + return + #Duplicate DMR payload to previuos packet (by CRC16) if _pkt_crc in self.STATUS[_stream_id]['crcs']: logger.warning("(%s) *PacketControl* DMR packet payload with CRC16: %s seen before in this stream, disgarding. Stream ID:, %s TGID: %s",self._system,_pkt_crc,int_id(_stream_id),int_id(_dst_id)) return @@ -1724,7 +1726,8 @@ class routerOBP(OPENBRIDGE): - self.STATUS[_stream_id][crcs].append(_pkt_crc) + self.STATUS[_stream_id]['crcs'].append(_pkt_crc) + print(self.STATUS[_stream_id]['crcs'] self.STATUS[_stream_id]['LAST'] = pkt_time From 0d93bbbccb33d07680350b2f1103a0706f3d9727 Mon Sep 17 00:00:00 2001 From: Simon Date: Sat, 8 Jan 2022 11:56:29 +0000 Subject: [PATCH 03/46] typo --- bridge_master.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bridge_master.py b/bridge_master.py index c64de38..3803756 100644 --- a/bridge_master.py +++ b/bridge_master.py @@ -1727,7 +1727,7 @@ class routerOBP(OPENBRIDGE): self.STATUS[_stream_id]['crcs'].append(_pkt_crc) - print(self.STATUS[_stream_id]['crcs'] + print(self.STATUS[_stream_id]['crcs']) self.STATUS[_stream_id]['LAST'] = pkt_time From 3a65e7379eeab9022b4a0d9e70f174bb333007d8 Mon Sep 17 00:00:00 2001 From: Simon Date: Sat, 8 Jan 2022 12:20:24 +0000 Subject: [PATCH 04/46] apply CRC check to HBP traffic too --- bridge_master.py | 26 ++++++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-) diff --git a/bridge_master.py b/bridge_master.py index 3803756..7aac592 100644 --- a/bridge_master.py +++ b/bridge_master.py @@ -1487,7 +1487,8 @@ class routerOBP(OPENBRIDGE): 'lastSeq': False, 'lastData': False, 'RX_PEER': _peer_id, - 'packets': 0 + 'packets': 0, + 'crcs': [] } @@ -1605,6 +1606,9 @@ class routerOBP(OPENBRIDGE): else: logger.info('(%s) UNIT Data not bridged to HBP on slot %s - target busy: %s DST_ID: %s',self._system,_d_slot,_d_system,_int_dst_id) + + self.STATUS[_stream_id]['crcs'].append(_pkt_crc) + if _call_type == 'group' or _call_type == 'vcsbk': # Is this a new call stream? @@ -1727,7 +1731,6 @@ class routerOBP(OPENBRIDGE): self.STATUS[_stream_id]['crcs'].append(_pkt_crc) - print(self.STATUS[_stream_id]['crcs']) self.STATUS[_stream_id]['LAST'] = pkt_time @@ -1794,7 +1797,8 @@ class routerHBP(HBSYSTEM): }, 'lastSeq': False, 'lastData': False, - 'packets': 0 + 'packets': 0, + 'crcs': [] }, 2: { 'RX_START': time(), @@ -1823,7 +1827,8 @@ class routerHBP(HBSYSTEM): }, 'lastSeq': False, 'lastData': False, - 'packets': 0 + 'packets': 0, + 'crcs': [] } } @@ -2054,6 +2059,8 @@ class routerHBP(HBSYSTEM): dmrpkt = _data[20:53] _bits = _data[15] + _pkt_crc = Crc16.calc(dmrpkt) + _nine = bytes_3(9) _lang = CONFIG['SYSTEMS'][self._system]['ANNOUNCEMENT_LANGUAGE'] @@ -2083,6 +2090,9 @@ class routerHBP(HBSYSTEM): if _call_type == 'unit' and (_dtype_vseq == 6 or _dtype_vseq == 7 or _dtype_vseq == 8 or (_stream_id != self.STATUS[_slot]['RX_STREAM_ID'] and _dtype_vseq == 3)): _data_call = True + self.STATUS[_slot]['packets'] = 0 + self.STATUS[_slot]['crcs'] = [] + if _dtype_vseq == 3: logger.info('(%s) *UNIT CSBK* STREAM ID: %s SUB: %s (%s) PEER: %s (%s) DST_ID %s (%s), TS %s', \ self._system, int_id(_stream_id), get_alias(_rf_src, subscriber_ids), int_id(_rf_src), get_alias(_peer_id, peer_ids), int_id(_peer_id), get_alias(_dst_id, talkgroup_ids), int_id(_dst_id), _slot) @@ -2181,6 +2191,7 @@ class routerHBP(HBSYSTEM): if (_stream_id != self.STATUS[_slot]['RX_STREAM_ID']): self.STATUS[_slot]['packets'] = 0 + self.STATUS[_slot]['crcs'] = [] self.STATUS[_slot]['_stopTgAnnounce'] = False @@ -2330,6 +2341,7 @@ class routerHBP(HBSYSTEM): if (_stream_id != self.STATUS[_slot]['RX_STREAM_ID']): self.STATUS[_slot]['packets'] = 0 + self.STATUS[_slot]['crcs'] = [] if (self.STATUS[_slot]['RX_TYPE'] != HBPF_SLT_VTERM) and (pkt_time < (self.STATUS[_slot]['RX_TIME'] + STREAM_TO)) and (_rf_src != self.STATUS[_slot]['RX_RFS']): logger.warning('(%s) Packet received with STREAM ID: %s SUB: %s PEER: %s TGID %s, SLOT %s collided with existing call', self._system, int_id(_stream_id), int_id(_rf_src), int_id(_peer_id), int_id(_dst_id), _slot) @@ -2418,6 +2430,10 @@ class routerHBP(HBSYSTEM): if _seq and _seq == self.STATUS[_slot]['lastSeq']: logger.warning("(%s) *PacketControl* Duplicate sequence number %s, disgarding. Stream ID:, %s TGID: %s",self._system,_seq,int_id(_stream_id),int_id(_dst_id)) return + #Duplicate DMR payload to previuos packet (by CRC16) + if _pkt_crc in self.STATUS[_slot]['crcs']: + logger.warning("(%s) *PacketControl* DMR packet payload with CRC16: %s seen before in this stream, disgarding. Stream ID:, %s TGID: %s",self._system,_pkt_crc,int_id(_stream_id),int_id(_dst_id)) + return #Inbound out-of-order packets if _seq and self.STATUS[_slot]['lastSeq'] and (_seq != 1) and (_seq < self.STATUS[_slot]['lastSeq']): logger.warning("%s) *PacketControl* Out of order packet - last SEQ: %s, this SEQ: %s, disgarding. Stream ID:, %s TGID: %s ",self._system,self.STATUS[_slot]['lastSeq'],_seq,int_id(_stream_id),int_id(_dst_id)) @@ -2552,6 +2568,8 @@ class routerHBP(HBSYSTEM): self.STATUS[_slot]['RX_TGID'] = _dst_id self.STATUS[_slot]['RX_TIME'] = pkt_time self.STATUS[_slot]['RX_STREAM_ID'] = _stream_id + + self.STATUS[_slot]['crcs'].append(_pkt_crc) # # Socket-based reporting section From b03b342227b81e7a5af32ab597b7173d2ae4318e Mon Sep 17 00:00:00 2001 From: Simon Date: Sat, 8 Jan 2022 12:32:03 +0000 Subject: [PATCH 05/46] debug --- bridge_master.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bridge_master.py b/bridge_master.py index 7aac592..bc76752 100644 --- a/bridge_master.py +++ b/bridge_master.py @@ -1713,7 +1713,7 @@ class routerOBP(OPENBRIDGE): return #Duplicate DMR payload to previuos packet (by CRC16) if _pkt_crc in self.STATUS[_stream_id]['crcs']: - logger.warning("(%s) *PacketControl* DMR packet payload with CRC16: %s seen before in this stream, disgarding. Stream ID:, %s TGID: %s",self._system,_pkt_crc,int_id(_stream_id),int_id(_dst_id)) + logger.warning("(%s) *PacketControl* DMR packet payload with CRC16: %s seen before in this stream, disgarding. Stream ID:, %s TGID: %s, crcs: %s",self._system,_pkt_crc,int_id(_stream_id),int_id(_dst_id),self.STATUS[_stream_id]['crcs']) return #Inbound out-of-order packets if _seq and self.STATUS[_stream_id]['lastSeq'] and (_seq != 1) and (_seq < self.STATUS[_stream_id]['lastSeq']): From 0a76fc08ef570dffa36b3f42c25ee92aad4b2180 Mon Sep 17 00:00:00 2001 From: Simon Date: Sat, 8 Jan 2022 12:37:43 +0000 Subject: [PATCH 06/46] debug --- bridge_master.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/bridge_master.py b/bridge_master.py index bc76752..a3c3246 100644 --- a/bridge_master.py +++ b/bridge_master.py @@ -39,7 +39,7 @@ import importlib.util import re import copy from setproctitle import setproctitle -from crccheck.crc import Crc16 +from crccheck.crc import Crc32 # Twisted is pretty important, so I keep it separate from twisted.internet.protocol import Factory, Protocol @@ -1464,7 +1464,7 @@ class routerOBP(OPENBRIDGE): pkt_time = time() dmrpkt = _data[20:53] _bits = _data[15] - _pkt_crc = Crc16.calc(dmrpkt) + _pkt_crc = Crc32.calc(dmrpkt) # Match UNIT data, SMS/GPS, and send it to the dst_id if it is in SUB_MAP if _call_type == 'unit' and (_dtype_vseq == 6 or _dtype_vseq == 7 or _dtype_vseq == 8 or ((_stream_id not in self.STATUS) and _dtype_vseq == 3)): @@ -1711,9 +1711,9 @@ class routerOBP(OPENBRIDGE): if _seq and _seq == self.STATUS[_stream_id]['lastSeq']: logger.warning("(%s) *PacketControl* Duplicate sequence number %s, disgarding. Stream ID:, %s TGID: %s",self._system,_seq,int_id(_stream_id),int_id(_dst_id)) return - #Duplicate DMR payload to previuos packet (by CRC16) + #Duplicate DMR payload to previuos packet (by Crc32) if _pkt_crc in self.STATUS[_stream_id]['crcs']: - logger.warning("(%s) *PacketControl* DMR packet payload with CRC16: %s seen before in this stream, disgarding. Stream ID:, %s TGID: %s, crcs: %s",self._system,_pkt_crc,int_id(_stream_id),int_id(_dst_id),self.STATUS[_stream_id]['crcs']) + logger.warning("(%s) *PacketControl* DMR packet payload with Crc32: %s seen before in this stream, disgarding. Stream ID:, %s TGID: %s, crcs: %s",self._system,_pkt_crc,int_id(_stream_id),int_id(_dst_id),self.STATUS[_stream_id]['crcs']) return #Inbound out-of-order packets if _seq and self.STATUS[_stream_id]['lastSeq'] and (_seq != 1) and (_seq < self.STATUS[_stream_id]['lastSeq']): @@ -2059,7 +2059,7 @@ class routerHBP(HBSYSTEM): dmrpkt = _data[20:53] _bits = _data[15] - _pkt_crc = Crc16.calc(dmrpkt) + _pkt_crc = Crc32.calc(dmrpkt) _nine = bytes_3(9) @@ -2430,9 +2430,9 @@ class routerHBP(HBSYSTEM): if _seq and _seq == self.STATUS[_slot]['lastSeq']: logger.warning("(%s) *PacketControl* Duplicate sequence number %s, disgarding. Stream ID:, %s TGID: %s",self._system,_seq,int_id(_stream_id),int_id(_dst_id)) return - #Duplicate DMR payload to previuos packet (by CRC16) + #Duplicate DMR payload to previuos packet (by Crc32) if _pkt_crc in self.STATUS[_slot]['crcs']: - logger.warning("(%s) *PacketControl* DMR packet payload with CRC16: %s seen before in this stream, disgarding. Stream ID:, %s TGID: %s",self._system,_pkt_crc,int_id(_stream_id),int_id(_dst_id)) + logger.warning("(%s) *PacketControl* DMR packet payload with Crc32: %s seen before in this stream, disgarding. Stream ID:, %s TGID: %s",self._system,_pkt_crc,int_id(_stream_id),int_id(_dst_id)) return #Inbound out-of-order packets if _seq and self.STATUS[_slot]['lastSeq'] and (_seq != 1) and (_seq < self.STATUS[_slot]['lastSeq']): From c48c69802eddae19f667c30e9b824f7dc1b50c65 Mon Sep 17 00:00:00 2001 From: Simon Date: Sat, 8 Jan 2022 13:12:10 +0000 Subject: [PATCH 07/46] extend pkt --- bridge_master.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/bridge_master.py b/bridge_master.py index a3c3246..c846192 100644 --- a/bridge_master.py +++ b/bridge_master.py @@ -39,7 +39,7 @@ import importlib.util import re import copy from setproctitle import setproctitle -from crccheck.crc import Crc32 +from crccheck.crc import Crc16 # Twisted is pretty important, so I keep it separate from twisted.internet.protocol import Factory, Protocol @@ -1464,7 +1464,7 @@ class routerOBP(OPENBRIDGE): pkt_time = time() dmrpkt = _data[20:53] _bits = _data[15] - _pkt_crc = Crc32.calc(dmrpkt) + _pkt_crc = Crc16.calc(_data[5:53]) # Match UNIT data, SMS/GPS, and send it to the dst_id if it is in SUB_MAP if _call_type == 'unit' and (_dtype_vseq == 6 or _dtype_vseq == 7 or _dtype_vseq == 8 or ((_stream_id not in self.STATUS) and _dtype_vseq == 3)): @@ -1711,9 +1711,9 @@ class routerOBP(OPENBRIDGE): if _seq and _seq == self.STATUS[_stream_id]['lastSeq']: logger.warning("(%s) *PacketControl* Duplicate sequence number %s, disgarding. Stream ID:, %s TGID: %s",self._system,_seq,int_id(_stream_id),int_id(_dst_id)) return - #Duplicate DMR payload to previuos packet (by Crc32) + #Duplicate DMR payload to previuos packet (by Crc16) if _pkt_crc in self.STATUS[_stream_id]['crcs']: - logger.warning("(%s) *PacketControl* DMR packet payload with Crc32: %s seen before in this stream, disgarding. Stream ID:, %s TGID: %s, crcs: %s",self._system,_pkt_crc,int_id(_stream_id),int_id(_dst_id),self.STATUS[_stream_id]['crcs']) + logger.warning("(%s) *PacketControl* DMR packet payload with Crc16: %s seen before in this stream, disgarding. Stream ID:, %s TGID: %s, crcs: %s",self._system,_pkt_crc,int_id(_stream_id),int_id(_dst_id),self.STATUS[_stream_id]['crcs']) return #Inbound out-of-order packets if _seq and self.STATUS[_stream_id]['lastSeq'] and (_seq != 1) and (_seq < self.STATUS[_stream_id]['lastSeq']): @@ -2059,7 +2059,7 @@ class routerHBP(HBSYSTEM): dmrpkt = _data[20:53] _bits = _data[15] - _pkt_crc = Crc32.calc(dmrpkt) + _pkt_crc = Crc16.calc(dmrpkt) _nine = bytes_3(9) @@ -2430,9 +2430,9 @@ class routerHBP(HBSYSTEM): if _seq and _seq == self.STATUS[_slot]['lastSeq']: logger.warning("(%s) *PacketControl* Duplicate sequence number %s, disgarding. Stream ID:, %s TGID: %s",self._system,_seq,int_id(_stream_id),int_id(_dst_id)) return - #Duplicate DMR payload to previuos packet (by Crc32) + #Duplicate DMR payload to previuos packet (by Crc16) if _pkt_crc in self.STATUS[_slot]['crcs']: - logger.warning("(%s) *PacketControl* DMR packet payload with Crc32: %s seen before in this stream, disgarding. Stream ID:, %s TGID: %s",self._system,_pkt_crc,int_id(_stream_id),int_id(_dst_id)) + logger.warning("(%s) *PacketControl* DMR packet payload with Crc16: %s seen before in this stream, disgarding. Stream ID:, %s TGID: %s",self._system,_pkt_crc,int_id(_stream_id),int_id(_dst_id)) return #Inbound out-of-order packets if _seq and self.STATUS[_slot]['lastSeq'] and (_seq != 1) and (_seq < self.STATUS[_slot]['lastSeq']): From 4d7bba989cd1a7a813ed501cbe38d57e5ea68fd6 Mon Sep 17 00:00:00 2001 From: Simon Date: Sat, 8 Jan 2022 13:15:01 +0000 Subject: [PATCH 08/46] extend pkt even more --- bridge_master.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bridge_master.py b/bridge_master.py index c846192..26d2ca3 100644 --- a/bridge_master.py +++ b/bridge_master.py @@ -1464,7 +1464,7 @@ class routerOBP(OPENBRIDGE): pkt_time = time() dmrpkt = _data[20:53] _bits = _data[15] - _pkt_crc = Crc16.calc(_data[5:53]) + _pkt_crc = Crc16.calc(_data[4:53]) # Match UNIT data, SMS/GPS, and send it to the dst_id if it is in SUB_MAP if _call_type == 'unit' and (_dtype_vseq == 6 or _dtype_vseq == 7 or _dtype_vseq == 8 or ((_stream_id not in self.STATUS) and _dtype_vseq == 3)): From 80b280290f8bbb9fdd51ff76a39da72040341289 Mon Sep 17 00:00:00 2001 From: Simon Date: Sat, 8 Jan 2022 13:21:39 +0000 Subject: [PATCH 09/46] refining... --- bridge_master.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bridge_master.py b/bridge_master.py index 26d2ca3..db3333a 100644 --- a/bridge_master.py +++ b/bridge_master.py @@ -1713,7 +1713,7 @@ class routerOBP(OPENBRIDGE): return #Duplicate DMR payload to previuos packet (by Crc16) if _pkt_crc in self.STATUS[_stream_id]['crcs']: - logger.warning("(%s) *PacketControl* DMR packet payload with Crc16: %s seen before in this stream, disgarding. Stream ID:, %s TGID: %s, crcs: %s",self._system,_pkt_crc,int_id(_stream_id),int_id(_dst_id),self.STATUS[_stream_id]['crcs']) + logger.warning("(%s) *PacketControl* DMR packet payload with Crc16: %s seen before in this stream, disgarding. Stream ID:, %s TGID: %s: SEQ:%s",self._system,_pkt_crc,int_id(_stream_id),int_id(_dst_id),_seq) return #Inbound out-of-order packets if _seq and self.STATUS[_stream_id]['lastSeq'] and (_seq != 1) and (_seq < self.STATUS[_stream_id]['lastSeq']): From 2eb090a3d3b59814cdc6110578ffe7c9da30b821 Mon Sep 17 00:00:00 2001 From: Simon Date: Sat, 8 Jan 2022 13:31:24 +0000 Subject: [PATCH 10/46] 32bit again --- bridge_master.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/bridge_master.py b/bridge_master.py index db3333a..1a5f49d 100644 --- a/bridge_master.py +++ b/bridge_master.py @@ -39,7 +39,7 @@ import importlib.util import re import copy from setproctitle import setproctitle -from crccheck.crc import Crc16 +from crccheck.crc import Crc32 # Twisted is pretty important, so I keep it separate from twisted.internet.protocol import Factory, Protocol @@ -1464,7 +1464,7 @@ class routerOBP(OPENBRIDGE): pkt_time = time() dmrpkt = _data[20:53] _bits = _data[15] - _pkt_crc = Crc16.calc(_data[4:53]) + _pkt_crc = Crc32.calc(_data[4:53]) # Match UNIT data, SMS/GPS, and send it to the dst_id if it is in SUB_MAP if _call_type == 'unit' and (_dtype_vseq == 6 or _dtype_vseq == 7 or _dtype_vseq == 8 or ((_stream_id not in self.STATUS) and _dtype_vseq == 3)): @@ -1711,9 +1711,9 @@ class routerOBP(OPENBRIDGE): if _seq and _seq == self.STATUS[_stream_id]['lastSeq']: logger.warning("(%s) *PacketControl* Duplicate sequence number %s, disgarding. Stream ID:, %s TGID: %s",self._system,_seq,int_id(_stream_id),int_id(_dst_id)) return - #Duplicate DMR payload to previuos packet (by Crc16) + #Duplicate DMR payload to previuos packet (by Crc32) if _pkt_crc in self.STATUS[_stream_id]['crcs']: - logger.warning("(%s) *PacketControl* DMR packet payload with Crc16: %s seen before in this stream, disgarding. Stream ID:, %s TGID: %s: SEQ:%s",self._system,_pkt_crc,int_id(_stream_id),int_id(_dst_id),_seq) + logger.warning("(%s) *PacketControl* DMR packet payload with Crc32: %s seen before in this stream, disgarding. Stream ID:, %s TGID: %s: SEQ:%s",self._system,_pkt_crc,int_id(_stream_id),int_id(_dst_id),_seq) return #Inbound out-of-order packets if _seq and self.STATUS[_stream_id]['lastSeq'] and (_seq != 1) and (_seq < self.STATUS[_stream_id]['lastSeq']): @@ -2059,7 +2059,7 @@ class routerHBP(HBSYSTEM): dmrpkt = _data[20:53] _bits = _data[15] - _pkt_crc = Crc16.calc(dmrpkt) + _pkt_crc = Crc32.calc(dmrpkt) _nine = bytes_3(9) @@ -2430,9 +2430,9 @@ class routerHBP(HBSYSTEM): if _seq and _seq == self.STATUS[_slot]['lastSeq']: logger.warning("(%s) *PacketControl* Duplicate sequence number %s, disgarding. Stream ID:, %s TGID: %s",self._system,_seq,int_id(_stream_id),int_id(_dst_id)) return - #Duplicate DMR payload to previuos packet (by Crc16) + #Duplicate DMR payload to previuos packet (by Crc32) if _pkt_crc in self.STATUS[_slot]['crcs']: - logger.warning("(%s) *PacketControl* DMR packet payload with Crc16: %s seen before in this stream, disgarding. Stream ID:, %s TGID: %s",self._system,_pkt_crc,int_id(_stream_id),int_id(_dst_id)) + logger.warning("(%s) *PacketControl* DMR packet payload with Crc32: %s seen before in this stream, disgarding. Stream ID:, %s TGID: %s",self._system,_pkt_crc,int_id(_stream_id),int_id(_dst_id)) return #Inbound out-of-order packets if _seq and self.STATUS[_slot]['lastSeq'] and (_seq != 1) and (_seq < self.STATUS[_slot]['lastSeq']): From 454fefce659a0ec01f39670630c28ec8ca9ce092 Mon Sep 17 00:00:00 2001 From: Simon Date: Sat, 8 Jan 2022 13:34:22 +0000 Subject: [PATCH 11/46] exclude seq = 0 --- bridge_master.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bridge_master.py b/bridge_master.py index 1a5f49d..31912d2 100644 --- a/bridge_master.py +++ b/bridge_master.py @@ -1712,7 +1712,7 @@ class routerOBP(OPENBRIDGE): logger.warning("(%s) *PacketControl* Duplicate sequence number %s, disgarding. Stream ID:, %s TGID: %s",self._system,_seq,int_id(_stream_id),int_id(_dst_id)) return #Duplicate DMR payload to previuos packet (by Crc32) - if _pkt_crc in self.STATUS[_stream_id]['crcs']: + if _seq != 0 and _pkt_crc in self.STATUS[_stream_id]['crcs']: logger.warning("(%s) *PacketControl* DMR packet payload with Crc32: %s seen before in this stream, disgarding. Stream ID:, %s TGID: %s: SEQ:%s",self._system,_pkt_crc,int_id(_stream_id),int_id(_dst_id),_seq) return #Inbound out-of-order packets From 038078c7333c8f0e69ab017afff51960becaafe5 Mon Sep 17 00:00:00 2001 From: Simon Date: Sat, 8 Jan 2022 13:38:12 +0000 Subject: [PATCH 12/46] record packets --- bridge_master.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bridge_master.py b/bridge_master.py index 31912d2..d910fdf 100644 --- a/bridge_master.py +++ b/bridge_master.py @@ -1713,7 +1713,7 @@ class routerOBP(OPENBRIDGE): return #Duplicate DMR payload to previuos packet (by Crc32) if _seq != 0 and _pkt_crc in self.STATUS[_stream_id]['crcs']: - logger.warning("(%s) *PacketControl* DMR packet payload with Crc32: %s seen before in this stream, disgarding. Stream ID:, %s TGID: %s: SEQ:%s",self._system,_pkt_crc,int_id(_stream_id),int_id(_dst_id),_seq) + logger.warning("(%s) *PacketControl* DMR packet payload with Crc32: %s seen before in this stream, disgarding. Stream ID:, %s TGID: %s: SEQ:%s packets: ",self._system,_pkt_crc,int_id(_stream_id),int_id(_dst_id),_seq, self.STATUS[_stream_id]['packets']) return #Inbound out-of-order packets if _seq and self.STATUS[_stream_id]['lastSeq'] and (_seq != 1) and (_seq < self.STATUS[_stream_id]['lastSeq']): From 434a6c79272720807f15c279ba1f29d43a784908 Mon Sep 17 00:00:00 2001 From: Simon Date: Sat, 8 Jan 2022 13:39:12 +0000 Subject: [PATCH 13/46] temp remove seq --- bridge_master.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bridge_master.py b/bridge_master.py index d910fdf..0324e0f 100644 --- a/bridge_master.py +++ b/bridge_master.py @@ -1712,7 +1712,7 @@ class routerOBP(OPENBRIDGE): logger.warning("(%s) *PacketControl* Duplicate sequence number %s, disgarding. Stream ID:, %s TGID: %s",self._system,_seq,int_id(_stream_id),int_id(_dst_id)) return #Duplicate DMR payload to previuos packet (by Crc32) - if _seq != 0 and _pkt_crc in self.STATUS[_stream_id]['crcs']: + if _pkt_crc in self.STATUS[_stream_id]['crcs']: logger.warning("(%s) *PacketControl* DMR packet payload with Crc32: %s seen before in this stream, disgarding. Stream ID:, %s TGID: %s: SEQ:%s packets: ",self._system,_pkt_crc,int_id(_stream_id),int_id(_dst_id),_seq, self.STATUS[_stream_id]['packets']) return #Inbound out-of-order packets From 9d3540e4bdd62f657d615a942badbb686fb3ea8d Mon Sep 17 00:00:00 2001 From: Simon Date: Sat, 8 Jan 2022 13:58:29 +0000 Subject: [PATCH 14/46] fix log --- bridge_master.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bridge_master.py b/bridge_master.py index 0324e0f..ba4cbbf 100644 --- a/bridge_master.py +++ b/bridge_master.py @@ -1713,7 +1713,7 @@ class routerOBP(OPENBRIDGE): return #Duplicate DMR payload to previuos packet (by Crc32) if _pkt_crc in self.STATUS[_stream_id]['crcs']: - logger.warning("(%s) *PacketControl* DMR packet payload with Crc32: %s seen before in this stream, disgarding. Stream ID:, %s TGID: %s: SEQ:%s packets: ",self._system,_pkt_crc,int_id(_stream_id),int_id(_dst_id),_seq, self.STATUS[_stream_id]['packets']) + logger.warning("(%s) *PacketControl* DMR packet payload with Crc32: %s seen before in this stream, disgarding. Stream ID:, %s TGID: %s: SEQ:%s packets: %s ",self._system,_pkt_crc,int_id(_stream_id),int_id(_dst_id),_seq, self.STATUS[_stream_id]['packets']) return #Inbound out-of-order packets if _seq and self.STATUS[_stream_id]['lastSeq'] and (_seq != 1) and (_seq < self.STATUS[_stream_id]['lastSeq']): From c2b3213da4c77fd3712016ad87de89a4f8ac3660 Mon Sep 17 00:00:00 2001 From: Simon Date: Sat, 8 Jan 2022 14:01:42 +0000 Subject: [PATCH 15/46] more loggy --- bridge_master.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bridge_master.py b/bridge_master.py index ba4cbbf..753ddca 100644 --- a/bridge_master.py +++ b/bridge_master.py @@ -1713,7 +1713,7 @@ class routerOBP(OPENBRIDGE): return #Duplicate DMR payload to previuos packet (by Crc32) if _pkt_crc in self.STATUS[_stream_id]['crcs']: - logger.warning("(%s) *PacketControl* DMR packet payload with Crc32: %s seen before in this stream, disgarding. Stream ID:, %s TGID: %s: SEQ:%s packets: %s ",self._system,_pkt_crc,int_id(_stream_id),int_id(_dst_id),_seq, self.STATUS[_stream_id]['packets']) + logger.warning("(%s) *PacketControl* DMR packet payload with Crc32: %s seen before in this stream, disgarding. Stream ID:, %s TGID: %s: SEQ:%s packets: %s %s ",self._system,_pkt_crc,int_id(_stream_id),int_id(_dst_id),_seq, self.STATUS[_stream_id,]['packets'],elf.STATUS[_stream_id]['crcs']) return #Inbound out-of-order packets if _seq and self.STATUS[_stream_id]['lastSeq'] and (_seq != 1) and (_seq < self.STATUS[_stream_id]['lastSeq']): From 6528e3dcb8c2798f5c125df21287bfee9b19fa49 Mon Sep 17 00:00:00 2001 From: Simon Date: Sat, 8 Jan 2022 14:04:48 +0000 Subject: [PATCH 16/46] more loggy fix --- bridge_master.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bridge_master.py b/bridge_master.py index 753ddca..71d92d3 100644 --- a/bridge_master.py +++ b/bridge_master.py @@ -1713,7 +1713,7 @@ class routerOBP(OPENBRIDGE): return #Duplicate DMR payload to previuos packet (by Crc32) if _pkt_crc in self.STATUS[_stream_id]['crcs']: - logger.warning("(%s) *PacketControl* DMR packet payload with Crc32: %s seen before in this stream, disgarding. Stream ID:, %s TGID: %s: SEQ:%s packets: %s %s ",self._system,_pkt_crc,int_id(_stream_id),int_id(_dst_id),_seq, self.STATUS[_stream_id,]['packets'],elf.STATUS[_stream_id]['crcs']) + logger.warning("(%s) *PacketControl* DMR packet payload with Crc32: %s seen before in this stream, disgarding. Stream ID:, %s TGID: %s: SEQ:%s packets: %s %s ",self._system,_pkt_crc,int_id(_stream_id),int_id(_dst_id),_seq, self.STATUS[_stream_id,]['packets'],self.STATUS[_stream_id]['crcs']) return #Inbound out-of-order packets if _seq and self.STATUS[_stream_id]['lastSeq'] and (_seq != 1) and (_seq < self.STATUS[_stream_id]['lastSeq']): From 23323078d0994521bd8f525f983fda2214a455cd Mon Sep 17 00:00:00 2001 From: Simon Date: Sat, 8 Jan 2022 14:07:47 +0000 Subject: [PATCH 17/46] more loggy fix --- bridge_master.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bridge_master.py b/bridge_master.py index 71d92d3..c1bb212 100644 --- a/bridge_master.py +++ b/bridge_master.py @@ -1713,7 +1713,7 @@ class routerOBP(OPENBRIDGE): return #Duplicate DMR payload to previuos packet (by Crc32) if _pkt_crc in self.STATUS[_stream_id]['crcs']: - logger.warning("(%s) *PacketControl* DMR packet payload with Crc32: %s seen before in this stream, disgarding. Stream ID:, %s TGID: %s: SEQ:%s packets: %s %s ",self._system,_pkt_crc,int_id(_stream_id),int_id(_dst_id),_seq, self.STATUS[_stream_id,]['packets'],self.STATUS[_stream_id]['crcs']) + logger.warning("(%s) *PacketControl* DMR packet payload with Crc32: %s seen before in this stream, disgarding. Stream ID:, %s TGID: %s: SEQ:%s packets: %s %s ",self._system,_pkt_crc,int_id(_stream_id),int_id(_dst_id),_seq, self.STATUS[_stream_id]['packets'],self.STATUS[_stream_id]['crcs']) return #Inbound out-of-order packets if _seq and self.STATUS[_stream_id]['lastSeq'] and (_seq != 1) and (_seq < self.STATUS[_stream_id]['lastSeq']): From 4992772b2348573d49fda02aeed64dd5ca5a399d Mon Sep 17 00:00:00 2001 From: Simon Date: Sat, 8 Jan 2022 14:23:36 +0000 Subject: [PATCH 18/46] seq again --- bridge_master.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bridge_master.py b/bridge_master.py index c1bb212..7172919 100644 --- a/bridge_master.py +++ b/bridge_master.py @@ -1712,7 +1712,7 @@ class routerOBP(OPENBRIDGE): logger.warning("(%s) *PacketControl* Duplicate sequence number %s, disgarding. Stream ID:, %s TGID: %s",self._system,_seq,int_id(_stream_id),int_id(_dst_id)) return #Duplicate DMR payload to previuos packet (by Crc32) - if _pkt_crc in self.STATUS[_stream_id]['crcs']: + if _seq != 0 and _pkt_crc in self.STATUS[_stream_id]['crcs']: logger.warning("(%s) *PacketControl* DMR packet payload with Crc32: %s seen before in this stream, disgarding. Stream ID:, %s TGID: %s: SEQ:%s packets: %s %s ",self._system,_pkt_crc,int_id(_stream_id),int_id(_dst_id),_seq, self.STATUS[_stream_id]['packets'],self.STATUS[_stream_id]['crcs']) return #Inbound out-of-order packets From 695154317c340199da515fcfad1fb0343225b4e8 Mon Sep 17 00:00:00 2001 From: Simon Date: Sat, 8 Jan 2022 14:25:59 +0000 Subject: [PATCH 19/46] change seq for packets > 1 --- bridge_master.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bridge_master.py b/bridge_master.py index 7172919..74e3033 100644 --- a/bridge_master.py +++ b/bridge_master.py @@ -1712,7 +1712,7 @@ class routerOBP(OPENBRIDGE): logger.warning("(%s) *PacketControl* Duplicate sequence number %s, disgarding. Stream ID:, %s TGID: %s",self._system,_seq,int_id(_stream_id),int_id(_dst_id)) return #Duplicate DMR payload to previuos packet (by Crc32) - if _seq != 0 and _pkt_crc in self.STATUS[_stream_id]['crcs']: + if self.STATUS[_stream_id]['packets'] > 1 and _pkt_crc in self.STATUS[_stream_id]['crcs']: logger.warning("(%s) *PacketControl* DMR packet payload with Crc32: %s seen before in this stream, disgarding. Stream ID:, %s TGID: %s: SEQ:%s packets: %s %s ",self._system,_pkt_crc,int_id(_stream_id),int_id(_dst_id),_seq, self.STATUS[_stream_id]['packets'],self.STATUS[_stream_id]['crcs']) return #Inbound out-of-order packets From d781355c05c5265943f0f593b46c1c0303558214 Mon Sep 17 00:00:00 2001 From: Simon Date: Sat, 8 Jan 2022 14:27:30 +0000 Subject: [PATCH 20/46] switch back to 16 bit crc --- bridge_master.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/bridge_master.py b/bridge_master.py index 74e3033..9330742 100644 --- a/bridge_master.py +++ b/bridge_master.py @@ -39,7 +39,7 @@ import importlib.util import re import copy from setproctitle import setproctitle -from crccheck.crc import Crc32 +from crccheck.crc import Crc16 # Twisted is pretty important, so I keep it separate from twisted.internet.protocol import Factory, Protocol @@ -1464,7 +1464,7 @@ class routerOBP(OPENBRIDGE): pkt_time = time() dmrpkt = _data[20:53] _bits = _data[15] - _pkt_crc = Crc32.calc(_data[4:53]) + _pkt_crc = Crc16.calc(_data[4:53]) # Match UNIT data, SMS/GPS, and send it to the dst_id if it is in SUB_MAP if _call_type == 'unit' and (_dtype_vseq == 6 or _dtype_vseq == 7 or _dtype_vseq == 8 or ((_stream_id not in self.STATUS) and _dtype_vseq == 3)): @@ -1711,9 +1711,9 @@ class routerOBP(OPENBRIDGE): if _seq and _seq == self.STATUS[_stream_id]['lastSeq']: logger.warning("(%s) *PacketControl* Duplicate sequence number %s, disgarding. Stream ID:, %s TGID: %s",self._system,_seq,int_id(_stream_id),int_id(_dst_id)) return - #Duplicate DMR payload to previuos packet (by Crc32) + #Duplicate DMR payload to previuos packet (by Crc16) if self.STATUS[_stream_id]['packets'] > 1 and _pkt_crc in self.STATUS[_stream_id]['crcs']: - logger.warning("(%s) *PacketControl* DMR packet payload with Crc32: %s seen before in this stream, disgarding. Stream ID:, %s TGID: %s: SEQ:%s packets: %s %s ",self._system,_pkt_crc,int_id(_stream_id),int_id(_dst_id),_seq, self.STATUS[_stream_id]['packets'],self.STATUS[_stream_id]['crcs']) + logger.warning("(%s) *PacketControl* DMR packet payload with Crc16: %s seen before in this stream, disgarding. Stream ID:, %s TGID: %s: SEQ:%s packets: %s %s ",self._system,_pkt_crc,int_id(_stream_id),int_id(_dst_id),_seq, self.STATUS[_stream_id]['packets'],self.STATUS[_stream_id]['crcs']) return #Inbound out-of-order packets if _seq and self.STATUS[_stream_id]['lastSeq'] and (_seq != 1) and (_seq < self.STATUS[_stream_id]['lastSeq']): @@ -2059,7 +2059,7 @@ class routerHBP(HBSYSTEM): dmrpkt = _data[20:53] _bits = _data[15] - _pkt_crc = Crc32.calc(dmrpkt) + _pkt_crc = Crc16.calc(dmrpkt) _nine = bytes_3(9) @@ -2430,9 +2430,9 @@ class routerHBP(HBSYSTEM): if _seq and _seq == self.STATUS[_slot]['lastSeq']: logger.warning("(%s) *PacketControl* Duplicate sequence number %s, disgarding. Stream ID:, %s TGID: %s",self._system,_seq,int_id(_stream_id),int_id(_dst_id)) return - #Duplicate DMR payload to previuos packet (by Crc32) + #Duplicate DMR payload to previuos packet (by Crc16) if _pkt_crc in self.STATUS[_slot]['crcs']: - logger.warning("(%s) *PacketControl* DMR packet payload with Crc32: %s seen before in this stream, disgarding. Stream ID:, %s TGID: %s",self._system,_pkt_crc,int_id(_stream_id),int_id(_dst_id)) + logger.warning("(%s) *PacketControl* DMR packet payload with Crc16: %s seen before in this stream, disgarding. Stream ID:, %s TGID: %s",self._system,_pkt_crc,int_id(_stream_id),int_id(_dst_id)) return #Inbound out-of-order packets if _seq and self.STATUS[_slot]['lastSeq'] and (_seq != 1) and (_seq < self.STATUS[_slot]['lastSeq']): From a246726528c656381c8bf7d60b5e326435bdfa02 Mon Sep 17 00:00:00 2001 From: Simon Date: Sat, 8 Jan 2022 14:32:12 +0000 Subject: [PATCH 21/46] try reducing included again --- bridge_master.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/bridge_master.py b/bridge_master.py index 9330742..1c6ffcb 100644 --- a/bridge_master.py +++ b/bridge_master.py @@ -1464,7 +1464,9 @@ class routerOBP(OPENBRIDGE): pkt_time = time() dmrpkt = _data[20:53] _bits = _data[15] - _pkt_crc = Crc16.calc(_data[4:53]) + #_pkt_crc = Crc16.calc(_data[4:53]) + _pkt_crc = Crc16.calc(dmrpkt) + # Match UNIT data, SMS/GPS, and send it to the dst_id if it is in SUB_MAP if _call_type == 'unit' and (_dtype_vseq == 6 or _dtype_vseq == 7 or _dtype_vseq == 8 or ((_stream_id not in self.STATUS) and _dtype_vseq == 3)): From 0a0bcf01d1e362ab91c28fec7e2b5e2e983d2375 Mon Sep 17 00:00:00 2001 From: Simon Date: Sat, 8 Jan 2022 14:33:37 +0000 Subject: [PATCH 22/46] log --- bridge_master.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bridge_master.py b/bridge_master.py index 1c6ffcb..c746837 100644 --- a/bridge_master.py +++ b/bridge_master.py @@ -1715,7 +1715,7 @@ class routerOBP(OPENBRIDGE): return #Duplicate DMR payload to previuos packet (by Crc16) if self.STATUS[_stream_id]['packets'] > 1 and _pkt_crc in self.STATUS[_stream_id]['crcs']: - logger.warning("(%s) *PacketControl* DMR packet payload with Crc16: %s seen before in this stream, disgarding. Stream ID:, %s TGID: %s: SEQ:%s packets: %s %s ",self._system,_pkt_crc,int_id(_stream_id),int_id(_dst_id),_seq, self.STATUS[_stream_id]['packets'],self.STATUS[_stream_id]['crcs']) + logger.warning("(%s) *PacketControl* DMR packet payload with Crc16: %s seen before in this stream, disgarding. Stream ID:, %s TGID: %s: SEQ:%s packets: %s %s ",self._system,_pkt_crc,int_id(_stream_id),int_id(_dst_id),_seq, self.STATUS[_stream_id]['packets']) return #Inbound out-of-order packets if _seq and self.STATUS[_stream_id]['lastSeq'] and (_seq != 1) and (_seq < self.STATUS[_stream_id]['lastSeq']): From c22e515046a86500f421440e57362a6651865929 Mon Sep 17 00:00:00 2001 From: Simon Date: Sat, 8 Jan 2022 14:39:55 +0000 Subject: [PATCH 23/46] remove crc list from log --- bridge_master.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bridge_master.py b/bridge_master.py index c746837..2ab808f 100644 --- a/bridge_master.py +++ b/bridge_master.py @@ -1715,7 +1715,7 @@ class routerOBP(OPENBRIDGE): return #Duplicate DMR payload to previuos packet (by Crc16) if self.STATUS[_stream_id]['packets'] > 1 and _pkt_crc in self.STATUS[_stream_id]['crcs']: - logger.warning("(%s) *PacketControl* DMR packet payload with Crc16: %s seen before in this stream, disgarding. Stream ID:, %s TGID: %s: SEQ:%s packets: %s %s ",self._system,_pkt_crc,int_id(_stream_id),int_id(_dst_id),_seq, self.STATUS[_stream_id]['packets']) + logger.warning("(%s) *PacketControl* DMR packet payload with Crc16: %s seen before in this stream, disgarding. Stream ID:, %s TGID: %s: SEQ:%s packets: %s ",self._system,_pkt_crc,int_id(_stream_id),int_id(_dst_id),_seq, self.STATUS[_stream_id]['packets']) return #Inbound out-of-order packets if _seq and self.STATUS[_stream_id]['lastSeq'] and (_seq != 1) and (_seq < self.STATUS[_stream_id]['lastSeq']): From be632b3097f07734eca8c57f1a2391dd47d79903 Mon Sep 17 00:00:00 2001 From: Simon Date: Sat, 8 Jan 2022 14:45:50 +0000 Subject: [PATCH 24/46] everything but sequence --- bridge_master.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bridge_master.py b/bridge_master.py index 2ab808f..319438a 100644 --- a/bridge_master.py +++ b/bridge_master.py @@ -1464,8 +1464,8 @@ class routerOBP(OPENBRIDGE): pkt_time = time() dmrpkt = _data[20:53] _bits = _data[15] - #_pkt_crc = Crc16.calc(_data[4:53]) - _pkt_crc = Crc16.calc(dmrpkt) + _pkt_crc = Crc16.calc(_data[5:53]) + #_pkt_crc = Crc16.calc(dmrpkt) # Match UNIT data, SMS/GPS, and send it to the dst_id if it is in SUB_MAP From 8bac0886c72a3370b6f4acd3ca99ac5b375cd75d Mon Sep 17 00:00:00 2001 From: Simon Date: Sat, 8 Jan 2022 14:47:54 +0000 Subject: [PATCH 25/46] back to everything including sequence --- bridge_master.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bridge_master.py b/bridge_master.py index 319438a..9e3d3df 100644 --- a/bridge_master.py +++ b/bridge_master.py @@ -1464,7 +1464,7 @@ class routerOBP(OPENBRIDGE): pkt_time = time() dmrpkt = _data[20:53] _bits = _data[15] - _pkt_crc = Crc16.calc(_data[5:53]) + _pkt_crc = Crc16.calc(_data[4:53]) #_pkt_crc = Crc16.calc(dmrpkt) From 4a343ad8a712ca479d56175d5d15b5d514c74651 Mon Sep 17 00:00:00 2001 From: Simon Date: Sat, 8 Jan 2022 14:51:44 +0000 Subject: [PATCH 26/46] back to 32 again --- bridge_master.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/bridge_master.py b/bridge_master.py index 9e3d3df..798a64d 100644 --- a/bridge_master.py +++ b/bridge_master.py @@ -39,7 +39,7 @@ import importlib.util import re import copy from setproctitle import setproctitle -from crccheck.crc import Crc16 +from crccheck.crc import Crc32 # Twisted is pretty important, so I keep it separate from twisted.internet.protocol import Factory, Protocol @@ -1464,8 +1464,8 @@ class routerOBP(OPENBRIDGE): pkt_time = time() dmrpkt = _data[20:53] _bits = _data[15] - _pkt_crc = Crc16.calc(_data[4:53]) - #_pkt_crc = Crc16.calc(dmrpkt) + _pkt_crc = Crc32.calc(_data[4:53]) + #_pkt_crc = Crc32.calc(dmrpkt) # Match UNIT data, SMS/GPS, and send it to the dst_id if it is in SUB_MAP @@ -1713,9 +1713,9 @@ class routerOBP(OPENBRIDGE): if _seq and _seq == self.STATUS[_stream_id]['lastSeq']: logger.warning("(%s) *PacketControl* Duplicate sequence number %s, disgarding. Stream ID:, %s TGID: %s",self._system,_seq,int_id(_stream_id),int_id(_dst_id)) return - #Duplicate DMR payload to previuos packet (by Crc16) + #Duplicate DMR payload to previuos packet (by Crc32) if self.STATUS[_stream_id]['packets'] > 1 and _pkt_crc in self.STATUS[_stream_id]['crcs']: - logger.warning("(%s) *PacketControl* DMR packet payload with Crc16: %s seen before in this stream, disgarding. Stream ID:, %s TGID: %s: SEQ:%s packets: %s ",self._system,_pkt_crc,int_id(_stream_id),int_id(_dst_id),_seq, self.STATUS[_stream_id]['packets']) + logger.warning("(%s) *PacketControl* DMR packet payload with Crc32: %s seen before in this stream, disgarding. Stream ID:, %s TGID: %s: SEQ:%s packets: %s ",self._system,_pkt_crc,int_id(_stream_id),int_id(_dst_id),_seq, self.STATUS[_stream_id]['packets']) return #Inbound out-of-order packets if _seq and self.STATUS[_stream_id]['lastSeq'] and (_seq != 1) and (_seq < self.STATUS[_stream_id]['lastSeq']): @@ -2061,7 +2061,7 @@ class routerHBP(HBSYSTEM): dmrpkt = _data[20:53] _bits = _data[15] - _pkt_crc = Crc16.calc(dmrpkt) + _pkt_crc = Crc32.calc(_data[4:53]) _nine = bytes_3(9) @@ -2432,9 +2432,9 @@ class routerHBP(HBSYSTEM): if _seq and _seq == self.STATUS[_slot]['lastSeq']: logger.warning("(%s) *PacketControl* Duplicate sequence number %s, disgarding. Stream ID:, %s TGID: %s",self._system,_seq,int_id(_stream_id),int_id(_dst_id)) return - #Duplicate DMR payload to previuos packet (by Crc16) + #Duplicate DMR payload to previuos packet (by Crc32) if _pkt_crc in self.STATUS[_slot]['crcs']: - logger.warning("(%s) *PacketControl* DMR packet payload with Crc16: %s seen before in this stream, disgarding. Stream ID:, %s TGID: %s",self._system,_pkt_crc,int_id(_stream_id),int_id(_dst_id)) + logger.warning("(%s) *PacketControl* DMR packet payload with Crc32: %s seen before in this stream, disgarding. Stream ID:, %s TGID: %s",self._system,_pkt_crc,int_id(_stream_id),int_id(_dst_id)) return #Inbound out-of-order packets if _seq and self.STATUS[_slot]['lastSeq'] and (_seq != 1) and (_seq < self.STATUS[_slot]['lastSeq']): From 12ffffde8b44f9a64882fffec36572e17f671520 Mon Sep 17 00:00:00 2001 From: Simon Date: Sat, 8 Jan 2022 15:14:20 +0000 Subject: [PATCH 27/46] apply same fixes to HBP --- bridge_master.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bridge_master.py b/bridge_master.py index 798a64d..8cdbfe5 100644 --- a/bridge_master.py +++ b/bridge_master.py @@ -2433,8 +2433,8 @@ class routerHBP(HBSYSTEM): logger.warning("(%s) *PacketControl* Duplicate sequence number %s, disgarding. Stream ID:, %s TGID: %s",self._system,_seq,int_id(_stream_id),int_id(_dst_id)) return #Duplicate DMR payload to previuos packet (by Crc32) - if _pkt_crc in self.STATUS[_slot]['crcs']: - logger.warning("(%s) *PacketControl* DMR packet payload with Crc32: %s seen before in this stream, disgarding. Stream ID:, %s TGID: %s",self._system,_pkt_crc,int_id(_stream_id),int_id(_dst_id)) + if self.STATUS.[_slot]['packets'] > 1 and _pkt_crc in self.STATUS[_slot]['crcs']: + logger.warning("(%s) *PacketControl* DMR packet payload with Crc32: %s seen before in this stream, disgarding. Stream ID:, %s TGID: %s, SEQ: %s",self._system,_pkt_crc,int_id(_stream_id),int_id(_dst_id),_seq) return #Inbound out-of-order packets if _seq and self.STATUS[_slot]['lastSeq'] and (_seq != 1) and (_seq < self.STATUS[_slot]['lastSeq']): From 05d12172b8830060e2cd3c4e4ce88e3d5686155d Mon Sep 17 00:00:00 2001 From: Simon Date: Sat, 8 Jan 2022 15:15:34 +0000 Subject: [PATCH 28/46] apply same fixes to HBP --- bridge_master.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bridge_master.py b/bridge_master.py index 8cdbfe5..de01182 100644 --- a/bridge_master.py +++ b/bridge_master.py @@ -2433,7 +2433,7 @@ class routerHBP(HBSYSTEM): logger.warning("(%s) *PacketControl* Duplicate sequence number %s, disgarding. Stream ID:, %s TGID: %s",self._system,_seq,int_id(_stream_id),int_id(_dst_id)) return #Duplicate DMR payload to previuos packet (by Crc32) - if self.STATUS.[_slot]['packets'] > 1 and _pkt_crc in self.STATUS[_slot]['crcs']: + if self.STATUS[_slot]['packets'] > 1 and _pkt_crc in self.STATUS[_slot]['crcs']: logger.warning("(%s) *PacketControl* DMR packet payload with Crc32: %s seen before in this stream, disgarding. Stream ID:, %s TGID: %s, SEQ: %s",self._system,_pkt_crc,int_id(_stream_id),int_id(_dst_id),_seq) return #Inbound out-of-order packets From 7df48827722ae312456ecfdbcd9e6648479489c7 Mon Sep 17 00:00:00 2001 From: Simon Date: Sat, 8 Jan 2022 15:17:12 +0000 Subject: [PATCH 29/46] packets --- bridge_master.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bridge_master.py b/bridge_master.py index de01182..e868f0d 100644 --- a/bridge_master.py +++ b/bridge_master.py @@ -2434,7 +2434,7 @@ class routerHBP(HBSYSTEM): return #Duplicate DMR payload to previuos packet (by Crc32) if self.STATUS[_slot]['packets'] > 1 and _pkt_crc in self.STATUS[_slot]['crcs']: - logger.warning("(%s) *PacketControl* DMR packet payload with Crc32: %s seen before in this stream, disgarding. Stream ID:, %s TGID: %s, SEQ: %s",self._system,_pkt_crc,int_id(_stream_id),int_id(_dst_id),_seq) + logger.warning("(%s) *PacketControl* DMR packet payload with Crc32: %s seen before in this stream, disgarding. Stream ID:, %s TGID: %s, SEQ: %s, packets: ",self._system,_pkt_crc,int_id(_stream_id),int_id(_dst_id),_seq,self.STATUS[_slot]['packets']) return #Inbound out-of-order packets if _seq and self.STATUS[_slot]['lastSeq'] and (_seq != 1) and (_seq < self.STATUS[_slot]['lastSeq']): From 8d5e3cfd1bb1d164f1ef35f98d66831cf3bd5607 Mon Sep 17 00:00:00 2001 From: Simon Date: Sat, 8 Jan 2022 15:19:01 +0000 Subject: [PATCH 30/46] packets --- bridge_master.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bridge_master.py b/bridge_master.py index e868f0d..4246e28 100644 --- a/bridge_master.py +++ b/bridge_master.py @@ -2434,7 +2434,7 @@ class routerHBP(HBSYSTEM): return #Duplicate DMR payload to previuos packet (by Crc32) if self.STATUS[_slot]['packets'] > 1 and _pkt_crc in self.STATUS[_slot]['crcs']: - logger.warning("(%s) *PacketControl* DMR packet payload with Crc32: %s seen before in this stream, disgarding. Stream ID:, %s TGID: %s, SEQ: %s, packets: ",self._system,_pkt_crc,int_id(_stream_id),int_id(_dst_id),_seq,self.STATUS[_slot]['packets']) + logger.warning("(%s) *PacketControl* DMR packet payload with Crc32: %s seen before in this stream, disgarding. Stream ID:, %s TGID: %s, SEQ: %s, packets %s: ",self._system,_pkt_crc,int_id(_stream_id),int_id(_dst_id),_seq,self.STATUS[_slot]['packets']) return #Inbound out-of-order packets if _seq and self.STATUS[_slot]['lastSeq'] and (_seq != 1) and (_seq < self.STATUS[_slot]['lastSeq']): From ed2cb5d66a28f0d43fa072aea9c8d35228aff4f0 Mon Sep 17 00:00:00 2001 From: Simon Date: Sat, 8 Jan 2022 15:20:52 +0000 Subject: [PATCH 31/46] packets --- bridge_master.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bridge_master.py b/bridge_master.py index 4246e28..4455155 100644 --- a/bridge_master.py +++ b/bridge_master.py @@ -2433,7 +2433,7 @@ class routerHBP(HBSYSTEM): logger.warning("(%s) *PacketControl* Duplicate sequence number %s, disgarding. Stream ID:, %s TGID: %s",self._system,_seq,int_id(_stream_id),int_id(_dst_id)) return #Duplicate DMR payload to previuos packet (by Crc32) - if self.STATUS[_slot]['packets'] > 1 and _pkt_crc in self.STATUS[_slot]['crcs']: + if self.STATUS[_slot]['packets'] > 2 and _pkt_crc in self.STATUS[_slot]['crcs']: logger.warning("(%s) *PacketControl* DMR packet payload with Crc32: %s seen before in this stream, disgarding. Stream ID:, %s TGID: %s, SEQ: %s, packets %s: ",self._system,_pkt_crc,int_id(_stream_id),int_id(_dst_id),_seq,self.STATUS[_slot]['packets']) return #Inbound out-of-order packets From f5c631109b9af8da54bdbb5ac4f047910c8ab530 Mon Sep 17 00:00:00 2001 From: Simon Date: Sat, 8 Jan 2022 18:21:58 +0000 Subject: [PATCH 32/46] back to eq --- bridge_master.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bridge_master.py b/bridge_master.py index 4455155..e8137a6 100644 --- a/bridge_master.py +++ b/bridge_master.py @@ -1714,7 +1714,7 @@ class routerOBP(OPENBRIDGE): logger.warning("(%s) *PacketControl* Duplicate sequence number %s, disgarding. Stream ID:, %s TGID: %s",self._system,_seq,int_id(_stream_id),int_id(_dst_id)) return #Duplicate DMR payload to previuos packet (by Crc32) - if self.STATUS[_stream_id]['packets'] > 1 and _pkt_crc in self.STATUS[_stream_id]['crcs']: + if _seq > 0 and _pkt_crc in self.STATUS[_stream_id]['crcs']: logger.warning("(%s) *PacketControl* DMR packet payload with Crc32: %s seen before in this stream, disgarding. Stream ID:, %s TGID: %s: SEQ:%s packets: %s ",self._system,_pkt_crc,int_id(_stream_id),int_id(_dst_id),_seq, self.STATUS[_stream_id]['packets']) return #Inbound out-of-order packets @@ -2433,7 +2433,7 @@ class routerHBP(HBSYSTEM): logger.warning("(%s) *PacketControl* Duplicate sequence number %s, disgarding. Stream ID:, %s TGID: %s",self._system,_seq,int_id(_stream_id),int_id(_dst_id)) return #Duplicate DMR payload to previuos packet (by Crc32) - if self.STATUS[_slot]['packets'] > 2 and _pkt_crc in self.STATUS[_slot]['crcs']: + if _seq > 0 and _pkt_crc in self.STATUS[_slot]['crcs']: logger.warning("(%s) *PacketControl* DMR packet payload with Crc32: %s seen before in this stream, disgarding. Stream ID:, %s TGID: %s, SEQ: %s, packets %s: ",self._system,_pkt_crc,int_id(_stream_id),int_id(_dst_id),_seq,self.STATUS[_slot]['packets']) return #Inbound out-of-order packets From 39570ba54d14903b57a7995f0c49c9e67a243a1a Mon Sep 17 00:00:00 2001 From: Simon Date: Sat, 8 Jan 2022 20:00:01 +0000 Subject: [PATCH 33/46] change order of conditions for PacketControl --- bridge_master.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/bridge_master.py b/bridge_master.py index e8137a6..8f36d27 100644 --- a/bridge_master.py +++ b/bridge_master.py @@ -1713,10 +1713,6 @@ class routerOBP(OPENBRIDGE): if _seq and _seq == self.STATUS[_stream_id]['lastSeq']: logger.warning("(%s) *PacketControl* Duplicate sequence number %s, disgarding. Stream ID:, %s TGID: %s",self._system,_seq,int_id(_stream_id),int_id(_dst_id)) return - #Duplicate DMR payload to previuos packet (by Crc32) - if _seq > 0 and _pkt_crc in self.STATUS[_stream_id]['crcs']: - logger.warning("(%s) *PacketControl* DMR packet payload with Crc32: %s seen before in this stream, disgarding. Stream ID:, %s TGID: %s: SEQ:%s packets: %s ",self._system,_pkt_crc,int_id(_stream_id),int_id(_dst_id),_seq, self.STATUS[_stream_id]['packets']) - return #Inbound out-of-order packets if _seq and self.STATUS[_stream_id]['lastSeq'] and (_seq != 1) and (_seq < self.STATUS[_stream_id]['lastSeq']): logger.warning("%s) *PacketControl* Out of order packet - last SEQ: %s, this SEQ: %s, disgarding. Stream ID:, %s TGID: %s ",self._system,self.STATUS[_stream_id]['lastSeq'],_seq,int_id(_stream_id),int_id(_dst_id)) @@ -1724,6 +1720,10 @@ class routerOBP(OPENBRIDGE): #Inbound missed packets if _seq and self.STATUS[_stream_id]['lastSeq'] and _seq > (self.STATUS[_stream_id]['lastSeq']+1): logger.warning("(%s) *PacketControl* Missed packet(s) - last SEQ: %s, this SEQ: %s. Stream ID:, %s TGID: %s ",self._system,self.STATUS[_stream_id]['lastSeq'],_seq,int_id(_stream_id),int_id(_dst_id)) + #Duplicate DMR payload to previuos packet (by Crc32) + if _seq > 0 and _pkt_crc in self.STATUS[_stream_id]['crcs']: + logger.warning("(%s) *PacketControl* DMR packet payload with Crc32: %s seen before in this stream, disgarding. Stream ID:, %s TGID: %s: SEQ:%s packets: %s ",self._system,_pkt_crc,int_id(_stream_id),int_id(_dst_id),_seq, self.STATUS[_stream_id]['packets']) + return #Save this sequence number self.STATUS[_stream_id]['lastSeq'] = _seq @@ -2432,10 +2432,6 @@ class routerHBP(HBSYSTEM): if _seq and _seq == self.STATUS[_slot]['lastSeq']: logger.warning("(%s) *PacketControl* Duplicate sequence number %s, disgarding. Stream ID:, %s TGID: %s",self._system,_seq,int_id(_stream_id),int_id(_dst_id)) return - #Duplicate DMR payload to previuos packet (by Crc32) - if _seq > 0 and _pkt_crc in self.STATUS[_slot]['crcs']: - logger.warning("(%s) *PacketControl* DMR packet payload with Crc32: %s seen before in this stream, disgarding. Stream ID:, %s TGID: %s, SEQ: %s, packets %s: ",self._system,_pkt_crc,int_id(_stream_id),int_id(_dst_id),_seq,self.STATUS[_slot]['packets']) - return #Inbound out-of-order packets if _seq and self.STATUS[_slot]['lastSeq'] and (_seq != 1) and (_seq < self.STATUS[_slot]['lastSeq']): logger.warning("%s) *PacketControl* Out of order packet - last SEQ: %s, this SEQ: %s, disgarding. Stream ID:, %s TGID: %s ",self._system,self.STATUS[_slot]['lastSeq'],_seq,int_id(_stream_id),int_id(_dst_id)) @@ -2443,6 +2439,10 @@ class routerHBP(HBSYSTEM): #Inbound missed packets if _seq and self.STATUS[_slot]['lastSeq'] and _seq > (self.STATUS[_slot]['lastSeq']+1): logger.warning("(%s) *PacketControl* Missed packet(s) - last SEQ: %s, this SEQ: %s. Stream ID:, %s TGID: %s ",self._system,self.STATUS[_slot]['lastSeq'],_seq,int_id(_stream_id),int_id(_dst_id)) + #Duplicate DMR payload to previuos packet (by Crc32) + if _seq > 0 and _pkt_crc in self.STATUS[_slot]['crcs']: + logger.warning("(%s) *PacketControl* DMR packet payload with Crc32: %s seen before in this stream, disgarding. Stream ID:, %s TGID: %s, SEQ: %s, packets %s: ",self._system,_pkt_crc,int_id(_stream_id),int_id(_dst_id),_seq,self.STATUS[_slot]['packets']) + return #Save this sequence number self.STATUS[_slot]['lastSeq'] = _seq From 111e1204f2d6057bcfaf396fe77b371d9d533e36 Mon Sep 17 00:00:00 2001 From: Simon Date: Sun, 9 Jan 2022 00:04:48 +0000 Subject: [PATCH 34/46] change order of conditions for PacketControl again --- bridge_master.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/bridge_master.py b/bridge_master.py index 8f36d27..ca2038e 100644 --- a/bridge_master.py +++ b/bridge_master.py @@ -1717,13 +1717,14 @@ class routerOBP(OPENBRIDGE): if _seq and self.STATUS[_stream_id]['lastSeq'] and (_seq != 1) and (_seq < self.STATUS[_stream_id]['lastSeq']): logger.warning("%s) *PacketControl* Out of order packet - last SEQ: %s, this SEQ: %s, disgarding. Stream ID:, %s TGID: %s ",self._system,self.STATUS[_stream_id]['lastSeq'],_seq,int_id(_stream_id),int_id(_dst_id)) return - #Inbound missed packets - if _seq and self.STATUS[_stream_id]['lastSeq'] and _seq > (self.STATUS[_stream_id]['lastSeq']+1): - logger.warning("(%s) *PacketControl* Missed packet(s) - last SEQ: %s, this SEQ: %s. Stream ID:, %s TGID: %s ",self._system,self.STATUS[_stream_id]['lastSeq'],_seq,int_id(_stream_id),int_id(_dst_id)) #Duplicate DMR payload to previuos packet (by Crc32) if _seq > 0 and _pkt_crc in self.STATUS[_stream_id]['crcs']: logger.warning("(%s) *PacketControl* DMR packet payload with Crc32: %s seen before in this stream, disgarding. Stream ID:, %s TGID: %s: SEQ:%s packets: %s ",self._system,_pkt_crc,int_id(_stream_id),int_id(_dst_id),_seq, self.STATUS[_stream_id]['packets']) return + #Inbound missed packets + if _seq and self.STATUS[_stream_id]['lastSeq'] and _seq > (self.STATUS[_stream_id]['lastSeq']+1): + logger.warning("(%s) *PacketControl* Missed packet(s) - last SEQ: %s, this SEQ: %s. Stream ID:, %s TGID: %s ",self._system,self.STATUS[_stream_id]['lastSeq'],_seq,int_id(_stream_id),int_id(_dst_id)) + #Save this sequence number self.STATUS[_stream_id]['lastSeq'] = _seq @@ -2436,13 +2437,13 @@ class routerHBP(HBSYSTEM): if _seq and self.STATUS[_slot]['lastSeq'] and (_seq != 1) and (_seq < self.STATUS[_slot]['lastSeq']): logger.warning("%s) *PacketControl* Out of order packet - last SEQ: %s, this SEQ: %s, disgarding. Stream ID:, %s TGID: %s ",self._system,self.STATUS[_slot]['lastSeq'],_seq,int_id(_stream_id),int_id(_dst_id)) return - #Inbound missed packets - if _seq and self.STATUS[_slot]['lastSeq'] and _seq > (self.STATUS[_slot]['lastSeq']+1): - logger.warning("(%s) *PacketControl* Missed packet(s) - last SEQ: %s, this SEQ: %s. Stream ID:, %s TGID: %s ",self._system,self.STATUS[_slot]['lastSeq'],_seq,int_id(_stream_id),int_id(_dst_id)) #Duplicate DMR payload to previuos packet (by Crc32) if _seq > 0 and _pkt_crc in self.STATUS[_slot]['crcs']: logger.warning("(%s) *PacketControl* DMR packet payload with Crc32: %s seen before in this stream, disgarding. Stream ID:, %s TGID: %s, SEQ: %s, packets %s: ",self._system,_pkt_crc,int_id(_stream_id),int_id(_dst_id),_seq,self.STATUS[_slot]['packets']) return + #Inbound missed packets + if _seq and self.STATUS[_slot]['lastSeq'] and _seq > (self.STATUS[_slot]['lastSeq']+1): + logger.warning("(%s) *PacketControl* Missed packet(s) - last SEQ: %s, this SEQ: %s. Stream ID:, %s TGID: %s ",self._system,self.STATUS[_slot]['lastSeq'],_seq,int_id(_stream_id),int_id(_dst_id)) #Save this sequence number self.STATUS[_slot]['lastSeq'] = _seq From b4c589fdb14650c15c26d7181de02d2e3b494627 Mon Sep 17 00:00:00 2001 From: Simon Date: Sun, 9 Jan 2022 02:27:01 +0000 Subject: [PATCH 35/46] For HBP, we can use a sha1 digest --- bridge_master.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/bridge_master.py b/bridge_master.py index ca2038e..2be6e22 100644 --- a/bridge_master.py +++ b/bridge_master.py @@ -40,6 +40,7 @@ import re import copy from setproctitle import setproctitle from crccheck.crc import Crc32 +from hashlib import sha1 # Twisted is pretty important, so I keep it separate from twisted.internet.protocol import Factory, Protocol @@ -2062,7 +2063,8 @@ class routerHBP(HBSYSTEM): dmrpkt = _data[20:53] _bits = _data[15] - _pkt_crc = Crc32.calc(_data[4:53]) + #_pkt_crc = Crc32.calc(_data[4:53]) + _pkt_crc = sha1(_data).hexdigest() _nine = bytes_3(9) From e15bab90b0b4df3635f8b15452072c92f81ffc75 Mon Sep 17 00:00:00 2001 From: Simon Date: Sun, 9 Jan 2022 02:28:52 +0000 Subject: [PATCH 36/46] binary digest --- bridge_master.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bridge_master.py b/bridge_master.py index 2be6e22..0dd382e 100644 --- a/bridge_master.py +++ b/bridge_master.py @@ -2064,7 +2064,7 @@ class routerHBP(HBSYSTEM): _bits = _data[15] #_pkt_crc = Crc32.calc(_data[4:53]) - _pkt_crc = sha1(_data).hexdigest() + _pkt_crc = sha1(_data).digest() _nine = bytes_3(9) From 5e1dc45ca275c877260bb8774e0b3d845f31f24f Mon Sep 17 00:00:00 2001 From: Simon Date: Sun, 9 Jan 2022 02:31:30 +0000 Subject: [PATCH 37/46] use existing HMAC for obp CRC --- bridge_master.py | 7 ++++--- hblink.py | 4 ++-- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/bridge_master.py b/bridge_master.py index 0dd382e..d69102e 100644 --- a/bridge_master.py +++ b/bridge_master.py @@ -39,7 +39,7 @@ import importlib.util import re import copy from setproctitle import setproctitle -from crccheck.crc import Crc32 +#from crccheck.crc import Crc32 from hashlib import sha1 # Twisted is pretty important, so I keep it separate @@ -1461,12 +1461,13 @@ class routerOBP(OPENBRIDGE): systems[_target]._report.send_bridgeEvent('UNIT DATA,START,TX,{},{},{},{},{},{}'.format(_target, int_id(_stream_id), int_id(_peer_id), int_id(_rf_src), 1, _int_dst_id).encode(encoding='utf-8', errors='ignore')) - def dmrd_received(self, _peer_id, _rf_src, _dst_id, _seq, _slot, _call_type, _frame_type, _dtype_vseq, _stream_id, _data): + def dmrd_received(self, _peer_id, _rf_src, _dst_id, _seq, _slot, _call_type, _frame_type, _dtype_vseq, _stream_id, _data,_hash): pkt_time = time() dmrpkt = _data[20:53] _bits = _data[15] - _pkt_crc = Crc32.calc(_data[4:53]) + _#pkt_crc = Crc32.calc(_data[4:53]) #_pkt_crc = Crc32.calc(dmrpkt) + )pkt_crc = _hash # Match UNIT data, SMS/GPS, and send it to the dst_id if it is in SUB_MAP diff --git a/hblink.py b/hblink.py index b12b529..8017b48 100755 --- a/hblink.py +++ b/hblink.py @@ -166,7 +166,7 @@ class OPENBRIDGE(DatagramProtocol): logger.debug('(%s) *BridgeControl* Not sent BCSQ Source Quench TARGET_IP not known , TG: %s, Stream ID: %s',self._system,int_id(_tgid)) - def dmrd_received(self, _peer_id, _rf_src, _dst_id, _seq, _slot, _call_type, _frame_type, _dtype_vseq, _stream_id, _data): + def dmrd_received(self, _peer_id, _rf_src, _dst_id, _seq, _slot, _call_type, _frame_type, _dtype_vseq, _stream_id, _data,_hash): pass #print(int_id(_peer_id), int_id(_rf_src), int_id(_dst_id), int_id(_seq), _slot, _call_type, _frame_type, repr(_dtype_vseq), int_id(_stream_id)) @@ -245,7 +245,7 @@ class OPENBRIDGE(DatagramProtocol): return # Userland actions -- typically this is the function you subclass for an application - self.dmrd_received(_peer_id, _rf_src, _dst_id, _seq, _slot, _call_type, _frame_type, _dtype_vseq, _stream_id, _data) + self.dmrd_received(_peer_id, _rf_src, _dst_id, _seq, _slot, _call_type, _frame_type, _dtype_vseq, _stream_id, _data,_hash) #Silently treat a DMRD packet like a keepalive - this is because it's traffic and the #Other end may not have enabled ENAHNCED_OBP self._config['_bcka'] = time() From f328b377ee03b9e7d57de9e0f1a8cdedc5f6639f Mon Sep 17 00:00:00 2001 From: Simon Date: Sun, 9 Jan 2022 02:32:21 +0000 Subject: [PATCH 38/46] use existing HMAC for obp CRC - fix --- bridge_master.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bridge_master.py b/bridge_master.py index d69102e..0102097 100644 --- a/bridge_master.py +++ b/bridge_master.py @@ -1467,7 +1467,7 @@ class routerOBP(OPENBRIDGE): _bits = _data[15] _#pkt_crc = Crc32.calc(_data[4:53]) #_pkt_crc = Crc32.calc(dmrpkt) - )pkt_crc = _hash + pkt_crc = _hash # Match UNIT data, SMS/GPS, and send it to the dst_id if it is in SUB_MAP From 942436ac4a5aa988d4425ae5468abcf2077a51de Mon Sep 17 00:00:00 2001 From: Simon Date: Sun, 9 Jan 2022 02:33:29 +0000 Subject: [PATCH 39/46] use existing HMAC for obp CRC - fix 2 --- bridge_master.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bridge_master.py b/bridge_master.py index 0102097..b09409b 100644 --- a/bridge_master.py +++ b/bridge_master.py @@ -1465,7 +1465,7 @@ class routerOBP(OPENBRIDGE): pkt_time = time() dmrpkt = _data[20:53] _bits = _data[15] - _#pkt_crc = Crc32.calc(_data[4:53]) + #pkt_crc = Crc32.calc(_data[4:53]) #_pkt_crc = Crc32.calc(dmrpkt) pkt_crc = _hash From 43a01c4f3f23ee78e2b9c048e92de921ad774382 Mon Sep 17 00:00:00 2001 From: Simon Date: Sun, 9 Jan 2022 02:34:56 +0000 Subject: [PATCH 40/46] use existing HMAC for obp CRC - fix 3 --- bridge_master.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bridge_master.py b/bridge_master.py index b09409b..5610f74 100644 --- a/bridge_master.py +++ b/bridge_master.py @@ -1467,7 +1467,7 @@ class routerOBP(OPENBRIDGE): _bits = _data[15] #pkt_crc = Crc32.calc(_data[4:53]) #_pkt_crc = Crc32.calc(dmrpkt) - pkt_crc = _hash + _pkt_crc = _hash # Match UNIT data, SMS/GPS, and send it to the dst_id if it is in SUB_MAP From a08864aa52597a63e4961621261f62c4d2924b09 Mon Sep 17 00:00:00 2001 From: Simon Date: Sun, 9 Jan 2022 02:42:21 +0000 Subject: [PATCH 41/46] change references to Crc32 to SHA1 --- bridge_master.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/bridge_master.py b/bridge_master.py index 5610f74..606c5bd 100644 --- a/bridge_master.py +++ b/bridge_master.py @@ -1719,9 +1719,9 @@ class routerOBP(OPENBRIDGE): if _seq and self.STATUS[_stream_id]['lastSeq'] and (_seq != 1) and (_seq < self.STATUS[_stream_id]['lastSeq']): logger.warning("%s) *PacketControl* Out of order packet - last SEQ: %s, this SEQ: %s, disgarding. Stream ID:, %s TGID: %s ",self._system,self.STATUS[_stream_id]['lastSeq'],_seq,int_id(_stream_id),int_id(_dst_id)) return - #Duplicate DMR payload to previuos packet (by Crc32) + #Duplicate DMR payload to previuos packet (by SHA1 if _seq > 0 and _pkt_crc in self.STATUS[_stream_id]['crcs']: - logger.warning("(%s) *PacketControl* DMR packet payload with Crc32: %s seen before in this stream, disgarding. Stream ID:, %s TGID: %s: SEQ:%s packets: %s ",self._system,_pkt_crc,int_id(_stream_id),int_id(_dst_id),_seq, self.STATUS[_stream_id]['packets']) + logger.warning("(%s) *PacketControl* DMR packet payload with SHA1: %s seen before in this stream, disgarding. Stream ID:, %s TGID: %s: SEQ:%s packets: %s ",self._system,_pkt_crc,int_id(_stream_id),int_id(_dst_id),_seq, self.STATUS[_stream_id]['packets']) return #Inbound missed packets if _seq and self.STATUS[_stream_id]['lastSeq'] and _seq > (self.STATUS[_stream_id]['lastSeq']+1): @@ -2440,9 +2440,9 @@ class routerHBP(HBSYSTEM): if _seq and self.STATUS[_slot]['lastSeq'] and (_seq != 1) and (_seq < self.STATUS[_slot]['lastSeq']): logger.warning("%s) *PacketControl* Out of order packet - last SEQ: %s, this SEQ: %s, disgarding. Stream ID:, %s TGID: %s ",self._system,self.STATUS[_slot]['lastSeq'],_seq,int_id(_stream_id),int_id(_dst_id)) return - #Duplicate DMR payload to previuos packet (by Crc32) + #Duplicate DMR payload to previuos packet (by SHA1) if _seq > 0 and _pkt_crc in self.STATUS[_slot]['crcs']: - logger.warning("(%s) *PacketControl* DMR packet payload with Crc32: %s seen before in this stream, disgarding. Stream ID:, %s TGID: %s, SEQ: %s, packets %s: ",self._system,_pkt_crc,int_id(_stream_id),int_id(_dst_id),_seq,self.STATUS[_slot]['packets']) + logger.warning("(%s) *PacketControl* DMR packet payload with SHA1: %s seen before in this stream, disgarding. Stream ID:, %s TGID: %s, SEQ: %s, packets %s: ",self._system,_pkt_crc,int_id(_stream_id),int_id(_dst_id),_seq,self.STATUS[_slot]['packets']) return #Inbound missed packets if _seq and self.STATUS[_slot]['lastSeq'] and _seq > (self.STATUS[_slot]['lastSeq']+1): From d0d0f77a96362c2930ac93a254091dd364f58267 Mon Sep 17 00:00:00 2001 From: Simon Date: Sun, 9 Jan 2022 10:58:11 +0000 Subject: [PATCH 42/46] use set instead of list for crcs --- bridge_master.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/bridge_master.py b/bridge_master.py index 606c5bd..3691b6c 100644 --- a/bridge_master.py +++ b/bridge_master.py @@ -1629,7 +1629,7 @@ class routerOBP(OPENBRIDGE): 'lastData': False, 'RX_PEER': _peer_id, 'packets': 0, - 'crcs': [] + 'crcs': {} } @@ -1803,7 +1803,7 @@ class routerHBP(HBSYSTEM): 'lastSeq': False, 'lastData': False, 'packets': 0, - 'crcs': [] + 'crcs': {} }, 2: { 'RX_START': time(), @@ -1833,7 +1833,7 @@ class routerHBP(HBSYSTEM): 'lastSeq': False, 'lastData': False, 'packets': 0, - 'crcs': [] + 'crcs': {} } } From d52b22ef9fb6bad64e9d74c5da8c94b68a7d3742 Mon Sep 17 00:00:00 2001 From: Simon Date: Sun, 9 Jan 2022 11:01:00 +0000 Subject: [PATCH 43/46] set uses add instead of append --- bridge_master.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/bridge_master.py b/bridge_master.py index 3691b6c..a18a164 100644 --- a/bridge_master.py +++ b/bridge_master.py @@ -1611,7 +1611,7 @@ class routerOBP(OPENBRIDGE): else: logger.info('(%s) UNIT Data not bridged to HBP on slot %s - target busy: %s DST_ID: %s',self._system,_d_slot,_d_system,_int_dst_id) - self.STATUS[_stream_id]['crcs'].append(_pkt_crc) + self.STATUS[_stream_id]['crcs'].add(_pkt_crc) if _call_type == 'group' or _call_type == 'vcsbk': @@ -1735,7 +1735,7 @@ class routerOBP(OPENBRIDGE): - self.STATUS[_stream_id]['crcs'].append(_pkt_crc) + self.STATUS[_stream_id]['crcs'].add(_pkt_crc) self.STATUS[_stream_id]['LAST'] = pkt_time @@ -2575,7 +2575,7 @@ class routerHBP(HBSYSTEM): self.STATUS[_slot]['RX_TIME'] = pkt_time self.STATUS[_slot]['RX_STREAM_ID'] = _stream_id - self.STATUS[_slot]['crcs'].append(_pkt_crc) + self.STATUS[_slot]['crcs'].add(_pkt_crc) # # Socket-based reporting section From 99b327e9e76650f806df3f1e1ab86cb5ee87e2c6 Mon Sep 17 00:00:00 2001 From: Simon Date: Sun, 9 Jan 2022 11:05:36 +0000 Subject: [PATCH 44/46] set defined by set() not {} --- bridge_master.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/bridge_master.py b/bridge_master.py index a18a164..7d1148d 100644 --- a/bridge_master.py +++ b/bridge_master.py @@ -1629,7 +1629,7 @@ class routerOBP(OPENBRIDGE): 'lastData': False, 'RX_PEER': _peer_id, 'packets': 0, - 'crcs': {} + 'crcs': set() } @@ -1803,7 +1803,7 @@ class routerHBP(HBSYSTEM): 'lastSeq': False, 'lastData': False, 'packets': 0, - 'crcs': {} + 'crcs': set() }, 2: { 'RX_START': time(), @@ -1833,7 +1833,7 @@ class routerHBP(HBSYSTEM): 'lastSeq': False, 'lastData': False, 'packets': 0, - 'crcs': {} + 'crcs': set() } } From f72adc7a00baf3d3f7d1790ed8ddab026b10880e Mon Sep 17 00:00:00 2001 From: Simon Date: Sun, 9 Jan 2022 11:16:17 +0000 Subject: [PATCH 45/46] set defined by set() not {} --- bridge_master.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/bridge_master.py b/bridge_master.py index 7d1148d..26dfb3e 100644 --- a/bridge_master.py +++ b/bridge_master.py @@ -2097,7 +2097,7 @@ class routerHBP(HBSYSTEM): _data_call = True self.STATUS[_slot]['packets'] = 0 - self.STATUS[_slot]['crcs'] = [] + self.STATUS[_slot]['crcs'] = set() if _dtype_vseq == 3: logger.info('(%s) *UNIT CSBK* STREAM ID: %s SUB: %s (%s) PEER: %s (%s) DST_ID %s (%s), TS %s', \ @@ -2197,7 +2197,7 @@ class routerHBP(HBSYSTEM): if (_stream_id != self.STATUS[_slot]['RX_STREAM_ID']): self.STATUS[_slot]['packets'] = 0 - self.STATUS[_slot]['crcs'] = [] + self.STATUS[_slot]['crcs'] = set() self.STATUS[_slot]['_stopTgAnnounce'] = False @@ -2347,7 +2347,7 @@ class routerHBP(HBSYSTEM): if (_stream_id != self.STATUS[_slot]['RX_STREAM_ID']): self.STATUS[_slot]['packets'] = 0 - self.STATUS[_slot]['crcs'] = [] + self.STATUS[_slot]['crcs'] = set() if (self.STATUS[_slot]['RX_TYPE'] != HBPF_SLT_VTERM) and (pkt_time < (self.STATUS[_slot]['RX_TIME'] + STREAM_TO)) and (_rf_src != self.STATUS[_slot]['RX_RFS']): logger.warning('(%s) Packet received with STREAM ID: %s SUB: %s PEER: %s TGID %s, SLOT %s collided with existing call', self._system, int_id(_stream_id), int_id(_rf_src), int_id(_peer_id), int_id(_dst_id), _slot) From 1ba394a5214f1f95024abcd8eb509976b1b08189 Mon Sep 17 00:00:00 2001 From: Simon Date: Sun, 9 Jan 2022 12:20:15 +0000 Subject: [PATCH 46/46] hash passthrough in bridge.py --- bridge.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bridge.py b/bridge.py index 7cb6d04..48dde59 100755 --- a/bridge.py +++ b/bridge.py @@ -249,7 +249,7 @@ class routerOBP(OPENBRIDGE): self._lastSeq = False - def dmrd_received(self, _peer_id, _rf_src, _dst_id, _seq, _slot, _call_type, _frame_type, _dtype_vseq, _stream_id, _data): + def dmrd_received(self, _peer_id, _rf_src, _dst_id, _seq, _slot, _call_type, _frame_type, _dtype_vseq, _stream_id, _data,_hash): pkt_time = time() dmrpkt = _data[20:53] _bits = _data[15]