def test3(): gnlogger.logconf() # initializes the logging facility module_logger.info('start this module') L1_ctrl_rx_q = Queue.Queue(10) L1_data_rx_q = Queue.Queue(10) L2_ctrl_rx_q = Queue.Queue(10) L2_data_rx_q = Queue.Queue(10) L1_event_tx_q = Queue.Queue(10) L2_event_tx_q = Queue.Queue(10) net_conf1 = NetworkConfiguration.NetworkConfiguration(101,'my network',256,1) # net_conf1.slots = 3 # " The first slot is the control slot, the others are for data" # net_conf1.control_time = 3 # " Each slot has 1 second" # net_conf1.list_nodes.append(101) # net_conf1.list_nodes.append(100) mac_control = MacTdma(net_conf1,L1_ctrl_rx_q,L1_data_rx_q,L2_ctrl_rx_q,L2_data_rx_q,L1_event_tx_q,L2_event_tx_q,False) event = events.mkevent("DataData") event.ev_dc['src_addr'] = 100 event.ev_dc['dst_addr'] = 101 L1_data_rx_q.put(event,False) myConsumer = EventConsumer.EventConsumer("L3consumer",L2_event_tx_q) myConsumer.start() time.sleep(5) mac_control.stop() myConsumer.stop()
def test2(): gnlogger.logconf() # initializes the logging facility module_logger.info('start this module') L1_ctrl_rx_q = Queue.Queue(10) L1_data_rx_q = Queue.Queue(10) L2_ctrl_rx_q = Queue.Queue(10) L2_data_rx_q = Queue.Queue(10) L1_event_tx_q = Queue.Queue(10) L2_event_tx_q = Queue.Queue(10) net_conf1 = NetworkConfiguration.NetworkConfiguration(101,'my network',256,1) mac_control = MacTdma(net_conf1,L1_ctrl_rx_q,L1_data_rx_q,L2_ctrl_rx_q,L2_data_rx_q,L1_event_tx_q,L2_event_tx_q,False) event = events.mkevent("DataData") event.ev_dc['src_addr'] = 101 event.ev_dc['dst_addr'] = 100 L2_data_rx_q.put(event,False) time.sleep(10) event = events.mkevent("MgmtBeacon") net_conf1.slots = 3 " The first slot is the control slot, the others are for data" net_conf1.control_time = 3 " Each slot has 1 second" net_conf1.list_nodes.append(101) net_conf1.list_nodes.append(100) event.ev_dc['src_addr'] = 100 event.ev_dc['dst_addr'] = net_conf1.broadcast_addr event.ev_dc['time_slot']= net_conf1.control_time/ net_conf1.slots event.ev_dc['allocation'] = net_conf1.list_nodes L1_ctrl_rx_q.put(event,False) time.sleep(5) mac_control.stop()
def main(): gnlogger.logconf() # initializes the logging facility module_logger.info('start this module') mods = digital.modulation_utils.type_1_mods() demods = digital.modulation_utils.type_1_demods() parser = OptionParser(option_class=eng_option, conflict_handler="resolve") expert_grp = parser.add_option_group("Expert") parser.add_option("-m", "--modulation", type="choice", choices=mods.keys(), default='bpsk', help="Select modulation from: %s [default=%%default]" % (', '.join(mods.keys()),)) parser.add_option("-s", "--size", type="eng_float", default=100, help="set packet size [default=%default]") parser.add_option("-M", "--megabytes", type="eng_float", default=1.0, help="set megabytes to transmit [default=%default]") parser.add_option("","--discontinuous", action="store_true", default=False, help="enable discontinous transmission (bursts of 5 packets)") parser.add_option("","--from-file", default=None, help="use intput file for packet contents") parser.add_option("","--to-file", default=None, help="Output file for modulated samples") parser.add_option("", "--mac", default=None , help = "MAC addres") parser.add_option("", "--version", default='6' , help = "gnuradio version, default 6 (3.6)") parser.add_option("", "--mac_dst", default=None , help = "Destination MAC addres") parser.add_option("","--master", action="store_true",default=False, dest= 'master', help="Master in TDMA Network") parser.add_option("","--slave", action="store_false",default=False, dest= 'master', help="Slave in TDMA Network") tp36.add_options(parser, expert_grp) tp37.add_options(parser, expert_grp) uhd_transmitter.add_options(parser) rp36.add_options(parser, expert_grp) rp37.add_options(parser, expert_grp) uhd_receiver.add_options(parser) for mod in demods.values(): mod.add_options(expert_grp) for mod in mods.values(): mod.add_options(expert_grp) (options, args) = parser.parse_args () if len(args) != 0: parser.print_help() sys.exit(1) if options.from_file is not None: source_file = open(options.from_file, 'r') r = gr.enable_realtime_scheduling() if r != gr.RT_OK: print "Warning: failed to enable realtime scheduling" q_L1_tx =Queue.Queue(10) q_L1_rx =Queue.Queue(10) l1=StartL1(q_L1_rx,q_L1_tx,options,mods[options.modulation],demods[options.modulation]) l1.start() schL1_L2= StartSchedL1_L2(q_L1_rx,q_L1_tx) schL1_L2.start() # POR AHORA NO USO CAPA MAC # l2Mgmt=StartL2Mgmt(schL1_L2.mgmt_q1,schL1_L2.tx_ev_q,options.mac,"256","Red IIE") # l2Mgmt.start() L2_ctrl_rx_q =Queue.Queue(10) L2_data_rx_q =Queue.Queue(5) L2_event_tx_q = Queue.Queue(10) l3= schedLayer3.Layer3(L2_data_rx_q,L2_event_tx_q,'/dev/net/tun',options.mac,options.mac_dst) "OJO POR AHORA LE ESTOY PASANDO A LA MAC TDMA LA COLA DE MGMT Y NO LA CTRL PORQUE EL CANAL DE CONTRL ES UN BEACON____!!!!!!!" if options.master: net_conf = NetworkConfiguration.NetworkConfiguration(options.mac,'my network',256,1) net_conf.slots = 3 " The first slot is the control slot, the others are for data" net_conf.control_time = 0.9 " Each slot has 1 second" net_conf.list_nodes.append(options.mac) net_conf.list_nodes.append(options.mac_dst) mac_tdma = Mac.MacTdma(net_conf,schL1_L2.mgmt_q,schL1_L2.data_q,L2_ctrl_rx_q,L2_data_rx_q,schL1_L2.tx_ev_q,L2_event_tx_q,options.master) else: net_conf = NetworkConfiguration.NetworkConfiguration(options.mac,'my network',256,1) mac_tdma = Mac.MacTdma(net_conf,schL1_L2.mgmt_q,schL1_L2.data_q,L2_ctrl_rx_q,L2_data_rx_q,schL1_L2.tx_ev_q,L2_event_tx_q,options.master) c = raw_input('Press #z to end, or #w to test commands :') while c != "#z": c = raw_input('Press #z to end, or #w to test commands :') print "Program ends" l3.stop() schL1_L2.stop() l1.stop() mac_tdma.stop() #POR AHORA NO ESTOY USANDO CAPA 2 # l2.stop() exit(0)
def simulates(): gnlogger.logconf() # initializes the logging facility module_logger.info('start this module') "-------------------NODO 100 MASTER-------------------------------------------------------" L2_ctrl_rx_q1 = Queue.Queue(10) L2_data_rx_q1 = Queue.Queue(10) L2_mgmt_rx_q1 = Queue.Queue(10) L2_event_tx_q1 = Queue.Queue(10) frame_rx_q1 = Queue.Queue(10) frame_tx_q1 = Queue.Queue(10) out_queues1 = { \ 'Ctrl': (L2_ctrl_rx_q1), \ 'Mgmt': (L2_mgmt_rx_q1), \ 'Data': (L2_data_rx_q1) \ } sch1 = schedFrToEv.SchedFrToEv(frame_rx_q1, out_queues1) sch1.start() # Configuration of the scheduler of Node 1 that receives events and generates frame events. out_queues_tx1 = { \ 'frames': (frame_tx_q1) \ } tx1 = schedEvToFr.SchedEvToFr( L2_event_tx_q1, out_queues_tx1) tx1.start() mySimulator1 = EventSimulator.EventSimulator( 15,"CtrlRTS",L2_event_tx_q1 ,"100000","101000") mySimulator1.start() myConsumer1 = EventConsumer.EventConsumer("N1--L3consumer",L2_data_rx_q1) myConsumer1.start() "---------------------FIN NODO 100 -----------------------------------------------" # "-------------------NODO 101 -------------------------------------------------------" L2_ctrl_rx_q2 = Queue.Queue(10) L2_data_rx_q2 = Queue.Queue(10) L2_mgmt_rx_q2 = Queue.Queue(10) L2_event_tx_q2 = Queue.Queue(10) frame_rx_q2 = Queue.Queue(10) frame_tx_q2 = frame_tx_q1 out_queues2 = { \ 'Ctrl': (L2_ctrl_rx_q2), \ 'Mgmt': (L2_ctrl_rx_q2), \ 'Data': (L2_data_rx_q2) \ } sch2 = schedFrToEv.SchedFrToEv(frame_rx_q2, out_queues2) sch2.start() # Configuration of the scheduler of Node 1 that receives events and generates frame events. out_queues_tx2 = { \ 'frames': (frame_tx_q2) \ } tx2 = schedEvToFr.SchedEvToFr( L2_event_tx_q2, out_queues_tx2) tx2.start() mySimulator1 = EventSimulator.EventSimulator( 15,"CtrlCTS",L2_event_tx_q2 ,"101000","100000") mySimulator1.start() myConsumer1 = EventConsumer.EventConsumer("N1--L3consumer",L2_data_rx_q2) myConsumer1.start() "---------------------FIN NODO 101 -----------------------------------------------" vc= virtualchannel.VirtualChannel(frame_tx_q2) vc.add(frame_rx_q1) vc.add(frame_rx_q2) vc.start()