Exemple #1
0
def main():
    """ Parser Options """
    parser = OptionParser (option_class=eng_option)
    MimoMPIF.add_parser_options (parser)
    if not parser.has_option("--phy-addr"):
        parser.add_option("", "--phy-addr", type="string", default="0.0.0.0", \
                help="set address for PHY [default=%default]")
    (options, args) = parser.parse_args ()
    if len(args)!=0:
        parser.print_help()
        sys.exit(1)

    global RATE_LIMIT
    if   (options.nchannels == 4): RATE_LIMIT = 32
    elif (options.nchannels == 2): RATE_LIMIT = 16
    elif (options.nchannels == 1): RATE_LIMIT = 8

    mac = mimo.mac(options.phy_addr, options.mac_port)
    mac.start()

    #f = FuncThread(send_data, "tx-data", mac)
    f = FuncThread(send_80211data, "tx-data", mac)
    f.setDaemon(1)
    g = FuncThread(recv_data, "rx-data", mac)
    g.setDaemon(1)
    h = FuncThread(recv_ctrl, "rx-ctrl", mac)
    h.setDaemon(1)

    for x in [f,g,h]: x.start()
    #for x in [g,h]: x.start()

    raw_input("Press Enter to quit:\n")
    mac.shutdown()

    p = persist()  # start a persitent thread
Exemple #2
0
 def add_options(cls, parser):
     """Add options to parser."""
     tunclient_defaults.add_options(parser)
     if not parser.has_option("--phy-addr"):
         parser.add_option("", "--phy-addr", type="string", \
                 default=cls.phy_addr, \
                 help="address for PHY side of MPIF [default=%default]")
     if not parser.has_option("--mtu"):
         parser.add_option("", "--mtu", type="int", default=cls.mtu, \
                 help="Maximum transmission unit that can be received from tun/tap interface [default=%default]")
     if not parser.has_option("--sifs"):
         parser.add_option("", "--sifs", type="float", default=cls.sifs, \
                 help="Short interframe spacing [default=%default]")
     if not parser.has_option("--difs"):
         parser.add_option("", "--difs", type="float", default=cls.difs, \
                 help="Distributed interframe spacing [default=%default]")
     if not parser.has_option("--slottime"):
         parser.add_option("", "--slottime", type="float",
                 default=cls.slottime, \
                 help="Contention slot duration [default=%default]")
     if not parser.has_option("--ackduration"):
         parser.add_option("", "--ackduration", type="float",
                 default=cls.ackduration, \
                 help="Duration of acknowledgement (used to calculate timeout) [default=%default]")
     MimoMPIF.add_parser_options(parser)
     return parser
Exemple #3
0
 def add_parser_options (parser):
     if not parser.has_option("-v"):
         parser.add_option ("-v", "--verbose", type="int", \
                 default=default_mimo_control_setup.d_options['verbose'], \
                 help="set verbose level of output [default=%default]")
     if not parser.has_option("--enable-beamforming"):
         parser.add_option("", "--enable-beamforming", action="store_true", \
                 default=default_mimo_control_setup.d_options['enable_beamforming'],
                 help="enable transmit beamforming in the PHY [default=%default]")
     PyHydra.control.add_parser_options (parser)
     MimoMPIF.add_parser_options (parser)
Exemple #4
0
def main():
    """ Parser Options """
    parser = OptionParser(option_class=eng_option)
    MimoManager.add_parser_options(parser)
    Channel.add_parser_options(parser)
    (options, args) = parser.parse_args()
    if len(args) != 0:
        parser.print_help()
        sys.exit(1)

    # overwrite fake_rf when --enable-channel is used
    if options.enable_channel:
        options.fake_rf = True

    mgr = MimoManager(options)
    phy = MimoTransceiver(options)
    phy.rx.packet_detector().set_debug(options.debug)
    phy.rx.packet_detector().set_window(64)
    phy.rx.packet_detector().set_delay(16)
    # phy.rx.packet_detector().set_thresh(0.70)
    phy.rx.packet_detector().set_nchannels(options.nchannels)
    """
    """
    sys.stderr.write("phy.rx.packet_detector().window()    = %s\n" % (phy.rx.packet_detector().window()))
    sys.stderr.write("phy.rx.packet_detector().delay()     = %s\n" % (phy.rx.packet_detector().delay()))
    sys.stderr.write("phy.rx.packet_detector().nchannels() = %s\n" % (phy.rx.packet_detector().nchannels()))
    # phy.rx.set_max_buffer_load(0.0)
    sys.stderr.write("phy.rx.nrx() = %s\n" % (phy.rx.nrx()))
    sys.stderr.write("phy.tx.nrx() = %s\n" % (phy.tx.ntx()))
    sys.stderr.write("phy.rx.max_buffer_size() = %s\n" % (phy.rx.max_buffer_size()))
    phy.txpath.pad.set_npre(2)
    phy.txpath.pad.set_npost(2)
    mpif = MimoMPIF(options)
    mpif.set_transceiver(phy)

    global RATE_LIMIT
    if options.nchannels == 4:
        RATE_LIMIT = 32
    elif options.nchannels == 2:
        RATE_LIMIT = 16
    elif options.nchannels == 1:
        RATE_LIMIT = 8

    mpif.start()
    phy.start()

    mgr.SetMPIF(mpif)

    ch = None
    if options.fake_rf and options.enable_channel:
        Nodb = 10
        chmodel = hydra.phy.channel_model()
        chmodel.set_noise_power_db(Nodb)
        ch = Channel(chmodel, options)
        ch.connect_phy(phy)
        ch.start()

    if not options.enable_socket:
        f = FuncThread(bar, "bar", mpif)
        f.setDaemon(1)
        f.start()
    elif mpif.tx.socket_enable():
        sys.stderr.write("MPIF TXPORT = %s\n" % (mpif.tx.port()))
        sys.stderr.write("MPIF RXPORT = %s\n" % (mpif.rx.port()))

    # mgr.run()
    g = mgr.start()
    if options.disable_gui:
        sys.stderr.write("Press Ctrl-c to quit\n")
        try:
            while 1:
                time.sleep(4)
        except KeyboardInterrupt:
            sys.stderr.write("exiting ...\n")
    else:
        if g is not None:
            g.join()
    mgr.stop()

    """
    if (len(TxData)>0):
        plot(numpy.abs(TxData) )
        grid()
        show()
    """

    if ch is not None:
        sys.stderr.write("CALLING Channel.stop()\n")
        ch.stop()
    sys.stderr.write("CALLING mpif.shutdown()\n")
    mpif.shutdown()
    for dd in range(8):
        time.sleep(0.5)
        sys.stderr.write(".")
    sys.stderr.write("\n")

    p = persist()  # start a persitent thread