RFC: Geohash Routing for MeshCore #3320
ttadegraaff
started this conversation in
Ideas
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
RFC: Geohash Path Discovery Optimization for MeshCore
1. Summary
This RFC proposes an optional extension to MeshCore that allows repeaters to learn and reuse successful path information to geographic areas using geohash-defined regions.
The goal is to reduce flooding for path discovery while maintaining multiple alternative routes for geographic areas.
The idea is that when one path to a specific area is learned, path discovery messages from other companions directed to that area can use this information instead of triggering a flood discovery. When a message reaches the destination area, hop limited flooding is used to learn the last bit of the path. This has the potential to reduce the discovery load on connections between distinct geographic areas.
How it works
When a companion want to send a text message to a contact that has a geohash but no known path, it first sends a geohash discovery message. Hop limited local flooding is used to send the message. When a repeater receives such a message and has one or more designated neighbour id's for the geohash in it's routing table, the local scope is removed only these repeaters will forward the message. The message now travels via one or more known paths through the mesh using geohash routing information from earlier discoveries until it reaches the destination area. At the destination area the scope local is set, and hop limited local flooding is used to reach the end destination.
For example a geohash discovery message that goes from companion A to companion F in geohash area u15aa. Repeater B, C and D have geohash information for a15aa in their routing table and repeater E is located in the geohash area of the endpoint.
The destination companion now responds with a geohash discovery returned path message. This response contains the successful path and is returned in the exact same way using geohash routing as the geohash path discovery message.
For example geohash path discovery response from companion F to companion A.
When the geohash path discovery response arrives at the original sender, a known path is added to the contact information of the destination companion. Then the text message is send using the known path as meshcore would normally.
When no geohash path discovery arrives at the original sender, a second geohash discovery is sent with a bigger local flooding hop limit. If that also fails a normal message is sent, triggering normal flood discovery without geohash.
When the normal text message is sent successfully a geohash route advert is sent to the destination using the learned path. This advert contains the geohash of the destination and the return path. While this advert travels along the path the repeaters update their geohash routing table using the path and the geohash.
For example a geohash route advert containing the geohash of F and the now confirmed return path for F to A traveling from A to F.
When the advert reaches the destination, the destination adds the now confirmed return path to the sender contact.
Discovery order
2. Current MeshCore compared with this proposal
Consider two people who have never communicated before.
With current MeshCore, a message path needs to be discovered through flooding. If a returned path message is received, the sender learned a succesfull path to the destination. A message to another person in the same area, or to the same person by a different sender, requires another flood discovery.
With this proposal, repeaters store designated neighbour information based on the destination's geohash.
For example, a first successful message from Person A to Person E in geohash area u15aa triggers a geohash route advert from Person A to person E:
This cuases repeater B to learn valid neighbour C for geohash u15aa:
And repeater C to learn:
When repeater B receives a geohash discovery message for another companion in geohash u15aa it will flow via C and D instead of flooding.
When repeater C receives a geohash discovery message from another repeater then B, it also flows via known route D.
3. Geohash usage
A geohash defines a square area where the size depends on the number of geohash characters.
Companions and repeaters only set a 5 character geohash.
4. Geohash Routing Table
When a geohash route advert passes through the mesh network, the repeaters being passed store or update information of the form:
Last confirmed time: epoch time in hours
Hotness: usage count with decay
Mechanism:
5. Limited Memory Usage
The routing table is stored in memory. For this reason the size of the routing table is restricted to a max table size.
Mechanism:
This way geohash routes that are used a lot are kept.
Using Dutch land-use data:
That gives about 280 densely populated geohashes.
Asuming a average geohash route has 1.5 designated repeaters then the memory usage for an average geohash is 1.5 x 11 = 16.5 bytes. For the Netherlands this would mean that routes for all densely populated areas would consume about 16.5 x 280 = 4.6Kb of memory.
5. Geohash Route Recovery
If a geohash route is broken in the middle, hop limited local flooding is triggered where the route ends. If within this local scope a geohash repeater with a geohash route for the destination is found, this path is picked up from there and as such a new path is formed. The broken geohash path will be automatically removed after some time because of route decay and max age.
If this fails a second attempt of geohash route discovery is triggered with increased_hop_limit flagged resulting in a higher hop limit increasing recovery chance.
If that too fails, a normal flood text message discovery is triggered to find a new route.
Consider a message from A to G at geohash u15aa.
The route breaks at C. The repeater at C has no designated neighbours for u15aa and triggers local discovery. Repeater H receives the geohash discovery message and has a route to I for u15aa.
Now a new geohash route from A to G will be added in the mesh.
6. Hierarchical Matching
When a destination is further away then a minimal coarse routing distance from a repeater, then the lookup of routes may be done by matching the first four characters of the geohash.
This way a discovery can use coarse geohash route information from a destination that is close to the message destination if no exact geohash route match is found.
Example
A repeater knows:
For a destination
u15a1that is not found in the table, the repeater may forward to A, D and E if the distance of the repeater to a15a is bigger then the minimal the minimal coarse routing distance.7. Companions Without Geohashes
Geohash advertisement is optional.
A companion without a geohash remains reachable through the existing MeshCore routing mechanisms.
Geohash routing is therefore an optimization rather than a requirement for communication.
8. Privacy
A companion and router can only set a geohash of 5 characters, this represents an area of about 5x5 km which in most cases is not specific enough to find the location.
A companion can also choose not to advertise a geohash.
9. Backward Compatibility
Nodes that do not support geohash routing continue to use existing discovery through flooding.
Geohash-aware fixed location repeaters provide an additional routing mechanism and can coexist with existing MeshCore nodes.
10. Implementation
Three new geohash messages are introduced:
Two new control types are introduced.
Messages
Geohash discovery message
Payload fields:
tagflagsdestination_hashdestination_geohashdesignated_repeatershop_limitsource_geohash(optional)Geohash discovery returned path
Geohash route advert
Repeater decision making
How does a repeater decide to forward a geohash discovery message or a geohash discovery return path or not?
A geohash message is initialized with a
destination_geohashandhop_limitinitialized toLOCAL_DISCOVERY_HOPSorINCREASED_LOCAL_DISCOVERY_HOPSdepending on messageincreased_hop_limitflag.All reactions