Exercise is reduced to BOB, CY & DAN. LINK is still broken, but writing history_of_a_LINK.md for a forensic analysis and referencing this version
This commit is contained in:
parent
7f78dfb70e
commit
197b46b4bb
5 changed files with 310 additions and 5 deletions
235
exercises/204_established_identities/history_of_a_LINK.md
Normal file
235
exercises/204_established_identities/history_of_a_LINK.md
Normal file
|
|
@ -0,0 +1,235 @@
|
|||
# History of a BOB to CY Link
|
||||
|
||||
Source logs: `/home/jlpoole/logs/20260528_2319`
|
||||
|
||||
This run used BOB, DAN, and CY only. ED was offline. The simulated physical
|
||||
block between BOB and CY was enabled, so direct BOB<->CY LoRa frames were
|
||||
dropped below microReticulum in `TBeamSupremeLoRaInterface`. Packets physically
|
||||
transmitted by DAN were still accepted by both BOB and CY.
|
||||
|
||||
## Key Evidence With Exact Log Lines
|
||||
|
||||
These are the most pertinent lines in `file:line:entry` form.
|
||||
|
||||
```text
|
||||
/home/jlpoole/logs/20260528_2319/BOB_raw_20260528_231955.log:85:20260528_232309.309 TX ANNOUNCE: Bob
|
||||
/home/jlpoole/logs/20260528_2319/BOB_raw_20260528_231955.log:88:20260528_232316.679 01-02:10:30.334 [NOT] MR TRANSPORT PATH: dest=f04ce61418eecae211de3f78d0e652e6 hops=2 via=d0524d8f1d98fc39f13772655640ea30 iface=Interface[TBeamSupremeLoRa]
|
||||
/home/jlpoole/logs/20260528_2319/BOB_raw_20260528_231955.log:89:20260528_232316.682 RX ANNOUNCE: label=Cy hash=f04ce61418eecae211de3f78d0e652e6 phy=Dan(3)
|
||||
|
||||
/home/jlpoole/logs/20260528_2319/BOB_raw_20260528_231955.log:97:20260528_232322.256 TX LINKREQUEST: opening link to Cy slot=19
|
||||
/home/jlpoole/logs/20260528_2319/BOB_raw_20260528_231955.log:98:20260528_232322.386 01-02:10:36.041 [NOT] MR TRANSPORT OUT: type=LINKREQUEST dest=f04ce61418eecae211de3f78d0e652e6 hops=2 next=d0524d8f1d98fc39f13772655640ea30 iface=Interface[TBeamSupremeLoRa]
|
||||
|
||||
/home/jlpoole/logs/20260528_2319/DAN_raw_20260528_231958.log:1680:20260528_232322.594 23:23:59.788 [NOT] MR TRANSPORT FWD: type=LINKREQUEST dest=f04ce61418eecae211de3f78d0e652e6 remaining=1 next=f04ce61418eecae211de3f78d0e652e6 iface=Interface[TBeamSupremeLoRa]
|
||||
/home/jlpoole/logs/20260528_2319/DAN_raw_20260528_231958.log:1681:20260528_232322.595 23:23:59.789 [---] Transport::inbound: Packet is next-hop LINKREQUEST
|
||||
|
||||
/home/jlpoole/logs/20260528_2319/CY_raw_20260528_231957.log:1314:20260528_232322.767 18:52:08.577 [---] Transport::inbound: packet: ht=0 tt=0 dt=0 pt=2 hp=1 ti= dh=f04ce61418eecae211de3f78d0e652e6 ph=387de6033cddc91ac6c583721fa79eb84b58bfc84dc4b8f35fb1d98ef0f3bffc
|
||||
/home/jlpoole/logs/20260528_2319/CY_raw_20260528_231957.log:1320:20260528_232322.773 18:52:08.583 [---] Transport::inbound: Packet is LINKREQUEST
|
||||
/home/jlpoole/logs/20260528_2319/CY_raw_20260528_231957.log:1322:20260528_232322.774 18:52:08.584 [---] Transport::inbound: Found local destination for LINKREQUEST
|
||||
/home/jlpoole/logs/20260528_2319/CY_raw_20260528_231957.log:1323:20260528_232322.775 18:52:08.585 [---] ***** Accepting link request
|
||||
/home/jlpoole/logs/20260528_2319/CY_raw_20260528_231957.log:1335:20260528_232322.846 18:52:08.656 [DBG] Link 387de6033cddc91ac6c583721fa79eb8 requesting proof
|
||||
/home/jlpoole/logs/20260528_2319/CY_raw_20260528_231957.log:1347:20260528_232322.910 18:52:08.720 [NOT] MR TRANSPORT OUT: type=PROOF dest=387de6033cddc91ac6c583721fa79eb8 path=unknown
|
||||
|
||||
/home/jlpoole/logs/20260528_2319/BOB_raw_20260528_231955.log:103:20260528_232323.747 LINK ACTIVE: initiator link established to Cy hash=387de6033cddc91ac6c583721fa79eb8
|
||||
|
||||
/home/jlpoole/logs/20260528_2319/BOB_raw_20260528_231955.log:110:20260528_232411.271 TX LINK: Hi from Bob iter=5 to=Cy
|
||||
/home/jlpoole/logs/20260528_2319/BOB_raw_20260528_231955.log:112:20260528_232411.306 01-02:11:24.961 [NOT] MR TRANSPORT OUT: type=DATA dest=387de6033cddc91ac6c583721fa79eb8 path=unknown
|
||||
|
||||
/home/jlpoole/logs/20260528_2319/DAN_raw_20260528_231958.log:1885:20260528_232411.501 23:24:48.694 [---] Transport::inbound: packet: ht=0 tt=0 dt=3 pt=0 hp=0 ti= dh=387de6033cddc91ac6c583721fa79eb8 ph=838aaf52dc8f5a71ca7d878154504fce9471a5e40cad556f55739287c01720f2
|
||||
/home/jlpoole/logs/20260528_2319/DAN_raw_20260528_231958.log:1893:20260528_232411.507 23:24:48.700 [---] Transport::inbound: Link inbound/outbound interfaes are same, transporting on same interface
|
||||
/home/jlpoole/logs/20260528_2319/DAN_raw_20260528_231958.log:1894:20260528_232411.509 23:24:48.701 [NOT] MR TRANSPORT LINKFWD: dest=387de6033cddc91ac6c583721fa79eb8 hops=1 link_remaining=1 link_hops=1 iface=Interface[TBeamSupremeLoRa]
|
||||
|
||||
/home/jlpoole/logs/20260528_2319/BOB_raw_20260528_231955.log:113:20260528_232411.702 RNSDEC ms=3378664 board=library role=unknown event=attempt link_id=387de6033cddc91ac6c583721fa79eb8 token_len=80 token_crc32=808C9304 sign_key_crc32=928C394D enc_key_crc32=D6DE582A link_obj={Link:387de6033cddc91ac6c583721fa79eb8}
|
||||
/home/jlpoole/logs/20260528_2319/BOB_raw_20260528_231955.log:114:20260528_232411.704 RX LINK ignored: self_or_wrong_recipient text=Hi from Bob iter=5 to=Cy
|
||||
|
||||
/home/jlpoole/logs/20260528_2319/CY_raw_20260528_231957.log:1534:20260528_232411.704 18:52:57.513 [---] Transport::inbound: packet: ht=0 tt=0 dt=3 pt=0 hp=1 ti= dh=387de6033cddc91ac6c583721fa79eb8 ph=838aaf52dc8f5a71ca7d878154504fce9471a5e40cad556f55739287c01720f2
|
||||
/home/jlpoole/logs/20260528_2319/CY_raw_20260528_231957.log:1541:20260528_232411.711 18:52:57.519 [---] Transport::inbound: Packet is DATA
|
||||
/home/jlpoole/logs/20260528_2319/CY_raw_20260528_231957.log:1542:20260528_232411.712 18:52:57.520 [---] Transport::inbound: Packet is DATA for a LINK
|
||||
/home/jlpoole/logs/20260528_2319/CY_raw_20260528_231957.log:1543:20260528_232411.712 18:52:57.520 [---] Transport::inbound: Packet is DATA for an active LINK
|
||||
/home/jlpoole/logs/20260528_2319/CY_raw_20260528_231957.log:1545:20260528_232411.714 RNSDEC ms=1197054 board=library role=unknown event=attempt link_id=387de6033cddc91ac6c583721fa79eb8 token_len=80 token_crc32=808C9304 sign_key_crc32=928C394D enc_key_crc32=D6DE582A link_obj={Link:387de6033cddc91ac6c583721fa79eb8}
|
||||
```
|
||||
|
||||
## Identity Legend
|
||||
|
||||
The relevant destination and transport identities in this run were:
|
||||
|
||||
```text
|
||||
BOB destination hash: e431430abeca68dca8411f50ca9864b0
|
||||
CY destination hash: f04ce61418eecae211de3f78d0e652e6
|
||||
DAN destination hash: d7217d5b6372e94aa78df9a43110723d
|
||||
DAN transport ID: d0524d8f1d98fc39f13772655640ea30
|
||||
|
||||
BOB->CY Link ID: 387de6033cddc91ac6c583721fa79eb8
|
||||
```
|
||||
|
||||
The application policy is that BOB is the initiator for this BOB/CY pair. The
|
||||
logs do not show the identity comparison itself, but they do show BOB initiating
|
||||
the LinkRequest and CY accepting the inbound request.
|
||||
|
||||
## 1. Announcements Establish the Path
|
||||
|
||||
BOB announces directly. DAN receives the BOB announce and records a direct
|
||||
one-hop path to BOB:
|
||||
|
||||
```text
|
||||
DAN line 1404: packet destination=e431430abeca68dca8411f50ca9864b0 hops=0
|
||||
DAN line 1414: Valid announce for e431430abeca68dca8411f50ca9864b0 1 hops away
|
||||
DAN line 1425: MR TRANSPORT PATH: dest=e431430abeca68dca8411f50ca9864b0 hops=1 via=e431430abeca68dca8411f50ca9864b0 iface=Interface[TBeamSupremeLoRa]
|
||||
DAN line 1436: RX ANNOUNCE: label=Bob hash=e431430abeca68dca8411f50ca9864b0 phy=Bob(1)
|
||||
```
|
||||
|
||||
DAN rebroadcasts BOB's announce with DAN as the transport ID:
|
||||
|
||||
```text
|
||||
DAN line 1444: Rebroadcasting announce for e431430abeca68dca8411f50ca9864b0 with hop count 1
|
||||
DAN line 1447: Packet::pack: transport id: d0524d8f1d98fc39f13772655640ea30
|
||||
DAN line 1448: Packet::pack: destination hash: e431430abeca68dca8411f50ca9864b0
|
||||
```
|
||||
|
||||
CY receives BOB's announce through DAN and records a two-hop path to BOB via
|
||||
DAN:
|
||||
|
||||
```text
|
||||
CY line 1497: packet: ... hp=1 ti=d0524d8f1d98fc39f13772655640ea30 dh=e431430abeca68dca8411f50ca9864b0
|
||||
CY line 1507: Valid announce for e431430abeca68dca8411f50ca9864b0 2 hops away, received via d0524d8f1d98fc39f13772655640ea30
|
||||
CY line 1517: Destination e431430abeca68dca8411f50ca9864b0 is now 2 hops away via d0524d8f1d98fc39f13772655640ea30
|
||||
CY line 1518: MR TRANSPORT PATH: dest=e431430abeca68dca8411f50ca9864b0 hops=2 via=d0524d8f1d98fc39f13772655640ea30 iface=Interface[TBeamSupremeLoRa]
|
||||
CY line 1529: RX ANNOUNCE: label=Bob hash=e431430abeca68dca8411f50ca9864b0 phy=Dan(3)
|
||||
```
|
||||
|
||||
The reverse direction is also known. BOB repeatedly receives CY announces via
|
||||
DAN and records a two-hop path to CY:
|
||||
|
||||
```text
|
||||
BOB line 88: MR TRANSPORT PATH: dest=f04ce61418eecae211de3f78d0e652e6 hops=2 via=d0524d8f1d98fc39f13772655640ea30 iface=Interface[TBeamSupremeLoRa]
|
||||
BOB line 89: RX ANNOUNCE: label=Cy hash=f04ce61418eecae211de3f78d0e652e6 phy=Dan(3)
|
||||
```
|
||||
|
||||
At this point, BOB knows that CY is reachable through DAN.
|
||||
|
||||
## 2. BOB Initiates the LinkRequest
|
||||
|
||||
BOB decides to open a Link to CY. Since BOB is the initiator for this pair, BOB
|
||||
creates a LinkRequest targeting CY's destination hash. Because CY is known as a
|
||||
two-hop destination via DAN, BOB sends the LinkRequest to DAN as the next hop:
|
||||
|
||||
```text
|
||||
BOB line 97: TX LINKREQUEST: opening link to Cy slot=19
|
||||
BOB line 98: MR TRANSPORT OUT: type=LINKREQUEST dest=f04ce61418eecae211de3f78d0e652e6 hops=2 next=d0524d8f1d98fc39f13772655640ea30 iface=Interface[TBeamSupremeLoRa]
|
||||
```
|
||||
|
||||
DAN receives that transported LinkRequest. DAN recognizes that it is the
|
||||
designated next hop and forwards the request toward CY:
|
||||
|
||||
```text
|
||||
DAN line 1680: MR TRANSPORT FWD: type=LINKREQUEST dest=f04ce61418eecae211de3f78d0e652e6 remaining=1 next=f04ce61418eecae211de3f78d0e652e6 iface=Interface[TBeamSupremeLoRa]
|
||||
DAN line 1681: Transport::inbound: Packet is next-hop LINKREQUEST
|
||||
```
|
||||
|
||||
CY also sees one direct physical BOB frame and drops it at the simulated PHY
|
||||
layer. This is expected and is not a microReticulum decision:
|
||||
|
||||
```text
|
||||
CY line 1310: SIM PHY DROP: rx=2 tx=1 len=107 blocked=113
|
||||
```
|
||||
|
||||
## 3. CY Accepts the LinkRequest
|
||||
|
||||
CY receives the forwarded LinkRequest from DAN. It is no longer a direct BOB
|
||||
physical frame; it is physically transmitted by DAN, so it passes the simulated
|
||||
PHY block and reaches microReticulum:
|
||||
|
||||
```text
|
||||
CY line 1314: packet: ht=0 tt=0 dt=0 pt=2 hp=1 ... dh=f04ce61418eecae211de3f78d0e652e6 ph=387de6033cddc91ac6c583721fa79eb8...
|
||||
CY line 1315: destination=f04ce61418eecae211de3f78d0e652e6 hops=1
|
||||
CY line 1320: Transport::inbound: Packet is LINKREQUEST
|
||||
CY line 1322: Transport::inbound: Found local destination for LINKREQUEST
|
||||
CY line 1323: ***** Accepting link request
|
||||
CY line 1327: Validating link request 387de6033cddc91ac6c583721fa79eb8
|
||||
CY line 1335: Link 387de6033cddc91ac6c583721fa79eb8 requesting proof
|
||||
```
|
||||
|
||||
CY sends a proof for the LinkRequest:
|
||||
|
||||
```text
|
||||
CY line 1342: Packet::pack: destination link id: 387de6033cddc91ac6c583721fa79eb8
|
||||
CY line 1345: Transport::outbound: destination=387de6033cddc91ac6c583721fa79eb8 hops=0
|
||||
CY line 1347: MR TRANSPORT OUT: type=PROOF dest=387de6033cddc91ac6c583721fa79eb8 path=unknown
|
||||
CY line 1353: Incoming link request {Link:387de6033cddc91ac6c583721fa79eb8} accepted
|
||||
```
|
||||
|
||||
BOB receives enough of the proof/handshake to mark the Link active:
|
||||
|
||||
```text
|
||||
BOB line 100: RNSDEC ... event=encrypt link_id=387de6033cddc91ac6c583721fa79eb8 token_len=64 ...
|
||||
BOB line 101: RNSDEC ... event=attempt link_id=387de6033cddc91ac6c583721fa79eb8 token_len=64 ...
|
||||
BOB line 102: MR TRANSPORT OUT: type=DATA dest=387de6033cddc91ac6c583721fa79eb8 path=unknown
|
||||
BOB line 103: LINK ACTIVE: initiator link established to Cy hash=387de6033cddc91ac6c583721fa79eb8
|
||||
```
|
||||
|
||||
This is the key success point: with ED removed, BOB successfully establishes a
|
||||
Link to CY through DAN.
|
||||
|
||||
## 4. First Data Packet After Link Establishment
|
||||
|
||||
After the Link is active, BOB sends an application payload over the Link:
|
||||
|
||||
```text
|
||||
BOB line 110: TX LINK: Hi from Bob iter=5 to=Cy
|
||||
BOB line 111: RNSDEC ... event=encrypt link_id=387de6033cddc91ac6c583721fa79eb8 token_len=80 ...
|
||||
BOB line 112: MR TRANSPORT OUT: type=DATA dest=387de6033cddc91ac6c583721fa79eb8 path=unknown
|
||||
```
|
||||
|
||||
DAN receives the Link data and identifies it as a packet that should be link
|
||||
transported. The inbound and outbound interfaces are the same LoRa interface, so
|
||||
DAN forwards the packet back out on the same interface:
|
||||
|
||||
```text
|
||||
DAN line 1885: packet: ht=0 tt=0 dt=3 pt=0 hp=0 ... dh=387de6033cddc91ac6c583721fa79eb8
|
||||
DAN line 1886: destination=387de6033cddc91ac6c583721fa79eb8 hops=0
|
||||
DAN line 1894: MR TRANSPORT LINKFWD: dest=387de6033cddc91ac6c583721fa79eb8 hops=1 link_remaining=1 link_hops=1 iface=Interface[TBeamSupremeLoRa]
|
||||
```
|
||||
|
||||
## 5. Failure Point
|
||||
|
||||
BOB hears the forwarded Link packet on the shared LoRa channel. Since the
|
||||
plaintext says it is from Bob and to Cy, BOB's application rejects it as
|
||||
self/wrong-recipient:
|
||||
|
||||
```text
|
||||
BOB line 113: RNSDEC ... event=attempt link_id=387de6033cddc91ac6c583721fa79eb8 token_len=80 ...
|
||||
BOB line 114: RX LINK ignored: self_or_wrong_recipient text=Hi from Bob iter=5 to=Cy
|
||||
```
|
||||
|
||||
CY also receives a packet for the same Link ID around the same time:
|
||||
|
||||
```text
|
||||
CY line 1532: Transport::inbound: received 99 bytes
|
||||
CY line 1534: packet: ht=0 tt=0 dt=3 pt=0 hp=1 ... dh=387de6033cddc91ac6c583721fa79eb8
|
||||
CY line 1535: destination=387de6033cddc91ac6c583721fa79eb8 hops=1
|
||||
CY line 1545: RNSDEC ... event=attempt link_id=387de6033cddc91ac6c583721fa79eb8 token_len=80 ...
|
||||
```
|
||||
|
||||
But CY does not log the expected application-level receive:
|
||||
|
||||
```text
|
||||
expected but absent:
|
||||
RX LINK: Hi from Bob iter=5 to=Cy
|
||||
```
|
||||
|
||||
The failure is therefore not in initial path discovery and not in LinkRequest
|
||||
delivery. The BOB->DAN->CY Link establishment succeeds. The observed failure is
|
||||
in post-establishment Link data handling after DAN forwards the Link data on the
|
||||
same broadcast LoRa interface. BOB hears the forwarded packet and ignores it as
|
||||
self/wrong-recipient; CY attempts to process the packet but does not emit the
|
||||
expected `RX LINK` application payload line.
|
||||
|
||||
## Working Interpretation
|
||||
|
||||
1. Announcement transport works: BOB and CY learn each other through DAN.
|
||||
2. LinkRequest transport works in the single-intermediary case: DAN forwards
|
||||
BOB's LinkRequest to CY.
|
||||
3. Link establishment works: BOB marks the BOB->CY Link active.
|
||||
4. Link data transport partially works: DAN recognizes and forwards Link data.
|
||||
5. The failure point is after Link data forwarding on the same LoRa interface.
|
||||
The forwarded packet is heard by BOB and apparently reaches CY, but CY does
|
||||
not produce the expected decrypted application payload log.
|
||||
|
|
@ -52,6 +52,7 @@ build_flags =
|
|||
-D USTORE_MAX_VALUE_LEN=1200
|
||||
-D SIM_PHY_ENVELOPE=1
|
||||
-D SIM_PHY_BLOCK_BOB_CY=1
|
||||
-D MR_TRANSPORT_PROBE=1
|
||||
; Live announces are enough for this single-hop field exercise. Do not define
|
||||
; RNS_PERSIST_PATHS here: the LittleFS-backed path_store compactor can leave an
|
||||
; active segment FD open while unlinking /path_store_*.dat on ESP32.
|
||||
|
|
@ -94,6 +95,7 @@ upload_port = /dev/ttytCY
|
|||
monitor_port = /dev/ttytCY
|
||||
build_flags =
|
||||
${env.build_flags}
|
||||
-D EX204_RNS_TRACE=1
|
||||
-D BOARD_ID=\"CY\"
|
||||
-D NODE_LABEL=\"Cy\"
|
||||
-D NODE_SLOT_INDEX=2
|
||||
|
|
@ -104,6 +106,7 @@ upload_port = /dev/ttytDAN
|
|||
monitor_port = /dev/ttytDAN
|
||||
build_flags =
|
||||
${env.build_flags}
|
||||
-D EX204_RNS_TRACE=1
|
||||
-D BOARD_ID=\"DAN\"
|
||||
-D NODE_LABEL=\"Dan\"
|
||||
-D NODE_SLOT_INDEX=3
|
||||
|
|
|
|||
|
|
@ -157,27 +157,39 @@ int TBeamSupremeLoRaInterface::transmit_frame(uint8_t header, const uint8_t* pay
|
|||
bool TBeamSupremeLoRaInterface::unpack_frame(uint8_t* frame, int& len, uint8_t& physical_tx) {
|
||||
#if SIM_PHY_ENVELOPE
|
||||
if (len < PHY_ENVELOPE_LEN + 1) {
|
||||
++_phy_bad_frames;
|
||||
DEBUGF("SIM PHY malformed: short frame len=%d", len);
|
||||
return false;
|
||||
}
|
||||
if (frame[0] != PHY_MAGIC_0 || frame[1] != PHY_MAGIC_1 || frame[2] != PHY_VERSION) {
|
||||
++_phy_bad_frames;
|
||||
DEBUGF("SIM PHY malformed: bad envelope len=%d", len);
|
||||
return false;
|
||||
}
|
||||
physical_tx = frame[3];
|
||||
if (should_drop_physical_tx(physical_tx)) {
|
||||
++_phy_blocked_frames;
|
||||
Serial.printf("SIM PHY DROP: rx=%u tx=%u len=%d blocked=%lu\r\n",
|
||||
(unsigned)NODE_SLOT_INDEX,
|
||||
(unsigned)physical_tx,
|
||||
len,
|
||||
(unsigned long)_phy_blocked_frames);
|
||||
DEBUGF("SIM PHY DROP: rx=%u tx=%u len=%d",
|
||||
(unsigned)NODE_SLOT_INDEX,
|
||||
(unsigned)physical_tx,
|
||||
len);
|
||||
return false;
|
||||
}
|
||||
_last_physical_tx = physical_tx;
|
||||
++_phy_rx_frames;
|
||||
len -= PHY_ENVELOPE_LEN;
|
||||
memmove(frame, frame + PHY_ENVELOPE_LEN, len);
|
||||
return true;
|
||||
#else
|
||||
(void)frame;
|
||||
physical_tx = 255;
|
||||
_last_physical_tx = physical_tx;
|
||||
++_phy_rx_frames;
|
||||
return true;
|
||||
#endif
|
||||
}
|
||||
|
|
|
|||
|
|
@ -18,6 +18,10 @@ public:
|
|||
|
||||
float last_rssi() const { return _last_rssi; }
|
||||
float last_snr() const { return _last_snr; }
|
||||
uint8_t last_physical_tx() const { return _last_physical_tx; }
|
||||
uint32_t phy_rx_frames() const { return _phy_rx_frames; }
|
||||
uint32_t phy_blocked_frames() const { return _phy_blocked_frames; }
|
||||
uint32_t phy_bad_frames() const { return _phy_bad_frames; }
|
||||
|
||||
private:
|
||||
void send_outgoing(const RNS::Bytes& data) override;
|
||||
|
|
@ -47,6 +51,10 @@ private:
|
|||
RNS::Bytes _rx_buffer;
|
||||
uint8_t _rx_seq = SEQ_UNSET;
|
||||
uint8_t _tx_seq_ctr = 0;
|
||||
uint8_t _last_physical_tx = 255;
|
||||
uint32_t _phy_rx_frames = 0;
|
||||
uint32_t _phy_blocked_frames = 0;
|
||||
uint32_t _phy_bad_frames = 0;
|
||||
float _last_rssi = 0.0f;
|
||||
float _last_snr = 0.0f;
|
||||
|
||||
|
|
|
|||
|
|
@ -35,6 +35,18 @@
|
|||
#define FW_BUILD_UTC "unknown"
|
||||
#endif
|
||||
|
||||
#ifndef SIM_PHY_ENVELOPE
|
||||
#define SIM_PHY_ENVELOPE 0
|
||||
#endif
|
||||
|
||||
#ifndef SIM_PHY_BLOCK_BOB_CY
|
||||
#define SIM_PHY_BLOCK_BOB_CY 0
|
||||
#endif
|
||||
|
||||
#ifndef EX204_RNS_TRACE
|
||||
#define EX204_RNS_TRACE 0
|
||||
#endif
|
||||
|
||||
static constexpr const char* APP_NAME = "microreticulum";
|
||||
static constexpr const char* APP_ASPECT = "linkping";
|
||||
static constexpr const char* ANNOUNCE_FILTER = "microreticulum.linkping";
|
||||
|
|
@ -109,6 +121,19 @@ static PeerState peers[MAX_PEERS];
|
|||
static void on_link_packet(const RNS::Bytes& data, const RNS::Packet& packet);
|
||||
static void on_link_closed(RNS::Link& link);
|
||||
|
||||
static const char* node_label_for_slot(uint8_t slot) {
|
||||
switch (slot) {
|
||||
case 0: return "Amy";
|
||||
case 1: return "Bob";
|
||||
case 2: return "Cy";
|
||||
case 3: return "Dan";
|
||||
case 4: return "Ed";
|
||||
case 5: return "Fay";
|
||||
case 6: return "Guy";
|
||||
default: return "unknown";
|
||||
}
|
||||
}
|
||||
|
||||
static void IRAM_ATTR on_pps_edge() {
|
||||
last_pps_ms = millis();
|
||||
}
|
||||
|
|
@ -726,8 +751,13 @@ static void on_link_packet(const RNS::Bytes& data, const RNS::Packet& packet) {
|
|||
}
|
||||
float rssi = lora_impl ? lora_impl->last_rssi() : 0.0f;
|
||||
float snr = lora_impl ? lora_impl->last_snr() : 0.0f;
|
||||
Serial.printf("RX LINK: %s | RSSI=%.1f SNR=%.1f\r\n",
|
||||
text.c_str(), rssi, snr);
|
||||
uint8_t physical_tx = lora_impl ? lora_impl->last_physical_tx() : 255;
|
||||
Serial.printf("RX LINK: %s | phy=%s(%u) RSSI=%.1f SNR=%.1f\r\n",
|
||||
text.c_str(),
|
||||
node_label_for_slot(physical_tx),
|
||||
(unsigned)physical_tx,
|
||||
rssi,
|
||||
snr);
|
||||
show_status("RX LINK", peer.c_str(), text.c_str());
|
||||
}
|
||||
|
||||
|
|
@ -794,7 +824,11 @@ static void on_inbound_link_established(RNS::Link& link) {
|
|||
peers[peer_index].last_link_active_ms = millis();
|
||||
peers[peer_index].tx_since_link_open = 0;
|
||||
}
|
||||
Serial.printf("RX LINK: inbound link established hash=%s\r\n", link.hash().toHex().c_str());
|
||||
uint8_t physical_tx = lora_impl ? lora_impl->last_physical_tx() : 255;
|
||||
Serial.printf("RX LINK: inbound link established hash=%s phy=%s(%u)\r\n",
|
||||
link.hash().toHex().c_str(),
|
||||
node_label_for_slot(physical_tx),
|
||||
(unsigned)physical_tx);
|
||||
show_status("LINK ACTIVE", "inbound", link.hash().toHex().c_str());
|
||||
}
|
||||
|
||||
|
|
@ -829,8 +863,12 @@ class LinkAnnounceHandler : public RNS::AnnounceHandler {
|
|||
destination_hash);
|
||||
peers[peer_index].announced = true;
|
||||
|
||||
Serial.printf("RX ANNOUNCE: label=%s hash=%s\r\n",
|
||||
peers[peer_index].label.c_str(), peers[peer_index].destination_hash.toHex().c_str());
|
||||
uint8_t physical_tx = lora_impl ? lora_impl->last_physical_tx() : 255;
|
||||
Serial.printf("RX ANNOUNCE: label=%s hash=%s phy=%s(%u)\r\n",
|
||||
peers[peer_index].label.c_str(),
|
||||
peers[peer_index].destination_hash.toHex().c_str(),
|
||||
node_label_for_slot(physical_tx),
|
||||
(unsigned)physical_tx);
|
||||
show_status("RX ANNOUNCE", peers[peer_index].label.c_str(), peers[peer_index].destination_hash.toHex().c_str());
|
||||
}
|
||||
};
|
||||
|
|
@ -845,6 +883,11 @@ static void print_config() {
|
|||
Serial.printf("LoRa: freq=%.1f BW=%.1f SF=%d CR=%d sync=0x%02x txp=%d\r\n",
|
||||
(double)LORA_FREQ_MHZ, (double)LORA_BW_KHZ, (int)LORA_SF,
|
||||
(int)LORA_CR, (int)LORA_SYNC_WORD, (int)LORA_TX_POWER_DBM);
|
||||
Serial.printf("Sim: phy_envelope=%d phy_block_bob_cy=%d node_slot=%d rns_trace=%d\r\n",
|
||||
(int)SIM_PHY_ENVELOPE,
|
||||
(int)SIM_PHY_BLOCK_BOB_CY,
|
||||
(int)NODE_SLOT_INDEX,
|
||||
(int)EX204_RNS_TRACE);
|
||||
}
|
||||
|
||||
static void send_announce() {
|
||||
|
|
@ -998,7 +1041,11 @@ void setup() {
|
|||
|
||||
Serial.println();
|
||||
Serial.println("Exercise 204: established identities transport Link ping-pong");
|
||||
#if EX204_RNS_TRACE
|
||||
RNS::loglevel(RNS::LOG_TRACE);
|
||||
#else
|
||||
RNS::loglevel(RNS::LOG_NOTICE);
|
||||
#endif
|
||||
|
||||
(void)tbeam_supreme::initPmuForPeripherals(pmu, &Serial);
|
||||
tbeam::DisplayConfig display_config;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue