Reviewed-on: https://gitea.farpn.net/w1cdn/mwtchahrd/pulls/32
mwtchahrd
mwtchahrd is a Rust-based command‑line tool designed for monitoring AGWPE frames from a Direwolf TNC. It connects to an AGWPE server over TCP, sends a monitor command, receives and parses AGWPE frames, and outputs a human‑readable summary of the session. The tool is written with a focus on Rust idiomatic practices, safety, and efficiency.
Features
- TCP Connection & Keepalive: Connects to an AGWPE server over TCP and uses socket options to enable TCP keepalive.
- Frame Parsing: Decodes AGWPE frame headers and payloads, extracting useful information such as callsigns, data kind, and payload length.
- Debug Logging: In debug mode, prints detailed hex dumps of the raw frame data along with timestamps.
- Session Buffering: Buffers and processes multi‑line frames, displaying session information in a clear, formatted output.
- Filtering Options: Filters out frames based on the destination (ignoring “NODES”) and payload content (ignoring XID frames). Optionally, it can restrict output to only UI frames.
Prerequisites
- Rust (version 1.XX or later)
- Cargo package manager (comes with Rust)
Installation
Clone the repository:
git https://gitea.farpn.net/n6cta/mwtchahrd.git
cd mwtchahrd
Build the project in release mode:
cargo build --release
The compiled executable will be located in the target/release directory.
Usage
Run the executable with the required arguments:
mwtchahrd -i <IP> -p <PORT> [-c <CHANNEL>] [-d] [-u]
Command‑Line Arguments
-
-i, --ip <IP>
The IP address of the AGWPE server (e.g.127.0.0.1). -
-p, --port <PORT>
The TCP port of the AGWPE server (e.g.8000). Must be greater than 0. -
-c, --channel <CHANNEL>
The AGWPE channel to monitor (default is0). Must be between 0 and 255. -
-d, --debug
Enable debug mode. When active, the tool prints detailed hex dumps and additional frame information. -
-u, --ui_only
Only display frames with a UI payload. When this flag is set, frames that are not UI are skipped. -
-b, --uip <UIP>Send UDP to what IP address (e.g. 127.0.0.1) [default: 127.0.0.1]. -
-k, --uport <UPORT>Send UDP to what port (e.g. 8000; 55555 disables UDP) [default: 55555]. -
-s, --spotter <SPOTTER>
Spotter callsign (e.g. W1CDN). -
-o, --spothole
Spot UI frames to a Spothole server. -
-O, --spothole-alt <SPOTHOLE_ALT>Provide a different URL than https://spothole.app/api/v1/spot. -
-f, --freq <FREQ>
Spotting frequency [default: 14105000]. -
-y, --my-lat <MY_LAT>
Spotter latitude, DD.dddd. -
-x, --my-lon <MY_LON>
Spotter longitude, DD.dddd. -
-t, --filter <CALL-SSID,CALL-SSID,...>
Filter out spots from these callsign-UUID combinations (self spots, for example), comma-separated. This is not regex, just full matches. -
-h, --help
Print help. -
-V, --version
Print version.
Examples
Monitoring All Frames
Connect to an AGWPE server at 127.0.0.1:8000 on channel 0 and display all frames:
mwtchahrd -i 127.0.0.1 -p 8000
Debug Mode
Enable debug mode to see detailed frame information including hex dumps:
mwtchahrd -i 127.0.0.1 -p 8000 -d
UI Frames Only
Monitor only UI frames:
mwtchahrd -i 127.0.0.1 -p 8000 -u
Spotting to Spothole.app API
Sends only UI frames and mode is hardcoded as PKT. Spot from callsign W1CDN and report fixed frequency 14.105 MHz. Report your location as spotter and don't spot your own beacons.
mwtchahrd --ip 192.168.0.6 --port 8000 --spotter W1CDN --spothole --freq 14105000 --my-lat 47.01 --my-lon -97.01 --filter W1CDN-1,W1CDN-7
Code Overview
-
Validation Functions:
validate_portandvalidate_channelensure that the provided port and channel values are within valid ranges.
-
Command‑Line Parsing:
- Uses the Clap crate to handle command‑line argument parsing and help message generation.
-
Frame Parsing:
- The
parse_headerandparse_framefunctions read the raw TCP stream, extract header fields and payload data, and convert them into Rust types.
- The
-
Debug Logging & Text Filtering:
debug_log_frameprints detailed debug information.filter_textcleans the payload for printable ASCII characters.
-
Session Buffering:
- A
BufferManagerhandles incomplete multi‑line frames and extracts complete lines for further processing.
- A
-
Main Loop:
- The
mainfunction repeatedly connects to the AGWPE server, sends a monitor command, reads data, and processes frames. On disconnection, it waits briefly before reconnecting.
- The
Binary Releases
Binary releases are provided for the following targets for your convinience. They were generated using using Cross.
- aarch64-unknown-linux-gnu
- aarch64-apple-darwin
- x86_64-unknown-linux-gnu
- armv7-unknown-linux-gnueabihf
- arm-unknown-linux-gnueabihf
Contributing
Contributions are welcome! Feel free to fork the repository and submit pull requests. For major changes, please open an issue first to discuss your ideas.