Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sending message packet with msg number #13

Open
hemna opened this issue Aug 2, 2022 · 10 comments
Open

Sending message packet with msg number #13

hemna opened this issue Aug 2, 2022 · 10 comments

Comments

@hemna
Copy link
Contributor

hemna commented Aug 2, 2022

I am seeing a problem with sending a message that includes a message number. It looks like the message number is being stripped off the packet, resulting in incorrect acks coming back.

Here is an example from aprsd.

08/02/2022 12:43:33 PM TXPKT-4-ping         INFO                                                                                  messaging.py:584
                                                     Sending Message _______________(TX:1)
                                                       Raw     : WB4BOR-12>APZ100::WB4BOR-11:ping{4

                                                       To      : WB4BOR-11
                                                       Message : ping
                                                       Msg #   : 4
                                                     Sending Message _______________ Complete
08/02/2022 12:43:33 PM TXPKT-4-ping         DEBUG    GET client tcpkiss                                                              client.py:226
08/02/2022 12:43:34 PM TXPKT-4-ping         DEBUG    Send WB4BOR-12>APZ100::WB4BOR-11:ping{4                                           kiss.py:108
                                                      TO KISS
08/02/2022 12:43:34 PM TXPKT-4-ping         INFO     Send one-shot to WB4BOR-11: ping                                                  aprs.py:160
08/02/2022 12:43:34 PM TXPKT-4-ping         INFO     Sending WB4BOR-12>WB4BOR-11,WIDE1-1,WIDE2-1: PID=0xf0 Payload=b':WB4BOR-11:ping'  aprs.py:330
08/02/2022 12:43:34 PM TXPKT-4-ping         DEBUG    Adding to queue: WB4BOR-12>WB4BOR-11,WIDE1-1,WIDE2-1: PID=0xf0                interface.py:62
                                                     Payload=b':WB4BOR-11:ping'
08/02/2022 12:43:34 PM TXPKT-4-ping         DEBUG    Scheduling next transmission ASAP                                            interface.py:113
08/02/2022 12:43:34 PM RX_MSG               DEBUG    Transmitting WB4BOR-12>WB4BOR-11,WIDE1-1,WIDE2-1: PID=0xf0                   interface.py:141
                                                     Payload=b':WB4BOR-11:ping'
08/02/2022 12:43:34 PM RX_MSG               DEBUG    XMIT AX.25 WB4BOR-12>WB4BOR-11,WIDE1-1,WIDE2-1: PID=0xf0                          kiss.py:619
                                                     Payload=b':WB4BOR-11:ping'
08/02/2022 12:43:34 PM RX_MSG               DEBUG    XMIT FRAME '00ae8468849ea4f6ae8468849ea478ae92888a624062ae92888a64406303f03a57423 kiss.py:226
                                                     4424f522d31313a70696e67'
                                                     

The direwolf log

[0L] WB4BOR-12>WB4BOR-11,WIDE1-1,WIDE2-1::WB4BOR-11:ping

The recieving APRSD instance view of the packet

today at 12:42:45 PM                                                     Received Message _______________                                                                                                                   
today at 12:42:45 PM                                                       Raw     : WB4BOR-12>WB4BOR-11,K4CQ-4,WIDE1*,WIDE2-1,qAR,APPOMX::WB4BOR-11:ping                                                                   
today at 12:42:45 PM                                                       From    : WB4BOR-12                                                                                                                              
today at 12:42:45 PM                                                       Message : ping                                                                                                                                   
today at 12:42:45 PM                                                       Msg #   : 0                                                                                                                                      
today at 12:42:45 PM                                                     Received Message _______________ Complete                                                                                                          
today at 12:42:45 PM08/02/2022 12:42:45 PM RXPKT-WB4BOR-12>     DEBUG    Send ACK(WB4BOR-12:0) to radio.

As you can see the original message was sent to tcpkiss with a message number of 4, so I can get acks for message 4 back from the destination.

The destination didn't get a message number as part of the packet as it was stripped out, so it sent an ack with message number of 0.

@hemna
Copy link
Contributor Author

hemna commented Aug 2, 2022

This is how the packet is being sent

https://github.com/craigerl/aprsd/blob/master/aprsd/clients/kiss.py#L89-L93

@sjlongland
Copy link
Owner

The message code actually manages the msgid field itself. If you set oneshot=False, it will fill in the msgid from a counter managed by the APRSInterface class.

Is there a requirement in your application to manage the msgid field directly?

@sjlongland
Copy link
Owner

Two ideas come to mind:

  • tweaking APRSInterface to support an external counter class that can be shared by other code that needs to track the message ID externally.
  • adding a msgid parameter to send_message so that you can specify the msgid (onus will be on the caller to ensure it is unique).

@hemna
Copy link
Contributor Author

hemna commented Aug 3, 2022

so aprsd uses aprslib for client connections to aprsis servers as well. i have to manage message numbers and ack counts and replies manually with it. i have abstracted out a client object that uses aprslib or tcpkiss or serialkiss underneath it. so i pack the message mumber as part of the message itself according to the aprs spec. aprslib can exctract that and creates an aprs "packet" dict with all the particulars.

So yes i need to be able to send a message packet that includes the msg number.

@sjlongland
Copy link
Owner

What's handling the retransmissions in the case of a dropped packet? Does aioax25 need to manage retransmissions with a caller-supplied msgid, or is it sufficient to send the message "one-shot" and rely on aprslib to handle retransmissions if a message gets lost?

@hemna
Copy link
Contributor Author

hemna commented Aug 3, 2022

in the case of aprsd it will detect that it hasnt gotten an ack and will retransmit the message itself via another one shot message

@sjlongland
Copy link
Owner

Right, so we just really need a dumb UI frame transmit with no real smarts behind the scenes, since the APRS message itself is already constructed and aprslib itself is managing retransmissions.

https://github.com/sjlongland/aioax25/blob/master/aioax25/aprs/aprs.py#L163-L170 is basically what send_message does when oneshot=True.

You might be able to do what you're after with something like this:

        self.aprsint.transmit(APRSFrame(
                destination=msg.tocall,
                source=self.mycall,
                payload=(':%-9s:%s' % (
                    msg.tocall,
                    payload
                )).encode('US-ASCII'),
                repeaters=["WIDE1-1", "WIDE2-1"]
        ))

@hemna
Copy link
Contributor Author

hemna commented Aug 3, 2022

Ok thanks for the help. I have a modified version of that that seems to get received on the other side. Now I'm running into replies getting dropped because they are all Third-party packets.

08/03/2022 09:16:01 AM TXPKT-3-help         INFO                                                                                  messaging.py:584
                                                     Sending Message _______________(TX:1)
                                                       Raw     : WB4BOR-12>APZ100::WB4BOR-11:help{3

                                                       To      : WB4BOR-11
                                                       Message : help
                                                       Msg #   : 3
                                                     Sending Message _______________ Complete
08/03/2022 09:16:01 AM TXPKT-3-help         DEBUG    GET client tcpkiss                                                              client.py:226
08/03/2022 09:16:01 AM TXPKT-3-help         DEBUG    Send 'WB4BOR-12>APZ100::WB4BOR-11:help{3                                          kiss.py:109
                                                     ' TO KISS
08/03/2022 09:16:01 AM TXPKT-3-help         INFO     Sending WB4BOR-12>WB4BOR-11,WIDE1-1,WIDE2-1: PID=0xf0                             aprs.py:330
                                                     Payload=b':WB4BOR-11:help{3'
08/03/2022 09:16:01 AM TXPKT-3-help         DEBUG    Adding to queue: WB4BOR-12>WB4BOR-11,WIDE1-1,WIDE2-1: PID=0xf0                interface.py:62
                                                     Payload=b':WB4BOR-11:help{3'
08/03/2022 09:16:01 AM TXPKT-3-help         DEBUG    Scheduling next transmission ASAP                                            interface.py:113
08/03/2022 09:16:05 AM RX_MSG               DEBUG    Transmitting WB4BOR-12>WB4BOR-11,WIDE1-1,WIDE2-1: PID=0xf0                   interface.py:141
                                                     Payload=b':WB4BOR-11:help{3'
08/03/2022 09:16:05 AM RX_MSG               DEBUG    XMIT AX.25 WB4BOR-12>WB4BOR-11,WIDE1-1,WIDE2-1: PID=0xf0                          kiss.py:619
                                                     Payload=b':WB4BOR-11:help{3'
08/03/2022 09:16:05 AM RX_MSG               DEBUG    XMIT FRAME '00ae8468849ea476ae8468849ea4f8ae92888a624062ae92888a64406303f03a57423 kiss.py:226
                                                     4424f522d31313a68656c707b33'
08/03/2022 09:16:05 AM RX_MSG               DEBUG    Clear-to-send expiry at 358.08661028348564                                    interface.py:89
08/03/2022 09:16:05 AM RX_MSG               DEBUG    XMIT RAW 'c000ae8468849ea476ae8468849ea4f8ae92888a624062ae92888a64406303f03a57423 kiss.py:319
                                                     4424f522d31313a68656c707b33c0'
08/03/2022 09:16:08 AM RX_MSG               DEBUG    RECV RAW 'c000ae8468849ea476ae8468849ea4f8966886a24040e8ae92888a6240e0ae92888a644 kiss.py:211
                                                     06303f03a574234424f522d31313a68656c707b33c0'

And the RX

08/03/2022 09:16:24 AM RX_MSG               DEBUG    Handling incoming frame APPOMX*>APDW16*,K4CQ-4*,WIDE1*,WIDE2-1: PID=0xf0         router.py:95
                                                     Payload=b'}WB4BOR-11>APZ100,TCPIP,APPOMX*::WB4BOR-12:plugins: avwxweather email
                                                     location location-slack openweathermap{15'
08/03/2022 09:16:24 AM RX_MSG               DEBUG    Dispatching frame to 0 receivers                                                router.py:133
08/03/2022 09:16:24 AM RX_MSG               DEBUG    Failed to decode as APRS                                                          frame.py:46
                                                     ╭────────────────────── Traceback (most recent call last) ──────────────────────╮
                                                     │                                                                               │
                                                     │ /Users/i530566/devel/mine/hamradio/aioax25/aioax25/aprs/frame.py:38 in decode │
                                                     │                                                                               │
                                                     │   35 │   │   try:                                                             │
                                                     │   36 │   │   │   # Inspect the first byte.                                    │
                                                     │   37 │   │   │   type_code = APRSDataType(uiframe.payload[0])                 │
                                                     │ ❱ 38 │   │   │   handler_class = cls.DATA_TYPE_HANDLERS[type_code]            │
                                                     │   39 │   │   │                                                                │
                                                     │   40 │   │   │   # Decode the payload as text                                 │
                                                     │   41 │   │   │   payload = uiframe.payload.decode('US-ASCII')                 │
                                                     ╰───────────────────────────────────────────────────────────────────────────────╯
                                                     KeyError: <APRSDataType.THIRD_PARTY: 125>
08/03/2022 09:16:24 AM RX_MSG               DEBUG    Processing incoming message APPOMX*>APDW16*,K4CQ-4*,WIDE1*,WIDE2-1: PID=0xf0      aprs.py:291
                                                     Payload=b'}WB4BOR-11>APZ100,TCPIP,APPOMX*::WB4BOR-12:plugins: avwxweather email
                                                     location location-slack openweathermap{15' (type AX25UnnumberedInformationFrame)
08/03/2022 09:16:24 AM RX_MSG               DEBUG    Handling incoming frame APPOMX*>APDW16*,K4CQ-4*,WIDE1*,WIDE2-1: PID=0xf0         router.py:95
                                                     Payload=b'}WB4BOR-11>APZ100,TCPIP,APPOMX*::WB4BOR-12:plugins: avwxweather email
                                                     location location-slack openweathermap{15'
08/03/2022 09:16:24 AM RX_MSG               DEBUG    Dispatching frame to 0 receivers

@hemna
Copy link
Contributor Author

hemna commented Aug 3, 2022

@sjlongland
Copy link
Owner

Yeah, third party packets is a whole area of APRS I'm unfamiliar with.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants