Download presentation
Presentation is loading. Please wait.
Published byRadek Toman Modified over 5 years ago
1
I am A I have heard: no one A B Have heard list Have heard list
2
I am A I have heard: no one A B Have heard list Have heard list A
3
I am B I have heard: A A B Have heard list Have heard list A
4
A B A I am B I have heard: A Have heard list Have heard list
B and B hears me A
5
A B A I am A I have heard: B Have heard list Have heard list
B and B hears me A
6
A B I am A I have heard: B, C, D Have heard list Have heard list
B and B hears me A and A hears me
7
List unidirectionalNeighbors bidirectionalNeighbors
A neighbor can be in at most one list (we could allow a neighbor to be in both, but let’s not do it that way)
8
A B What is in the hello message? - The source of the message I am A
I have heard: no one A B Have heard list Have heard list Unidirectional Neighbors Bidirectional Neighbors Unidirectional Neighbors Bidirectional Neighbors
9
A B A A What is in the hello message? The source of the message I am A
I have heard: no one A B Have heard list Have heard list A Unidirectional Neighbors Bidirectional Neighbors Unidirectional Neighbors Bidirectional Neighbors A
10
A B A A What is in the hello message? The source of the message
Any element in the unidirectional neighbors list I am B I have heard: A A B Have heard list Have heard list A Unidirectional Neighbors Bidirectional Neighbors Unidirectional Neighbors Bidirectional Neighbors A
11
A B A B A What is in the hello message? The source of the message
Any element in the unidirectional neighbors list I am B I have heard: A A B Have heard list Have heard list B and B hears me A Unidirectional Neighbors Bidirectional Neighbors Unidirectional Neighbors Bidirectional Neighbors B A
12
A B A B A What is in the hello message? The source of the message
Any element in the unidirectional neighbors list Any element in the bidirectional neighbors list I am A I have heard: B A B Have heard list Have heard list B and B hears me A Unidirectional Neighbors Bidirectional Neighbors Unidirectional Neighbors Bidirectional Neighbors B A
13
A B A B A What is in the hello message? The source of the message
Any element in the unidirectional neighbors list Any element in the bidirectional neighbors list HelloMessage helloMessage; helloMessage.source = thisHost; for (NeighborInfo &neighbor : bidirectionalNeighbors) { helloMessage. addToNeighborsList(neighbor); } for (NeighborInfo &neighbor : unidirectionalNeighbors) I am A I have heard: B A B Have heard list Have heard list B and B hears me A Unidirectional Neighbors Bidirectional Neighbors Unidirectional Neighbors Bidirectional Neighbors B A
14
Sending a hello message
HelloMessage helloMessage; // fill in hello message Packet pkt; pkt.getPacketReadyForWriting(); helloMessage.addToPacket(pkt); udpSocket.sendTo(pkt, destination); What should the destination be? Send the hello message to every neighbor HelloMessage helloMessage; // TODO: fill hello message // make pkt for (NeighborInfo &neighbor : bidirectionalNeighbors) { udpSocket.sendTo(pkt, neighbor); } for (NeighborInfo &neighbor : unidirectionalNeighbors) Pick a new neighbor at random, and send a hello to them What if you have no neighbors? What if you don’t have enough neighbors? NeighborInfo temp = selectNeighbor(bidirectionalNeighbors, unidirectionalNeighbors, allHosts, thisHost); udpSocket.sendTo(pkt, temp);
15
Sending a hello message
HelloMessage helloMessage; // fill in hello message Packet pkt; pkt.getPacketReadyForWriting(); helloMessage.addToPacket(pkt); udpSocket.sendTo(pkt, destination); What should the destination be? Send the hello message to every neighbor HelloMessage helloMessage; // TODO: fill hello message // make pkt for (NeighborInfo &neighbor : bidirectionalNeighbors) { udpSocket.sendTo(pkt, neighbor); } for (NeighborInfo &neighbor : unidirectionalNeighbors) Pick a new neighbor at random, and send a hello to them What if you have no neighbors? What if you don’t have enough neighbors? If (bidirectionalNeighbors.size() + unidirectionalNeighbors.size() < TARGET_NUMBER_OF_NEIGHBORS) { NeighborInfo temp = selectNeighbor(bidirectionalNeighbors, unidirectionalNeighbors, allHosts, thisHost); udpSocket.sendTo(pkt, temp); }
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.