Skip to content

Commit

Permalink
excluding USRP packets by parse, pcap extraction of single-fragment-l…
Browse files Browse the repository at this point in the history
…c and vbptc32,11, release v0.5
  • Loading branch information
smarek committed Mar 12, 2022
1 parent 3861e42 commit a02b38c
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 2 deletions.
5 changes: 4 additions & 1 deletion okdmr/dmrlib/tools/pcap_tool.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

from bitarray import bitarray
from kaitaistruct import KaitaiStruct
from okdmr.dmrlib.etsi.fec.vbptc_32_11 import VBPTC3211
from okdmr.kaitai.homebrew.mmdvm2020 import Mmdvm2020
from okdmr.kaitai.hytera.ip_site_connect_heartbeat import IpSiteConnectHeartbeat
from okdmr.kaitai.hytera.ip_site_connect_protocol import IpSiteConnectProtocol
Expand Down Expand Up @@ -43,10 +44,12 @@ def process_packet(self, data: bytes, packet: IP) -> Optional[FullLinkControl]:
burst
and burst.has_emb
and burst.emb.link_control_start_stop == LCSS.SingleFragmentLCorCSBK
and burst.embedded_signalling_bits.count(1)
):
print(
f"Single burst data for VBPTC 32,11 [{burst.emb.preemption_and_power_control_indicator}] {burst.embedded_signalling_bits}"
f"Single burst data for VBPTC 32,11 [{burst.emb.preemption_and_power_control_indicator}] on-air(fec protected) {burst.embedded_signalling_bits} (vbptc deinterleaved) {VBPTC3211.deinterleave_data_bits(burst.embedded_signalling_bits)} in {data.hex()}"
)
return

if (
not burst
Expand Down
6 changes: 6 additions & 0 deletions okdmr/dmrlib/utils/parsing.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,12 @@ def parse_hytera_data(bytedata: bytes) -> KaitaiStruct:

def try_parse_packet(udpdata: bytes) -> Optional[KaitaiStruct]:

try:
if udpdata[:4] == b"USRP":
return None
finally:
pass

# Try MMDVM/Homebrew packets
try:
mmdvm = Mmdvm2020.from_bytes(udpdata)
Expand Down
3 changes: 3 additions & 0 deletions okdmr/tests/dmrlib/etsi/fec/test_vbptc_32_11.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ def test_vbptc_sanity():
def test_encode_decode_vbptc():
bursts: List[(str,)] = [
("00000100010110000000100010100100",),
# following are not valid vbptc protected payloads, probably something proprietary / unidentified
# ("00001100000100010010010001000001",),
# ("00010111000010100000011001000100",),
]

for (burst,) in bursts:
Expand Down
4 changes: 4 additions & 0 deletions okdmr/tests/dmrlib/utils/test_parsing.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,3 +53,7 @@ def test_parsing_detection():
mmdvm_hex: str = "52505443002338c84f4b314c5044202034333331303030303034333331303030303030313031302e30303030303030302e3030303030303030304e6f7768657265202020202020202020202020204d756c74692d4d6f6465205265706561746572347777772e676f6f676c652e636f2e756b202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020323031393031333120202020202020202020202020202020202020202020202020202020202020204d4d44564d5f4d4d44564d5f48535f48617420202020202020202020202020202020202020202020"
pkt: KaitaiStruct = try_parse_packet(bytes.fromhex(mmdvm_hex))
assert isinstance(pkt, Mmdvm2020)

usrp_hex: str = "55535250000000730000000000000001000000000000000000000000000000001e00faffe2ffeeff00000c0012000c00e2ffcaffe2ff0c0048008400b400a2005a00060094ff3aff2eff4cff7cffd6ff1e00420066007e005a002a001800e2ffc4ffbeffacff9affa0ffcaff1200540084007e003600eeffbeffb2ffd6fffaff0c0012000600eefff4fffaff12003c003c001800f4ffd6ffc4ffdcff0c002a002a001e000000e2ffe8fffaff12002a001e00f4ffdcffcaffcaff00004e0084009c009c005a001200d0ff88ff58ff58ff64ff88ffd0ff240060006c0072005a0030001800eeffc4ffa6ff88ff82ffa6ffdcff12003c0054005400360018000600faffeeffe2ffe8ffe8ffeefffaff060006000c00180024001e0018000000eefff4ffeeff000018000c00faff06000600faff0c000c00faff06000000e8ffe8fffaff0c003c009000b40096004e00e2ff6aff2eff4cff7cffb8ffeeff00001200"
pkt: Optional[KaitaiStruct] = try_parse_packet(bytes.fromhex(usrp_hex))
assert pkt is None
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
author="Marek Sebera",
author_email="[email protected]",
license="AGPL-3.0",
version="0.4",
version="0.5",
packages=[
"okdmr.dmrlib",
"okdmr.dmrlib.transmission",
Expand Down

0 comments on commit a02b38c

Please sign in to comment.