índice de refracción.
D) Mecanismos de cambio del índice de refracción
Each node maintains a set of nodes called Neighbours containing all of a node’s neighbours. When first connecting to a node in the network, this set is empty on a new node. Therefore, the new node sends out an empty NetworkView containing only its own address. Upon receiving a NetworkView, a node calculates its local Delaunay graph including the nodes in the NetworkView. Then it notices whether it is missing a neighbour it needs to add. Every new neighbour it is already connected to is added as a neighbour directly. This might be the case if nodes are connected after bootstrapping or because one is in the routing table of the other.
If a node adds a neighbour, it has to inform its neighbours about its new neighbour- hood by sending them a NetworkView. Furthermore, adding a neighbour means an existing neighbour might be removed from the neighbourhood and become an ex- neighbour. All ex-neighbours will also receive a NetworkView before disconnecting them so they know the reason for the disconnection. For example if the new node
c lies in the middle between two neighbours a, b and c sends a NetworkView to a, a will add c as neighbour and remove b. By sending a NetworkView including c to b before disconnecting, b knows that c is there and needs to become its neighbour,
see figure 4.7.
NetworkViews are never routed over multiple hops but only exchanged directly be- tween connected nodes. Since the channel uses FIFO order, it is guaranteed a receiving node always acts on the most current state reported by other nodes. It will also always receive that state. Once a NetworkView is sent is will be trans- ferred reliably. Only node fail can prevent this. However, when a node fails new NetworkViews with updated information will be exchanged anyway.
60 Chapter 4 A Self-Stabilizing Delaunay Overlay O n N e t w o r k V i e w ( N e t w o r k V i e w nv ) { n o d e s = { L o c a l N o d e } ∪ Neighbours ∪ PendingNeighbours D e l a u n a y G r a p h dg = C a l c u l a t e D e l a u n a y G r a p h ( n o d e s ∪ nv) // add or c o n n e c t new n e i g h b o u r s
foreach ( Node neighbour in dg. GetNeighbours ( LocalNode )\Neighbours ) if( IsConnected ( neighbour ))
A d d N e i g h b o u r ( n e i g h b o u r ) else C o n n e c t N e i g h b o u r ( n e i g h b o u r ) // r e m o v e p e n d i n g n e i g h b o u r s t h a t are no l o n g e r our n e i g h b o u r s e x P e n d i n g N e i g h b o u r s = P e n d i n g N e i g h b o u r s\dg. GetNeighbours ( LocalNode ) P e n d i n g N e i g h b o u r s . R e m o v e A l l ( e x P e n d i n g N e i g h b o u r s )
// send back a N e t w o r k V i e w if n e i g h b o u r h o o d v i e w s are d i f f e r e n t
if(dg. GetNeighbours (nv. Source ) = nv. Neighbours )
Q u e u e N e t w o r k V i e w s ({ nv . S o u r c e }) } A d d N e i g h b o u r ( Node n e i g h b o u r ) { N e i g h b o u r s . Add ( n e i g h b o u r ) D e l a u n a y G r a p h dg = C a l c u l a t e D e l a u n a y G r a p h ({ L o c a l N o d e } ∪ Neighbours ) e x N e i g h b o u r s = N e i g h b o u r s\dg. GetNeighbours ( LocalNode ) N e i g h b o r s . R e m o v e A l l ( e x N e i g h b o r s ) Q u e u e N e t w o r k V i e w s ( N e i g h b o u r s ∪ exNeighbours ) } C o n n e c t N e i g h b o u r ( Node n e i g h b o u r ) { P e n d i n g N e i g h b o u r s . Add ( n e i g h b o u r ) B e g i n C o n n e c t ( n e i g h b o u r ) }
4.3 Delaunay Structure Maintenance 61
O n C o n n e c t i o n O p e n e d ( Node node ) {
if( node ∈ PendingNeighbours )
{ P e n d i n g N e i g h b o u r s . R e m o v e ( node ) A d d N e i g h b o u r ( node ) } } O n C o n n e c t i o n C l o s e d ( Node node ) {
if( node ∈ PendingNeighbours )
P e n d i n g N e i g h b o u r s . R e m o v e ( node )
if( node ∈ Neighbours )
{
N e i g h b o u r s . R e m o v e ( n o d e )
Q u e u e N e t w o r k V i e w s ( N e i g h b o u r s ) }
}
Listing 4.2: Connection state change