I was learning how to do a P2P for my game and came up with something for Wakan....
The stations find paths to the stations that they can hear in ReturnFlows.
That keep track of all stations that they are in ReturnFlows with.
The information that stations keep track of about other stations is what stations those stations can hear.
Each station send a Heartbeat with a list of stations it can hear and stations looking for a ReturnFlow.
Each station tries to find a ReturnFlow to the stations it hears with a RFLooking message.
When a station hears a RFLooking message for itself it broadcasts a RFChain message with the found ReturnFlow.
The station in the ReturnFlow reboadcast the RFChain message and update their routing tables
If I know another station that <B> can hear will send the information I don't have too.
- If station I know, <B>, can receive the information I information I don't have to send it?
- Calculate the flow out form the <END>?
when (station_A hears a Heartbeat message from station_B) { if (station_A doesn't have a ReturnFlow to station_B) then { station_A broadcasts the message RFlooking(END:station_B, PATH:[station_A]) } }
when (station_A receives a RFLooking and (RFLooking["END"] == station_A)) then { station_A broadcasts RFChain(CHAIN:[...RFLooking["PATH"], station_A]) }
If (station_A recieves a RFLooking from station_B) then { if RelayKa(station_A, station_B, RFLooking["END"])then { add station_A to the end of RFLooking["PATH"] broadcast the modified RFLooking } }
If (station_A hears a RFChain from station_B then { if (RFChain isn't in station_A["recent_message_list"]) if (station_A in RFChain["CHAIN"]) then { add RFChain["CHAIN"] to station_A's routing_table rebroadcast the RFChain var downstream = [] var upsteam =[] for node in RFChain["CHAIN"] { if RelayKa(station_A, station_B, node){ downsteam.append(node) else { upsteam.append(node) } } var routes = {} for station_X in upstream { routes[station_x]["can_hear"] = station_A['routing_table'][station_x]["can_hear"] } broadcast Hearsay(ROUTES: routes) } } } when (you receive a Hearsay or a Heartbeat message) then { compare the reported can_hear's to your current routing_table and keep track of the added or removed links. var routes = {} for changed link from station_A to station_B { if (you are in the shortest path from station_B to station_A in your routing_table) then { routes[station_A]["can_hear"] =Hearsay[station_A]["can_hear"] routes[station_B]["can_hear"] =Hearsay[station_B]["can_hear"] } } broadcast Hearsay(ROUTES: routes) }
Functions
func RelayKa(station_R, station_A, station_B) { If (I don't know of a shorter route from station_A to station_B than the route that goes thru station_R. then { return (True) else { return (False) } }
Glossary
'ReturnFlow': The quince of hops needed for a message to get from station <A> to some station <B> which station <A> can hear.
'RFLooking': Has two parameters: END, The station we are looking for a ReturnFlow to, and PATH, a list of stations this message has past thru. Can assume that the last station on the list is the broadcaster(or that the broadcaster is the last station on the list?)
'broadcast': an undirected transmission of a message to unknown recipients.
'hear': the reception of a broadcast
'send': transmission of a message to specific recipient.
Discussions
Become a Hackaday.io Member
Create an account to leave a comment. Already have an account? Log In.