In peertopeer networks such as gnutella each host

  • Slides: 28
Download presentation
In peer-to-peer networks such as gnutella, each host must search out other hosts. When

In peer-to-peer networks such as gnutella, each host must search out other hosts. When a host finds another host, these hosts become neighbors. Often a host will continue to search for peers until a sufficient number of hosts have been found. Lets assume that a host will continue to search for hosts until it has N neighbors. In this project, peer-to-peer neighborhoods are made and maintained. Each host maintains list of neighbors and sends hello packets to these neighbors every 10 seconds. If a host is on the neighbor list, and no hello packet is received from the host for 40 seconds, then this host is removed from the neighbor list. If a node does not have enough neighbors, then it selects an address (e. g. , IP and port) at random and tries to become its neighbor.

Objectives • Find N neighbors – A node is a neighbor if two-way communication

Objectives • Find N neighbors – A node is a neighbor if two-way communication is possible and verified • Two-communication == bidirectional link • Maintain N neighbors – If two-way communication is no longer verified, the node is no longer a neighbor

Detecting Bidirectional Links • Node A has a bidirectional with node B if –

Detecting Bidirectional Links • Node A has a bidirectional with node B if – Node A can hear node B – Node B can hear node A • To determine if a link between node A and B is bidirectional – Node A sends a message to node B – Node B sends a message to node A saying that it can hear node A • Now node A believes the link is bidirectional – Node A sends a message to node B saying that it can hear node B • Now node B believes the link is bidirectional • In general, to determine is links are bidirectional – Send hello messages where the message includes a list of all nodes that have been heard – Upon receiving a hello message, • If you are listed as one of the nodes that has been recently heard, then the link is bidirectional • Add the sender of the hello to the list of nodes that you can hear

I am A I have heard: no one A B Have heard list

I am A I have heard: no one A B Have heard list

I am A I have heard: no one A B Have heard list A

I am A I have heard: no one A B Have heard list A

I am B I have heard: A A B Have heard list A

I am B I have heard: A A B Have heard list A

I am B I have heard: A A Have heard list B and B

I am B I have heard: A A Have heard list B and B hears me B Have heard list A

I am A I have heard: B A Have heard list B and B

I am A I have heard: B A Have heard list B and B hears me B Have heard list A

I am A I have heard: B, C, D A Have heard list B

I am A I have heard: B, C, D A Have heard list B and B hears me B Have heard list A and A hears me

List • unidirectional. Neighbors • bidirectional. Neighbors • A neighbor can be in at

List • unidirectional. Neighbors • bidirectional. Neighbors • 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)

I am A I have heard: no one A B Have heard list Unidirectional

I am A I have heard: no one A B Have heard list Unidirectional Neighbors Bidirectional Neighbors

I am A I have heard: no one A B Have heard list A

I am A I have heard: no one A B Have heard list A Unidirectional Neighbors Bidirectional Neighbors Unidirectional Neighbors A Bidirectional Neighbors

I am B I have heard: A A B Have heard list A Unidirectional

I am B I have heard: A A B Have heard list A Unidirectional Neighbors Bidirectional Neighbors Unidirectional Neighbors A Bidirectional Neighbors

I am B I have heard: A A B Have heard list B and

I am B I have heard: A A B Have heard list B and B hears me Unidirectional Neighbors Have heard list A Bidirectional Neighbors B Unidirectional Neighbors A Bidirectional Neighbors

I am A I have heard: B A B Have heard list B and

I am A I have heard: B A B Have heard list B and B hears me Unidirectional Neighbors Have heard list A Bidirectional Neighbors B Unidirectional Neighbors A Bidirectional Neighbors

I am A I have heard: B, C, D A B Have heard list

I am A I have heard: B, C, D A B Have heard list B and B hears me Unidirectional Neighbors Have heard list A and A hears me Bidirectional Neighbors B Unidirectional Neighbors A Bidirectional Neighbors

Let’s try to make pseudo code

Let’s try to make pseudo code

I am A I have heard: no one A B Have heard list Unidirectional

I am A I have heard: no one A B Have heard list Unidirectional Neighbors Bidirectional Neighbors

 • Received message from A • if this. Host is in the hello.

• Received message from A • if this. Host is in the hello. Message’s list of neighbors • is. Bidirectional = True • else • is. Bidirectional = False • • Add A to list of unidirectional neighbors Q: Why did we add A to the list of unidirectional neighbors and not the list of bidirectional neighbors? A: Because A has not heard any messages from B A: The hello message from A did not include B I am A I have heard: no one A B Have heard list A Unidirectional Neighbors Bidirectional Neighbors Unidirectional Neighbors A Bidirectional Neighbors

 • Received message from A • if this. Host is in the hello.

• Received message from A • if this. Host is in the hello. Message’s list of neighbors • is. Bidirectional = True • else • is. Bidirectional = False • if (is. Bidirectional == False) • Add A to list of unidirectional neighbors Q: Why did we add A to the list of unidirectional neighbors and not the list of bidirectional neighbors? A: Because A has not heard any messages from B A: The hello message from A did not include B I am A I have heard: no one A B Have heard list A Unidirectional Neighbors Bidirectional Neighbors Unidirectional Neighbors A A Bidirectional Neighbors

 • Received message from A • if this. Host is in the hello.

• Received message from A • if this. Host is in the hello. Message’s list of neighbors • is. Bidirectional = True • else • is. Bidirectional = False • if (is. Bidirectional == False) • Add A to list of unidirectional neighbors, if not already in that list Q: Why did we add A to the list of unidirectional neighbors and not the list of bidirectional neighbors? A: Because A has not heard any messages from B A: The hello message from A did not include B I am A I have heard: no one A B Have heard list A Unidirectional Neighbors Bidirectional Neighbors Unidirectional Neighbors A Bidirectional Neighbors

 • Received message from A • if this. Host is in the hello.

• Received message from A • if this. Host is in the hello. Message’s list of neighbors • is. Bidirectional = True • else • is. Bidirectional = False • if (is. Bidirectional == False) • Add source of hello message to list of unidirectional neighbors, if not already in that list Q: Why did we add A to the list of unidirectional neighbors and not the list of bidirectional neighbors? A: Because A has not heard any messages from B A: The hello message from A did not include B I am A I have heard: no one A B Have heard list A Unidirectional Neighbors Bidirectional Neighbors Unidirectional Neighbors A Bidirectional Neighbors

 • Received message from A • if this. Host is in the hello.

• Received message from A • if this. Host is in the hello. Message’s list of neighbors • is. Bidirectional = True • else • is. Bidirectional = False • if (is. Bidirectional == False) • Add source of hello message to list of unidirectional neighbors, if not already in that list I am B I have heard: A A B Have heard list A Unidirectional Neighbors Bidirectional Neighbors Unidirectional Neighbors A Bidirectional Neighbors

 • Received message from A • if this. Host is in the hello.

• Received message from A • if this. Host is in the hello. Message’s list of neighbors • is. Bidirectional = True • else • is. Bidirectional = False • if (is. Bidirectional == False) • Add source of hello message to list of unidirectional neighbors, if not already in that list • if (is. Bidirectional == True) • Add source of hello message to list of bidirectional neighbors, if not already in that list I am B I have heard: A A B Have heard list B and B hears me Unidirectional Neighbors Have heard list A Bidirectional Neighbors B Unidirectional Neighbors A Bidirectional Neighbors

 • Received message from A • if this. Host is in the hello.

• Received message from A • if this. Host is in the hello. Message’s list of neighbors • is. Bidirectional = True • else • is. Bidirectional = False • if (is. Bidirectional == False) • Add source of hello message to list of unidirectional neighbors, if not already in that list • if (is. Bidirectional == True) • Add source of hello message to list of bidirectional neighbors, if not already in that list I am A I have heard: B A B Have heard list B and B hears me Unidirectional Neighbors Have heard list A Bidirectional Neighbors B Unidirectional Neighbors A Bidirectional Neighbors

 • Received message from A • if this. Host is in the hello.

• Received message from A • if this. Host is in the hello. Message’s list of neighbors • is. Bidirectional = True • else • is. Bidirectional = False • if (is. Bidirectional == False) • Add source of hello message to list of unidirectional neighbors, if not already in that list • if (is. Bidirectional == True) No, this does not move A to the • Add source of hello message to list of other list, it would just add it to the bidirectional neighbors, if not already in that list bidirectional neighbor’s list I am A I have heard: B, C, D A B Have heard list B and B hears me Unidirectional Neighbors Have heard list A and A hears me Bidirectional Neighbors B Unidirectional Neighbors A Bidirectional Neighbors

 • Received message from A • if this. Host is in the hello.

• Received message from A • if this. Host is in the hello. Message’s list of neighbors • is. Bidirectional = True • else • is. Bidirectional = False • if (is. Bidirectional == False) • Add source of hello message to list of unidirectional neighbors, if not already in that list • if (is. Bidirectional == True) • Add source of hello message to list of bidirectional neighbors, if not already in that list • Remove source from list of unidirectional neighbor No, this does not move A to the other list, it would just add it to the bidirectional neighbor’s list This fixes it I am A I have heard: B, C, D A B Have heard list B and B hears me Unidirectional Neighbors Have heard list A and A hears me Bidirectional Neighbors B Unidirectional Neighbors A Bidirectional Neighbors

 • Received message from A • if this. Host is in the hello.

• Received message from A • if this. Host is in the hello. Message’s list of neighbors • is. Bidirectional = True • else • is. Bidirectional = False • if (is. Bidirectional == False) • Add source of hello message to list of unidirectional neighbors, if not already in that list • if (is. Bidirectional == True) • Add source of hello message to list of bidirectional neighbors, if not already in that list • Remove source from list of unidirectional neighbor No, this does not move A to the Warning: There are some more steps processing other list, to it would just add it to the newly bidirectional neighbor’s list received hello messages. We’ll cover them later This fixes it I am A I have heard: B, C, D A B Have heard list B and B hears me Unidirectional Neighbors Have heard list A and A hears me Bidirectional Neighbors B Unidirectional Neighbors A Bidirectional Neighbors