#!/usr/bin/env python import sys sys.path.append('../../../../maximus/python/obj'); sys.path.append('../../../../maximus/python'); from interface import * from string import * from struct import * from maximus import * maximus = Maximus() maximus.init (sys.argv + ['-e', './obj/hle-cl-sar-pbproc.elf']) sta1_mac = 0x101112131415 sta1_mac_str = pack ('>Q', sta1_mac)[2:8] sta2_mac = 0x20212232425 sta2_mac_str = pack('>Q', sta2_mac)[2:8] f = open ('../../packet1', 'r') packet = f.read() f.close() # TEI of station 1 will be 1 station1 = maximus.create_sta() #station1.debug() # TEI of station 2 will be 2 station2 = maximus.create_sta() #station2.debug() fc1 = maximus.create_fcall ("fc_station_init_config") fc1.set_sta (station1) fc1.add_param_ushort ("snid", 1) fc1.add_param_ushort ("tei", 1) fc1.add_param_ushort ("auto_sched", 1) fc1.send() fc2 = maximus.create_fcall ("fc_station_init_config") fc2.set_sta (station2) fc2.add_param_ushort ("snid", 1) fc2.add_param_ushort ("tei", 2) fc2.add_param_ushort ("auto_sched", 1) fc2.send() #neighbour discovery fc1 = maximus.create_fcall ("fc_station_discover") fc1.set_sta (station1) fc1.add_param_ushort ("qte", 1) fc1.add_param_ushort ("tei0", 2) fc1.add_param ("mac0", sta2_mac_str) fc1.send() fc2 = maximus.create_fcall ("fc_station_discover") fc2.set_sta (station2) fc2.add_param_ushort ("qte", 1) fc2.add_param_ushort ("tei0", 1) fc2.add_param ("mac0", sta1_mac_str) fc2.send() fc1 = maximus.create_fcall ("fc_station_link_add") fc1.set_sta (station1) fc1.add_param_ushort ("type", 1) fc1.add_param_ushort ("bcast", 0) fc1.add_param_ushort ("mme", 0) fc1.add_param_ushort ("lid", 1) fc1.add_param_ushort ("tei", 2) fc1.send() fc1 = maximus.create_fcall ("fc_station_link_add") fc1.set_sta (station1) fc1.add_param_ushort ("type", 1) fc1.add_param_ushort ("bcast", 0) fc1.add_param_ushort ("mme", 1) fc1.add_param_ushort ("lid", 248) fc1.add_param_ushort ("tei", 2) fc1.send() fc2 = maximus.create_fcall ("fc_station_link_add") fc2.set_sta (station2) fc2.add_param_ushort ("type", 0) fc2.add_param_ushort ("bcast", 0) fc2.add_param_ushort ("mme", 0) fc2.add_param_ushort ("lid", 1) fc2.add_param_ushort ("tei", 1) fc2.send() fc2 = maximus.create_fcall ("fc_station_link_add") fc2.set_sta (station2) fc2.add_param_ushort ("type", 0) fc2.add_param_ushort ("bcast", 0) fc2.add_param_ushort ("mme", 1) fc2.add_param_ushort ("lid", 248) fc2.add_param_ushort ("tei", 1) fc2.send() fc1 = maximus.create_fcall ("fc_ipmbox_mme_buffer_add") fc1.set_sta (station1) fc1.send() fc1 = maximus.create_fcall ("fc_ipmbox_mme_buffer_add") fc1.set_sta (station2) fc1.send() fc2 = maximus.create_fcall ("fc_ipmbox_data_buffer_add") fc2.set_sta (station2) fc2.send() frame0 = Eth() frame0.src = '10:11:12:13:14:15' frame0.dst = '20:21:22:23:24:25' frame0.vlantag = 0x81004D4E frame0.type = 0x4F50 frame0.payload = packet[0:106] fc1 = maximus.create_fcall ("fc_ipmbox_data_send") fc1.set_sta (station1) fc1.add_param_ushort ("length", 106) fc1.add_param ("packet", frame0.get() ) fc1.send() fc1 = maximus.create_fcall ("fc_ipmbox_mme_send") fc1.set_sta (station1) fc1.add_param_ushort ("length", 106) fc1.add_param ("packet", frame0.get() ) fc1.send() fc1 = maximus.create_fcall ("fc_ipmbox_mme_send") fc1.set_sta (station1) fc1.add_param_ushort ("length", 106) fc1.add_param ("packet", frame0.get() ) fc1.send() fc1 = maximus.create_fcall ("fc_cp_mme_send_as_mme") fc1.set_sta (station1) fc1.add_param_ushort ("tei", 2) fc1.add_param_ushort ("bcast", 0) fc1.add_param_ushort ("length", 106) fc1.add_param ("buffer", frame0.get() ) fc1.send() maximus.wait (1000000) while not station1.is_idle() and not station2.is_idle() : maximus.wait(10000) maximus.wait(1000) print "\n ************** Sta 1 traces *******************\n" fc1 = maximus.create_fcall ("fc_hle_print_trace") fc1.set_sta (station1) fc1.send() fc1 = maximus.create_fcall ("fc_cl_print_trace") fc1.set_sta (station1) fc1.send() fc1 = maximus.create_fcall ("fc_sar_print_trace") fc1.set_sta (station1) fc1.send() print "\n ************** Sta 2 traces *******************\n" fc1 = maximus.create_fcall ("fc_hle_print_trace") fc1.set_sta (station2) fc1.send() fc1 = maximus.create_fcall ("fc_cl_print_trace") fc1.set_sta (station2) fc1.send() fc1 = maximus.create_fcall ("fc_sar_print_trace") fc1.set_sta (station2) fc1.send() #fc1 = maximus.create_fcall ("fc_station_uninit") #fc1.set_sta (station1) #fc1.send() #fc2 = maximus.create_fcall ("fc_station_uninit") #fc2.set_sta (station2) #fc2.send() station1.remove() station2.remove()