예제 #1
0
    def __init__(self, wire, ber, speed, id, stationType = "client"):
        super(Station, self).__init__("node" + str(id))

        self.contextProviders.append(
            openwns.probebus.ConstantContextProvider(
                "DLL.StationType", Evaluation.toStaTypeId(stationType)))

        # Physical Layer (PHY)
        self.phy = copper.Copper.Transceiver(self,
                                             # Name of the PHY
                                             "phy",

                                             # Medium to which the instance is attached to
                                             wire,

                                             # BER this instance experiences
                                             ber,

                                             # Transmit data rate
                                             speed)

        # Data Link Layer (DLL)
        self.dll = Tutorial.Experiment4(self, "ShortCut", 
                                        self.phy.dataTransmission, self.phy.notification, 
                                        stationType = stationType)

        # Network Layer (NL)
        domainName = "node" + str(id) + ".glue.wns.org"
        self.nl = ip.Component.IPv4Component(self,
                                             # Name of the NL
                                             domainName + ".ip",

                                             # Domain name
                                             domainName)

        # Connect NL instance to the DLL interface
        self.nl.addDLL(
            # Name of the DLL interface (Only used within the NL module. Hence, it may differ from
            # the name given to the DLL instance during instantiation)
            _name = "glue",

            # Where to get my IP Address
            _addressResolver = ip.AddressResolver.VirtualDHCPResolver("theOnlySubnet"),

            # ARP zone
            _arpZone = "theOnlySubnet",

            # We can deliver locally
            _pointToPoint = False,

            # DLL SAP for outgoing unicast transmissions
            _dllDataTransmission = self.dll.unicastDataTransmission,

            # DLL SAP for incoming unicast transmissions
            _dllNotification = self.dll.unicastNotification)


        # Traffic generator
        self.load = constanze.node.ConstanzeComponent(self, "constanze", parentLogger = self.logger)