Expand description
The Semtech packet forwarder protocol, both sides.
A gateway and a network server exchange six kinds of UDP datagram, described by
PROTOCOL.TXT in Semtech’s packet_forwarder. Each begins with the same three bytes, a
protocol version of 2 and a random token, then an identifier that says which kind it is:
- The gateway sends PUSH_DATA with the packets it heard, and the server answers PUSH_ACK with the same token.
- The gateway sends PULL_DATA to hold a route open through whatever network address translation sits in front of it, and the server answers PULL_ACK.
- The server sends PULL_RESP with a packet to transmit, and the gateway answers TX_ACK saying whether it accepted it.
The protocol has no authentication and no retries, which is why it belongs on a private
network or behind a tunnel. Packet builds and parses every kind, and the objects they
carry are in Rxpk, Stat, Txpk, and TxStatus.
§Examples
A server reads a forwarded packet and answers it.
use pamoja_gateway::udp::{Eui, Packet, PacketKind, Rxpk, Uplink};
use pamoja_lora::LinkSettings;
let gateway = Eui::new([0xB8, 0x27, 0xEB, 0xFF, 0xFE, 0x01, 0x02, 0x03]);
let datagram = Packet::PushData {
token: 0x0102,
gateway,
uplink: Uplink::from(Rxpk::new(
868_100_000,
LinkSettings::new(7, 125_000),
b"hello".to_vec(),
)),
}
.to_bytes();
let packet = Packet::parse(&datagram)?;
assert_eq!(packet.kind(), PacketKind::PushData);
assert_eq!(packet.gateway(), Some(gateway));
assert_eq!(packet.acknowledgment().map(|ack| ack.to_bytes()), Some(vec![2, 0x01, 0x02, 0x01]));Structs§
- Eui
- A gateway’s unique identifier, the eight bytes it puts in every datagram it sends.
- Rxpk
- A packet the gateway heard, with the metadata the protocol carries beside it.
- Stat
- The gateway’s own status report.
- Txpk
- A packet the server asks the gateway to transmit.
- Uplink
- What a PUSH_DATA carries: the packets heard, and the gateway’s own report.
Enums§
- CrcStatus
- What the CRC of a received packet said.
- Modulation
- How a packet was modulated.
- Packet
- One datagram of the protocol.
- Packet
Kind - Which kind of datagram, as its fourth byte says.
- Protocol
Error - Why a datagram is not one this protocol defines.
- TxStatus
- What became of a downlink the server asked for.
Constants§
- EUI_LEN
- The length of a gateway’s unique identifier.
- HEADER_
LEN - The bytes before a datagram’s payload: the version, the token, and the identifier.
- PROTOCOL_
VERSION - The protocol version every datagram starts with.