pirate / mesh-networking

:globe_with_meridians: LEGO blocks for networking, a Python library to help create and test flexible network topologies across real and simulated physical links.
MIT License
360 stars 62 forks source link

multinode.py all nodes connect to one link #7

Closed zlgunn closed 9 years ago

zlgunn commented 9 years ago

All nodes, when spawned, are connected to the same link, which seems to be chosen at random, though all links appear to spawn correctly.

[n0]:[<l18>]
[n1]:[<l18>]
[n2]:[<l18>]
[n3]:[<l18>]
[n4]:[<l18>]
[n5]:[<l18>]
[n6]:[<l18>]
[n7]:[<l18>]
[n8]:[<l18>]
[n9]:[<l18>]
[n10]:[<l18>]
[n11]:[<l18>]
[n12]:[<l18>]
[n13]:[<l18>]
[n14]:[<l18>]
[n15]:[<l18>]
[n16]:[<l18>]
[n17]:[<l18>]
[n18]:[<l18>]
[n19]:[<l18>]
[n20]:[<l18>]
[n21]:[<l18>]
[n22]:[<l18>]
[n23]:[<l18>]
[n24]:[<l18>]
[n25]:[<l18>]
Type a nodename or linkname to send messages.
        e.g. [$]:n35
             [n35]<en1> ∂5:hi
        or
             [$]:l5
             <l5>(3) [n1,n4,n3]:whats up
    WARNING: ROUTING IS NOT IMPLEMENTED RIGHT NOW, EVERY NODE IS CONNECTED TO EVERY LINK (THIS IS A BUG)
[$]:
sergkondr commented 9 years ago

In Node.py:

class Node(threading.Thread, MeshProtocol):
    interfaces = []
    keep_listening = True
    mac_addr = "de:ad:be:ef:de:ad"
    ip_addr = "eeee:::::::1"
    own_addr = "fasdfsdafsa"

    def __init__(self, network_links=None, name=None):
        self.interfaces = []
        self.keep_listening = True
        self.mac_addr = "de:ad:be:ef:de:ad"
        self.ip_addr = "eeee:::::::1"
        self.own_addr = "fasdfsdafsa"
pirate commented 9 years ago

Fixed. They key part was that self.interfaces = [] has to happen after threading.Thread.__init__(), otherwise all the nodes would share one interface list.