ronelib
Operating System for the r-one robot
 All Data Structures Files Functions Variables Typedefs
BroadcastComms.h File Reference

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...
 

Detailed Description

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.

Since
April 6, 2011
Author
Golnaz Habibi

Function Documentation

void broadcastMsgClear ( BroadcastMessage msgPtr)

Clears the broadcast message state.

Parameters
msgPtrpointer for broadcast message to clear
Returns
void
void broadcastMsgCreate ( BroadcastMessage msgPtr,
uint8  maxHops 
)

Creates a broadcast message.

Parameters
msgPtrpointer for broadcast message
maxHopsthe maximum number of hops that this message can propagate
Returns
void
uint8 broadcastMsgGetHops ( BroadcastMessage msgPtr)

Gets the number of message hops for the given broadcast message.

Parameters
msgPtrpointer for broadcast message
Returns
the number of message hops
uint8 broadcastMsgGetHopsNbr ( BroadcastMessage msgPtr,
Nbr *  nbrPtr 
)

Gets the number of message hops for the given neighbor.

Parameters
msgPtrpointer for broadcast message
nbrPtrneighbor
Returns
the number of message hops for the given neighbor
uint8 broadcastMsgGetSenderID ( BroadcastMessage msgPtr)

Gets the sender ID for the input message.

Parameters
msgPtrpointer for the message
Returns
sender ID for the input message
uint8 broadcastMsgGetSenderIDNbr ( BroadcastMessage msgPtr,
Nbr *  nbrPtr 
)
Parameters
msgPtr
nbrPtr
Returns
uint8 broadcastMsgGetSourceID ( BroadcastMessage msgPtr)

Gets the source ID of the input broadcast message.

Parameters
msgPtrpointer for the broadcast message
Returns
source ID
uint8 broadcastMsgGetSourceIDNbr ( BroadcastMessage msgPtr,
Nbr *  nbrPtr 
)

Gets the source ID of a neighbor.

Parameters
msgPtrpointer for the message
nbrPtrpointer for the neighbor
Returns
The source ID of a neighbor
uint8 broadcastMsgGetTimestamp ( BroadcastMessage msgPtr)

Gets the timestamp of the input message.

Parameters
msgPtrmessage
Returns
the timestamp of the message
uint8 broadcastMsgGetTimestampNbr ( BroadcastMessage msgPtr,
Nbr *  nbrPtr 
)

Gets the current timestamp of the neighbor.

Parameters
msgPtrpointer for the message
nbrPtrpointer for the neighbor
Returns
the timestamp of the neighbor
void broadcastMsgSetSource ( BroadcastMessage msgPtr,
boolean  val 
)

Sets the isSource property of the input message to val.

Parameters
msgPtrpointer to broadcast message
valsource value
Returns
void
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.

Parameters
msgPtrbroadcast message data structure
nbrListPtrthe list of neighbors whose messages to consider
Returns
void
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.

Parameters
msgPtrbroadcast message data structure
nbrListPtrthe list of neighbors whose messages to consider
Returns
void
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.

Parameters
msgPtrpointer for the broadcast message
nbrDataPtrpointer for the neighbor data to be updated
Returns
void
Nbr* nbrListFindSource ( NbrList *  nbrListPtr,
BroadcastMessage msgPtr 
)

Finds source of Message.

Parameters
nbrListPtrthe list of neighbors
msgPtrmessage to be sent
Returns
void
NbrList* nbrListGetChildren ( NbrList *  nbrListChildren,
NbrList *  nbrListIn,
BroadcastMessage msgPtr 
)
Parameters
nbrListChildren
nbrListIn
msgPtr
Returns
void
NbrList* nbrListGetParents ( NbrList *  nbrListParents,
NbrList *  nbrListIn,
BroadcastMessage msgPtr 
)

Puts the parents in nbrListIn into nbrListParents.

Parameters
nbrListParentsthe existing parents list
nbrListInthe list of neighbors
msgPtrthe broadcast message
Returns
void
NbrList* nbrListGetSiblings ( NbrList *  nbrListSiblings,
NbrList *  nbrListIn,
BroadcastMessage msgPtr 
)

Gets sibling.

Parameters
nbrListSiblings
nbrListIn
msgPtr
Returns
void
void nbrListPrintHops ( NbrList *  nbrListPtr,
BroadcastMessage broadcastMessagePtr,
char *  name 
)

Prints NbrID and the number of hops taken.

Parameters
nbrListPtr- list of neighbors to updatet
broadcastMessagePtr
nameof node
Returns
void