Revert "add packet rate counter"

This reverts commit 5636f8627b.
crc16
Simon 4 years ago
parent 04df10154e
commit 418c87e2d7

@ -0,0 +1,124 @@
#import log
#import config
from time import time
from random import randint
from twisted.internet import reactor,task
from twisted.internet.defer import Deferred
from twisted.internet.protocol import ClientFactory,ReconnectingClientFactory,Protocol
from twisted.protocols.basic import LineReceiver
#from pyrtp import *
# The module needs logging logging, but handlers, etc. are controlled by the parent
#import logging
#logger = logging.getLogger(__name__)
class CCCC():
def __init__(self,host,port):
self._CCClient = self.CCClient
self._rnd_number = randint(0x00, 0xFFFFFFFF)
self.hex_id = bytes(hex(self._rnd_number),'utf8')
self.bytes_id = self._rnd_number.to_bytes(4,byteorder="big")
self.CF = reactor.connectTCP(host, port, self.CCClientFactory(self._CCClient,self.hex_id))
def closeConnection(self):
self.transport.loseConnection()
class CCClient(LineReceiver):
delimiter = b'\n'
end = b"Bye-bye!"
def connectionMade(self):
#self.peer = self.transport.getPeer()
_hexid = self.hex_id
#
#CCCC._ssrc_list[_hexid] = self._peer
_linkid = b'91 '
_channel_name = b'CC outbound link'
_local_site_name = b'FreeDMR-Testing'
#Generate a random MAC that looks like a real one
#We don't really want to share our MAC ;-)
_local_mac = bytes(hex(randint(0x00, 0xFFFFFFFFFFFF)),'utf8')
#Fake a recent code_rev of CBridge
_code_rev = b'9959__December_5_2021__13.25.28'
#We'll use artistic licence on this one
_os_ver = b'FreeDMR Peer Server'
self.sendLine(_hexid)
self.sendLine(_linkid)
self.sendLine(_channel_name)
self.sendLine(_local_site_name)
self.sendLine(b'Server Inbound')
self.sendLine(_local_mac)
self.sendLine(_code_rev)
self.sendLine(_os_ver)
def lineReceived(self,line):
packet_dict = {}
#If we get codec AMBE (that's all we support)
if line == b'AMBE' or self._counter != 0:
self._counter = 6
else:
self.transport.loseConnection()
if self._counter:
if self._counter == 6:
self._ms_window = line
self._counter = 5
elif self._counter == 5:
self._seconds_microseconds = line
self._counter = 4
elif self._counter == 4:
self._syn_and_safe_ver_date = line
self._counter = 3
elif self._counter == 3:
self._remote_sys_name = line
self._counter = 2
elif self._counter == 2:
self._remote_tos_value = line
self._counter = 1
elif self._counter == 1:
self._remote_os_ver = line
self._counter = 0
line = line.decode("utf8")
if line[0:1] == 'B':
if line[1:3] == '01':
packet_dict['type'] = 'ON'
packet_dict['linkid'] = line[3:5]
packet_dict['line'] = line
else:
packet_dict['type'] = 'OFF'
packet_dict['linkid'] = line[1:3]
packet_dict['line'] = line
self.controlLine(packet_dict)
def controlLine(self,packet_dict):
pass
class CCClientFactory(ReconnectingClientFactory):
def __init__(self,CCClient,hex_id):
self.done = Deferred()
self.protocol = CCClient
self.protocol.hex_id = hex_id
def clientConnectionFailed(self, connector, reason):
print("connection failed:", reason.getErrorMessage())
ReconnectingClientFactory.clientConnectionLost(self, connector, reason)
def clientConnectionLost(self, connector, reason):
print("connection lost:", reason.getErrorMessage())
ReconnectingClientFactory.clientConnectionLost(self, connector, reason)

@ -1483,13 +1483,11 @@ class routerOBP(OPENBRIDGE):
'1ST': perf_counter(), '1ST': perf_counter(),
'lastSeq': False, 'lastSeq': False,
'lastData': False, 'lastData': False,
'RX_PEER': _peer_id, 'RX_PEER': _peer_id
'packets': 0
} }
self.STATUS[_stream_id]['LAST'] = pkt_time self.STATUS[_stream_id]['LAST'] = pkt_time
self.STATUS[_stream_id][packets] = self.STATUS[_stream_id][packets] + 1
hr_times = {} hr_times = {}
for system in systems: for system in systems:
@ -1612,13 +1610,10 @@ class routerOBP(OPENBRIDGE):
'1ST': perf_counter(), '1ST': perf_counter(),
'lastSeq': False, 'lastSeq': False,
'lastData': False, 'lastData': False,
'RX_PEER': _peer_id, 'RX_PEER': _peer_id
'packets': 0
} }
self.STATUS[_stream_id]['packets'] = self.STATUS[_stream_id]['packets'] +1
# If we can, use the LC from the voice header as to keep all options intact # 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: if _frame_type == HBPF_DATA_SYNC and _dtype_vseq == HBPF_SLT_VHEAD:
decoded = decode.voice_head_term(dmrpkt) decoded = decode.voice_head_term(dmrpkt)
@ -1736,9 +1731,8 @@ class routerOBP(OPENBRIDGE):
# Final actions - Is this a voice terminator? # Final actions - Is this a voice terminator?
if (_frame_type == HBPF_DATA_SYNC) and (_dtype_vseq == HBPF_SLT_VTERM): if (_frame_type == HBPF_DATA_SYNC) and (_dtype_vseq == HBPF_SLT_VTERM):
call_duration = pkt_time - self.STATUS[_stream_id]['START'] call_duration = pkt_time - self.STATUS[_stream_id]['START']
packet_rate = self.STATUS[_stream_id][packets] / call_duration logger.info('(%s) *CALL END* STREAM ID: %s SUB: %s (%s) PEER: %s (%s) TGID %s (%s), TS %s, Duration: %.2f', \
logger.info('(%s) *CALL END* STREAM ID: %s SUB: %s (%s) PEER: %s (%s) TGID %s (%s), TS %s, Duration: %.2f, Packet rate: %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, call_duration)
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, call_duration, packet_rate)
if CONFIG['REPORTS']['REPORT']: if CONFIG['REPORTS']['REPORT']:
self._report.send_bridgeEvent('GROUP VOICE,END,RX,{},{},{},{},{},{},{:.2f}'.format(self._system, int_id(_stream_id), int_id(_peer_id), int_id(_rf_src), _slot, int_id(_dst_id), call_duration).encode(encoding='utf-8', errors='ignore')) self._report.send_bridgeEvent('GROUP VOICE,END,RX,{},{},{},{},{},{},{:.2f}'.format(self._system, int_id(_stream_id), int_id(_peer_id), int_id(_rf_src), _slot, int_id(_dst_id), call_duration).encode(encoding='utf-8', errors='ignore'))
self.STATUS[_stream_id]['_fin'] = True self.STATUS[_stream_id]['_fin'] = True

Loading…
Cancel
Save

Powered by TurnKey Linux.