dsd icon indicating copy to clipboard operation
dsd copied to clipboard

Potential fix for P25 encryption muting

Open balr0g opened this issue 11 years ago • 46 comments

This may fix the erroneous muting of unencrypted P25 packets. However, I'm lacking a P25 sample and have no way to test it, so can someone please test it and report on whether it works before this is merged?

balr0g avatar Dec 16 '13 19:12 balr0g

I'd let you know if this fixed P25 encryption muting, but I cannot currently since I"m unable to build DSD (no makefile). I could also possibly upload a P25 sample, but I wouldn't know where to upload it to.

mbt25 avatar Dec 17 '13 04:12 mbt25

Sample files would be a big help to the project. Simply fork the project and add the sample files to the samples directory. Then submit a pull request.

Thanks!

szechyjs avatar Dec 17 '13 06:12 szechyjs

I'll admit to not understanding how Github works at all. With that said, is the potential fix for P25 encryption muting in the master yet, or is somebody actually wanting to test it with some P25 audio samples first?

Secondly I did fork the project and am willing to add some audio samples and submit a pull request; however, I don't know the best way to capture the sound (i.e. sample rate, format, etc)

Something along the lines of 'arecord -f dat -t wav p25.wav ?

mbt25 avatar Dec 17 '13 18:12 mbt25

You can post the samples on Dropbox or another site and link them here. Samples should be 48khz, preferably FLAC but WAV works too. I think samples should be in their own repo, so this one doesn't grow too large.

I'll add updated building instructions.

balr0g avatar Dec 17 '13 18:12 balr0g

@mbt25 yes, we'd like to test the P25 muting fix before merging it.

@balr0g I agree that we don't want to fill the repo with large amounts of sample data. I would like to have a small set of sample data in the repo to use with unit testing though. These sample clips only need to be a few seconds in length. If the size gets to be a problem we can always make it a sub repo.

I've also updated the README last night, it should contain better building instructions now.

szechyjs avatar Dec 17 '13 19:12 szechyjs

Ok. Does it matter if samples are mono or stereo?

mbt25 avatar Dec 17 '13 19:12 mbt25

mono would probably be preferred.

szechyjs avatar Dec 17 '13 23:12 szechyjs

I lose all audio with this update.

dreinhold avatar Dec 18 '13 09:12 dreinhold

@mbt25: Is the sample you posted encrypted? I'm seeing a key id of 0x81 (should be 0x80 for unencrypted), and worse, if I disable the detection all I get is gibberish... @dreinhold: Can you provide a sample of unencrypted P25 Phase 1?

balr0g avatar Dec 18 '13 14:12 balr0g

balr0g, I don't think so. There is very little encryption on this system in my area, but it is possible that it was encrypted. I have a longer version of that sample that I'm sure has multiple agencies communicating and is guaranteed to have some unencrypted traffic. But it was a bit larger and so I did not post it.

I could have swarn that I listened to the decoded audio while taking the sample and that it was all unencrypted, but I could be wrong. I'll get another sample up shortly that I'll be able to guarantee is unencrypted.

mbt25 avatar Dec 18 '13 14:12 mbt25

Yep, encrypted. Sorry about that. Unencrypted will be put up shortly

mbt25 avatar Dec 18 '13 14:12 mbt25

Good to know, I was getting ready to post that this fix doesn't work.

szechyjs avatar Dec 18 '13 15:12 szechyjs

There ya go -- I renamed the encrypted sample and added a guaranteed unencrypted sample

mbt25 avatar Dec 18 '13 15:12 mbt25

All right; you did forget to resample it to 48KHz though. At some point I should implement PortAudio support as well as on-the-fly resampling....

balr0g avatar Dec 18 '13 15:12 balr0g

I think I need to stick with .wav uploads. It was a wav converted to flac after the fact. This wasn't generated by DSD in any fashion. The DSD I have operational on Windows is a version that doesn't support any of that.

mbt25 avatar Dec 18 '13 15:12 mbt25

DSD cannot generate wavs or flacs of this sort. I generally use audacity for processing. If you're using audacity, be sure the project rate is set correctly after resampling the track. Anyway, this particular sample is too short to be conclusive. I'm getting all sorts of strange algids for it, which should not be happening... it's possible dsd's parsing is broken :/

balr0g avatar Dec 18 '13 16:12 balr0g

I have a raw file right out of sdr_fm I was using for quick back to back compares of the new versions. https://www.dropbox.com/sh/vz1asilre8t2onk/6xJfo0Wbj_

I just pipe it right in, 1.4.1 and 1.6.0 plays audio with about the same decode rate, and this patch no audio at all. cat p25_raw_from_sdr.dat | padsp ./dsd -i /dev/stdin

dreinhold avatar Dec 18 '13 16:12 dreinhold

That unencrypted sample was a 96khz wav loaded into audacity, resampled to 48k, and then exported as a flac. Because my uploaded flac was in question, I opened it in Audacity and exported it as a .wav. Then I fed the wav into a previous incarnation of dsd 1.6 where I had commented out all of the automuting code and rebuilt it. It decoded just fine. Well, just fine as far as DSD goes -- DSD isn't anywhere near 100% on a good day. But if you aren't getting any decode at all, it's a problem with the current DSD P25 code, probably related to the automuting code.

mbt25 avatar Dec 18 '13 16:12 mbt25

@dreinhold: I'm using OS X here; can you convert it into a wav file if possible?

@mbt25: I'm getting a highly unintelligible decode even when automuting is fully disabled.

balr0g avatar Dec 18 '13 18:12 balr0g

@balr0g Doesn't surprise me. DSD is lousy on P25. Sometimes it works great, sometimes it doesn't. I have an application capable of decoding the very same audio at 100%. And, as I said, if I take that flac file, convert it back to a wav, and then feed that wav into DSD 1.6 (a previous incarnation of it), it decodes at probably 75-80%. Is the flac file at fault? I wouldn't know since I don't know how to feed the flac file into DSD. But I know if I take the flac file and convert it back to a .wav and feed the wav in, it decodes as I would expect in DSD. I'm of a strong mindset that there is not anything wrong with the audio I have provided.

You say the audio sample is too short; Jared says audio samples should be no more than a few seconds long. I prefer to work with wav files; you guys prefer to work with flac. I'm pretty much damned if I do and damned if i don't. I'm not a programmer, but I'm not a moron either. The audio isn't the issue. Likely DSD is the issue.

If you like I can record a nice long P25 file (it'll have encrypted and nonencrypted audio, strong audio and weak signal audio all combined) and upload it to my site, as a wav, and you can download it and work with it if you wish. That's the best I can do.

mbt25 avatar Dec 18 '13 19:12 mbt25

@mbt25 what is the other app you use, why do you use dsd if you have something that works 100%. I also cant decode any voice in your sample.

dreinhold avatar Dec 18 '13 19:12 dreinhold

@mbt25 I've been able to read flac files directly into DSD like so ./dsd -i ../samples/P25\ sample\ -\ unencrypted.flac -w test.wav. Keep in mind that the process of re-encoding the streams in different formats at different bit rates is going to most likely screw up the files a little bit.

here is the output of the most recent file you posted:

Sync:  -P25p1     mod: QPSK inlvl: 11% nac:  944 src:        0 tg:     0  duid:01 *Unknown DUID*
Sync:  -P25p1     mod: QPSK inlvl: 11% nac:  160 src:        0 tg:     0  duid:01 *Unknown DUID*
Sync:  -P25p1     mod: QPSK inlvl: 13% nac:  144 src:        0 tg:     0  duid:01 *Unknown DUID*
Sync:  -P25p1     mod: QPSK inlvl: 10% nac:  964 src:        0 tg:     0  duid:02 *Unknown DUID*
Sync:  -P25p1     mod: QPSK inlvl: 13% nac:  904 src:        0 tg:     0  duid:01 *Unknown DUID*
Sync:  -P25p1     mod: QPSK inlvl: 11% nac:  920 src:        0 tg:     0  duid:01 *Unknown DUID*

I had gotten better results from the original file you posted, the only problem was that it was encrypted:

Sync:  -P25p1     mod: C4FM inlvl: 50% src:        0 tg:     0  HDU
Sync: (-P25p1)    mod: C4FM inlvl: 28% nac:  828 src:        0 tg:   168 (LDU1)                                   e:
Sync:  -P25p1     mod: C4FM inlvl: 19% src:        0 tg:   168  HDU
Sync: (-P25p1)    mod: C4FM inlvl: 14% nac:  A01 src:        0 tg:   544 (LDU1)

szechyjs avatar Dec 18 '13 19:12 szechyjs

@balr0g i will capture a new sample, i would think you could pipe it in using osx also. Did you try cat p25_raw_from_sdr.dat | ./dsd -i /dev/stdin

dreinhold avatar Dec 18 '13 19:12 dreinhold

dsd has the following input/output options

Input/Output options:
  -i <device>   Audio input device (default is /dev/audio)
  -o <device>  Audio output device (default is /dev/audio)
  -d <dir>       Create mbe data files, use this directory
  -g <num>    Audio output gain (default = 0 = auto, disable = -1)
  -n                Do not send synthesized speech to audio output device
  -w <file>      Output synthesized speech to a .wav file
  -r <files>      Read/Play saved mbe data from file(s)

szechyjs avatar Dec 18 '13 20:12 szechyjs

http://www.tindorconsulting.com/dsd/audiotest

note: rawmixed.wav was the source for both tests

rawmixed.wav # 44 khz (16-bit mono I think) raw_audio_fed_into_quality_p25_decode_software.wav # self explanatory raw_audio_fed_into_dsd.wav # self explanatory

mbt25 avatar Dec 18 '13 20:12 mbt25

Thanks, Jared. I thought DSD only worked with mbe stuff. The raw_audio_fed_into_dsd.wav is the output from dsd using -r. Worked well.

mbt25 avatar Dec 18 '13 20:12 mbt25

Also do keep in mind that for a while now, P25 has worked better if you force it with -f1 -mc, or at the very least -f1. The monitored signal definitely is not QPSK, but recent versions of DSD seem to think it is without forcing.

mbt25 avatar Dec 18 '13 20:12 mbt25

Just uploaded a flac version of some voice traffic. https://www.dropbox.com/sh/vz1asilre8t2onk/6xJfo0Wbj_ File : p25_raw.flac

I can decode voice in version previous to this patch, but not with the patch

./dsd.1.6.0 -i p25_raw.flac Digital Speech Decoder 1.6.0 mbelib version 1.2.5 Audio Out Device: /dev/audio Audio In Device: p25_raw.flac Sync: +P25p1 mod: QPSK inlvl: 35% nac: F1 src: 0 tg: 0 TDU Sync: +P25p1 mod: QPSK inlvl: 28% nac: 1F5 src: 0 tg: 0 TDU Sync: +P25p1 mod: QPSK inlvl: 31% nac: 1A1 src: 0 tg: 0 duid:32 Unknown DUID Sync: +P25p1 mod: QPSK inlvl: 28% nac: B5 src: 0 tg: 0 Ignoring LDU2 not preceeded by LDU1 Sync: +P25p1 mod: QPSK inlvl: 29% nac: 1F5 src: 0 tg: 0 TDU Sync: +P25p1 mod: QPSK inlvl: 30% nac: 1F5 src: 0 tg: 0 TDU Sync: +P25p1 mod: QPSK inlvl: 34% nac: 1F5 src: 0 tg: 0 HDU Sync: +P25p1 mod: QPSK inlvl: 32% nac: 1F5 src: 0 tg: 7455 LDU1 e:= Sync: +P25p1 mod: QPSK inlvl: 28% nac: 1F5 src: 0 tg: 7455 LDU2 e:=======R=========R=============R===== Sync: +P25p1 mod: QPSK inlvl: 29% nac: 1F5 src: 0 tg: 7455 LDU1 e:= Sync: +P25p1 mod: QPSK inlvl: 33% nac: 1F5 src: 0 tg: 7455 LDU2 e:===== Sync: +P25p1 mod: QPSK inlvl: 28% nac: 1F5 src: 0 tg: 7455 LDU1 e:= Sync: +P25p1 mod: QPSK inlvl: 32% nac: 1F5 src: 4270002 tg: 7455 LDU2 e:= Sync: +P25p1 mod: QPSK inlvl: 25% nac: 1B5 src: 4270002 tg: 7455 LDU1 e:================R Sync: +P25p1 mod: QPSK inlvl: 33% nac: 1F5 src: 4270002 tg: 7455 LDU2 e: Sync: +P25p1 mod: QPSK inlvl: 32% nac: 1F5 src: 4270002 tg: 7455 LDU1 e:===== Sync: +P25p1 mod: QPSK inlvl: 29% nac: 1F5 src: 4270002 tg: 7455 LDU2 e:= Sync: +P25p1 mod: QPSK inlvl: 32% nac: 1F5 src: 4270002 tg: 7455 LDU1 e: Sync: +P25p1 mod: QPSK inlvl: 27% nac: 1F5 src: 4270002 tg: 7455 LDU2 e:================= Sync: +P25p1 mod: QPSK inlvl: 30% nac: 1A5 src: 4270002 tg: 7455 LDU1 e:================== Sync: +P25p1 mod: QPSK inlvl: 34% nac: 1F5 src: 4270002 tg: 7455 LDU2 e: Sync: +P25p1 mod: QPSK inlvl: 31% nac: 1F5 src: 4270002 tg: 7455 LDU1 e: Sync: +P25p1 mod: QPSK inlvl: 34% nac: 1F5 src: 4270002 tg: 7455 LDU2 e:= Sync: +P25p1 mod: QPSK inlvl: 27% nac: 1F5 src: 4270002 tg: 7455 LDU1 e: Sync: +P25p1 mod: QPSK inlvl: 32% nac: 1F5 src: 4270002 tg: 7455 LDU2 e: Sync: +P25p1 mod: QPSK inlvl: 30% nac: 1F5 src: 4270002 tg: 7455 LDU1 e:==========R==========R==========R==========RM==========R==========R Sync: +P25p1 mod: QPSK inlvl: 31% nac: 1F5 src: 4270002 tg: 7455 TDULC Sync: +P25p1 mod: QPSK inlvl: 35% nac: 1F5 src: 4270002 tg: 7455 TDULC

dreinhold avatar Dec 18 '13 20:12 dreinhold

@dreinhold run dsd with '-f1 -mc' additional switches. I ran your raw audio through and it sounded significantly better when forcing.

mbt25 avatar Dec 18 '13 20:12 mbt25

@mbt25 hmm when it's playing live i normally use -f1 -mq. I dont get anything if I use -mc.

So you get voice with my sample using this latest patch?

dreinhold avatar Dec 18 '13 21:12 dreinhold