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
Three new message types are introduced:
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 and only these designated 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 a successful path is discovered using geohash routing then a normal text message is sent. When that message is acknowledged a successful path has been learned, and the user can continue sending messages using this path.
When the route advert interval time has passed, and after sending a text message to the destination the user receives a acknowledge received message, then 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
Repeaters have a geohash routing table that stores geohash routing information.
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:
route_advert_intervalhours a companion sends a geohash route advert after a successful text message to a companion containing a destinationgeohashvalue and themessages_since_last_advertcount.last_confirmed_timeis updated and thehotnessis increased with the number of messages that were send since the last advert.hotness_decay_intervalhours the hotness score is multiplied by thehotness_decay_factor.5. Limited Memory Usage
The routing table is stored in memory. For this reason the size of the routing table is restricted to the
max_route_table_size.Mechanism:
last_confirmed_timeexceeds theroute_expiration_time.max_routes_per_geohashroutes already exist, the route with the lowesthotnessis replaced.max_route_table_size, remove the existing entry with lowesthotnessfirst.This way geohash routes that are used a lot survive while little used routes perish.
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.
6. 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_limitflagged 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.
7. Hierarchical Matching
There will not always be a exact match for the geohash in the table.
For example
A repeater knows:
A message with geohash
u15a1is will not find a exact geohash match.But there is a destination area that is really close to the destination area:
u15aa. If the message is still far away from the endpoint, then using the path fromu15aawould a very good guess to get closer.Both
u15a1andu15aaare subareas ofu15a.To make it possible to use routing information from a geohash area near the destination area we allow the lookup of a partial geohash match of 4 or even 3 characters in the routing table when there is a minimal distance between repeater and destination 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.
The two coarse routing distances for geohash size 3 and 4 are stored in protocol constants.
COARSE_ROUTING_DISTANCE_GEOHASH_LENGTH_4COARSE_ROUTING_DISTANCE_GEOHASH_LENGTH_3Destination
u15a1is not found in the table. If this destination is more then 100 km away from the repeater, then the repeater will lookupu15a. This will make it forward to A and B.Destination
u15b1is not found in the table. if the destination is more then 100 km away, then the repeater will lookupu15b. No result found. If the destination is more then 600km away then it will look foru15and find A, B and C to forward to.8. 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.
9. Privacy
Setting geohash is optional for a companion and router.
The geohash size is 5 characters. This represents an area of about 5x5 km which in most cases is not specific enough to find the location.
10. 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.
11. Implementation
Messages
Three new geohash messages are introduced:
Two new control types are introduced.
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.Companion decision making
Sending a text message
Receiving a message received acknowledgement from destination
Protocol constants, Configuration parameters and variables
The following parameters control geohash routing behaviour.
In the future some configurable options may become protocol constants when sane values have been found.
Protocol constants:
GEOHASH_LENGTHLOCAL_DISCOVERY_HOPSINCREASED_LOCAL_DISCOVERY_HOPSCOARSE_ROUTING_DISTANCE_GEOHASH_LENGTH_4COARSE_ROUTING_DISTANCE_GEOHASH_LENGTH_3INITIAL_HOTNESS_SCOREMINIMAL_ROUTE_ADVERT_INTERVALRepeater configuration:
route_expiration_timehotness_decay_factorhotness_decay_intervalmax_routes_per_geohashmax_route_table_sizegeohashCompanion configuration:
route_advert_intervalgeohashCompanion state:
contact.route_advert_timecontact.messages_since_last_advertcontact.geohashcontact.out_pathRepeater state:
12. Scheme
All reactions