From e522e47544f446760ea55ab5b200d6bf0bb9b9b9 Mon Sep 17 00:00:00 2001 From: geeksville Date: Wed, 3 Jun 2020 12:49:36 -0700 Subject: [PATCH] Full DSR WIP --- docs/software/mesh-alg.md | 1 + src/mesh/DSRRouter.cpp | 93 +++++++++++++++++++++++++++++++++++++++ src/mesh/DSRRouter.h | 6 +++ 3 files changed, 100 insertions(+) diff --git a/docs/software/mesh-alg.md b/docs/software/mesh-alg.md index dc4203aba..7d7837be9 100644 --- a/docs/software/mesh-alg.md +++ b/docs/software/mesh-alg.md @@ -30,6 +30,7 @@ dsr tasks optimizations / low priority: +- read @cyclomies long email with good ideas on optimizations and reply - low priority: think more careful about reliable retransmit intervals - make ReliableRouter.pending threadsafe - bump up PacketPool size for all the new ack/nak/routing packets diff --git a/src/mesh/DSRRouter.cpp b/src/mesh/DSRRouter.cpp index 7d788441e..f1ec32e32 100644 --- a/src/mesh/DSRRouter.cpp +++ b/src/mesh/DSRRouter.cpp @@ -56,6 +56,8 @@ ErrorCode DSRRouter::send(MeshPacket *p) // start discovery, but only if we don't already a discovery in progress for that node number startDiscovery(p->decoded.dest); } + + return ERRNO_OK; } else return ReliableRouter::send(p); } @@ -149,4 +151,95 @@ void DSRRouter::sniffReceived(const MeshPacket *p) } return ReliableRouter::sniffReceived(p); +} + +/** + * Does our node appear in the specified route + */ +bool DSRRouter::weAreInRoute(const RouteDiscovery &route) +{ + return true; // FIXME +} + +/** + * Given a DSR route, use that route to update our DB of possible routes + * + * Note: routes are always listed in the same order - from sender to receipient (i.e. route_replies also use this some order) + * + * @param isRequest is true if we are looking at a route request, else we are looking at a reply + **/ +void DSRRouter::updateRoutes(const RouteDiscovery &route, bool isRequest) +{ + DEBUG_MSG("FIXME not implemented"); +} + +/** + * send back a route reply (the sender address will be first in the list) + */ +void DSRRouter::sendRouteReply(const RouteDiscovery &route, NodeNum toAppend) +{ + DEBUG_MSG("FIXME not implemented"); +} + +/** + * Given a nodenum return the next node we should forward to if we want to reach that node. + * + * @return 0 if no route found + */ +NodeNum DSRRouter::getNextHop(NodeNum dest) +{ + DEBUG_MSG("FIXME not implemented"); + return 0; +} + +/** Not in our route cache, rebroadcast on their behalf (after adding ourselves to the request route) + * + * We will bump down hop_limit in this call. + */ +void DSRRouter::resendRouteRequest(const MeshPacket *p) +{ + DEBUG_MSG("FIXME not implemented"); +} + +/** + * Record that forwarder can reach dest for us, but they will need numHops to get there. + * If our routing tables already have something that can reach that node in fewer hops we will keep the existing route + * instead. + */ +void DSRRouter::addRoute(NodeNum dest, NodeNum forwarder, uint8_t numHops) +{ + DEBUG_MSG("FIXME not implemented"); +} + +/** + * Record that we no longer have a route to the dest + */ +void DSRRouter::removeRoute(NodeNum dest) +{ + DEBUG_MSG("FIXME not implemented"); +} + +/** + * Forward the specified packet to the specified node + */ +void DSRRouter::sendNextHop(NodeNum n, const MeshPacket *p) +{ + DEBUG_MSG("FIXME not implemented"); +} + +/** + * Send a route error packet towards whoever originally sent this message + */ +void DSRRouter::sendRouteError(const MeshPacket *p, RouteError err) +{ + DEBUG_MSG("FIXME not implemented"); +} + +/** make a copy of p, start discovery, but only if we don't + * already a discovery in progress for that node number. Caller has already scheduled this message for retransmission + * when the discovery is complete. + */ +void DSRRouter::startDiscovery(NodeNum dest) +{ + DEBUG_MSG("FIXME not implemented"); } \ No newline at end of file diff --git a/src/mesh/DSRRouter.h b/src/mesh/DSRRouter.h index 904f99980..3bc461571 100644 --- a/src/mesh/DSRRouter.h +++ b/src/mesh/DSRRouter.h @@ -71,4 +71,10 @@ class DSRRouter : public ReliableRouter * Send a route error packet towards whoever originally sent this message */ void sendRouteError(const MeshPacket *p, RouteError err); + + /** make a copy of p, start discovery, but only if we don't + * already a discovery in progress for that node number. Caller has already scheduled this message for retransmission + * when the discovery is complete. + */ + void startDiscovery(NodeNum dest); }; \ No newline at end of file