Possible problem with KMTronic UDP switch operation?

Hi,

re Antenna switch extension as now built in:

Trying to test switch operation, I see WireShark ICMP port unavailable responses from KiWi to any UDP data sent to it. Outgoing UDP packets from KiwI seem ok. I've tried the port as set in the config, and also the default 12345, and random ports - all with the same response.

What response does KiWi expect to see to turn the antenna button green, and on what port?

I'm just looking for confirmation the KiWi code works before diving deeper at my end.

Thanks

Dave

Comments

  • jksjks
    edited September 8

    In the file /root/Beagle_SDR_GPS/pkgs/ant_switch/backends/ant-switch-backend-kmtronic-udp try changing:

    NETCAT_EXEC="timeout 0.2 nc"

    to:

    NETCAT_EXEC="timeout 1 nc"

    This will make netcat (nc) wait longer for a reply from the switch. If that works then try 0.5, the goal being to find the lowest value that gives reliable results.

  • Hi John.

    I see three packets from KiWi upon pressing an antenna button.

    I'm responding to each in under 1 ms according to Wireshark timestamp.

    The data payload may not be correct but in any case the ICMP Port Unreachable message stops anything further each time.

    Question: If I set the antenna switch config port number to be say 1234 (and I do then see port 1234 being used by KiWi) is that the port that is also open for replies from the relay unit? If not, what port should be used? Should I use the random source port each KiWi packet uses?

    Very frustrating as this should be a childishly simple operation :-)

    Thanks.

  • jksjks
    edited September 20

    Well, I don't know as I didn't write this code originally.

    But I did a contrived test showing it working:

    On the Kiwi running the antenna switch change the backend script netcat timeout to 10 seconds.

    file: /root/Beagle_SDR_GPS/pkgs/ant_switch/backends/ant-switch-backend-kmtronic-udp

    change:

    NETCAT_EXEC="timeout 0.2 nc"

    to:

    NETCAT_EXEC="timeout 10 nc"

    Setup the antenna switch kmtronic-udp device to point to another Kiwi or Linux machine. I used another Kiwi at 192.168.1.102:1234

    On that .102 machine run netcat (nc) in UDP listen mode:

    nc -l -u -p 1234

    On the Kiwi with the ant switch use the admin console and go to the ant switch directory directly:

    cda

    Type the following command to get the antenna status, but then immediately return to the netcat on .102 and type 01100000 (return) before the 10 second timer runs out.

    as

    The as should print this as a result of the 01100000 but only after the 10 sec timer runs out:

    Selected antennas: 2,3
    

    You'll also note that the .102 netcat sees the Kiwi sending FF0000 as soon as you type the as which is the antenna switch script asking for antenna status to be returned.

    The 01100000 is of course the selection status of antennas 1-8, left to right, each with its own selection bit since there can be antenna mixing.

    So the way this normally works is that the netcat on the Kiwi side is waiting 0.2 sec after it sends the FF0000 before it gives up and returns a default antenna status of grounded. So your side has to respond within that timeframe and you said you respond within 0.001 sec.

    Does your reply contain a newline termination? Are you waiting for the FF0000 to be received before returning the status?

    The UDP communication happens on the same port number, both ways.

    If you're still getting ICMP errors try clearing the Kiwi blacklist (admin network tab) and restarting. Although it's difficult for me to see how this could be a problem. It worked fine for me with the blacklist enabled and the two Kiwis on the same local network (192.168.1.x)

  • Hi John.

    A lot to work through there - many thanks for taking the time to help.

    I'll do some more work on it based on your info.

    Thanks again,

    Dave

  • Hi again,

    I can see my timeout in the NETCAT line in my (only) KiWi as 0.2 and don't really want to change it from what any user would see on theirs. 200ms should be plenty.

    The fact remains that whatever I send to KiWi, I get an ICMP port unreachable response:

    As you can see, my response is under 1 ms. I'm just sending a channel status back with 0a at the end (8 ascii + LF) as a response to each packet from KiWi - which, even if not correct, is irrelevant as if KiWi is rejecting the port it won't be looking at the payload anyway.

    I can't get beyond the ICMP error.

    Thanks

    Dave

  • jksjks
    edited September 22

    If you were to duplicate my manual netcat example, and found you did not get the ICMP error, I think that would be a very valuable data point.

  • Hi John,

    Thanks for the reply.

    I only have one KiWi, and I'd like this to work on a standard KiWi config setting. (Also I'm not a Linux expert and while I can list the file you mention I don't know how to edit it :-)

    As I understand it the ICMP port unreachable message is issued from .221 not something else in the network and to my mind the only confirmation test would be from someone else either replicating a response or running an actual UDP switch. Apples with apples etc.

    You may recall there was a previous bug which caused nothing to be sent from KiWi. I've no reason to doubt Wireshark, as last time. If KiWi rejects the port in 1ms then it's live, but not listening on it, end of.

    I think I've bothered you long enough and I'm most grateful for your support and suggestions.

    I need to abandon this and move on. I'll let my users know I can't make it work.

    Thanks again

    Dave

  • Well, another day later and progress.

    Many thanks to Mike N8OOU for guiding me in the right direction.

    It seems I should be replying using the random UDP port that KiWi generates, NOT (in my case) 8022 as in the previous Wireshark traces (and as set in the KiWi switch config) which I may have misunderstood to be correct.

    That change has stopped ports being rejected, so I guess it's right.

    However, still no green.

    John:

    If I may could I ask you to check the buttons are capable of turning green with the KMTronic UDP switch when operating normally (as opposed to internal tests)? I understand other switch type selections didn't actually do this until the code was tweaked a bit. Is the UDP switch known to work?

    What I'm doing:

    In response to just the get status command FF0000, 1 ms later I'm sending 9 ascii bytes: 1 0 0 0 0 0 0 0 then 0a (for antenna 1 set to ON) using the random port KiWi provided. No rejects but no green.

    Is this correct please?

    Many thanks

    Dave

  • Well, this is the problem. I don't have a Kmtronic UDP, or any antenna switch hardware for that matter (except for Beagle-GPIO). And I didn't write or test any of the antenna switch backend scripts originally. They were all scripts developed by, or contributed to, the original OH1KK add-on antenna switch extension.

    So I can't help you with this. You need to find someone with actual kmtronic UDP hardware who can answer this question. In reviewing my notes I don't have anyone listed that actually has this hardware that we tested with. But a forum search has a single post from Terry G0EZY three years ago. I find that I also traded some emails with him. The URL I have for his Kiwi is not responding. And I don't know if it was ever public.

    https://forum.kiwisdr.com/index.php?p=/discussion/comment/12168#Comment_12168

  • Hi john,

    Thanks for the prompt reply. Your time is much appreciated.

    I appreciate it's not your code and you don't have a switch. And I'm beginning to suspect no-one else does either:-)

    The irony of that is that I do have this feature requested by some Aziloop users who actually use Aziloop with their KiWis. The KMTronic implementation is the only one afaik that uses UDP. (My app uses UDP which works error free 100% of the time, and writing a TCP module just for this seems overkill, and may be out for the FP into the F anyway)

    If there's any quick way to bolt the KMT send code onto something else that simply turns the button green that's all I need really, just to act as visual feedback. No interlocks no exclusions just 4 simple channels.

    I can comply with any protocol as long as I know exactly what it is.

    Dave

  • edited September 25


    I also do not have Kmtronic an UDP relay controller, but noticed they have a UDP test program on their website, which may be of use in troubleshooting the UDP interfacing to Aziloop.

    Screenshot from https://www.kmtronic.com/UDP-LAN-Ethernet-IP-Eight-channels-Relay-Controller.html

    Best regards, Ben

  • Hi Ben,

    Thanks for the suggestion.

    I've looked at that, but it's just emulating a controller (in place of the KiWi) not emulating a switch.

    However, now you've reminded me I could check if it talks to my code and updates itself from my reply.

    Thanks again

    Dave

  • jksjks
    edited October 2

    I found the guy who has one of these (KMtronic-UDP). He’s on vacation for a bit but will let me debug using it when he returns.

  • Was able to test using the real KMtronic-UDP switch just now. And everything works fine.

    I realize now there is a difference from how the old external antenna switch extension worked. I believe it actively polled the switch for its status once every ten seconds. The integrated extension doesn't do that. It only receives status in response to any commands it sends the switch.

    So if you were to change the selected antenna using the script interface directly (/root/Beagle_SDR_GPS/pkgs/ant_switch/ant-switch-frontend) the extension won't see the change (i.e. on the RF tab of the user control panel). But this shouldn't be an issue. Any changes made on the user side are seen by the frontend script as you'd expect.

  • Hi John,

    I have now managed to get this working, so many thanks for your kind assistance along with others - all much appreciated.

    Dave

  • What the problem was: Kiwi sends out a packet to say a configured port of 8022, with a random source port (as you'd expect). I didn't realise that when I replied to that random source port I needed to force my source port to be 8022, not the more usual random port. Kiwi must be looking at the source port from me as a validator, which is neat. But I wasn't expecting that :-)

    So, in the next imminent release of the Aziloop app, Kiwi antennas 1-4 will recall pre-stored Aziloop headings, and antennas 5-8 will activate the 2 channel Aux I/O lines so that you can have up to three external antennas plus four Aziloop headings to choose from. Works a treat! There isn't an Aziloop drop down of course, users will need to select KMTronic-UDP.

    Thanks.

    Dave GW4GTE / QuietRadio

Sign In or Register to comment.