![]() |
ronelib
Operating System for the r-one robot
|
Multi-hop broadcast message communications library. More...
#include "roneos.h"
Go to the source code of this file.
Data Structures | |
struct | BroadcastMessage |
Message that is broadcast. More... | |
Typedefs | |
typedef struct BroadcastMessage | BroadcastMessage |
Message that is broadcast. | |
Functions | |
void | broadcastMsgCreate (BroadcastMessage *msgPtr, uint8 maxHops) |
Creates a broadcast message. More... | |
void | broadcastMsgClear (BroadcastMessage *msgPtr) |
Clears the broadcast message state. More... | |
void | broadcastMsgSetSource (BroadcastMessage *msgPtr, boolean val) |
Sets the isSource property of the input message to val. More... | |
void | broadcastMsgUpdate (BroadcastMessage *msgPtr, NbrList *nbrListPtr) |
Updates the broadcast messages of this robot. Does not elect a leader, will tessellate the network if there are multiple sources. More... | |
void | broadcastMsgUpdateLeaderElection (BroadcastMessage *msgPtr, NbrList *nbrListPtr) |
Updates the broadcast messages of this robot. Does not elect a leader, will not tessellate the network if there are multiple sources. More... | |
void | broadcastMsgUpdateNbrData (BroadcastMessage *msgPtr, NbrData *nbrDataPtr) |
Updates the neighbor data with the neighbor data from the sender of the broadcast message if the message is not the source. More... | |
uint8 | broadcastMsgGetHops (BroadcastMessage *msgPtr) |
Gets the number of message hops for the given broadcast message. More... | |
uint8 | broadcastMsgGetHopsNbr (BroadcastMessage *msgPtr, Nbr *nbrPtr) |
Gets the number of message hops for the given neighbor. More... | |
uint8 | broadcastMsgGetSourceID (BroadcastMessage *msgPtr) |
Gets the source ID of the input broadcast message. More... | |
uint8 | broadcastMsgGetSourceIDNbr (BroadcastMessage *msgPtr, Nbr *nbrPtr) |
Gets the source ID of a neighbor. More... | |
uint8 | broadcastMsgGetSenderID (BroadcastMessage *msgPtr) |
Gets the sender ID for the input message. More... | |
uint8 | broadcastMsgGetSenderIDNbr (BroadcastMessage *msgPtr, Nbr *nbrPtr) |
uint8 | broadcastMsgGetTimestampNbr (BroadcastMessage *msgPtr, Nbr *nbrPtr) |
Gets the current timestamp of the neighbor. More... | |
uint8 | broadcastMsgGetTimestamp (BroadcastMessage *msgPtr) |
Gets the timestamp of the input message. More... | |
void | nbrListPrintHops (NbrList *nbrListPtr, BroadcastMessage *broadcastMessagePtr, char *name) |
Prints NbrID and the number of hops taken. More... | |
NbrList * | nbrListGetParents (NbrList *nbrListParents, NbrList *nbrListIn, BroadcastMessage *msgPtr) |
Puts the parents in nbrListIn into nbrListParents. More... | |
NbrList * | nbrListGetSiblings (NbrList *nbrListSiblings, NbrList *nbrListIn, BroadcastMessage *msgPtr) |
Gets sibling. More... | |
NbrList * | nbrListGetChildren (NbrList *nbrListChildren, NbrList *nbrListIn, BroadcastMessage *msgPtr) |
Nbr * | nbrListFindSource (NbrList *nbrListPtr, BroadcastMessage *msgPtr) |
Finds source of Message. More... | |
Multi-hop broadcast message communications library.
Multi-hop broadcast messages are used to communicate over long distances in the system. After creation, the message is INACTIVE, and no data is transmitted. Once at least one robot becomes the source of a message by using the broadcastMsgSetSource() function. This robot will have a message hops of 0, and will source the data that will be transmitted throughout the network.
Call broadcastMsgUpdate() or broadcastMsgUpdateLeaderElection() each neighbor round to update the status of the broadcast message. In a normal broadcast message,broadcastMsgUpdate() will select the message from the neighbor in nbrList with the fewest number of hops, with a secondary sorting based on the [check this] robotID of the sending robot.
broadcastMsgUpdateLeaderElection() selects messages from neighbors first from the robot with the lowest source ID, then secondarily based on the hops from the source. This means that a message from a source with a lower ID will override a message from a source with a higher ID, ultimately reaching the entire network. In at most O(diam(G)) time, each robot will learn the ID of the source robot.
void broadcastMsgClear | ( | BroadcastMessage * | msgPtr) |
Clears the broadcast message state.
msgPtr | pointer for broadcast message to clear |
void broadcastMsgCreate | ( | BroadcastMessage * | msgPtr, |
uint8 | maxHops | ||
) |
Creates a broadcast message.
msgPtr | pointer for broadcast message |
maxHops | the maximum number of hops that this message can propagate |
uint8 broadcastMsgGetHops | ( | BroadcastMessage * | msgPtr) |
Gets the number of message hops for the given broadcast message.
msgPtr | pointer for broadcast message |
uint8 broadcastMsgGetHopsNbr | ( | BroadcastMessage * | msgPtr, |
Nbr * | nbrPtr | ||
) |
Gets the number of message hops for the given neighbor.
msgPtr | pointer for broadcast message |
nbrPtr | neighbor |
uint8 broadcastMsgGetSenderID | ( | BroadcastMessage * | msgPtr) |
Gets the sender ID for the input message.
msgPtr | pointer for the message |
uint8 broadcastMsgGetSenderIDNbr | ( | BroadcastMessage * | msgPtr, |
Nbr * | nbrPtr | ||
) |
msgPtr | |
nbrPtr |
uint8 broadcastMsgGetSourceID | ( | BroadcastMessage * | msgPtr) |
Gets the source ID of the input broadcast message.
msgPtr | pointer for the broadcast message |
uint8 broadcastMsgGetSourceIDNbr | ( | BroadcastMessage * | msgPtr, |
Nbr * | nbrPtr | ||
) |
Gets the source ID of a neighbor.
msgPtr | pointer for the message |
nbrPtr | pointer for the neighbor |
uint8 broadcastMsgGetTimestamp | ( | BroadcastMessage * | msgPtr) |
Gets the timestamp of the input message.
msgPtr | message |
uint8 broadcastMsgGetTimestampNbr | ( | BroadcastMessage * | msgPtr, |
Nbr * | nbrPtr | ||
) |
Gets the current timestamp of the neighbor.
msgPtr | pointer for the message |
nbrPtr | pointer for the neighbor |
void broadcastMsgSetSource | ( | BroadcastMessage * | msgPtr, |
boolean | val | ||
) |
Sets the isSource property of the input message to val.
msgPtr | pointer to broadcast message |
val | source value |
void broadcastMsgUpdate | ( | BroadcastMessage * | msgPtr, |
NbrList * | nbrListPtr | ||
) |
Updates the broadcast messages of this robot. Does not elect a leader, will tessellate the network if there are multiple sources.
msgPtr | broadcast message data structure |
nbrListPtr | the list of neighbors whose messages to consider |
void broadcastMsgUpdateLeaderElection | ( | BroadcastMessage * | msgPtr, |
NbrList * | nbrListPtr | ||
) |
Updates the broadcast messages of this robot. Does not elect a leader, will not tessellate the network if there are multiple sources.
msgPtr | broadcast message data structure |
nbrListPtr | the list of neighbors whose messages to consider |
void broadcastMsgUpdateNbrData | ( | BroadcastMessage * | msgPtr, |
NbrData * | nbrDataPtr | ||
) |
Updates the neighbor data with the neighbor data from the sender of the broadcast message if the message is not the source.
msgPtr | pointer for the broadcast message |
nbrDataPtr | pointer for the neighbor data to be updated |
Nbr* nbrListFindSource | ( | NbrList * | nbrListPtr, |
BroadcastMessage * | msgPtr | ||
) |
Finds source of Message.
nbrListPtr | the list of neighbors |
msgPtr | message to be sent |
NbrList* nbrListGetChildren | ( | NbrList * | nbrListChildren, |
NbrList * | nbrListIn, | ||
BroadcastMessage * | msgPtr | ||
) |
nbrListChildren | |
nbrListIn | |
msgPtr |
NbrList* nbrListGetParents | ( | NbrList * | nbrListParents, |
NbrList * | nbrListIn, | ||
BroadcastMessage * | msgPtr | ||
) |
Puts the parents in nbrListIn into nbrListParents.
nbrListParents | the existing parents list |
nbrListIn | the list of neighbors |
msgPtr | the broadcast message |
NbrList* nbrListGetSiblings | ( | NbrList * | nbrListSiblings, |
NbrList * | nbrListIn, | ||
BroadcastMessage * | msgPtr | ||
) |
Gets sibling.
nbrListSiblings | |
nbrListIn | |
msgPtr |
void nbrListPrintHops | ( | NbrList * | nbrListPtr, |
BroadcastMessage * | broadcastMessagePtr, | ||
char * | name | ||
) |
Prints NbrID and the number of hops taken.
nbrListPtr | - list of neighbors to updatet |
broadcastMessagePtr | |
name | of node |