Esempio n. 1
0
    def setup_method(self, method):
        """This function is called before each test method is called as is
        given a reference to the test method."""
        if _debug: TestRouter._debug("setup_method %r", method)

        # create a state machine group that has all nodes on all networks
        self.smg = StateMachineGroup()

        # make some networks
        vlan10 = IPNetwork()
        vlan20 = IPNetwork()

        # make a router and add the networks
        trouter = IPRouter()
        trouter.add_network(Address("192.168.10.1/24"), vlan10)
        trouter.add_network(Address("192.168.20.1/24"), vlan20)

        # add nodes to the networks
        for pattern, lan in (
            ("192.168.10.{}/24", vlan10),
            ("192.168.20.{}/24", vlan20),
        ):
            for i in range(2):
                node_address = Address(pattern.format(i + 2))
                node = IPNode(node_address, lan)
                if _debug: TestRouter._debug("    - node: %r", node)

                # bind a client state machine to the node
                csm = ClientStateMachine()
                bind(csm, node)

                # add it to the group
                self.smg.append(csm)
Esempio n. 2
0
    def __init__(self, address, vlan):
        if _debug: SnifferNode._debug("__init__ %r %r", address, vlan)
        ClientStateMachine.__init__(self)

        # save the name and address
        self.name = address
        self.address = Address(address)

        # create a promiscuous node, added to the network
        self.node = IPNode(self.address, vlan, promiscuous=True)
        if _debug: SnifferNode._debug("    - node: %r", self.node)

        # bind this to the node
        bind(self, self.node)
Esempio n. 3
0
    def __init__(self, addr, network, cid=None, sid=None):
        if _debug: FauxMux._debug("__init__")

        Client.__init__(self, cid)
        Server.__init__(self, sid)

        # get the unicast and broadcast tuples
        self.unicast_tuple = addr.addrTuple
        self.broadcast_tuple = addr.addrBroadcastTuple

        # make an internal node and bind to it, this takes the place of
        # both the direct port and broadcast port of the real UDPMultiplexer
        self.node = IPNode(addr, network)
        bind(self, self.node)
Esempio n. 4
0
    def __init__(self, node_count, address_pattern):
        if _debug: TNetwork._debug("__init__ %r", node_count)
        StateMachineGroup.__init__(self)

        self.vlan = IPNetwork()

        for i in range(node_count):
            node_address = Address(address_pattern.format(i + 1))
            node = IPNode(node_address, self.vlan)
            if _debug: TNetwork._debug("    - node: %r", node)

            # bind a client state machine to the node
            csm = ClientStateMachine()
            bind(csm, node)

            # add it to this group
            self.append(csm)