예제 #1
0
    def get_radio_info(self, platform_id):
        if platform_id == "sensor":
            sensor = SpectrumSensor(self.node)
            config_list = sensor.get_config_list()
        elif platform_id == "generator":
            generator = SignalGenerator(self.node)
            config_list = generator.get_config_list()
        else:
            config_list = str(platform_id) + ": Not supported! Try: sensor or generator"

        return config_list
예제 #2
0
    def __init__(self, txnode, rxnode):
        # We set up the SignalGenerator and SpectrumSensor objects here
        # for later use. We also query both nodes for their
        # corresponding lists of available hardware configurations.
        #
        # Since hardware will not change during the experiment, we only
        # do the query once in object constructor. This makes repeated
        # measurements faster.
        self.generator = SignalGenerator(txnode)
        self.generator_cl = self.generator.get_config_list()

        self.sensor = SpectrumSensor(rxnode)
        self.sensor_cl = self.sensor.get_config_list()
예제 #3
0
    def play_waveform(self, iface, freq, power_lvl, kwargs):
        if not self.generator:
            self.generator = SignalGenerator(self.node)
            config_list = self.generator.get_config_list()
            self.tx_config = config_list.get_tx_config(freq, power_lvl)
            if self.tx_config is None:
                self.generator = None
                return 2

        now = time.time()
        program = SignalGeneratorProgram(self.tx_config, now + 5, kwargs['play_time'])
        self.generator.program(program)

        return 0
def main():
    # Turn on logging so that we can see ALH requests happening in the
    # background.
    logging.basicConfig(level=logging.INFO)

    coor = alh.ALHWeb("https://crn.log-a-tec.eu/communicator", 10001)

    # Node 16 is equipped with an 2.4 GHz tranceiver (CC2500 on
    # SNE-ISMTV-24) that is capable of transmitting on the 2.4 GHz ISM
    # band.
    node = alh.ALHProxy(coor, 16)

    # We the ALHProxy object with a SignalGenerator object that provides an
    # convenient interface to the signal generation functionality.
    generator = SignalGenerator(node)

    # Get a ConfigList object that contains a list of device configurations
    # supported by the chosen transmitter node.
    config_list = generator.get_config_list()

    # ConfigList.get_tx_config() method will automatically choose
    # a device and hardware configuration that can be used to transmit on
    # the requested frequency. It returns an instance of TxConfig class
    # that describes all settings for signal generation.
    #
    # We request a transmission at 2.425 GHz with 0 dBm.
    tx_config = config_list.get_tx_config(2425e6, 0)
    if tx_config is None:
        raise Exception(
            "Node can not transmit at the specified frequency and/or power.")

    # SignalGeneratorProgram object joins the transmit config with timing
    # information. Here we specify that we want to start the transmission 5
    # seconds from now and that the transmission should be 30 seconds long.
    now = time.time()
    program = SignalGeneratorProgram(tx_config, now + 5, 30)

    generator.program(program)
def main():
	coor_industrial_zone = alh.ALHWeb(get_communicator_url(), 10001)

	time_start = time.time() + 30

	# Set up transmissions

	for node_id in [10, 8, 7]:
		node = alh.ALHProxy(coor_industrial_zone, node_id)
		node.post("prog/firstCall", "1")

	su1 = SignalGenerator(alh.ALHProxy(coor_industrial_zone, 10))
	su2 = SignalGenerator(alh.ALHProxy(coor_industrial_zone, 8))
	mic = SignalGenerator(alh.ALHProxy(coor_industrial_zone, 7))

	config_list = su1.get_config_list()

	tx_config = config_list.get_tx_config(0, 0)

	mic.program( SignalGeneratorProgram(
		config_list.get_tx_config(f_hz=790e6, power_dbm=0),
		time_start=time_start+30,
		time_duration=40) )

	mic.program( SignalGeneratorProgram(
		config_list.get_tx_config(f_hz=807e6, power_dbm=0),
		time_start=time_start+80,
		time_duration=40) )

	su1.program( SignalGeneratorProgram(
		config_list.get_tx_config(f_hz=787e6, power_dbm=0),
		time_start=time_start,
		time_duration=35) )

	su1.program( SignalGeneratorProgram(
		config_list.get_tx_config(f_hz=780e6, power_dbm=0),
		time_start=time_start+35,
		time_duration=90) )

	su2.program( SignalGeneratorProgram(
		config_list.get_tx_config(f_hz=795e6, power_dbm=0),
		time_start=time_start,
		time_duration=35) )

	su2.program( SignalGeneratorProgram(
		config_list.get_tx_config(f_hz=800e6, power_dbm=0),
		time_start=time_start+35,
		time_duration=50) )

	su2.program( SignalGeneratorProgram(
		config_list.get_tx_config(f_hz=797e6, power_dbm=0),
		time_start=time_start+85,
		time_duration=35) )

	# Set up spectrum sensing

	sensor_node_ids = [ 19 ]

	sensor_nodes = [ alh.ALHProxy(coor_industrial_zone, id) for id in sensor_node_ids ]
	sensors = [ SpectrumSensor(sensor_node) for sensor_node in sensor_nodes ]

	config_list = sensors[0].get_config_list()
	sweep_config = config_list.get_sweep_config(
			start_hz=770000000, stop_hz=820000000, step_hz=400000)
	
	# -1 below is a work-around for an off-by-one error somewhere in the spectrum sensing
	# resource handler
	sweep_config.num_channels -= 1

	program = SpectrumSensorProgram(sweep_config, time_start, time_duration=120, slot_id=5)

	for sensor in sensors:
		sensor.program(program)

	
	# Wait for the experiment to finish

	for sensor in sensors:
		while not sensor.is_complete(program):
			print "waiting..."
			time.sleep(2)

			if time.time() > (program.time_start + program.time_duration + 30):
				raise Exception("Something went wrong")

		print "experiment is finished. retrieving data."

		result = sensor.retrieve(program)

		try:
			os.mkdir("data")
		except OSError:
			pass

		result.write("data/node_%d.dat" % (sensor.alh.addr,))
def main():
    coor_industrial_zone = alh.ALHWeb(get_communicator_url(), 10001)

    time_start = time.time() + 15

    # Set up transmissions

    cognitive_terminal = SignalGenerator(alh.ALHProxy(coor_industrial_zone,
                                                      25))

    config_list = cognitive_terminal.get_config_list()
    device_config = config_list.get_config(0, 0)

    cognitive_terminal.program(
        SignalGeneratorProgram(TxConfig(device_config, 110, 0),
                               time_start=(time_start + 5),
                               time_duration=25))

    cognitive_terminal.program(
        SignalGeneratorProgram(TxConfig(device_config, 225, 0),
                               time_start=(time_start + 32),
                               time_duration=23))

    legacy_terminal = SignalGenerator(alh.ALHProxy(coor_industrial_zone, 16))

    legacy_terminal.program(
        SignalGeneratorProgram(TxConfig(device_config, 114, 0),
                               time_start=(time_start + 25),
                               time_duration=30))

    # Set up spectrum sensing

    sensor_node_ids = [2, 17, 6]

    sensor_nodes = [
        alh.ALHProxy(coor_industrial_zone, id) for id in sensor_node_ids
    ]
    sensors = [SpectrumSensor(sensor_node) for sensor_node in sensor_nodes]

    config_list = sensors[0].get_config_list()
    sweep_config = config_list.get_config(0, 0).get_full_sweep_config()

    program = SpectrumSensorProgram(sweep_config,
                                    time_start,
                                    time_duration=60,
                                    slot_id=5)

    for sensor in sensors:
        sensor.program(program)

    # Wait for the experiment to finish

    for sensor in sensors:
        while not sensor.is_complete(program):
            print "waiting..."
            time.sleep(2)

            if time.time() > (program.time_start + program.time_duration + 60):
                raise Exception("Something went wrong")

        print "experiment is finished. retrieving data."

        result = sensor.retrieve(program)

        try:
            os.mkdir("data")
        except OSError:
            pass

        result.write("data/node_%d.dat" % (sensor.alh.addr, ))
예제 #7
0
def main():

    # Turn on logging so that we can see requests and responses in the
    # terminal. This is useful to keep track of what is going on during the
    # experiment.
    logging.basicConfig(level=logging.INFO)

    # We must first create an object representing the coordinator node.
    # Each cluster in the LOG-a-TEC has its own coordinator and all
    # communication with the nodes must go through it.
    #
    # The parameters used here correspond to the LOG-a-TEC City Center
    # out-door cluster (see LOG-a-TEC documentation for other valid
    # options).
    #
    # Note that you must have a valid user name and password saved in an
    # "alhrc" file in order for this to work. See vesna-alh-tools README
    # for instructions on how to do that.
    #
    # Also make sure you reserved the cluster in the calendar before
    # running the experiment!
    coor = alh.ALHWeb("https://crn.log-a-tec.eu/communicator", 10002)

    # We will be using node 45 in this example. First we create a generic
    # node object for it.
    node = alh.ALHProxy(coor, 45)

    # We will use our node as a signal generator. Here, we wrap the generic
    # node object with the SignalGenerator class that provides a convenient
    # interface to the signal generation capabilities of the node's radio
    # hardware.
    generator = SignalGenerator(node)

    # Request the list of signal generation configurations that the node
    # supports.
    #
    # Node 45 is equipped with a SNE-ISMTV-2400 radio board that contains a
    # CC2500 reconfigurable transceiver. This tranceiver currently supports
    # one configuration in the 2.4 GHz ISM band.
    gen_config_list = generator.get_config_list()

    # Let's print the list out in a nice format for future reference.
    print
    print "Signal generation devices and configurations available"
    print "======================================================"
    print gen_config_list
    print

    # For a demonstration, we'll transmit a random signal at 2.425 GHz and
    # 0 dBm. We create a TxConfig object that describes the transmission.
    tx_config = gen_config_list.get_tx_config(2425e6, 0)
    if tx_config is None:
        raise Exception(
            "Node can not transmit at the specified frequency and/or power.")

    # Take note of current time.
    now = time.time()

    # SignalGeneratorProgram object allows us to program a node to perform a
    # signal generation task in advance. We'll setup a task for transmission
    # parameters we selected above, starting 5 seconds from now and lasting
    # for 10 seconds.
    gen_program = SignalGeneratorProgram(tx_config, now + 5, 10)

    # Finally, we actually send the programming instructions over the testbed's
    # management network to the node.
    generator.program(gen_program)
예제 #8
0
def main():
    # Turn on logging so that we can see requests and responses in the
    # terminal.
    logging.basicConfig(level=logging.INFO)

    # We must first create an object representing the coordinator node.
    coor_campus = alh.ALHWeb("https://crn.log-a-tec.eu/communicator", 9501)

    # Our experiment will start 15 seconds into the future - this should
    # give us plenty of time to set up everything.
    time_start = time.time() + 15

    # First we set up the two transmitting nodes:
    #
    # Node 53 in the LOG-a-TEC Campus Zone will be playing the role of
    # the cognitive terminal.
    cognitive_terminal = SignalGenerator(alh.ALHProxy(coor_campus, 53))

    # All nodes we will be using are equipped with SNE-ISMTV-2400 radio
    # boards with CC2500 transceivers. From the available list of
    # signal generation configurations supported by this hardware, we
    # choose the first one: It allows to transmit in 200 kHz wide channels.
    config_list = cognitive_terminal.get_config_list()
    device_config = config_list.get_config(0, 0)

    # Here we program the "cognitive_terminal" node to transmit for 25
    # seconds on channel 110 (2422.0 MHz) and then change to channel 225
    # (2445.0 MHz). Transmission power is set to 0 dBm.
    cognitive_terminal.program(
        SignalGeneratorProgram(TxConfig(device_config, 110, 0),
                               time_start=(time_start + 5),
                               time_duration=25))

    cognitive_terminal.program(
        SignalGeneratorProgram(TxConfig(device_config, 225, 0),
                               time_start=(time_start + 32),
                               time_duration=23))

    # Node 54 in the LOG-a-TEC Campus Zone will be playing the role of
    # the legacy terminal.
    legacy_terminal = SignalGenerator(alh.ALHProxy(coor_campus, 54))

    # The legacy terminal, lacking the capability to change channels on
    # demand, is programmed to just transmit for 30 seconds on channel 114
    # (2422.8 MHz)
    legacy_terminal.program(
        SignalGeneratorProgram(TxConfig(device_config, 114, 0),
                               time_start=(time_start + 25),
                               time_duration=30))

    # Now we setup some sensing nodes so that we can observe the
    # transmissions from different points in the testbed.

    # We will use nodes 51 and 58 for this purpose.
    sensor_node_ids = [51, 58]

    sensor_nodes = [alh.ALHProxy(coor_campus, id) for id in sensor_node_ids]
    sensors = [SpectrumSensor(sensor_node) for sensor_node in sensor_nodes]

    # For sensing, we will use the first sensing configuration (255
    # channels starting at 2.4 GHz with 400 kHz bandwidth)
    config_list = sensors[0].get_config_list()
    sweep_config = config_list.get_config(0, 0).get_full_sweep_config()

    # We instruct the nodes to perform spectrum sensing for 60 seconds.
    program = SpectrumSensorProgram(sweep_config,
                                    time_start,
                                    time_duration=60,
                                    slot_id=5)
    for sensor in sensors:
        sensor.program(program)

    # All nodes have been programmed at this point - wait for the experiment to finish.

    for sensor in sensors:
        while not sensor.is_complete(program):
            print "waiting..."
            time.sleep(2)

            if time.time() > (program.time_start + program.time_duration + 60):
                raise Exception("Something went wrong")

        print "experiment is finished. retrieving data."

        result = sensor.retrieve(program)

        # We will save the sensing results in a "data/" subdirectory.
        # Create it, if it doesn't already exist.
        try:
            os.mkdir("data")
        except OSError:
            pass

        # For each sensing node, we write the results into a CSV file.
        # The CSV file can be easily imported and plotted into tools
        # like MatLab. For example, to plot the recorded spectrogram
        # using GNU Plot, use the following commands:
        #
        # gnuplot> set pm3d map
        # gnuplot> set xlabel "frequency [MHz]"
        # gnuplot> set ylabel "time [s]"
        # gnuplot> set cblabel "power [dBm]"
        # gnuplot> unset key
        # gnuplot> splot "node17.csv" using ($2/1e6):1:3
        result.write("data/node_%d.csv" % (sensor.alh.addr, ))
def main():
    # Turn on logging so that we can see ALH requests happening in the
    # background.
    logging.basicConfig(level=logging.INFO)

    coor = alh.ALHWeb("https://crn.log-a-tec.eu/communicator", 10001)

    # Nodes 16 and 17 are equipped with an 2.4 GHz tranceiver (CC2500 on
    # SNE-ISMTV-24) that is capable of transmitting and receiving on the
    # 2.4 GHz ISM band.
    node16 = alh.ALHProxy(coor, 16)
    node17 = alh.ALHProxy(coor, 17)

    # We will use node 16 as a signal generator. We wrap its ALHProxy
    # object with a SignalGenerator object for convenience.
    generator = SignalGenerator(node16)

    # Set up a transmission configuration for 2.425 GHz and 0 dBm
    generator_config_list = generator.get_config_list()

    tx_config = generator_config_list.get_tx_config(2425e6, 0)
    if tx_config is None:
        raise Exception("Node can not scan specified frequency range.")

    # We will use node 17 as a spectrum sensor. Again, we wrap it with a
    # SpectrumSensor object for convenience.
    sensor = SpectrumSensor(node17)

    # We set up a frequency sweep configuration covering 2.40 GHz to 2.45
    # GHz band with 400 kHz steps.
    sensor_config_list = sensor.get_config_list()

    sweep_config = sensor_config_list.get_sweep_config(2400e6, 2450e6, 400e3)
    if sweep_config is None:
        raise Exception("Node can not scan specified frequency range.")

    # Take note of current time.
    now = time.time()

    # SignalGeneratorProgram and SpectrumSensorProgram objects allow us to
    # program signal generation and spectrum sensing tasks in advance.
    #
    # In this case, we setup a signal generation task using the
    # configuration we prepared above starting 10 seconds from now and
    # lasting for 20 seconds.
    #
    # Similarly for spectrum sensing, we setup a task using frequency sweep
    # we prepared above starting 5 seconds from now and lasting for 30
    # seconds. Results of the measurement will be stored in slot 4.
    generator_program = SignalGeneratorProgram(tx_config, now + 10, 20)
    sensor_program = SpectrumSensorProgram(sweep_config, now + 5, 30, 4)

    # Now actually send instructions over the management network to nodes
    # in the testbed.
    generator.program(generator_program)
    sensor.program(sensor_program)

    # Query the spectrum sensing node and wait until the task has been
    # completed.
    while not sensor.is_complete(sensor_program):
        print "waiting..."
        time.sleep(2)

    # Retrieve spectrum sensing results. This might take a while since the
    # management mesh network is slow.
    result = sensor.retrieve(sensor_program)

    # Write results into a CSV file.
    result.write("06-programmed-tasks.dat")