From 89924972a91b5b266d83da16f7cab8eebf2528a2 Mon Sep 17 00:00:00 2001 From: Geoff Twardokus Date: Mon, 28 Sep 2020 13:25:22 -0400 Subject: [PATCH 01/22] Updated GRC for best B210 performance --- wifi_rx.grc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wifi_rx.grc b/wifi_rx.grc index 50e536a4..38d1acb4 100644 --- a/wifi_rx.grc +++ b/wifi_rx.grc @@ -2328,7 +2328,7 @@ ant0 - + TX/RX bw0 From 100e849f92c048cd1e2b6e225398b316321cb354 Mon Sep 17 00:00:00 2001 From: Geoff Twardokus Date: Mon, 28 Sep 2020 13:26:47 -0400 Subject: [PATCH 02/22] Updated wifi_tx.grc for best performance with B210 --- wifi_tx.grc | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/wifi_tx.grc b/wifi_tx.grc index 37fe99fd..1f440f3b 100644 --- a/wifi_tx.grc +++ b/wifi_tx.grc @@ -358,7 +358,7 @@ value - 6e6 + 0 _enabled @@ -646,7 +646,7 @@ value - 0.9 + 0.97 _enabled @@ -984,7 +984,7 @@ ant0 - + TX/RX bw0 @@ -1648,7 +1648,7 @@ _coordinate - (400, 620) + (504, 540) _rotation From 3ecfc1bec6d1b0dfb003408fe51f873ae763f874 Mon Sep 17 00:00:00 2001 From: Geoff Twardokus Date: Mon, 28 Sep 2020 13:34:47 -0400 Subject: [PATCH 03/22] Edited files to remove attacker functionality from main execution, and slow down message rate for initial experimentation. --- RemoteVehicle.py | 2 +- remote_main.py | 71 ++++++++++-------------------------------------- 2 files changed, 15 insertions(+), 58 deletions(-) diff --git a/RemoteVehicle.py b/RemoteVehicle.py index 6ce07492..4b2100a3 100644 --- a/RemoteVehicle.py +++ b/RemoteVehicle.py @@ -15,4 +15,4 @@ def start(self): print("Sending BSM") loader = subprocess.Popen(("echo","-n","-e",BSM), stdout=subprocess.PIPE) sender = subprocess.check_output(("nc","-w0","-u","localhost","52001"),stdin=loader.stdout) - time.sleep(0.1) \ No newline at end of file + time.sleep(1) \ No newline at end of file diff --git a/remote_main.py b/remote_main.py index 1379b967..95e2acb2 100644 --- a/remote_main.py +++ b/remote_main.py @@ -7,10 +7,7 @@ from multiprocessing import Process from RemoteVehicle import RemoteVehicle from Utility import Utility -from ReplayAttacker import ReplayAttacker -import time import os -import random if os.geteuid() != 0: print("Error - you must be root! Try running with sudo") @@ -34,57 +31,17 @@ except IndexError: print("Error starting vehicles. Ensure you have entered enough trace files and BSM file paths in \"init.yml\" to match the number of vehicles specified in that file.") -# Loop until the user chooses to exit the program -while True: - - # Make the user choose a (valid) option - validResponse = False - while not validResponse: - option = input("Please choose an option: ") - if option in ['0', '1', '2', 'q', 'Q']: - validResponse = True - else: - print("Invalid response. Please enter 0, 1, 2, or press Q to quit.") - - # If the user wants to exit the program, quit with a message. - if option in ['q', 'Q']: - print("Goodbye!") - break - - # If not 'q' or 'Q', then the user entered an integer choice that must be cast from string input - option = int(option) - - # list to hold all spawned processes - vehicleProcesses = [] - - # start transmitting packets for all legitimate vehicles - for rv in remoteVehicles: - vehicle = Process(target=rv.start) - vehicleProcesses.append(vehicle) - vehicle.start() - print("Started legitimate vehicle") - - if option == 1: - # start running the replay attacker - replayer = ReplayAttacker() - replay = Process(target=replayer.replayAttack, args=(2,)) - vehicleProcesses.append(replay) - replay.start() - print("Started replay attacker") - - elif option == 2: - # start a spoofing attack - traceFilePath = config["spoofer"]["traceFile"] - spoofedBSMQueue = util.buildSpoofedBSMQueue(random.randint(0,10), traceFilePath) - spoofer = RemoteVehicle(spoofedBSMQueue) - spoofProc = Process(target=spoofer.start) - vehicleProcesses.append(spoofProc) - spoofProc.start() - print("Started spoofing attacker") - - - for vehicle in vehicleProcesses: - vehicle.join() - - - \ No newline at end of file +# list to hold all spawned processes +vehicleProcesses = [] + +# start transmitting packets for all legitimate vehicles +for rv in remoteVehicles: + vehicle = Process(target=rv.start) + vehicleProcesses.append(vehicle) + vehicle.start() + print("Started legitimate vehicle") + +for vehicle in vehicleProcesses: + vehicle.join() + + From da40a2e86dc06be03ba9d12fe379f60cfab72cbf Mon Sep 17 00:00:00 2001 From: Geoff Twardokus Date: Mon, 28 Sep 2020 13:57:31 -0400 Subject: [PATCH 04/22] Edited test coordinates file to send over 100 BSMs instead of a few --- test_coords | 139 ++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 134 insertions(+), 5 deletions(-) diff --git a/test_coords b/test_coords index e54a2e00..72134a81 100644 --- a/test_coords +++ b/test_coords @@ -1,6 +1,135 @@ -237.5,394 -237.5,393 -237.5,392 -237.5,391 -237.5,390 +237.5,389 +237.5,389 +237.5,389 +237.5,389 +237.5,389 +237.5,389 +237.5,389 +237.5,389 +237.5,389 +237.5,389 +237.5,389 +237.5,389 +237.5,389 +237.5,389 +237.5,389 +237.5,389 +237.5,389 +237.5,389 +237.5,389 +237.5,389 +237.5,389 +237.5,389 +237.5,389 +237.5,389 +237.5,389 +237.5,389 +237.5,389 +237.5,389 +237.5,389 +237.5,389 +237.5,389 +237.5,389 +237.5,389 +237.5,389 +237.5,389 +237.5,389 +237.5,389 +237.5,389 +237.5,389 +237.5,389 +237.5,389 +237.5,389 +237.5,389 +237.5,389 +237.5,389 +237.5,389 +237.5,389 +237.5,389 +237.5,389 +237.5,389 +237.5,389 +237.5,389 +237.5,389 +237.5,389 +237.5,389 +237.5,389 +237.5,389 +237.5,389 +237.5,389 +237.5,389 +237.5,389 +237.5,389 +237.5,389 +237.5,389 +237.5,389 +237.5,389 +237.5,389 +237.5,389 +237.5,389 +237.5,389 +237.5,389 +237.5,389 +237.5,389 +237.5,389 +237.5,389 +237.5,389 +237.5,389 +237.5,389 +237.5,389 +237.5,389 +237.5,389 +237.5,389 +237.5,389 +237.5,389 +237.5,389 +237.5,389 +237.5,389 +237.5,389 +237.5,389 +237.5,389 +237.5,389 +237.5,389 +237.5,389 +237.5,389 +237.5,389 +237.5,389 +237.5,389 +237.5,389 +237.5,389 +237.5,389 +237.5,389 +237.5,389 +237.5,389 +237.5,389 +237.5,389 +237.5,389 +237.5,389 +237.5,389 +237.5,389 +237.5,389 +237.5,389 +237.5,389 +237.5,389 +237.5,389 +237.5,389 +237.5,389 +237.5,389 +237.5,389 +237.5,389 +237.5,389 +237.5,389 +237.5,389 +237.5,389 +237.5,389 +237.5,389 +237.5,389 +237.5,389 +237.5,389 +237.5,389 +237.5,389 +237.5,389 +237.5,389 +237.5,389 +237.5,389 237.5,389 \ No newline at end of file From 607ca1df11317d79c2318c2ad947c74dfc91b7ee Mon Sep 17 00:00:00 2001 From: Geoff Twardokus Date: Mon, 28 Sep 2020 13:58:28 -0400 Subject: [PATCH 05/22] Major changes to remove GUI and non-signature validation checks from main execution on the receiver. Now the only output is a T/F print to the console for the signature validation of each received message. --- Receiver.py | 34 +++++++++++++++++++++------------- local_main.py | 15 +++++++++++---- 2 files changed, 32 insertions(+), 17 deletions(-) diff --git a/Receiver.py b/Receiver.py index 047c0fcc..ea9c176e 100644 --- a/Receiver.py +++ b/Receiver.py @@ -11,32 +11,34 @@ def __init__(self): self.verifier = Verifier() self.messageCounter = 1 - def runReceiver(self, socketToGUI, guiLock): - listener = Thread(target=self.listenForWSMs(socketToGUI, guiLock)) + def runReceiver(self): + listener = Thread(target=self.listenForWSMs()) listener.start() - def listenForWSMs(self, s, lock): + def listenForWSMs(self): # print a console message to confirm the network connection is active print("Listening on localhost:4444 for WSMs") # listen on localhost:4444 which is the UDP sink from GNURadio in wifi_rx.py # received packets are passed to processPacket() for data extraction - sniff(iface="lo", filter="dst port 4444", prn=lambda x: self.filterDuplicatePackets(str(binascii.hexlify(x.load))[130:],s,lock)) + sniff(iface="lo", filter="dst port 4444", prn=lambda x: self.filterDuplicatePackets(str(binascii.hexlify(x.load))[130:])) - def filterDuplicatePackets(self, payload, s, lock): + def filterDuplicatePackets(self, payload): if self.messageCounter % 2 == 1: - self.processPacket(payload, s, lock) + self.processPacket(payload) self.messageCounter += 1 # uses returned tuple from parseWSM to verify message and send to GUI - def processPacket(self, payload, s, lock): + def processPacket(self, payload): # extract the elements "(unsecuredData,r,s,time)" from the 1609.2 structure data = self.parseWSM(payload) + """ #BSMData = data[0].decode('hex').replace("\n","").split(",") BSMData = bytes.fromhex(data[0]).decode('ascii').replace("\n","").split(",") + # create a dictionary to pack and send decodedData = {} @@ -45,24 +47,30 @@ def processPacket(self, payload, s, lock): decodedData['y'] = BSMData[2] decodedData['heading'] = BSMData[3] decodedData['speed'] = BSMData[4] + """ + +# publicKey = keys.import_key("keys/" + decodedData['id'] + "/p256.pub",curve=curve.P256, public=True) + publicKey = keys.import_key("keys/0/p256.pub",curve=curve.P256, public=True) + - publicKey = keys.import_key("keys/" + decodedData['id'] + "/p256.pub",curve=curve.P256, public=True) - # verify the signature isValidSig = self.verifier.verifySignature(data[1],data[2],data[0],publicKey) - elapsed, isRecent = self.verifier.verifyTime(data[3]) - + #elapsed, isRecent = self.verifier.verifyTime(data[3]) + """ decodedData['sig'] = isValidSig decodedData['elapsed'] = elapsed decodedData['recent'] = isRecent decodedData['receiver'] = False - + vehicleDataJSON = json.dumps(decodedData) with lock: s.send(vehicleDataJSON.encode()) - + """ + + print(isValidSig) + # takes the hex payload from an 802.11p frame as an argument, returns tuple of extracted bytestrings def parseWSM(self, WSM): diff --git a/local_main.py b/local_main.py index 64995bae..bf30f608 100644 --- a/local_main.py +++ b/local_main.py @@ -1,20 +1,21 @@ # this is the main execution file for the "local vehicle" import os +""" import sys + print(os.getcwd()) sys.path.append("/home/administrator/eclipse-workspace/v2verifier/v2verifier") +""" import yaml from threading import Lock, Thread from socket import socket from Receiver import Receiver -from GUI import GUI -import tkinter as tk -from LocalVehicle import LocalVehicle +#from LocalVehicle import LocalVehicle with open("init.yml", "r") as confFile: config = yaml.load(confFile,Loader=yaml.FullLoader) @@ -25,25 +26,31 @@ print("Error - you must be root! Try running with sudo") exit(1) + """ root = tk.Tk() gui = GUI(root) gui.runGUIReceiver() print("GUI Initialized...") + s2 = socket() s2.connect(('127.0.0.1',6666)) + """ lock = Lock() receiver = Receiver() - listener = Thread(target=receiver.listenForWSMs, args=(s2,lock,)) + listener = Thread(target=receiver.runReceiver()) listener.start() print("Listener running...") + """ lv = LocalVehicle(config["localConfig"]["tracefile"]) local = Thread(target=lv.start, args=(s2,lock,)) local.start() + root.mainloop() + """ \ No newline at end of file From 801bed15f2b56940de33706e8ffbd6387522bc39 Mon Sep 17 00:00:00 2001 From: Samantha Baker Date: Tue, 29 Sep 2020 15:36:36 -0700 Subject: [PATCH 06/22] test commit --- .idea/UltimateGUI.iml | 2 +- .idea/misc.xml | 2 +- WavePacketBuilder.py | 3 ++- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/.idea/UltimateGUI.iml b/.idea/UltimateGUI.iml index 670299b5..3733cacf 100644 --- a/.idea/UltimateGUI.iml +++ b/.idea/UltimateGUI.iml @@ -4,7 +4,7 @@ - + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml index e4f0146c..f974e401 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -1,4 +1,4 @@ - + \ No newline at end of file diff --git a/WavePacketBuilder.py b/WavePacketBuilder.py index 5f7bd022..fcf217e1 100644 --- a/WavePacketBuilder.py +++ b/WavePacketBuilder.py @@ -5,7 +5,8 @@ import math class WAVEPacketBuilder(): - + + #hello def getWSMPayload(self, bsmString, key): payload = self.getLLCBytestring() + self.getWSMHeaders() + self.getIeee1609Dot2Data(bsmString,key) From 301d2bec69fad23f15c987140b4745ddafad60d7 Mon Sep 17 00:00:00 2001 From: Geoff Twardokus Date: Wed, 30 Sep 2020 12:41:50 -0400 Subject: [PATCH 07/22] Add to tracking. As of this commit, the GRC receives frames on 2.412 GHz and re-transmits the frames on the 5.89 GHz channel. This commit confirms that the reactive jammer using an N210 with two antennas is a workable idea. --- reactive_jammer.grc | 5410 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 5410 insertions(+) create mode 100644 reactive_jammer.grc diff --git a/reactive_jammer.grc b/reactive_jammer.grc new file mode 100644 index 00000000..629d6e78 --- /dev/null +++ b/reactive_jammer.grc @@ -0,0 +1,5410 @@ + + + + Sat Sep 26 16:02:40 2020 + + options + + author + + + + window_size + 2048, 1280 + + + category + [GRC Hier Blocks] + + + comment + + + + description + + + + _enabled + True + + + _coordinate + (8, 8) + + + _rotation + 0 + + + generate_options + qt_gui + + + hier_block_src_path + .: + + + id + reactive_jammer + + + max_nouts + 0 + + + qt_qss_theme + + + + realtime_scheduling + + + + run_command + {python} -u {filename} + + + run_options + prompt + + + run + True + + + sizing_mode + fixed + + + thread_safe_setters + + + + title + + + + placement + (0,0) + + + + variable_qtgui_chooser + + comment + + + + value + 0 + + + _enabled + True + + + _coordinate + (264, 76) + + + gui_hint + + + + _rotation + 0 + + + id + chan_est + + + label0 + + + + label1 + + + + label2 + + + + label3 + + + + label4 + + + + label + + + + labels + ["LS", "LMS", "STA", "Linear Comb"] + + + num_opts + 0 + + + option0 + 0 + + + option1 + 1 + + + option2 + 2 + + + option3 + 3 + + + option4 + 4 + + + options + [ieee802_11.LS, ieee802_11.LMS, ieee802_11.STA, ieee802_11.COMB] + + + orient + Qt.QHBoxLayout + + + type + int + + + widget + radio_buttons + + + + variable_qtgui_chooser + + comment + + + + value + 0 + + + _enabled + 1 + + + _coordinate + (1520, 68) + + + gui_hint + + + + _rotation + 0 + + + id + encoding + + + label0 + + + + label1 + + + + label2 + + + + label3 + + + + label4 + + + + label + + + + labels + ["BPSK 1/2", "BPSK 3/4", "QPSK 1/2", "QPSK 3/4", "16QAM 1/2", "16QAM 3/4", "64QAM 2/3", "64QAM 3/4"] + + + num_opts + 0 + + + option0 + 0 + + + option1 + 1 + + + option2 + 2 + + + option3 + 3 + + + option4 + 4 + + + options + [0, 1, 2, 3, 4, 5, 6, 7] + + + orient + Qt.QHBoxLayout + + + type + int + + + widget + radio_buttons + + + + variable_qtgui_chooser + + comment + + + + value + 2412000000 + + + _enabled + True + + + _coordinate + (576, 76) + + + gui_hint + + + + _rotation + 0 + + + id + freq + + + label0 + + + + label1 + + + + label2 + + + + label3 + + + + label4 + + + + label + + + + labels + [' 1 | 2412.0 | 11g', ' 2 | 2417.0 | 11g', ' 3 | 2422.0 | 11g', ' 4 | 2427.0 | 11g', ' 5 | 2432.0 | 11g', ' 6 | 2437.0 | 11g', ' 7 | 2442.0 | 11g', ' 8 | 2447.0 | 11g', ' 9 | 2452.0 | 11g', ' 10 | 2457.0 | 11g', ' 11 | 2462.0 | 11g', ' 12 | 2467.0 | 11g', ' 13 | 2472.0 | 11g', ' 14 | 2484.0 | 11g', ' 34 | 5170.0 | 11a', ' 36 | 5180.0 | 11a', ' 38 | 5190.0 | 11a', ' 40 | 5200.0 | 11a', ' 42 | 5210.0 | 11a', ' 44 | 5220.0 | 11a', ' 46 | 5230.0 | 11a', ' 48 | 5240.0 | 11a', ' 50 | 5250.0 | 11a', ' 52 | 5260.0 | 11a', ' 54 | 5270.0 | 11a', ' 56 | 5280.0 | 11a', ' 58 | 5290.0 | 11a', ' 60 | 5300.0 | 11a', ' 62 | 5310.0 | 11a', ' 64 | 5320.0 | 11a', '100 | 5500.0 | 11a', '102 | 5510.0 | 11a', '104 | 5520.0 | 11a', '106 | 5530.0 | 11a', '108 | 5540.0 | 11a', '110 | 5550.0 | 11a', '112 | 5560.0 | 11a', '114 | 5570.0 | 11a', '116 | 5580.0 | 11a', '118 | 5590.0 | 11a', '120 | 5600.0 | 11a', '122 | 5610.0 | 11a', '124 | 5620.0 | 11a', '126 | 5630.0 | 11a', '128 | 5640.0 | 11a', '132 | 5660.0 | 11a', '134 | 5670.0 | 11a', '136 | 5680.0 | 11a', '138 | 5690.0 | 11a', '140 | 5700.0 | 11a', '142 | 5710.0 | 11a', '144 | 5720.0 | 11a', '149 | 5745.0 | 11a (SRD)', '151 | 5755.0 | 11a (SRD)', '153 | 5765.0 | 11a (SRD)', '155 | 5775.0 | 11a (SRD)', '157 | 5785.0 | 11a (SRD)', '159 | 5795.0 | 11a (SRD)', '161 | 5805.0 | 11a (SRD)', '165 | 5825.0 | 11a (SRD)', '172 | 5860.0 | 11p', '174 | 5870.0 | 11p', '176 | 5880.0 | 11p', '178 | 5890.0 | 11p', '180 | 5900.0 | 11p', '182 | 5910.0 | 11p', '184 | 5920.0 | 11p'] + + + num_opts + 0 + + + option0 + 0 + + + option1 + 1 + + + option2 + 2 + + + option3 + 3 + + + option4 + 4 + + + options + [2412000000.0, 2417000000.0, 2422000000.0, 2427000000.0, 2432000000.0, 2437000000.0, 2442000000.0, 2447000000.0, 2452000000.0, 2457000000.0, 2462000000.0, 2467000000.0, 2472000000.0, 2484000000.0, 5170000000.0, 5180000000.0, 5190000000.0, 5200000000.0, 5210000000.0, 5220000000.0, 5230000000.0, 5240000000.0, 5250000000.0, 5260000000.0, 5270000000.0, 5280000000.0, 5290000000.0, 5300000000.0, 5310000000.0, 5320000000.0, 5500000000.0, 5510000000.0, 5520000000.0, 5530000000.0, 5540000000.0, 5550000000.0, 5560000000.0, 5570000000.0, 5580000000.0, 5590000000.0, 5600000000.0, 5610000000.0, 5620000000.0, 5630000000.0, 5640000000.0, 5660000000.0, 5670000000.0, 5680000000.0, 5690000000.0, 5700000000.0, 5710000000.0, 5720000000.0, 5745000000.0, 5755000000.0, 5765000000.0, 5775000000.0, 5785000000.0, 5795000000.0, 5805000000.0, 5825000000.0, 5860000000.0, 5870000000.0, 5880000000.0, 5890000000.0, 5900000000.0, 5910000000.0, 5920000000.0] + + + orient + Qt.QVBoxLayout + + + type + real + + + widget + combo_box + + + + variable_qtgui_range + + comment + + + + value + 0.95 + + + _enabled + True + + + _coordinate + (440, 76) + + + gui_hint + + + + _rotation + 0 + + + id + gain + + + label + + + + min_len + 200 + + + orient + Qt.Horizontal + + + start + 0 + + + step + 0.01 + + + stop + 1 + + + rangeType + float + + + widget + counter_slider + + + + variable_qtgui_chooser + + comment + + + + value + 11e6 + + + _enabled + True + + + _coordinate + (128, 76) + + + gui_hint + + + + _rotation + 0 + + + id + lo_offset + + + label0 + + + + label1 + + + + label2 + + + + label3 + + + + label4 + + + + label + + + + labels + [] + + + num_opts + 3 + + + option0 + 0 + + + option1 + 6e6 + + + option2 + 11e6 + + + option3 + 3 + + + option4 + 4 + + + options + [0, 1, 2] + + + orient + Qt.QVBoxLayout + + + type + real + + + widget + combo_box + + + + variable + + comment + + + + _enabled + 1 + + + _coordinate + (1264, 68) + + + _rotation + 0 + + + id + out_buf_size + + + value + 96000 + + + + variable_qtgui_chooser + + comment + + + + value + 20e6 + + + _enabled + True + + + _coordinate + (752, 76) + + + gui_hint + + + + _rotation + 0 + + + id + samp_rate + + + label0 + + + + label1 + + + + label2 + + + + label3 + + + + label4 + + + + label + + + + labels + ["1 MHz", "5 MHz", "10 MHz", "20 MHz"] + + + num_opts + 0 + + + option0 + 0 + + + option1 + 1 + + + option2 + 2 + + + option3 + 3 + + + option4 + 4 + + + options + [1e6,5e6, 10e6, 20e6] + + + orient + Qt.QVBoxLayout + + + type + real + + + widget + combo_box + + + + variable + + comment + + + + _enabled + True + + + _coordinate + (8, 204) + + + _rotation + 0 + + + id + sync_length + + + value + 320 + + + + variable_qtgui_chooser + + comment + + + + value + 5890000000 + + + _enabled + True + + + _coordinate + (1736, 68) + + + gui_hint + + + + _rotation + 0 + + + id + tx_freq + + + label0 + + + + label1 + + + + label2 + + + + label3 + + + + label4 + + + + label + + + + labels + [' 1 | 2412.0 | 11g', ' 2 | 2417.0 | 11g', ' 3 | 2422.0 | 11g', ' 4 | 2427.0 | 11g', ' 5 | 2432.0 | 11g', ' 6 | 2437.0 | 11g', ' 7 | 2442.0 | 11g', ' 8 | 2447.0 | 11g', ' 9 | 2452.0 | 11g', ' 10 | 2457.0 | 11g', ' 11 | 2462.0 | 11g', ' 12 | 2467.0 | 11g', ' 13 | 2472.0 | 11g', ' 14 | 2484.0 | 11g', ' 34 | 5170.0 | 11a', ' 36 | 5180.0 | 11a', ' 38 | 5190.0 | 11a', ' 40 | 5200.0 | 11a', ' 42 | 5210.0 | 11a', ' 44 | 5220.0 | 11a', ' 46 | 5230.0 | 11a', ' 48 | 5240.0 | 11a', ' 50 | 5250.0 | 11a', ' 52 | 5260.0 | 11a', ' 54 | 5270.0 | 11a', ' 56 | 5280.0 | 11a', ' 58 | 5290.0 | 11a', ' 60 | 5300.0 | 11a', ' 62 | 5310.0 | 11a', ' 64 | 5320.0 | 11a', '100 | 5500.0 | 11a', '102 | 5510.0 | 11a', '104 | 5520.0 | 11a', '106 | 5530.0 | 11a', '108 | 5540.0 | 11a', '110 | 5550.0 | 11a', '112 | 5560.0 | 11a', '114 | 5570.0 | 11a', '116 | 5580.0 | 11a', '118 | 5590.0 | 11a', '120 | 5600.0 | 11a', '122 | 5610.0 | 11a', '124 | 5620.0 | 11a', '126 | 5630.0 | 11a', '128 | 5640.0 | 11a', '132 | 5660.0 | 11a', '134 | 5670.0 | 11a', '136 | 5680.0 | 11a', '138 | 5690.0 | 11a', '140 | 5700.0 | 11a', '142 | 5710.0 | 11a', '144 | 5720.0 | 11a', '149 | 5745.0 | 11a (SRD)', '151 | 5755.0 | 11a (SRD)', '153 | 5765.0 | 11a (SRD)', '155 | 5775.0 | 11a (SRD)', '157 | 5785.0 | 11a (SRD)', '159 | 5795.0 | 11a (SRD)', '161 | 5805.0 | 11a (SRD)', '165 | 5825.0 | 11a (SRD)', '172 | 5860.0 | 11p', '174 | 5870.0 | 11p', '176 | 5880.0 | 11p', '178 | 5890.0 | 11p', '180 | 5900.0 | 11p', '182 | 5910.0 | 11p', '184 | 5920.0 | 11p'] + + + num_opts + 0 + + + option0 + 0 + + + option1 + 1 + + + option2 + 2 + + + option3 + 3 + + + option4 + 4 + + + options + [2412000000.0, 2417000000.0, 2422000000.0, 2427000000.0, 2432000000.0, 2437000000.0, 2442000000.0, 2447000000.0, 2452000000.0, 2457000000.0, 2462000000.0, 2467000000.0, 2472000000.0, 2484000000.0, 5170000000.0, 5180000000.0, 5190000000.0, 5200000000.0, 5210000000.0, 5220000000.0, 5230000000.0, 5240000000.0, 5250000000.0, 5260000000.0, 5270000000.0, 5280000000.0, 5290000000.0, 5300000000.0, 5310000000.0, 5320000000.0, 5500000000.0, 5510000000.0, 5520000000.0, 5530000000.0, 5540000000.0, 5550000000.0, 5560000000.0, 5570000000.0, 5580000000.0, 5590000000.0, 5600000000.0, 5610000000.0, 5620000000.0, 5630000000.0, 5640000000.0, 5660000000.0, 5670000000.0, 5680000000.0, 5690000000.0, 5700000000.0, 5710000000.0, 5720000000.0, 5745000000.0, 5755000000.0, 5765000000.0, 5775000000.0, 5785000000.0, 5795000000.0, 5805000000.0, 5825000000.0, 5860000000.0, 5870000000.0, 5880000000.0, 5890000000.0, 5900000000.0, 5910000000.0, 5920000000.0] + + + orient + Qt.QVBoxLayout + + + type + real + + + widget + combo_box + + + + variable_qtgui_range + + comment + + + + value + 0.9 + + + _enabled + 1 + + + _coordinate + (1376, 68) + + + gui_hint + + + + _rotation + 0 + + + id + tx_gain + + + label + + + + min_len + 200 + + + orient + Qt.Horizontal + + + start + 0 + + + step + 0.01 + + + stop + 1 + + + rangeType + float + + + widget + counter_slider + + + + variable_qtgui_chooser + + comment + + + + value + 10e6 + + + _enabled + True + + + _coordinate + (1808, 212) + + + gui_hint + + + + _rotation + 0 + + + id + tx_samp_rate + + + label0 + + + + label1 + + + + label2 + + + + label3 + + + + label4 + + + + label + + + + labels + ["1 MHz", "5 MHz", "10 MHz", "20 MHz"] + + + num_opts + 0 + + + option0 + 0 + + + option1 + 1 + + + option2 + 2 + + + option3 + 3 + + + option4 + 4 + + + options + [1e6,5e6, 10e6, 20e6] + + + orient + Qt.QVBoxLayout + + + type + real + + + widget + combo_box + + + + variable + + comment + + + + _enabled + True + + + _coordinate + (8, 140) + + + _rotation + 0 + + + id + window_size + + + value + 48 + + + + blocks_complex_to_mag + + alias + + + + comment + + + + affinity + + + + _enabled + True + + + _coordinate + (488, 440) + + + _rotation + 0 + + + id + blocks_complex_to_mag_0 + + + maxoutbuf + 0 + + + minoutbuf + 0 + + + vlen + 1 + + + + blocks_complex_to_mag_squared + + alias + + + + comment + + + + affinity + + + + _enabled + True + + + _coordinate + (256, 264) + + + _rotation + 0 + + + id + blocks_complex_to_mag_squared_0 + + + maxoutbuf + 0 + + + minoutbuf + 0 + + + vlen + 1 + + + + blocks_conjugate_cc + + alias + + + + comment + + + + affinity + + + + _enabled + True + + + _coordinate + (128, 384) + + + _rotation + 180 + + + id + blocks_conjugate_cc_0 + + + maxoutbuf + 0 + + + minoutbuf + 0 + + + + blocks_delay + + alias + + + + comment + + + + affinity + + + + delay + sync_length + + + _enabled + True + + + _coordinate + (648, 388) + + + _rotation + 0 + + + id + blocks_delay_0 + + + maxoutbuf + 0 + + + minoutbuf + 0 + + + num_ports + 1 + + + type + complex + + + vlen + 1 + + + + blocks_delay + + alias + + + + comment + + + + affinity + + + + delay + 16 + + + _enabled + True + + + _coordinate + (280, 300) + + + _rotation + 0 + + + id + blocks_delay_0_0 + + + maxoutbuf + 0 + + + minoutbuf + 0 + + + num_ports + 1 + + + type + complex + + + vlen + 1 + + + + blocks_divide_xx + + alias + + + + comment + + + + affinity + + + + _enabled + True + + + _coordinate + (648, 464) + + + _rotation + 180 + + + id + blocks_divide_xx_0 + + + type + float + + + maxoutbuf + 0 + + + minoutbuf + 0 + + + num_inputs + 2 + + + vlen + 1 + + + + blocks_file_sink + + append + False + + + alias + + + + comment + + + + affinity + + + + _enabled + 1 + + + file + /tmp/out.pcap + + + _coordinate + (920, 420) + + + _rotation + 0 + + + id + blocks_file_sink_0 + + + type + byte + + + unbuffered + False + + + vlen + 1 + + + + blocks_multiply_const_vxx + + alias + + + + comment + + + + const + 0.6 + + + affinity + + + + _enabled + 1 + + + _coordinate + (1344, 428) + + + _rotation + 180 + + + id + blocks_multiply_const_vxx_0 + + + type + complex + + + maxoutbuf + 0 + + + minoutbuf + 100000 + + + vlen + 1 + + + + blocks_multiply_xx + + alias + + + + comment + + + + affinity + + + + _enabled + True + + + _coordinate + (96, 424) + + + _rotation + 0 + + + id + blocks_multiply_xx_0 + + + type + complex + + + maxoutbuf + 0 + + + minoutbuf + 0 + + + num_inputs + 2 + + + vlen + 1 + + + + blocks_null_source + + alias + + + + bus_conns + [[0,],] + + + comment + + + + affinity + + + + _enabled + 1 + + + _coordinate + (1832, 416) + + + _rotation + 180 + + + id + blocks_null_source_0 + + + maxoutbuf + 0 + + + minoutbuf + 0 + + + num_outputs + 1 + + + type + complex + + + vlen + 1 + + + + blocks_pdu_to_tagged_stream + + alias + + + + comment + + + + affinity + + + + _enabled + True + + + _coordinate + (224, 692) + + + _rotation + 180 + + + id + blocks_pdu_to_tagged_stream_1 + + + type + complex + + + tag + packet_len + + + maxoutbuf + 0 + + + minoutbuf + 0 + + + + blocks_socket_pdu + + alias + + + + comment + + + + affinity + + + + _enabled + 1 + + + _coordinate + (1192, 228) + + + _rotation + 0 + + + host + + + + id + blocks_socket_pdu_0 + + + mtu + 10000 + + + maxoutbuf + 0 + + + minoutbuf + 0 + + + port + 52001 + + + tcp_no_delay + False + + + type + "UDP_SERVER" + + + + blocks_stream_to_vector + + alias + + + + comment + + + + affinity + + + + _enabled + True + + + _coordinate + (780, 432) + + + _rotation + 270 + + + id + blocks_stream_to_vector_0 + + + type + complex + + + maxoutbuf + 0 + + + minoutbuf + 0 + + + num_items + 64 + + + vlen + 1 + + + + blocks_udp_sink + + alias + + + + comment + + + + affinity + + + + ipaddr + localhost + + + port + 52001 + + + _enabled + 1 + + + _coordinate + (904, 652) + + + _rotation + 0 + + + id + blocks_udp_sink_0 + + + type + byte + + + psize + 1472 + + + eof + True + + + vlen + 1 + + + + fft_vxx + + alias + + + + comment + + + + affinity + + + + _enabled + True + + + fft_size + 64 + + + forward + True + + + _coordinate + (48, 580) + + + _rotation + 0 + + + id + fft_vxx_0 + + + type + complex + + + maxoutbuf + 0 + + + minoutbuf + 0 + + + nthreads + 1 + + + shift + True + + + window + window.rectangular(64) + + + + foo_packet_pad2 + + alias + + + + comment + + + + affinity + + + + debug + False + + + delay_sec + 0.01 + + + delay + False + + + _enabled + 1 + + + _coordinate + (1320, 532) + + + _rotation + 0 + + + id + foo_packet_pad2_0 + + + maxoutbuf + 0 + + + minoutbuf + out_buf_size + + + pad_front + 100 + + + pad_tail + 1000 + + + + foo_wireshark_connector + + alias + + + + comment + + + + affinity + + + + debug + False + + + _enabled + 1 + + + _coordinate + (672, 668) + + + _rotation + 0 + + + id + foo_wireshark_connector_0 + + + maxoutbuf + 0 + + + minoutbuf + 0 + + + tech + 127 + + + + ieee802_11_decode_mac + + alias + + + + comment + + + + affinity + + + + debug + False + + + _enabled + 1 + + + _coordinate + (488, 604) + + + _rotation + 0 + + + id + ieee802_11_decode_mac_0 + + + log + True + + + maxoutbuf + 0 + + + minoutbuf + 0 + + + + ieee802_11_frame_equalizer + + algo + chan_est + + + bw + samp_rate + + + alias + + + + comment + + + + affinity + + + + debug + False + + + _enabled + True + + + freq + freq + + + _coordinate + (280, 580) + + + _rotation + 0 + + + id + ieee802_11_frame_equalizer_0 + + + log + False + + + maxoutbuf + 0 + + + minoutbuf + 0 + + + + ieee802_11_mac + + bss_mac + [0xff, 0xff, 0xff, 0xff, 0xff, 255] + + + alias + + + + comment + + + + affinity + + + + dst_mac + [0x42, 0x42, 0x42, 0x42, 0x42, 0x42] + + + _enabled + 1 + + + _coordinate + (1496, 252) + + + _rotation + 0 + + + id + ieee802_11_mac_0 + + + maxoutbuf + 0 + + + minoutbuf + 0 + + + src_mac + [0x23, 0x23, 0x23, 0x23, 0x23, 0x23] + + + + ieee802_11_moving_average_xx + + alias + + + + comment + + + + affinity + + + + _enabled + True + + + _coordinate + (248, 436) + + + _rotation + 0 + + + id + ieee802_11_moving_average_xx_0 + + + length + window_size + + + maxoutbuf + 0 + + + minoutbuf + 0 + + + type + complex + + + + ieee802_11_moving_average_xx + + alias + + + + comment + + + + affinity + + + + _enabled + True + + + _coordinate + (432, 260) + + + _rotation + 0 + + + id + ieee802_11_moving_average_xx_1 + + + length + window_size + 16 + + + maxoutbuf + 0 + + + minoutbuf + 0 + + + type + float + + + + ieee802_11_parse_mac + + alias + + + + comment + + + + affinity + + + + debug + True + + + _enabled + True + + + _coordinate + (680, 572) + + + _rotation + 0 + + + id + ieee802_11_parse_mac_0 + + + log + True + + + maxoutbuf + 0 + + + minoutbuf + 0 + + + + ieee802_11_sync_long + + alias + + + + comment + + + + affinity + + + + debug + False + + + _enabled + True + + + _coordinate + (800, 284) + + + _rotation + 0 + + + id + ieee802_11_sync_long_0 + + + log + True + + + maxoutbuf + 0 + + + minoutbuf + 0 + + + sync_length + sync_length + + + + ieee802_11_sync_short + + alias + + + + comment + + + + affinity + + + + debug + False + + + _enabled + True + + + _coordinate + (472, 304) + + + _rotation + 0 + + + id + ieee802_11_sync_short_0 + + + log + False + + + maxoutbuf + 0 + + + minoutbuf + 0 + + + min_plateau + 2 + + + threshold + 0.56 + + + + qtgui_const_sink_x + + autoscale + False + + + axislabels + True + + + alias + + + + comment + + + + affinity + + + + _enabled + True + + + _coordinate + (224, 748) + + + gui_hint + + + + _rotation + 0 + + + grid + False + + + id + qtgui_const_sink_x_0 + + + legend + True + + + alpha1 + 1.0 + + + color1 + "blue" + + + label1 + + + + marker1 + 0 + + + style1 + 0 + + + width1 + 1 + + + alpha10 + 1.0 + + + color10 + "red" + + + label10 + + + + marker10 + 0 + + + style10 + 0 + + + width10 + 1 + + + alpha2 + 1.0 + + + color2 + "red" + + + label2 + + + + marker2 + 0 + + + style2 + 0 + + + width2 + 1 + + + alpha3 + 1.0 + + + color3 + "red" + + + label3 + + + + marker3 + 0 + + + style3 + 0 + + + width3 + 1 + + + alpha4 + 1.0 + + + color4 + "red" + + + label4 + + + + marker4 + 0 + + + style4 + 0 + + + width4 + 1 + + + alpha5 + 1.0 + + + color5 + "red" + + + label5 + + + + marker5 + 0 + + + style5 + 0 + + + width5 + 1 + + + alpha6 + 1.0 + + + color6 + "red" + + + label6 + + + + marker6 + 0 + + + style6 + 0 + + + width6 + 1 + + + alpha7 + 1.0 + + + color7 + "red" + + + label7 + + + + marker7 + 0 + + + style7 + 0 + + + width7 + 1 + + + alpha8 + 1.0 + + + color8 + "red" + + + label8 + + + + marker8 + 0 + + + style8 + 0 + + + width8 + 1 + + + alpha9 + 1.0 + + + color9 + "red" + + + label9 + + + + marker9 + 0 + + + style9 + 0 + + + width9 + 1 + + + name + "" + + + nconnections + 1 + + + size + 48*10 + + + tr_chan + 0 + + + tr_level + 0.0 + + + tr_mode + qtgui.TRIG_MODE_FREE + + + tr_slope + qtgui.TRIG_SLOPE_POS + + + tr_tag + "" + + + type + complex + + + update_time + 0.10 + + + xmax + 2 + + + xmin + -2 + + + ymax + 2 + + + ymin + -2 + + + + qtgui_time_sink_x + + autoscale + False + + + axislabels + True + + + alias + + + + comment + + + + ctrlpanel + False + + + affinity + + + + entags + True + + + _enabled + True + + + _coordinate + (232, 484) + + + gui_hint + + + + _rotation + 180 + + + grid + False + + + id + qtgui_time_sink_x_0 + + + legend + True + + + alpha1 + 1.0 + + + color1 + "blue" + + + label1 + + + + marker1 + -1 + + + style1 + 1 + + + width1 + 1 + + + alpha10 + 1.0 + + + color10 + "blue" + + + label10 + + + + marker10 + -1 + + + style10 + 1 + + + width10 + 1 + + + alpha2 + 1.0 + + + color2 + "red" + + + label2 + + + + marker2 + -1 + + + style2 + 1 + + + width2 + 1 + + + alpha3 + 1.0 + + + color3 + "green" + + + label3 + + + + marker3 + -1 + + + style3 + 1 + + + width3 + 1 + + + alpha4 + 1.0 + + + color4 + "black" + + + label4 + + + + marker4 + -1 + + + style4 + 1 + + + width4 + 1 + + + alpha5 + 1.0 + + + color5 + "cyan" + + + label5 + + + + marker5 + -1 + + + style5 + 1 + + + width5 + 1 + + + alpha6 + 1.0 + + + color6 + "magenta" + + + label6 + + + + marker6 + -1 + + + style6 + 1 + + + width6 + 1 + + + alpha7 + 1.0 + + + color7 + "yellow" + + + label7 + + + + marker7 + -1 + + + style7 + 1 + + + width7 + 1 + + + alpha8 + 1.0 + + + color8 + "dark red" + + + label8 + + + + marker8 + -1 + + + style8 + 1 + + + width8 + 1 + + + alpha9 + 1.0 + + + color9 + "dark green" + + + label9 + + + + marker9 + -1 + + + style9 + 1 + + + width9 + 1 + + + name + "" + + + nconnections + 1 + + + size + 1024 + + + srate + samp_rate + + + stemplot + False + + + tr_chan + 0 + + + tr_delay + 0 + + + tr_level + 0.0 + + + tr_mode + qtgui.TRIG_MODE_FREE + + + tr_slope + qtgui.TRIG_SLOPE_POS + + + tr_tag + "" + + + type + float + + + update_time + 0.10 + + + ylabel + Amplitude + + + yunit + "" + + + ymax + 1 + + + ymin + -1 + + + + uhd_usrp_sink + + alias + + + + ant0 + TX/RX + + + bw0 + 0 + + + center_freq0 + uhd.tune_request(tx_freq, rf_freq = tx_freq - lo_offset, rf_freq_policy=uhd.tune_request.POLICY_MANUAL) + + + norm_gain0 + True + + + gain0 + tx_gain + + + ant10 + + + + bw10 + 0 + + + center_freq10 + 0 + + + norm_gain10 + False + + + gain10 + 0 + + + ant11 + + + + bw11 + 0 + + + center_freq11 + 0 + + + norm_gain11 + False + + + gain11 + 0 + + + ant12 + + + + bw12 + 0 + + + center_freq12 + 0 + + + norm_gain12 + False + + + gain12 + 0 + + + ant13 + + + + bw13 + 0 + + + center_freq13 + 0 + + + norm_gain13 + False + + + gain13 + 0 + + + ant14 + + + + bw14 + 0 + + + center_freq14 + 0 + + + norm_gain14 + False + + + gain14 + 0 + + + ant15 + + + + bw15 + 0 + + + center_freq15 + 0 + + + norm_gain15 + False + + + gain15 + 0 + + + ant16 + + + + bw16 + 0 + + + center_freq16 + 0 + + + norm_gain16 + False + + + gain16 + 0 + + + ant17 + + + + bw17 + 0 + + + center_freq17 + 0 + + + norm_gain17 + False + + + gain17 + 0 + + + ant18 + + + + bw18 + 0 + + + center_freq18 + 0 + + + norm_gain18 + False + + + gain18 + 0 + + + ant19 + + + + bw19 + 0 + + + center_freq19 + 0 + + + norm_gain19 + False + + + gain19 + 0 + + + ant1 + + + + bw1 + 0 + + + center_freq1 + 0 + + + norm_gain1 + False + + + gain1 + 0 + + + ant20 + + + + bw20 + 0 + + + center_freq20 + 0 + + + norm_gain20 + False + + + gain20 + 0 + + + ant21 + + + + bw21 + 0 + + + center_freq21 + 0 + + + norm_gain21 + False + + + gain21 + 0 + + + ant22 + + + + bw22 + 0 + + + center_freq22 + 0 + + + norm_gain22 + False + + + gain22 + 0 + + + ant23 + + + + bw23 + 0 + + + center_freq23 + 0 + + + norm_gain23 + False + + + gain23 + 0 + + + ant24 + + + + bw24 + 0 + + + center_freq24 + 0 + + + norm_gain24 + False + + + gain24 + 0 + + + ant25 + + + + bw25 + 0 + + + center_freq25 + 0 + + + norm_gain25 + False + + + gain25 + 0 + + + ant26 + + + + bw26 + 0 + + + center_freq26 + 0 + + + norm_gain26 + False + + + gain26 + 0 + + + ant27 + + + + bw27 + 0 + + + center_freq27 + 0 + + + norm_gain27 + False + + + gain27 + 0 + + + ant28 + + + + bw28 + 0 + + + center_freq28 + 0 + + + norm_gain28 + False + + + gain28 + 0 + + + ant29 + + + + bw29 + 0 + + + center_freq29 + 0 + + + norm_gain29 + False + + + gain29 + 0 + + + ant2 + + + + bw2 + 0 + + + center_freq2 + 0 + + + norm_gain2 + False + + + gain2 + 0 + + + ant30 + + + + bw30 + 0 + + + center_freq30 + 0 + + + norm_gain30 + False + + + gain30 + 0 + + + ant31 + + + + bw31 + 0 + + + center_freq31 + 0 + + + norm_gain31 + False + + + gain31 + 0 + + + ant3 + + + + bw3 + 0 + + + center_freq3 + 0 + + + norm_gain3 + False + + + gain3 + 0 + + + ant4 + + + + bw4 + 0 + + + center_freq4 + 0 + + + norm_gain4 + False + + + gain4 + 0 + + + ant5 + + + + bw5 + 0 + + + center_freq5 + 0 + + + norm_gain5 + False + + + gain5 + 0 + + + ant6 + + + + bw6 + 0 + + + center_freq6 + 0 + + + norm_gain6 + False + + + gain6 + 0 + + + ant7 + + + + bw7 + 0 + + + center_freq7 + 0 + + + norm_gain7 + False + + + gain7 + 0 + + + ant8 + + + + bw8 + 0 + + + center_freq8 + 0 + + + norm_gain8 + False + + + gain8 + 0 + + + ant9 + + + + bw9 + 0 + + + center_freq9 + 0 + + + norm_gain9 + False + + + gain9 + 0 + + + clock_rate + 0.0 + + + comment + + + + affinity + + + + dev_addr + + + + dev_args + "" + + + _enabled + 1 + + + _coordinate + (1568, 532) + + + _rotation + 0 + + + id + uhd_usrp_sink_0 + + + type + fc32 + + + clock_source0 + + + + sd_spec0 + + + + time_source0 + + + + clock_source1 + + + + sd_spec1 + + + + time_source1 + + + + clock_source2 + + + + sd_spec2 + + + + time_source2 + + + + clock_source3 + + + + sd_spec3 + + + + time_source3 + + + + clock_source4 + + + + sd_spec4 + + + + time_source4 + + + + clock_source5 + + + + sd_spec5 + + + + time_source5 + + + + clock_source6 + + + + sd_spec6 + + + + time_source6 + + + + clock_source7 + + + + sd_spec7 + + + + time_source7 + + + + nchan + 1 + + + num_mboards + 1 + + + samp_rate + tx_samp_rate + + + hide_cmd_port + False + + + hide_lo_controls + True + + + stream_args + + + + stream_chans + [] + + + sync + pc_clock + + + len_tag_name + packet_len + + + otw + + + + + uhd_usrp_source + + alias + + + + ant0 + RX2 + + + bw0 + 0 + + + center_freq0 + uhd.tune_request(freq, rf_freq = freq - lo_offset, rf_freq_policy=uhd.tune_request.POLICY_MANUAL) + + + dc_offs_enb0 + False + + + iq_imbal_enb0 + False + + + norm_gain0 + True + + + gain0 + gain + + + lo_export0 + False + + + lo_source0 + internal + + + ant10 + + + + bw10 + 0 + + + center_freq10 + 0 + + + dc_offs_enb10 + "" + + + iq_imbal_enb10 + "" + + + norm_gain10 + False + + + gain10 + 0 + + + lo_export10 + False + + + lo_source10 + internal + + + ant11 + + + + bw11 + 0 + + + center_freq11 + 0 + + + dc_offs_enb11 + "" + + + iq_imbal_enb11 + "" + + + norm_gain11 + False + + + gain11 + 0 + + + lo_export11 + False + + + lo_source11 + internal + + + ant12 + + + + bw12 + 0 + + + center_freq12 + 0 + + + dc_offs_enb12 + "" + + + iq_imbal_enb12 + "" + + + norm_gain12 + False + + + gain12 + 0 + + + lo_export12 + False + + + lo_source12 + internal + + + ant13 + + + + bw13 + 0 + + + center_freq13 + 0 + + + dc_offs_enb13 + "" + + + iq_imbal_enb13 + "" + + + norm_gain13 + False + + + gain13 + 0 + + + lo_export13 + False + + + lo_source13 + internal + + + ant14 + + + + bw14 + 0 + + + center_freq14 + 0 + + + dc_offs_enb14 + "" + + + iq_imbal_enb14 + "" + + + norm_gain14 + False + + + gain14 + 0 + + + lo_export14 + False + + + lo_source14 + internal + + + ant15 + + + + bw15 + 0 + + + center_freq15 + 0 + + + dc_offs_enb15 + "" + + + iq_imbal_enb15 + "" + + + norm_gain15 + False + + + gain15 + 0 + + + lo_export15 + False + + + lo_source15 + internal + + + ant16 + + + + bw16 + 0 + + + center_freq16 + 0 + + + dc_offs_enb16 + "" + + + iq_imbal_enb16 + "" + + + norm_gain16 + False + + + gain16 + 0 + + + lo_export16 + False + + + lo_source16 + internal + + + ant17 + + + + bw17 + 0 + + + center_freq17 + 0 + + + dc_offs_enb17 + "" + + + iq_imbal_enb17 + "" + + + norm_gain17 + False + + + gain17 + 0 + + + lo_export17 + False + + + lo_source17 + internal + + + ant18 + + + + bw18 + 0 + + + center_freq18 + 0 + + + dc_offs_enb18 + "" + + + iq_imbal_enb18 + "" + + + norm_gain18 + False + + + gain18 + 0 + + + lo_export18 + False + + + lo_source18 + internal + + + ant19 + + + + bw19 + 0 + + + center_freq19 + 0 + + + dc_offs_enb19 + "" + + + iq_imbal_enb19 + "" + + + norm_gain19 + False + + + gain19 + 0 + + + lo_export19 + False + + + lo_source19 + internal + + + ant1 + + + + bw1 + 0 + + + center_freq1 + 0 + + + dc_offs_enb1 + "" + + + iq_imbal_enb1 + "" + + + norm_gain1 + False + + + gain1 + 0 + + + lo_export1 + False + + + lo_source1 + internal + + + ant20 + + + + bw20 + 0 + + + center_freq20 + 0 + + + dc_offs_enb20 + "" + + + iq_imbal_enb20 + "" + + + norm_gain20 + False + + + gain20 + 0 + + + lo_export20 + False + + + lo_source20 + internal + + + ant21 + + + + bw21 + 0 + + + center_freq21 + 0 + + + dc_offs_enb21 + "" + + + iq_imbal_enb21 + "" + + + norm_gain21 + False + + + gain21 + 0 + + + lo_export21 + False + + + lo_source21 + internal + + + ant22 + + + + bw22 + 0 + + + center_freq22 + 0 + + + dc_offs_enb22 + "" + + + iq_imbal_enb22 + "" + + + norm_gain22 + False + + + gain22 + 0 + + + lo_export22 + False + + + lo_source22 + internal + + + ant23 + + + + bw23 + 0 + + + center_freq23 + 0 + + + dc_offs_enb23 + "" + + + iq_imbal_enb23 + "" + + + norm_gain23 + False + + + gain23 + 0 + + + lo_export23 + False + + + lo_source23 + internal + + + ant24 + + + + bw24 + 0 + + + center_freq24 + 0 + + + dc_offs_enb24 + "" + + + iq_imbal_enb24 + "" + + + norm_gain24 + False + + + gain24 + 0 + + + lo_export24 + False + + + lo_source24 + internal + + + ant25 + + + + bw25 + 0 + + + center_freq25 + 0 + + + dc_offs_enb25 + "" + + + iq_imbal_enb25 + "" + + + norm_gain25 + False + + + gain25 + 0 + + + lo_export25 + False + + + lo_source25 + internal + + + ant26 + + + + bw26 + 0 + + + center_freq26 + 0 + + + dc_offs_enb26 + "" + + + iq_imbal_enb26 + "" + + + norm_gain26 + False + + + gain26 + 0 + + + lo_export26 + False + + + lo_source26 + internal + + + ant27 + + + + bw27 + 0 + + + center_freq27 + 0 + + + dc_offs_enb27 + "" + + + iq_imbal_enb27 + "" + + + norm_gain27 + False + + + gain27 + 0 + + + lo_export27 + False + + + lo_source27 + internal + + + ant28 + + + + bw28 + 0 + + + center_freq28 + 0 + + + dc_offs_enb28 + "" + + + iq_imbal_enb28 + "" + + + norm_gain28 + False + + + gain28 + 0 + + + lo_export28 + False + + + lo_source28 + internal + + + ant29 + + + + bw29 + 0 + + + center_freq29 + 0 + + + dc_offs_enb29 + "" + + + iq_imbal_enb29 + "" + + + norm_gain29 + False + + + gain29 + 0 + + + lo_export29 + False + + + lo_source29 + internal + + + ant2 + + + + bw2 + 0 + + + center_freq2 + 0 + + + dc_offs_enb2 + "" + + + iq_imbal_enb2 + "" + + + norm_gain2 + False + + + gain2 + 0 + + + lo_export2 + False + + + lo_source2 + internal + + + ant30 + + + + bw30 + 0 + + + center_freq30 + 0 + + + dc_offs_enb30 + "" + + + iq_imbal_enb30 + "" + + + norm_gain30 + False + + + gain30 + 0 + + + lo_export30 + False + + + lo_source30 + internal + + + ant31 + + + + bw31 + 0 + + + center_freq31 + 0 + + + dc_offs_enb31 + "" + + + iq_imbal_enb31 + "" + + + norm_gain31 + False + + + gain31 + 0 + + + lo_export31 + False + + + lo_source31 + internal + + + ant3 + + + + bw3 + 0 + + + center_freq3 + 0 + + + dc_offs_enb3 + "" + + + iq_imbal_enb3 + "" + + + norm_gain3 + False + + + gain3 + 0 + + + lo_export3 + False + + + lo_source3 + internal + + + ant4 + + + + bw4 + 0 + + + center_freq4 + 0 + + + dc_offs_enb4 + "" + + + iq_imbal_enb4 + "" + + + norm_gain4 + False + + + gain4 + 0 + + + lo_export4 + False + + + lo_source4 + internal + + + ant5 + + + + bw5 + 0 + + + center_freq5 + 0 + + + dc_offs_enb5 + "" + + + iq_imbal_enb5 + "" + + + norm_gain5 + False + + + gain5 + 0 + + + lo_export5 + False + + + lo_source5 + internal + + + ant6 + + + + bw6 + 0 + + + center_freq6 + 0 + + + dc_offs_enb6 + "" + + + iq_imbal_enb6 + "" + + + norm_gain6 + False + + + gain6 + 0 + + + lo_export6 + False + + + lo_source6 + internal + + + ant7 + + + + bw7 + 0 + + + center_freq7 + 0 + + + dc_offs_enb7 + "" + + + iq_imbal_enb7 + "" + + + norm_gain7 + False + + + gain7 + 0 + + + lo_export7 + False + + + lo_source7 + internal + + + ant8 + + + + bw8 + 0 + + + center_freq8 + 0 + + + dc_offs_enb8 + "" + + + iq_imbal_enb8 + "" + + + norm_gain8 + False + + + gain8 + 0 + + + lo_export8 + False + + + lo_source8 + internal + + + ant9 + + + + bw9 + 0 + + + center_freq9 + 0 + + + dc_offs_enb9 + "" + + + iq_imbal_enb9 + "" + + + norm_gain9 + False + + + gain9 + 0 + + + lo_export9 + False + + + lo_source9 + internal + + + clock_rate + 0.0 + + + comment + + + + affinity + + + + dev_addr + + + + dev_args + "" + + + _enabled + True + + + _coordinate + (24, 276) + + + _rotation + 0 + + + id + uhd_usrp_source_0 + + + maxoutbuf + 0 + + + clock_source0 + + + + sd_spec0 + + + + time_source0 + + + + clock_source1 + + + + sd_spec1 + + + + time_source1 + + + + clock_source2 + + + + sd_spec2 + + + + time_source2 + + + + clock_source3 + + + + sd_spec3 + + + + time_source3 + + + + clock_source4 + + + + sd_spec4 + + + + time_source4 + + + + clock_source5 + + + + sd_spec5 + + + + time_source5 + + + + clock_source6 + + + + sd_spec6 + + + + time_source6 + + + + clock_source7 + + + + sd_spec7 + + + + time_source7 + + + + minoutbuf + 0 + + + nchan + 1 + + + num_mboards + 1 + + + type + fc32 + + + samp_rate + samp_rate + + + hide_cmd_port + False + + + hide_lo_controls + True + + + stream_args + + + + stream_chans + [] + + + sync + + + + otw + + + + + wifi_phy_hier + + alias + + + + comment + + + + affinity + + + + _enabled + 1 + + + _coordinate + (1584, 364) + + + _rotation + 180 + + + id + wifi_phy_hier_0 + + + maxoutbuf + 0 + + + minoutbuf + 0 + + + bandwidth + 10e6 + + + chan_est + 0 + + + encoding + encoding + + + frequency + freq + + + sensitivity + 0.56 + + + + blocks_complex_to_mag_0 + blocks_divide_xx_0 + 0 + 0 + + + blocks_complex_to_mag_squared_0 + ieee802_11_moving_average_xx_1 + 0 + 0 + + + blocks_conjugate_cc_0 + blocks_multiply_xx_0 + 0 + 1 + + + blocks_delay_0 + ieee802_11_sync_long_0 + 0 + 1 + + + blocks_delay_0_0 + blocks_conjugate_cc_0 + 0 + 0 + + + blocks_delay_0_0 + ieee802_11_sync_short_0 + 0 + 0 + + + blocks_divide_xx_0 + ieee802_11_sync_short_0 + 0 + 2 + + + blocks_divide_xx_0 + qtgui_time_sink_x_0 + 0 + 0 + + + blocks_multiply_const_vxx_0 + foo_packet_pad2_0 + 0 + 0 + + + blocks_multiply_xx_0 + ieee802_11_moving_average_xx_0 + 0 + 0 + + + blocks_null_source_0 + wifi_phy_hier_0 + 0 + 0 + + + blocks_pdu_to_tagged_stream_1 + qtgui_const_sink_x_0 + 0 + 0 + + + blocks_socket_pdu_0 + ieee802_11_mac_0 + pdus + app in + + + blocks_stream_to_vector_0 + fft_vxx_0 + 0 + 0 + + + fft_vxx_0 + ieee802_11_frame_equalizer_0 + 0 + 0 + + + foo_packet_pad2_0 + uhd_usrp_sink_0 + 0 + 0 + + + foo_wireshark_connector_0 + blocks_file_sink_0 + 0 + 0 + + + foo_wireshark_connector_0 + blocks_udp_sink_0 + 0 + 0 + + + ieee802_11_decode_mac_0 + foo_wireshark_connector_0 + out + in + + + ieee802_11_decode_mac_0 + ieee802_11_parse_mac_0 + out + in + + + ieee802_11_frame_equalizer_0 + ieee802_11_decode_mac_0 + 0 + 0 + + + ieee802_11_frame_equalizer_0 + blocks_pdu_to_tagged_stream_1 + symbols + pdus + + + ieee802_11_mac_0 + wifi_phy_hier_0 + phy out + mac_in + + + ieee802_11_moving_average_xx_0 + blocks_complex_to_mag_0 + 0 + 0 + + + ieee802_11_moving_average_xx_0 + ieee802_11_sync_short_0 + 0 + 1 + + + ieee802_11_moving_average_xx_1 + blocks_divide_xx_0 + 0 + 1 + + + ieee802_11_sync_long_0 + blocks_stream_to_vector_0 + 0 + 0 + + + ieee802_11_sync_short_0 + blocks_delay_0 + 0 + 0 + + + ieee802_11_sync_short_0 + ieee802_11_sync_long_0 + 0 + 0 + + + uhd_usrp_source_0 + blocks_complex_to_mag_squared_0 + 0 + 0 + + + uhd_usrp_source_0 + blocks_delay_0_0 + 0 + 0 + + + uhd_usrp_source_0 + blocks_multiply_xx_0 + 0 + 0 + + + wifi_phy_hier_0 + ieee802_11_mac_0 + mac_out + phy in + + + wifi_phy_hier_0 + blocks_multiply_const_vxx_0 + 0 + 0 + + From 08c13968c9149726ae2c98d3db054cc67ceb51f0 Mon Sep 17 00:00:00 2001 From: Samantha Baker Date: Thu, 1 Oct 2020 17:11:44 -0700 Subject: [PATCH 08/22] Modified signer field to choice certificate; basic framework --- WavePacketBuilder.py | 62 ++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 57 insertions(+), 5 deletions(-) diff --git a/WavePacketBuilder.py b/WavePacketBuilder.py index fcf217e1..04b0dc78 100644 --- a/WavePacketBuilder.py +++ b/WavePacketBuilder.py @@ -6,7 +6,6 @@ class WAVEPacketBuilder(): - #hello def getWSMPayload(self, bsmString, key): payload = self.getLLCBytestring() + self.getWSMHeaders() + self.getIeee1609Dot2Data(bsmString,key) @@ -88,12 +87,65 @@ def getIeee1609Dot2Data(self, message, key): # this is a placeholder byte pattern that is unlikely to occur in practice, used to inject actual time # when packet is transmitted bytestring += "F0E0F0E0F0E0F0E0" - - # signer - bytestring += "80" - + # Digest (8 bytes) - this is a dummy value as we have not used certificates, which would be involved here + # NOT NEEDED, for if signerIdentifier = "digest" + # bytestring += "80" + # bytestring += "2122232425262728" + + # signerIdentifier = "certificate" + bytestring += "80" #@TODO figure out identifier for "certificate" choice + + #START CERTIFICATE BASE + + #version = 3 + bytestring += "03" + + #CertificateType = "explicit" + #@TODO implement ExplicitCertificate structure here + + #Issuer = "sha256AndDigest" + #dummy value here for issuerID bytestring += "2122232425262728" + + #toBeSigned + # - START ToBeSignedCertificate HERE - + + #id = linkageData + #this data is used to compare/add certificates to a CRL + #START linkageData HERE + + #iCert DUMMY VALUE + bytestring += "100" + + #linkage-value(size = 9) DUMMY VALUE + bytestring += "0fa12245f4c3c1cd54" + #END linkageData HERE + + #cracaID(size = 3) DUMMY VALUE + bytestring += "52641c" + + #crlSeries DUMMY VALUE + bytestring += "20" + + #START validityPeriod HERE + #start(time32) + bytestring += "24c34587" + + #duration + bytestring += "20" + + #END validityPeriod HERE + + # - OPTIONAL FIELDS CAN GO HERE - + # IN ORDER: + # region, assuranceLevel, appPermissions, certIssuePermissions, certRequestPermissions, + # canRequestRollover, encryptionKey + + #verifyKeyIndicator + #@TODO get more information on KeyIndicator + + # - END ToBeSignedCertificate HERE - # signature (ecdsaNistP256Signature = 80) bytestring += "80" From d081d3c23096a222813f9bff209a9b528c077ed2 Mon Sep 17 00:00:00 2001 From: Samantha Baker Date: Fri, 2 Oct 2020 14:29:58 -0700 Subject: [PATCH 09/22] signerIdentifier TODO resolved --- WavePacketBuilder.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/WavePacketBuilder.py b/WavePacketBuilder.py index 04b0dc78..7b76273e 100644 --- a/WavePacketBuilder.py +++ b/WavePacketBuilder.py @@ -94,7 +94,8 @@ def getIeee1609Dot2Data(self, message, key): # bytestring += "2122232425262728" # signerIdentifier = "certificate" - bytestring += "80" #@TODO figure out identifier for "certificate" choice + #Assuming digest is 80, set to 81 + bytestring += "81" #START CERTIFICATE BASE From 01fc07c7d9e0cba835173751374e62af831cac90 Mon Sep 17 00:00:00 2001 From: Geoff Twardokus Date: Tue, 6 Oct 2020 21:59:38 -0400 Subject: [PATCH 10/22] Adding some modified files to tracking - for backup purposes. These don't work yet. --- gr-ieee-files/decode_mac.cc | 357 ++++++++++++++++++++++ gr-ieee-files/sync_long.cc | 265 +++++++++++++++++ gr-ieee-files/viterbi_decoder.cc | 491 +++++++++++++++++++++++++++++++ 3 files changed, 1113 insertions(+) create mode 100644 gr-ieee-files/decode_mac.cc create mode 100644 gr-ieee-files/sync_long.cc create mode 100644 gr-ieee-files/viterbi_decoder.cc diff --git a/gr-ieee-files/decode_mac.cc b/gr-ieee-files/decode_mac.cc new file mode 100644 index 00000000..011d66db --- /dev/null +++ b/gr-ieee-files/decode_mac.cc @@ -0,0 +1,357 @@ +/* + * Copyright (C) 2013, 2016 Bastian Bloessl + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +#include + +#include "utils.h" +#include "viterbi_decoder.h" + +#include +#include + +using namespace gr::ieee802_11; + +#define LINKTYPE_IEEE802_11 105 /* http://www.tcpdump.org/linktypes.html */ + +class decode_mac_impl : public decode_mac { + +public: +decode_mac_impl(bool log, bool debug) : + block("decode_mac", + gr::io_signature::make(1, 1, 48), + gr::io_signature::make(0, 0, 0)), + d_log(log), + d_debug(debug), + d_snr(0), + d_nom_freq(0.0), + d_freq_offset(0.0), + d_ofdm(BPSK_1_2), + d_frame(d_ofdm, 0), + d_frame_complete(true) { + + message_port_register_out(pmt::mp("out")); +} + +int general_work (int noutput_items, gr_vector_int& ninput_items, + gr_vector_const_void_star& input_items, + gr_vector_void_star& output_items) { + + const uint8_t *in = (const uint8_t*)input_items[0]; + + int i = 0; + + std::vector tags; + const uint64_t nread = this->nitems_read(0); + + dout << "Decode MAC: input " << ninput_items[0] << std::endl; + + while(i < ninput_items[0]) { + + get_tags_in_range(tags, 0, nread + i, nread + i + 1, + pmt::string_to_symbol("wifi_start")); + + if(tags.size()) { + if (d_frame_complete == false) { + dout << "Warning: starting to receive new frame before old frame was complete" << std::endl; + dout << "Already copied " << copied << " out of " << d_frame.n_sym << " symbols of last frame" << std::endl; + } + d_frame_complete = false; + + pmt::pmt_t dict = tags[0].value; + int len_data = pmt::to_uint64(pmt::dict_ref(dict, pmt::mp("frame_bytes"), pmt::from_uint64(MAX_PSDU_SIZE+1))); + int encoding = pmt::to_uint64(pmt::dict_ref(dict, pmt::mp("encoding"), pmt::from_uint64(0))); + d_snr = pmt::to_double(pmt::dict_ref(dict, pmt::mp("snr"), pmt::from_double(0))); + d_nom_freq = pmt::to_double(pmt::dict_ref(dict, pmt::mp("freq"), pmt::from_double(0))); + d_freq_offset = pmt::to_double(pmt::dict_ref(dict, pmt::mp("freq_offset"), pmt::from_double(0))); + + ofdm_param ofdm = ofdm_param((Encoding)encoding); + frame_param frame = frame_param(ofdm, len_data); + + // check for maximum frame size + if(frame.n_sym <= MAX_SYM && frame.psdu_size <= MAX_PSDU_SIZE) { + d_ofdm = ofdm; + d_frame = frame; + copied = 0; + dout << "Decode MAC: frame start -- len " << len_data + << " symbols " << frame.n_sym << " encoding " + << encoding << std::endl; + } else { + dout << "Dropping frame which is too large (symbols or bits)" << std::endl; + } + } + + if(copied < d_frame.n_sym) { + dout << "copy one symbol, copied " << copied << " out of " << d_frame.n_sym << std::endl; + std::memcpy(d_rx_symbols + (copied * 48), in, 48); + copied++; + + /* + Here - add a condition to decode and check the pseudonym at a specified symbol? + */ + int SYMBOL_TO_DECODE = 17; + if(copied == SYMBOL_TO_DECODE) { + dout << "decoding selected symbol" << std::endl; + decode_selected(SYMBOL_TO_DECODE); + } + + if(copied == d_frame.n_sym) { + dout << "received complete frame - decoding" << std::endl; + decode(); + in += 48; + i++; + d_frame_complete = true; + break; + } + } + + in += 48; + i++; + } + + consume(0, i); + + return 0; +} + +void decode_selected(int symbol_to_decode) { + /* + working with frames of 1312 bits + OFDM in 802.11p uses 48 subcarriers per symbol + with BPSK 1/2, one bit per subcarrier -> 24 data bits per symbol + start by looking for the LLC type field which is bytes 47-48 -> bits 376-392 + symbol 15 will be bits 24*15 = 360 to 383 + go for symbol 16, will start with second half of the type field. + */ + dout<<"Entered decode_selected()"< 31) && (out_bytes[i] < 127)) { + dout << ((char) out_bytes[i]); + } else { + dout << "."; + } + } + dout << std::endl; +} + +private: + bool d_debug; + bool d_log; + + frame_param d_frame; + ofdm_param d_ofdm; + double d_snr; // dB + double d_nom_freq; // nominal frequency, Hz + double d_freq_offset; // frequency offset, Hz + viterbi_decoder d_decoder; + + uint8_t d_rx_symbols[48 * MAX_SYM]; + uint8_t d_rx_bits[MAX_ENCODED_BITS]; + uint8_t d_deinterleaved_bits[MAX_ENCODED_BITS]; + uint8_t out_bytes[MAX_PSDU_SIZE + 2]; // 2 for signal field + + int copied; + bool d_frame_complete; + + // added privates + uint8_t d_rx_selected_bits[MAX_ENCODED_BITS]; + viterbi_decoder d_selected_decoder; + uint8_t d_selected_deinterleaved_bits[MAX_ENCODED_BITS]; + uint8_t selected_out_bytes[MAX_PSDU_SIZE + 2]; + +}; + +decode_mac::sptr +decode_mac::make(bool log, bool debug) { + return gnuradio::get_initial_sptr(new decode_mac_impl(log, debug)); +} diff --git a/gr-ieee-files/sync_long.cc b/gr-ieee-files/sync_long.cc new file mode 100644 index 00000000..7171ca54 --- /dev/null +++ b/gr-ieee-files/sync_long.cc @@ -0,0 +1,265 @@ +/* + * Copyright (C) 2013, 2016 Bastian Bloessl + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +#include +#include "utils.h" +#include +#include +#include + +#include +#include + +using namespace gr::ieee802_11; +using namespace std; + + +bool compare_abs(const std::pair& first, const std::pair& second) { + return abs(get<0>(first)) > abs(get<0>(second)); +} + +class sync_long_impl : public sync_long { + +public: +sync_long_impl(unsigned int sync_length, bool log, bool debug) : block("sync_long", + gr::io_signature::make2(2, 2, sizeof(gr_complex), sizeof(gr_complex)), + gr::io_signature::make(1, 1, sizeof(gr_complex))), + d_fir(gr::filter::kernel::fir_filter_ccc(1, LONG)), + d_log(log), + d_debug(debug), + d_offset(0), + d_state(SYNC), + SYNC_LENGTH(sync_length) { + + set_tag_propagation_policy(block::TPP_DONT); + d_correlation = gr::fft::malloc_complex(8192); +} + +~sync_long_impl(){ + gr::fft::free(d_correlation); +} + +int general_work (int noutput, gr_vector_int& ninput_items, + gr_vector_const_void_star& input_items, + gr_vector_void_star& output_items) { + + const gr_complex *in = (const gr_complex*)input_items[0]; + const gr_complex *in_delayed = (const gr_complex*)input_items[1]; + gr_complex *out = (gr_complex*)output_items[0]; + + dout << "LONG ninput[0] " << ninput_items[0] << " ninput[1] " << + ninput_items[1] << " noutput " << noutput << + " state " << d_state << std::endl; + + int ninput = std::min(std::min(ninput_items[0], ninput_items[1]), 8192); + + const uint64_t nread = nitems_read(0); + get_tags_in_range(d_tags, 0, nread, nread + ninput); + if (d_tags.size()) { + std::sort(d_tags.begin(), d_tags.end(), gr::tag_t::offset_compare); + + const uint64_t offset = d_tags.front().offset; + + if(offset > nread) { + ninput = offset - nread; + } else { + if(d_offset && (d_state == SYNC)) { + throw std::runtime_error("wtf"); + } + if(d_state == COPY) { + d_state = RESET; + } + d_freq_offset_short = pmt::to_double(d_tags.front().value); + } + } + + + int i = 0; + int o = 0; + + switch(d_state) { + + case SYNC: + d_fir.filterN(d_correlation, in, std::min(SYNC_LENGTH, std::max(ninput - 63, 0))); + + while(i + 63 < ninput) { + + d_cor.push_back(pair(d_correlation[i], d_offset)); + + i++; + d_offset++; + + if(d_offset == SYNC_LENGTH) { + search_frame_start(); + //mylog(boost::format("LONG: frame start at %1%") % d_frame_start); + d_offset = 0; + d_count = 0; + d_state = COPY; + + break; + } + } + + break; + + case COPY: + while(i < ninput && o < noutput) { + + int rel = d_offset - d_frame_start; + + if(!rel) { + add_item_tag(0, nitems_written(0), + pmt::string_to_symbol("wifi_start"), + pmt::from_double(d_freq_offset_short - d_freq_offset), + pmt::string_to_symbol(name())); + } + + if(rel >= 0 && (rel < 128 || ((rel - 128) % 80) > 15)) { + out[o] = in_delayed[i] * exp(gr_complex(0, d_offset * d_freq_offset)); + o++; + } + + i++; + d_offset++; + } + + break; + + case RESET: { + while(o < noutput) { + if(((d_count + o) % 64) == 0) { + d_offset = 0; + d_state = SYNC; + break; + } else { + out[o] = 0; + o++; + } + } + + break; + } + } + + dout << "produced : " << o << " consumed: " << i << std::endl; + + d_count += o; + consume(0, i); + consume(1, i); + return o; +} + +void forecast (int noutput_items, gr_vector_int &ninput_items_required) { + + // in sync state we need at least a symbol to correlate + // with the pattern + if(d_state == SYNC) { + ninput_items_required[0] = 64; + ninput_items_required[1] = 64; + + } else { + ninput_items_required[0] = noutput_items; + ninput_items_required[1] = noutput_items; + } +} + +void search_frame_start() { + + // sort list (highest correlation first) + assert(d_cor.size() == SYNC_LENGTH); + d_cor.sort(compare_abs); + + // copy list in vector for nicer access + vector > vec(d_cor.begin(), d_cor.end()); + d_cor.clear(); + + // in case we don't find anything use SYNC_LENGTH + d_frame_start = SYNC_LENGTH; + + for(int i = 0; i < 3; i++) { + for(int k = i + 1; k < 4; k++) { + gr_complex first; + gr_complex second; + if(get<1>(vec[i]) > get<1>(vec[k])) { + first = get<0>(vec[k]); + second = get<0>(vec[i]); + } else { + first = get<0>(vec[i]); + second = get<0>(vec[k]); + } + int diff = abs(get<1>(vec[i]) - get<1>(vec[k])); + if(diff == 64) { + d_frame_start = min(get<1>(vec[i]), get<1>(vec[k])); + d_freq_offset = arg(first * conj(second)) / 64; + // nice match found, return immediately + return; + + } else if(diff == 63) { + d_frame_start = min(get<1>(vec[i]), get<1>(vec[k])); + d_freq_offset = arg(first * conj(second)) / 63; + } else if(diff == 65) { + d_frame_start = min(get<1>(vec[i]), get<1>(vec[k])); + d_freq_offset = arg(first * conj(second)) / 65; + } + } + } +} + +private: + enum {SYNC, COPY, RESET} d_state; + int d_count; + int d_offset; + int d_frame_start; + float d_freq_offset; + double d_freq_offset_short; + + gr_complex *d_correlation; + list > d_cor; + std::vector d_tags; + gr::filter::kernel::fir_filter_ccc d_fir; + + const bool d_log; + const bool d_debug; + const int SYNC_LENGTH; + + static const std::vector LONG; +}; + +sync_long::sptr +sync_long::make(unsigned int sync_length, bool log, bool debug) { + return gnuradio::get_initial_sptr(new sync_long_impl(sync_length, log, debug)); +} + +const std::vector sync_long_impl::LONG = { + +gr_complex(-0.0455, -1.0679), gr_complex( 0.3528, -0.9865), gr_complex( 0.8594, 0.7348), gr_complex( 0.1874, 0.2475), +gr_complex( 0.5309, -0.7784), gr_complex(-1.0218, -0.4897), gr_complex(-0.3401, -0.9423), gr_complex( 0.8657, -0.2298), +gr_complex( 0.4734, 0.0362), gr_complex( 0.0088, -1.0207), gr_complex(-1.2142, -0.4205), gr_complex( 0.2172, -0.5195), +gr_complex( 0.5207, -0.1326), gr_complex(-0.1995, 1.4259), gr_complex( 1.0583, -0.0363), gr_complex( 0.5547, -0.5547), +gr_complex( 0.3277, 0.8728), gr_complex(-0.5077, 0.3488), gr_complex(-1.1650, 0.5789), gr_complex( 0.7297, 0.8197), +gr_complex( 0.6173, 0.1253), gr_complex(-0.5353, 0.7214), gr_complex(-0.5011, -0.1935), gr_complex(-0.3110, -1.3392), +gr_complex(-1.0818, -0.1470), gr_complex(-1.1300, -0.1820), gr_complex( 0.6663, -0.6571), gr_complex(-0.0249, 0.4773), +gr_complex(-0.8155, 1.0218), gr_complex( 0.8140, 0.9396), gr_complex( 0.1090, 0.8662), gr_complex(-1.3868, -0.0000), +gr_complex( 0.1090, -0.8662), gr_complex( 0.8140, -0.9396), gr_complex(-0.8155, -1.0218), gr_complex(-0.0249, -0.4773), +gr_complex( 0.6663, 0.6571), gr_complex(-1.1300, 0.1820), gr_complex(-1.0818, 0.1470), gr_complex(-0.3110, 1.3392), +gr_complex(-0.5011, 0.1935), gr_complex(-0.5353, -0.7214), gr_complex( 0.6173, -0.1253), gr_complex( 0.7297, -0.8197), +gr_complex(-1.1650, -0.5789), gr_complex(-0.5077, -0.3488), gr_complex( 0.3277, -0.8728), gr_complex( 0.5547, 0.5547), +gr_complex( 1.0583, 0.0363), gr_complex(-0.1995, -1.4259), gr_complex( 0.5207, 0.1326), gr_complex( 0.2172, 0.5195), +gr_complex(-1.2142, 0.4205), gr_complex( 0.0088, 1.0207), gr_complex( 0.4734, -0.0362), gr_complex( 0.8657, 0.2298), +gr_complex(-0.3401, 0.9423), gr_complex(-1.0218, 0.4897), gr_complex( 0.5309, 0.7784), gr_complex( 0.1874, -0.2475), +gr_complex( 0.8594, -0.7348), gr_complex( 0.3528, 0.9865), gr_complex(-0.0455, 1.0679), gr_complex( 1.3868, -0.0000), + +}; diff --git a/gr-ieee-files/viterbi_decoder.cc b/gr-ieee-files/viterbi_decoder.cc new file mode 100644 index 00000000..71740e04 --- /dev/null +++ b/gr-ieee-files/viterbi_decoder.cc @@ -0,0 +1,491 @@ +/* + * Copyright 1995 Phil Karn, KA9Q + * Copyright 2008 Free Software Foundation, Inc. + * 2014 Added SSE2 implementation Bogdan Diaconescu + * + * This file is part of GNU Radio + * + * GNU Radio is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3, or (at your option) + * any later version. + * + + * GNU Radio is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Radio; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, + * Boston, MA 02110-1301, USA. + */ + +/* + * Viterbi decoder for K=7 rate=1/2 convolutional code + * Some modifications from original Karn code by Matt Ettus + * Major modifications by adding SSE2 code by Bogdan Diaconescu + */ +#include "viterbi_decoder.h" +#include +#include + +/* The basic Viterbi decoder operation, called a "butterfly" + * operation because of the way it looks on a trellis diagram. Each + * butterfly involves an Add-Compare-Select (ACS) operation on the two nodes + * where the 0 and 1 paths from the current node merge at the next step of + * the trellis. + * + * The code polynomials are assumed to have 1's on both ends. Given a + * function encode_state() that returns the two symbols for a given + * encoder state in the low two bits, such a code will have the following + * identities for even 'n' < 64: + * + * encode_state(n) = encode_state(n+65) + * encode_state(n+1) = encode_state(n+64) = (3 ^ encode_state(n)) + * + * Any convolutional code you would actually want to use will have + * these properties, so these assumptions aren't too limiting. + * + * Doing this as a macro lets the compiler evaluate at compile time the + * many expressions that depend on the loop index and encoder state and + * emit them as immediate arguments. + * This makes an enormous difference on register-starved machines such + * as the Intel x86 family where evaluating these expressions at runtime + * would spill over into memory. + */ + +#define BUTTERFLY(i,sym) { \ + int m0,m1,m2,m3; \ + /* ACS for 0 branch */ \ + m0 = state[i].metric + mets[sym]; /* 2*i */ \ + m1 = state[i+32].metric + mets[3 ^ sym]; /* 2*i + 64 */ \ + if(m0 > m1){ \ + next[2*i].metric = m0; \ + next[2*i].path = state[i].path << 1; \ + } else { \ + next[2*i].metric = m1; \ + next[2*i].path = (state[i+32].path << 1)|1; \ + } \ + /* ACS for 1 branch */ \ + m2 = state[i].metric + mets[3 ^ sym]; /* 2*i + 1 */ \ + m3 = state[i+32].metric + mets[sym]; /* 2*i + 65 */ \ + if(m2 > m3){ \ + next[2*i+1].metric = m2; \ + next[2*i+1].path = state[i].path << 1; \ + } else { \ + next[2*i+1].metric = m3; \ + next[2*i+1].path = (state[i+32].path << 1)|1; \ + } \ + } + + +using namespace gr::ieee802_11; + + +viterbi_decoder::viterbi_decoder() : + d_store_pos(0) { +} + +viterbi_decoder::~viterbi_decoder() { +} + +void +viterbi_decoder::viterbi_butterfly2_sse2(unsigned char *symbols, + __m128i *mm0, __m128i *mm1, __m128i *pp0, __m128i *pp1) { + int i; + + __m128i *metric0, *metric1; + __m128i *path0, *path1; + + metric0 = mm0; + path0 = pp0; + metric1 = mm1; + path1 = pp1; + + // Operate on 4 symbols (2 bits) at a time + + __m128i m0, m1, m2, m3, decision0, decision1, survivor0, survivor1; + __m128i metsv, metsvm; + __m128i shift0, shift1; + __m128i tmp0, tmp1; + __m128i sym0v, sym1v; + + sym0v = _mm_set1_epi8(symbols[0]); + sym1v = _mm_set1_epi8(symbols[1]); + + for (i = 0; i < 2; i++) { + if (symbols[0] == 2) { + metsvm = _mm_xor_si128(d_branchtab27_sse2[1].v[i],sym1v); + metsv = _mm_sub_epi8(_mm_set1_epi8(1),metsvm); + } else if (symbols[1] == 2) { + metsvm = _mm_xor_si128(d_branchtab27_sse2[0].v[i],sym0v); + metsv = _mm_sub_epi8(_mm_set1_epi8(1),metsvm); + } else { + metsvm = _mm_add_epi8(_mm_xor_si128(d_branchtab27_sse2[0].v[i],sym0v),_mm_xor_si128(d_branchtab27_sse2[1].v[i],sym1v)); + metsv = _mm_sub_epi8(_mm_set1_epi8(2),metsvm); + } + + m0 = _mm_add_epi8(metric0[i], metsv); + m1 = _mm_add_epi8(metric0[i+2], metsvm); + m2 = _mm_add_epi8(metric0[i], metsvm); + m3 = _mm_add_epi8(metric0[i+2], metsv); + + decision0 = _mm_cmpgt_epi8(_mm_sub_epi8(m0,m1),_mm_setzero_si128()); + decision1 = _mm_cmpgt_epi8(_mm_sub_epi8(m2,m3),_mm_setzero_si128()); + survivor0 = _mm_or_si128(_mm_and_si128(decision0,m0),_mm_andnot_si128(decision0,m1)); + survivor1 = _mm_or_si128(_mm_and_si128(decision1,m2),_mm_andnot_si128(decision1,m3)); + + shift0 = _mm_slli_epi16(path0[i], 1); + shift1 = _mm_slli_epi16(path0[2+i], 1); + shift1 = _mm_add_epi8(shift1, _mm_set1_epi8(1)); + + metric1[2*i] = _mm_unpacklo_epi8(survivor0,survivor1); + tmp0 = _mm_or_si128(_mm_and_si128(decision0,shift0),_mm_andnot_si128(decision0,shift1)); + + metric1[2*i+1] = _mm_unpackhi_epi8(survivor0,survivor1); + tmp1 = _mm_or_si128(_mm_and_si128(decision1,shift0),_mm_andnot_si128(decision1,shift1)); + + path1[2*i] = _mm_unpacklo_epi8(tmp0, tmp1); + path1[2*i+1] = _mm_unpackhi_epi8(tmp0, tmp1); + } + + metric0 = mm1; + path0 = pp1; + metric1 = mm0; + path1 = pp0; + + sym0v = _mm_set1_epi8(symbols[2]); + sym1v = _mm_set1_epi8(symbols[3]); + + for (i = 0; i < 2; i++) { + if (symbols[2] == 2) { + metsvm = _mm_xor_si128(d_branchtab27_sse2[1].v[i],sym1v); + metsv = _mm_sub_epi8(_mm_set1_epi8(1),metsvm); + + } else if (symbols[3] == 2) { + metsvm = _mm_xor_si128(d_branchtab27_sse2[0].v[i],sym0v); + metsv = _mm_sub_epi8(_mm_set1_epi8(1),metsvm); + + } else { + metsvm = _mm_add_epi8(_mm_xor_si128(d_branchtab27_sse2[0].v[i],sym0v),_mm_xor_si128(d_branchtab27_sse2[1].v[i],sym1v)); + metsv = _mm_sub_epi8(_mm_set1_epi8(2),metsvm); + } + + m0 = _mm_add_epi8(metric0[i], metsv); + m1 = _mm_add_epi8(metric0[i+2], metsvm); + m2 = _mm_add_epi8(metric0[i], metsvm); + m3 = _mm_add_epi8(metric0[i+2], metsv); + + decision0 = _mm_cmpgt_epi8(_mm_sub_epi8(m0,m1),_mm_setzero_si128()); + decision1 = _mm_cmpgt_epi8(_mm_sub_epi8(m2,m3),_mm_setzero_si128()); + survivor0 = _mm_or_si128(_mm_and_si128(decision0,m0),_mm_andnot_si128(decision0,m1)); + survivor1 = _mm_or_si128(_mm_and_si128(decision1,m2),_mm_andnot_si128(decision1,m3)); + + shift0 = _mm_slli_epi16(path0[i], 1); + shift1 = _mm_slli_epi16(path0[2+i], 1); + shift1 = _mm_add_epi8(shift1, _mm_set1_epi8(1)); + + metric1[2*i] = _mm_unpacklo_epi8(survivor0,survivor1); + tmp0 = _mm_or_si128(_mm_and_si128(decision0,shift0),_mm_andnot_si128(decision0,shift1)); + + metric1[2*i+1] = _mm_unpackhi_epi8(survivor0,survivor1); + tmp1 = _mm_or_si128(_mm_and_si128(decision1,shift0),_mm_andnot_si128(decision1,shift1)); + + path1[2*i] = _mm_unpacklo_epi8(tmp0, tmp1); + path1[2*i+1] = _mm_unpackhi_epi8(tmp0, tmp1); + } +} + +// Find current best path +unsigned char +viterbi_decoder::viterbi_get_output_sse2(__m128i *mm0, __m128i *pp0, + int ntraceback, unsigned char *outbuf) { + int i; + int bestmetric, minmetric; + int beststate = 0; + int pos = 0; + + // circular buffer with the last ntraceback paths + d_store_pos = (d_store_pos + 1) % ntraceback; + + for (i = 0; i < 4; i++) { + _mm_store_si128((__m128i *) &d_mmresult[i*16], mm0[i]); + _mm_store_si128((__m128i *) &d_ppresult[d_store_pos][i*16], pp0[i]); + } + + // Find out the best final state + bestmetric = d_mmresult[beststate]; + minmetric = d_mmresult[beststate]; + + for (i = 1; i < 64; i++) { + if (d_mmresult[i] > bestmetric) { + bestmetric = d_mmresult[i]; + beststate = i; + } + if (d_mmresult[i] < minmetric) { + minmetric = d_mmresult[i]; + } + } + + // Trace back + for (i = 0, pos = d_store_pos; i < (ntraceback - 1); i++) { + // Obtain the state from the output bits + // by clocking in the output bits in reverse order. + // The state has only 6 bits + beststate = d_ppresult[pos][beststate] >> 2; + pos = (pos - 1 + ntraceback) % ntraceback; + } + + // Store output byte + *outbuf = d_ppresult[pos][beststate]; + + // Zero out the path variable + // and prevent metric overflow + for (i = 0; i < 4; i++) { + pp0[i] = _mm_setzero_si128(); + mm0[i] = _mm_sub_epi8(mm0[i], _mm_set1_epi8(minmetric)); + } + + return bestmetric; +} + +uint8_t* +viterbi_decoder::depuncture(uint8_t *in) { + + int count; + int n_cbps = d_ofdm->n_cbps; + uint8_t *depunctured; + + if (d_ntraceback == 5) { + count = d_frame->n_sym * n_cbps; + depunctured = in; + + } else { + depunctured = d_depunctured; + count = 0; + for(int i = 0; i < d_frame->n_sym; i++) { + for(int k = 0; k < n_cbps; k++) { + while (d_depuncture_pattern[count % (2 * d_k)] == 0) { + depunctured[count] = 2; + count++; + } + + // Insert received bits + depunctured[count] = in[i * n_cbps + k]; + count++; + + while (d_depuncture_pattern[count % (2 * d_k)] == 0) { + depunctured[count] = 2; + count++; + } + } + } + } + + return depunctured; +} + +uint8_t* +viterbi_decoder::depuncture_one(uint8_t *in) { + + int count; + int n_cbps = d_ofdm->n_cbps; + uint8_t *depunctured; + + if (d_ntraceback == 5) { + count = n_cbps; + depunctured = in; + + } else { + depunctured = d_depunctured; + count = 0; + for(int k = 0; k < n_cbps; k++) { + while (d_depuncture_pattern[count % (2 * d_k)] == 0) { + depunctured[count] = 2; + count++; + } + + // Insert received bits + depunctured[count] = in[n_cbps + k]; + count++; + + while (d_depuncture_pattern[count % (2 * d_k)] == 0) { + depunctured[count] = 2; + count++; + } + } + } + + return depunctured; +} + +uint8_t* +viterbi_decoder::decode(ofdm_param *ofdm, frame_param *frame, uint8_t *in) { + + d_ofdm = ofdm; + d_frame = frame; + + reset(); + uint8_t *depunctured = depuncture(in); + + int in_count = 0; + int out_count = 0; + int n_decoded = 0; + + while(n_decoded < d_frame->n_data_bits) { + + if ((in_count % 4) == 0) { //0 or 3 + viterbi_butterfly2_sse2(&depunctured[in_count & 0xfffffffc], d_metric0, d_metric1, d_path0, d_path1); + + if ((in_count > 0) && (in_count % 16) == 8) { // 8 or 11 + unsigned char c; + + viterbi_get_output_sse2(d_metric0, d_path0, d_ntraceback, &c); + + if (out_count >= d_ntraceback) { + for (int i= 0; i < 8; i++) { + d_decoded[(out_count - d_ntraceback) * 8 + i] = (c >> (7 - i)) & 0x1; + n_decoded++; + } + } + out_count++; + } + } + in_count++; + } + + return d_decoded; +} + +uint8_t* +viterbi_decoder::decode_one(ofdm_param *ofdm, uint8_t *in) { + //std::cout << "Entered decode_one()"<< std::endl; + d_ofdm = ofdm; + //std::cout << "Line 332" << std::endl; + reset(); + //std::cout << "Line 334" << std::endl; + uint8_t *depunctured = depuncture_one(in); + //std::cout << "Line 335" << std::endl; + int in_count = 0; + int out_count = 0; + int n_decoded = 0; + + while(n_decoded < 24) { + //std::cout << "Line 341" << std::endl; + if ((in_count % 4) == 0) { //0 or 3 + viterbi_butterfly2_sse2(&depunctured[in_count & 0xfffffffc], d_metric0, d_metric1, d_path0, d_path1); + + if ((in_count > 0) && (in_count % 16) == 8) { // 8 or 11 + unsigned char c; + + viterbi_get_output_sse2(d_metric0, d_path0, d_ntraceback, &c); + + if (out_count >= d_ntraceback) { + for (int i= 0; i < 8; i++) { + d_decoded[(out_count - d_ntraceback) * 8 + i] = (c >> (7 - i)) & 0x1; + n_decoded++; + } + } + out_count++; + } + } + in_count++; + } + //std::cout << "Exiting decode_one()"<< std::endl; + return d_decoded; +} + +void +viterbi_decoder::reset() { + + viterbi_chunks_init_sse2(); + + switch(d_ofdm->encoding) { + case BPSK_1_2: + case QPSK_1_2: + case QAM16_1_2: + d_ntraceback = 5; + d_depuncture_pattern = PUNCTURE_1_2; + d_k = 1; + break; + case QAM64_2_3: + d_ntraceback = 9; + d_depuncture_pattern = PUNCTURE_2_3; + d_k = 2; + break; + case BPSK_3_4: + case QPSK_3_4: + case QAM16_3_4: + case QAM64_3_4: + d_ntraceback = 10; + d_depuncture_pattern = PUNCTURE_3_4; + d_k = 3; + break; + } +} + +void // Initialize starting metrics to prefer 0 state +viterbi_decoder::viterbi_chunks_init_sse2() { + int i, j; + + for (i = 0; i < 4; i++) { + d_metric0[i] = _mm_setzero_si128(); + d_path0[i] = _mm_setzero_si128(); + } + + int polys[2] = { 0x6d, 0x4f }; + for(i=0; i < 32; i++) { + d_branchtab27_sse2[0].c[i] = (polys[0] < 0) ^ PARTAB[(2*i) & abs(polys[0])] ? 1 : 0; + d_branchtab27_sse2[1].c[i] = (polys[1] < 0) ^ PARTAB[(2*i) & abs(polys[1])] ? 1 : 0; + } + + for (i = 0; i < 64; i++) { + d_mmresult[i] = 0; + for (j = 0; j < TRACEBACK_MAX; j++) { + d_ppresult[j][i] = 0; + } + } +} + + +/* Parity lookup table */ +const unsigned char viterbi_decoder::PARTAB[256] = { + 0, 1, 1, 0, 1, 0, 0, 1, + 1, 0, 0, 1, 0, 1, 1, 0, + 1, 0, 0, 1, 0, 1, 1, 0, + 0, 1, 1, 0, 1, 0, 0, 1, + 1, 0, 0, 1, 0, 1, 1, 0, + 0, 1, 1, 0, 1, 0, 0, 1, + 0, 1, 1, 0, 1, 0, 0, 1, + 1, 0, 0, 1, 0, 1, 1, 0, + 1, 0, 0, 1, 0, 1, 1, 0, + 0, 1, 1, 0, 1, 0, 0, 1, + 0, 1, 1, 0, 1, 0, 0, 1, + 1, 0, 0, 1, 0, 1, 1, 0, + 0, 1, 1, 0, 1, 0, 0, 1, + 1, 0, 0, 1, 0, 1, 1, 0, + 1, 0, 0, 1, 0, 1, 1, 0, + 0, 1, 1, 0, 1, 0, 0, 1, + 1, 0, 0, 1, 0, 1, 1, 0, + 0, 1, 1, 0, 1, 0, 0, 1, + 0, 1, 1, 0, 1, 0, 0, 1, + 1, 0, 0, 1, 0, 1, 1, 0, + 0, 1, 1, 0, 1, 0, 0, 1, + 1, 0, 0, 1, 0, 1, 1, 0, + 1, 0, 0, 1, 0, 1, 1, 0, + 0, 1, 1, 0, 1, 0, 0, 1, + 0, 1, 1, 0, 1, 0, 0, 1, + 1, 0, 0, 1, 0, 1, 1, 0, + 1, 0, 0, 1, 0, 1, 1, 0, + 0, 1, 1, 0, 1, 0, 0, 1, + 1, 0, 0, 1, 0, 1, 1, 0, + 0, 1, 1, 0, 1, 0, 0, 1, + 0, 1, 1, 0, 1, 0, 0, 1, + 1, 0, 0, 1, 0, 1, 1, 0, +}; + +const unsigned char viterbi_decoder::PUNCTURE_1_2[2] = {1, 1}; +const unsigned char viterbi_decoder::PUNCTURE_2_3[4] = {1, 1, 1, 0}; +const unsigned char viterbi_decoder::PUNCTURE_3_4[6] = {1, 1, 1, 0, 0, 1}; From b3a4f4205c22ffdd00336b7c3f110923f6a44ee0 Mon Sep 17 00:00:00 2001 From: Geoff Twardokus Date: Tue, 6 Oct 2020 21:59:53 -0400 Subject: [PATCH 11/22] GRC updates --- reactive_jammer.grc | 329 ++++++++++++++++++++++++++++---------------- wifi_rx.grc | 2 +- 2 files changed, 215 insertions(+), 116 deletions(-) diff --git a/reactive_jammer.grc b/reactive_jammer.grc index 629d6e78..69b2a539 100644 --- a/reactive_jammer.grc +++ b/reactive_jammer.grc @@ -204,7 +204,7 @@ _coordinate - (1520, 68) + (1376, 44) gui_hint @@ -287,6 +287,69 @@ radio_buttons + + variable_qtgui_range + + comment + + + + value + 0.95 + + + _enabled + True + + + _coordinate + (440, 76) + + + gui_hint + + + + _rotation + 0 + + + id + gain + + + label + + + + min_len + 200 + + + orient + Qt.Horizontal + + + start + 0 + + + step + 0.01 + + + stop + 1 + + + rangeType + float + + + widget + counter_slider + + variable_qtgui_chooser @@ -295,7 +358,7 @@ value - 2412000000 + 11e6 _enabled @@ -303,7 +366,7 @@ _coordinate - (576, 76) + (128, 76) gui_hint @@ -315,7 +378,7 @@ id - freq + lo_offset label0 @@ -343,11 +406,11 @@ labels - [' 1 | 2412.0 | 11g', ' 2 | 2417.0 | 11g', ' 3 | 2422.0 | 11g', ' 4 | 2427.0 | 11g', ' 5 | 2432.0 | 11g', ' 6 | 2437.0 | 11g', ' 7 | 2442.0 | 11g', ' 8 | 2447.0 | 11g', ' 9 | 2452.0 | 11g', ' 10 | 2457.0 | 11g', ' 11 | 2462.0 | 11g', ' 12 | 2467.0 | 11g', ' 13 | 2472.0 | 11g', ' 14 | 2484.0 | 11g', ' 34 | 5170.0 | 11a', ' 36 | 5180.0 | 11a', ' 38 | 5190.0 | 11a', ' 40 | 5200.0 | 11a', ' 42 | 5210.0 | 11a', ' 44 | 5220.0 | 11a', ' 46 | 5230.0 | 11a', ' 48 | 5240.0 | 11a', ' 50 | 5250.0 | 11a', ' 52 | 5260.0 | 11a', ' 54 | 5270.0 | 11a', ' 56 | 5280.0 | 11a', ' 58 | 5290.0 | 11a', ' 60 | 5300.0 | 11a', ' 62 | 5310.0 | 11a', ' 64 | 5320.0 | 11a', '100 | 5500.0 | 11a', '102 | 5510.0 | 11a', '104 | 5520.0 | 11a', '106 | 5530.0 | 11a', '108 | 5540.0 | 11a', '110 | 5550.0 | 11a', '112 | 5560.0 | 11a', '114 | 5570.0 | 11a', '116 | 5580.0 | 11a', '118 | 5590.0 | 11a', '120 | 5600.0 | 11a', '122 | 5610.0 | 11a', '124 | 5620.0 | 11a', '126 | 5630.0 | 11a', '128 | 5640.0 | 11a', '132 | 5660.0 | 11a', '134 | 5670.0 | 11a', '136 | 5680.0 | 11a', '138 | 5690.0 | 11a', '140 | 5700.0 | 11a', '142 | 5710.0 | 11a', '144 | 5720.0 | 11a', '149 | 5745.0 | 11a (SRD)', '151 | 5755.0 | 11a (SRD)', '153 | 5765.0 | 11a (SRD)', '155 | 5775.0 | 11a (SRD)', '157 | 5785.0 | 11a (SRD)', '159 | 5795.0 | 11a (SRD)', '161 | 5805.0 | 11a (SRD)', '165 | 5825.0 | 11a (SRD)', '172 | 5860.0 | 11p', '174 | 5870.0 | 11p', '176 | 5880.0 | 11p', '178 | 5890.0 | 11p', '180 | 5900.0 | 11p', '182 | 5910.0 | 11p', '184 | 5920.0 | 11p'] + [] num_opts - 0 + 3 option0 @@ -355,11 +418,11 @@ option1 - 1 + 6e6 option2 - 2 + 11e6 option3 @@ -371,7 +434,7 @@ options - [2412000000.0, 2417000000.0, 2422000000.0, 2427000000.0, 2432000000.0, 2437000000.0, 2442000000.0, 2447000000.0, 2452000000.0, 2457000000.0, 2462000000.0, 2467000000.0, 2472000000.0, 2484000000.0, 5170000000.0, 5180000000.0, 5190000000.0, 5200000000.0, 5210000000.0, 5220000000.0, 5230000000.0, 5240000000.0, 5250000000.0, 5260000000.0, 5270000000.0, 5280000000.0, 5290000000.0, 5300000000.0, 5310000000.0, 5320000000.0, 5500000000.0, 5510000000.0, 5520000000.0, 5530000000.0, 5540000000.0, 5550000000.0, 5560000000.0, 5570000000.0, 5580000000.0, 5590000000.0, 5600000000.0, 5610000000.0, 5620000000.0, 5630000000.0, 5640000000.0, 5660000000.0, 5670000000.0, 5680000000.0, 5690000000.0, 5700000000.0, 5710000000.0, 5720000000.0, 5745000000.0, 5755000000.0, 5765000000.0, 5775000000.0, 5785000000.0, 5795000000.0, 5805000000.0, 5825000000.0, 5860000000.0, 5870000000.0, 5880000000.0, 5890000000.0, 5900000000.0, 5910000000.0, 5920000000.0] + [0, 1, 2] orient @@ -387,26 +450,18 @@ - variable_qtgui_range + variable comment - - value - 0.95 - _enabled - True + 1 _coordinate - (440, 76) - - - gui_hint - + (1120, 44) _rotation @@ -414,39 +469,11 @@ id - gain - - - label - - - - min_len - 200 - - - orient - Qt.Horizontal - - - start - 0 - - - step - 0.01 - - - stop - 1 - - - rangeType - float + out_buf_size - widget - counter_slider + value + 96000 @@ -457,7 +484,7 @@ value - 11e6 + 5890000000 _enabled @@ -465,7 +492,7 @@ _coordinate - (128, 76) + (576, 76) gui_hint @@ -477,7 +504,7 @@ id - lo_offset + rx_freq label0 @@ -505,11 +532,11 @@ labels - [] + [' 1 | 2412.0 | 11g', ' 2 | 2417.0 | 11g', ' 3 | 2422.0 | 11g', ' 4 | 2427.0 | 11g', ' 5 | 2432.0 | 11g', ' 6 | 2437.0 | 11g', ' 7 | 2442.0 | 11g', ' 8 | 2447.0 | 11g', ' 9 | 2452.0 | 11g', ' 10 | 2457.0 | 11g', ' 11 | 2462.0 | 11g', ' 12 | 2467.0 | 11g', ' 13 | 2472.0 | 11g', ' 14 | 2484.0 | 11g', ' 34 | 5170.0 | 11a', ' 36 | 5180.0 | 11a', ' 38 | 5190.0 | 11a', ' 40 | 5200.0 | 11a', ' 42 | 5210.0 | 11a', ' 44 | 5220.0 | 11a', ' 46 | 5230.0 | 11a', ' 48 | 5240.0 | 11a', ' 50 | 5250.0 | 11a', ' 52 | 5260.0 | 11a', ' 54 | 5270.0 | 11a', ' 56 | 5280.0 | 11a', ' 58 | 5290.0 | 11a', ' 60 | 5300.0 | 11a', ' 62 | 5310.0 | 11a', ' 64 | 5320.0 | 11a', '100 | 5500.0 | 11a', '102 | 5510.0 | 11a', '104 | 5520.0 | 11a', '106 | 5530.0 | 11a', '108 | 5540.0 | 11a', '110 | 5550.0 | 11a', '112 | 5560.0 | 11a', '114 | 5570.0 | 11a', '116 | 5580.0 | 11a', '118 | 5590.0 | 11a', '120 | 5600.0 | 11a', '122 | 5610.0 | 11a', '124 | 5620.0 | 11a', '126 | 5630.0 | 11a', '128 | 5640.0 | 11a', '132 | 5660.0 | 11a', '134 | 5670.0 | 11a', '136 | 5680.0 | 11a', '138 | 5690.0 | 11a', '140 | 5700.0 | 11a', '142 | 5710.0 | 11a', '144 | 5720.0 | 11a', '149 | 5745.0 | 11a (SRD)', '151 | 5755.0 | 11a (SRD)', '153 | 5765.0 | 11a (SRD)', '155 | 5775.0 | 11a (SRD)', '157 | 5785.0 | 11a (SRD)', '159 | 5795.0 | 11a (SRD)', '161 | 5805.0 | 11a (SRD)', '165 | 5825.0 | 11a (SRD)', '172 | 5860.0 | 11p', '174 | 5870.0 | 11p', '176 | 5880.0 | 11p', '178 | 5890.0 | 11p', '180 | 5900.0 | 11p', '182 | 5910.0 | 11p', '184 | 5920.0 | 11p'] num_opts - 3 + 0 option0 @@ -517,11 +544,11 @@ option1 - 6e6 + 1 option2 - 11e6 + 2 option3 @@ -533,7 +560,7 @@ options - [0, 1, 2] + [2412000000.0, 2417000000.0, 2422000000.0, 2427000000.0, 2432000000.0, 2437000000.0, 2442000000.0, 2447000000.0, 2452000000.0, 2457000000.0, 2462000000.0, 2467000000.0, 2472000000.0, 2484000000.0, 5170000000.0, 5180000000.0, 5190000000.0, 5200000000.0, 5210000000.0, 5220000000.0, 5230000000.0, 5240000000.0, 5250000000.0, 5260000000.0, 5270000000.0, 5280000000.0, 5290000000.0, 5300000000.0, 5310000000.0, 5320000000.0, 5500000000.0, 5510000000.0, 5520000000.0, 5530000000.0, 5540000000.0, 5550000000.0, 5560000000.0, 5570000000.0, 5580000000.0, 5590000000.0, 5600000000.0, 5610000000.0, 5620000000.0, 5630000000.0, 5640000000.0, 5660000000.0, 5670000000.0, 5680000000.0, 5690000000.0, 5700000000.0, 5710000000.0, 5720000000.0, 5745000000.0, 5755000000.0, 5765000000.0, 5775000000.0, 5785000000.0, 5795000000.0, 5805000000.0, 5825000000.0, 5860000000.0, 5870000000.0, 5880000000.0, 5890000000.0, 5900000000.0, 5910000000.0, 5920000000.0] orient @@ -548,33 +575,6 @@ combo_box - - variable - - comment - - - - _enabled - 1 - - - _coordinate - (1264, 68) - - - _rotation - 0 - - - id - out_buf_size - - - value - 96000 - - variable_qtgui_chooser @@ -583,7 +583,7 @@ value - 20e6 + 10e6 _enabled @@ -713,11 +713,11 @@ _enabled - True + 1 _coordinate - (1736, 68) + (1592, 44) gui_hint @@ -816,7 +816,7 @@ _coordinate - (1376, 68) + (1232, 44) gui_hint @@ -871,7 +871,7 @@ value - 10e6 + 11e6 _enabled @@ -879,7 +879,106 @@ _coordinate - (1808, 212) + (1856, 180) + + + gui_hint + + + + _rotation + 0 + + + id + tx_lo_offset + + + label0 + + + + label1 + + + + label2 + + + + label3 + + + + label4 + + + + label + + + + labels + [] + + + num_opts + 3 + + + option0 + 0 + + + option1 + 6e6 + + + option2 + 11e6 + + + option3 + 3 + + + option4 + 4 + + + options + [0, 1, 2] + + + orient + Qt.QVBoxLayout + + + type + real + + + widget + combo_box + + + + variable_qtgui_chooser + + comment + + + + value + 10e6 + + + _enabled + 1 + + + _coordinate + (1784, 44) gui_hint @@ -1095,7 +1194,7 @@ _coordinate - (128, 384) + (128, 400) _rotation @@ -1303,7 +1402,7 @@ _coordinate - (920, 420) + (960, 460) _rotation @@ -1346,7 +1445,7 @@ _enabled - 1 + 0 _coordinate @@ -1397,7 +1496,7 @@ _coordinate - (96, 424) + (96, 448) _rotation @@ -1448,7 +1547,7 @@ _enabled - 1 + 0 _coordinate @@ -1546,11 +1645,11 @@ _enabled - 1 + 0 _coordinate - (1192, 228) + (1288, 228) _rotation @@ -1668,7 +1767,7 @@ _coordinate - (904, 652) + (1000, 540) _rotation @@ -1786,7 +1885,7 @@ _enabled - 1 + 0 _coordinate @@ -1841,7 +1940,7 @@ _coordinate - (672, 668) + (760, 652) _rotation @@ -1888,7 +1987,7 @@ _coordinate - (488, 604) + (504, 604) _rotation @@ -1943,7 +2042,7 @@ freq - freq + rx_freq _coordinate @@ -1994,7 +2093,7 @@ _enabled - 1 + 0 _coordinate @@ -2131,7 +2230,7 @@ debug - True + False _enabled @@ -2139,7 +2238,7 @@ _coordinate - (680, 572) + (768, 572) _rotation @@ -2998,7 +3097,7 @@ center_freq0 - uhd.tune_request(tx_freq, rf_freq = tx_freq - lo_offset, rf_freq_policy=uhd.tune_request.POLICY_MANUAL) + uhd.tune_request(tx_freq, rf_freq = tx_freq - tx_lo_offset, rf_freq_policy=uhd.tune_request.POLICY_MANUAL) norm_gain0 @@ -3650,11 +3749,11 @@ _enabled - 1 + 0 _coordinate - (1568, 532) + (1672, 540) _rotation @@ -3821,7 +3920,7 @@ center_freq0 - uhd.tune_request(freq, rf_freq = freq - lo_offset, rf_freq_policy=uhd.tune_request.POLICY_MANUAL) + uhd.tune_request(rx_freq, rf_freq = rx_freq - lo_offset, rf_freq_policy=uhd.tune_request.POLICY_MANUAL) dc_offs_enb0 @@ -4965,7 +5064,7 @@ clock_rate - 0.0 + 200e6 comment @@ -4989,7 +5088,7 @@ _coordinate - (24, 276) + (24, 268) _rotation @@ -5160,7 +5259,7 @@ _enabled - 1 + 0 _coordinate @@ -5196,7 +5295,7 @@ frequency - freq + tx_freq sensitivity diff --git a/wifi_rx.grc b/wifi_rx.grc index 38d1acb4..5ef7d18d 100644 --- a/wifi_rx.grc +++ b/wifi_rx.grc @@ -2328,7 +2328,7 @@ ant0 - TX/RX + RX2 bw0 From 19808f2594658b01a3613affdc4598e35c7c8978 Mon Sep 17 00:00:00 2001 From: Geoff Twardokus Date: Sat, 10 Oct 2020 08:56:52 -0400 Subject: [PATCH 12/22] Editing cert implementation --- WavePacketBuilder.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/WavePacketBuilder.py b/WavePacketBuilder.py index 7b76273e..b4919a57 100644 --- a/WavePacketBuilder.py +++ b/WavePacketBuilder.py @@ -102,6 +102,9 @@ def getIeee1609Dot2Data(self, message, key): #version = 3 bytestring += "03" + # Number of items + bytestring += "000001" + #CertificateType = "explicit" #@TODO implement ExplicitCertificate structure here From a1b47a62099291b42169ee8f5dcc2cf51534dd2c Mon Sep 17 00:00:00 2001 From: Geoff Twardokus Date: Sat, 10 Oct 2020 09:00:53 -0400 Subject: [PATCH 13/22] Editing cert implementation --- WavePacketBuilder.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/WavePacketBuilder.py b/WavePacketBuilder.py index b4919a57..cf207e7e 100644 --- a/WavePacketBuilder.py +++ b/WavePacketBuilder.py @@ -108,6 +108,15 @@ def getIeee1609Dot2Data(self, message, key): #CertificateType = "explicit" #@TODO implement ExplicitCertificate structure here + # Filler? + bytestring += "00" + + # version + bytestring += "03" + + # type + bytestring += "00" + #Issuer = "sha256AndDigest" #dummy value here for issuerID bytestring += "2122232425262728" From 18a3b9772940c6ef88932c94380824c78b70c274 Mon Sep 17 00:00:00 2001 From: Geoff Twardokus Date: Sat, 10 Oct 2020 09:24:25 -0400 Subject: [PATCH 14/22] This commit is the verified, syntactically correct implementation of the certificate and signedData structures. --- WavePacketBuilder.py | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/WavePacketBuilder.py b/WavePacketBuilder.py index cf207e7e..2e933c21 100644 --- a/WavePacketBuilder.py +++ b/WavePacketBuilder.py @@ -119,7 +119,7 @@ def getIeee1609Dot2Data(self, message, key): #Issuer = "sha256AndDigest" #dummy value here for issuerID - bytestring += "2122232425262728" + bytestring += "002122232425262728" #toBeSigned # - START ToBeSignedCertificate HERE - @@ -128,8 +128,16 @@ def getIeee1609Dot2Data(self, message, key): #this data is used to compare/add certificates to a CRL #START linkageData HERE + + #buffer + bytestring += "0000" + + # certificateID choice + bytestring += "00" + + #iCert DUMMY VALUE - bytestring += "100" + bytestring += "0100" #linkage-value(size = 9) DUMMY VALUE bytestring += "0fa12245f4c3c1cd54" @@ -139,14 +147,21 @@ def getIeee1609Dot2Data(self, message, key): bytestring += "52641c" #crlSeries DUMMY VALUE - bytestring += "20" + bytestring += "2000" #START validityPeriod HERE #start(time32) bytestring += "24c34587" #duration - bytestring += "20" + bytestring += "030005" + + # VerificationKeyIndicator + bytestring += "01" + + # EccP256CurvePoint + bytestring += "00" + bytestring += "00"*32 #END validityPeriod HERE From 9e06c59422ac0b6a0682701758ee8b5e7ef9fe50 Mon Sep 17 00:00:00 2001 From: Geoff Twardokus Date: Sun, 11 Oct 2020 17:01:16 -0400 Subject: [PATCH 15/22] semi-working version --- reactive_jammer.grc | 331 ++++---------------------------------------- 1 file changed, 24 insertions(+), 307 deletions(-) diff --git a/reactive_jammer.grc b/reactive_jammer.grc index 69b2a539..8415cd76 100644 --- a/reactive_jammer.grc +++ b/reactive_jammer.grc @@ -875,11 +875,11 @@ _enabled - True + 1 _coordinate - (1856, 180) + (1896, 180) gui_hint @@ -1374,57 +1374,6 @@ 1 - - blocks_file_sink - - append - False - - - alias - - - - comment - - - - affinity - - - - _enabled - 1 - - - file - /tmp/out.pcap - - - _coordinate - (960, 460) - - - _rotation - 0 - - - id - blocks_file_sink_0 - - - type - byte - - - unbuffered - False - - - vlen - 1 - - blocks_multiply_const_vxx @@ -1445,11 +1394,11 @@ _enabled - 0 + 1 _coordinate - (1344, 428) + (1320, 428) _rotation @@ -1547,11 +1496,11 @@ _enabled - 0 + 1 _coordinate - (1832, 416) + (1752, 456) _rotation @@ -1602,7 +1551,7 @@ _coordinate - (224, 692) + (224, 788) _rotation @@ -1629,65 +1578,6 @@ 0 - - blocks_socket_pdu - - alias - - - - comment - - - - affinity - - - - _enabled - 0 - - - _coordinate - (1288, 228) - - - _rotation - 0 - - - host - - - - id - blocks_socket_pdu_0 - - - mtu - 10000 - - - maxoutbuf - 0 - - - minoutbuf - 0 - - - port - 52001 - - - tcp_no_delay - False - - - type - "UDP_SERVER" - - blocks_stream_to_vector @@ -1708,11 +1598,11 @@ _coordinate - (780, 432) + (784, 548) _rotation - 270 + 180 id @@ -1739,61 +1629,6 @@ 1 - - blocks_udp_sink - - alias - - - - comment - - - - affinity - - - - ipaddr - localhost - - - port - 52001 - - - _enabled - 1 - - - _coordinate - (1000, 540) - - - _rotation - 0 - - - id - blocks_udp_sink_0 - - - type - byte - - - psize - 1472 - - - eof - True - - - vlen - 1 - - fft_vxx @@ -1822,7 +1657,7 @@ _coordinate - (48, 580) + (56, 660) _rotation @@ -1885,11 +1720,11 @@ _enabled - 0 + 1 _coordinate - (1320, 532) + (1240, 500) _rotation @@ -1916,53 +1751,6 @@ 1000 - - foo_wireshark_connector - - alias - - - - comment - - - - affinity - - - - debug - False - - - _enabled - 1 - - - _coordinate - (760, 652) - - - _rotation - 0 - - - id - foo_wireshark_connector_0 - - - maxoutbuf - 0 - - - minoutbuf - 0 - - - tech - 127 - - ieee802_11_decode_mac @@ -1979,7 +1767,7 @@ debug - False + True _enabled @@ -1987,7 +1775,7 @@ _coordinate - (504, 604) + (856, 628) _rotation @@ -2046,7 +1834,7 @@ _coordinate - (280, 580) + (336, 660) _rotation @@ -2093,11 +1881,11 @@ _enabled - 0 + 1 _coordinate - (1496, 252) + (1312, 204) _rotation @@ -2214,53 +2002,6 @@ float - - ieee802_11_parse_mac - - alias - - - - comment - - - - affinity - - - - debug - False - - - _enabled - True - - - _coordinate - (768, 572) - - - _rotation - 0 - - - id - ieee802_11_parse_mac_0 - - - log - True - - - maxoutbuf - 0 - - - minoutbuf - 0 - - ieee802_11_sync_long @@ -2395,7 +2136,7 @@ _coordinate - (224, 748) + (224, 852) gui_hint @@ -3749,11 +3490,11 @@ _enabled - 0 + 1 _coordinate - (1672, 540) + (1712, 636) _rotation @@ -5259,11 +5000,11 @@ _enabled - 0 + 1 _coordinate - (1584, 364) + (1512, 348) _rotation @@ -5374,12 +5115,6 @@ 0 0 - - blocks_socket_pdu_0 - ieee802_11_mac_0 - pdus - app in - blocks_stream_to_vector_0 fft_vxx_0 @@ -5398,29 +5133,11 @@ 0 0 - - foo_wireshark_connector_0 - blocks_file_sink_0 - 0 - 0 - - - foo_wireshark_connector_0 - blocks_udp_sink_0 - 0 - 0 - - - ieee802_11_decode_mac_0 - foo_wireshark_connector_0 - out - in - ieee802_11_decode_mac_0 - ieee802_11_parse_mac_0 + ieee802_11_mac_0 out - in + app in ieee802_11_frame_equalizer_0 From b4d6362b1135835d061d062b17d0ca5b0fbb2edc Mon Sep 17 00:00:00 2001 From: Geoff Twardokus Date: Mon, 12 Oct 2020 11:49:44 -0400 Subject: [PATCH 16/22] file updates --- Receiver.py | 74 ++++++++++++++++++++++++-------------------- RemoteVehicle.py | 2 +- WavePacketBuilder.py | 10 +++--- 3 files changed, 47 insertions(+), 39 deletions(-) diff --git a/Receiver.py b/Receiver.py index ea9c176e..64555a47 100644 --- a/Receiver.py +++ b/Receiver.py @@ -34,6 +34,9 @@ def processPacket(self, payload): # extract the elements "(unsecuredData,r,s,time)" from the 1609.2 structure data = self.parseWSM(payload) + if data == -1: + return + """ #BSMData = data[0].decode('hex').replace("\n","").split(",") BSMData = bytes.fromhex(data[0]).decode('ascii').replace("\n","").split(",") @@ -73,39 +76,42 @@ def processPacket(self, payload): # takes the hex payload from an 802.11p frame as an argument, returns tuple of extracted bytestrings def parseWSM(self, WSM): - - # The first 8 bytes are WSMP N/T headers that do not change in size and can be discarded - ieee1609Dot2Data = WSM[8:] - - # First item to extract is the payload in unsecured data field - - # Note that the numbers for positions are double the byte value - # because this is a string of "hex numbers" so 1 byte = 2 chars - - unsecuredDataLength = int(ieee1609Dot2Data[14:16],16)*2 - unsecuredData = ieee1609Dot2Data[16:16+(unsecuredDataLength)] - timePostition = 16 + unsecuredDataLength + 6 - time = ieee1609Dot2Data[timePostition:timePostition+16] + try: + # The first 8 bytes are WSMP N/T headers that do not change in size and can be discarded + ieee1609Dot2Data = WSM[8:] - # the ecdsaNistP256Signature structure is 66 bytes - # r - 32 bytes - # s - 32 bytes - # field separators - 2 bytes - signature = ieee1609Dot2Data[len(ieee1609Dot2Data)-(2*66)-1:] - - # drop the two field identification bytes at the start of the block - signature = signature[4:] + # First item to extract is the payload in unsecured data field - # split into r and s - - r = signature[:64] - s = signature[64:128] - - # convert from string into ten-bit integer - r = int(r,16) - s = int(s,16) - - r = int(str(r)) - s = int(str(s)) - - return (unsecuredData,r,s,time) + # Note that the numbers for positions are double the byte value + # because this is a string of "hex numbers" so 1 byte = 2 chars + + unsecuredDataLength = int(ieee1609Dot2Data[14:16],16)*2 + unsecuredData = ieee1609Dot2Data[16:16+(unsecuredDataLength)] + timePostition = 16 + unsecuredDataLength + 6 + time = ieee1609Dot2Data[timePostition:timePostition+16] + + # the ecdsaNistP256Signature structure is 66 bytes + # r - 32 bytes + # s - 32 bytes + # field separators - 2 bytes + signature = ieee1609Dot2Data[len(ieee1609Dot2Data)-(2*66)-1:] + + # drop the two field identification bytes at the start of the block + signature = signature[4:] + + # split into r and s + + r = signature[:64] + s = signature[64:128] + + # convert from string into ten-bit integer + r = int(r,16) + s = int(s,16) + + r = int(str(r)) + s = int(str(s)) + + return (unsecuredData,r,s,time) + except: + print("Not a WSM.") + return -1 diff --git a/RemoteVehicle.py b/RemoteVehicle.py index 4b2100a3..0af63bdf 100644 --- a/RemoteVehicle.py +++ b/RemoteVehicle.py @@ -15,4 +15,4 @@ def start(self): print("Sending BSM") loader = subprocess.Popen(("echo","-n","-e",BSM), stdout=subprocess.PIPE) sender = subprocess.check_output(("nc","-w0","-u","localhost","52001"),stdin=loader.stdout) - time.sleep(1) \ No newline at end of file + time.sleep(3) \ No newline at end of file diff --git a/WavePacketBuilder.py b/WavePacketBuilder.py index 2e933c21..f927946a 100644 --- a/WavePacketBuilder.py +++ b/WavePacketBuilder.py @@ -103,11 +103,12 @@ def getIeee1609Dot2Data(self, message, key): bytestring += "03" # Number of items - bytestring += "000001" + bytestring += "000006" #CertificateType = "explicit" #@TODO implement ExplicitCertificate structure here + #for i in range(0, 6): # Filler? bytestring += "00" @@ -140,7 +141,8 @@ def getIeee1609Dot2Data(self, message, key): bytestring += "0100" #linkage-value(size = 9) DUMMY VALUE - bytestring += "0fa12245f4c3c1cd54" + #bytestring += "0fa12245f4c3c1cd54" + bytestring += "414243444546474849" #END linkageData HERE #cracaID(size = 3) DUMMY VALUE @@ -160,8 +162,8 @@ def getIeee1609Dot2Data(self, message, key): bytestring += "01" # EccP256CurvePoint - bytestring += "00" - bytestring += "00"*32 + bytestring += "04" + bytestring += "00"*64 #END validityPeriod HERE From d80956b0c9aa54549c2730be8d453301ba7dbb41 Mon Sep 17 00:00:00 2001 From: Geoff Twardokus Date: Sun, 8 Nov 2020 19:01:14 -0500 Subject: [PATCH 17/22] Updating files. This commit will need to be cleaned up at a later date. --- block_editing_notes.txt | 8 + reactive_jammer.py | 524 ++++++++++++++++++++++++++++++++++++++++ wifi_tx.grc | 8 +- 3 files changed, 536 insertions(+), 4 deletions(-) create mode 100644 block_editing_notes.txt create mode 100755 reactive_jammer.py diff --git a/block_editing_notes.txt b/block_editing_notes.txt new file mode 100644 index 00000000..f0c49890 --- /dev/null +++ b/block_editing_notes.txt @@ -0,0 +1,8 @@ +To rebuild gr-foo: + +Make the changes to /home/gr-foo/lib/wireshark_connector_impl.cc + +cd ~/gr-foo/build +cmake ../ +make +sudo make install diff --git a/reactive_jammer.py b/reactive_jammer.py new file mode 100755 index 00000000..b7165137 --- /dev/null +++ b/reactive_jammer.py @@ -0,0 +1,524 @@ +#!/usr/bin/env python2 +# -*- coding: utf-8 -*- +################################################## +# GNU Radio Python Flow Graph +# Title: Reactive Jammer +# GNU Radio version: 3.7.14.0 +################################################## + +if __name__ == '__main__': + import ctypes + import sys + if sys.platform.startswith('linux'): + try: + x11 = ctypes.cdll.LoadLibrary('libX11.so') + x11.XInitThreads() + except: + print "Warning: failed to XInitThreads()" + +import os +import sys +sys.path.append(os.environ.get('GRC_HIER_PATH', os.path.expanduser('~/.grc_gnuradio'))) + +from PyQt4 import Qt +from PyQt4.QtCore import QObject, pyqtSlot +from gnuradio import blocks +from gnuradio import eng_notation +from gnuradio import fft +from gnuradio import gr +from gnuradio import qtgui +from gnuradio import uhd +from gnuradio.eng_option import eng_option +from gnuradio.fft import window +from gnuradio.filter import firdes +from gnuradio.qtgui import Range, RangeWidget +from optparse import OptionParser +from wifi_phy_hier import wifi_phy_hier # grc-generated hier_block +import foo +import ieee802_11 +import sip +import time +from gnuradio import qtgui + + +class reactive_jammer(gr.top_block, Qt.QWidget): + + def __init__(self): + gr.top_block.__init__(self, "Reactive Jammer") + Qt.QWidget.__init__(self) + self.setWindowTitle("Reactive Jammer") + qtgui.util.check_set_qss() + try: + self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc')) + except: + pass + self.top_scroll_layout = Qt.QVBoxLayout() + self.setLayout(self.top_scroll_layout) + self.top_scroll = Qt.QScrollArea() + self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame) + self.top_scroll_layout.addWidget(self.top_scroll) + self.top_scroll.setWidgetResizable(True) + self.top_widget = Qt.QWidget() + self.top_scroll.setWidget(self.top_widget) + self.top_layout = Qt.QVBoxLayout(self.top_widget) + self.top_grid_layout = Qt.QGridLayout() + self.top_layout.addLayout(self.top_grid_layout) + + self.settings = Qt.QSettings("GNU Radio", "reactive_jammer") + self.restoreGeometry(self.settings.value("geometry").toByteArray()) + + + ################################################## + # Variables + ################################################## + self.window_size = window_size = 48 + self.tx_samp_rate = tx_samp_rate = 10e6 + self.tx_lo_offset = tx_lo_offset = 11e6 + self.tx_gain = tx_gain = 0.9 + self.tx_freq = tx_freq = 5890000000 + self.sync_length = sync_length = 320 + self.samp_rate = samp_rate = 10e6 + self.rx_freq = rx_freq = 5890000000 + self.out_buf_size = out_buf_size = 96000 + self.lo_offset = lo_offset = 11e6 + self.gain = gain = 0.95 + self.encoding = encoding = 0 + self.chan_est = chan_est = 0 + + ################################################## + # Blocks + ################################################## + self._tx_samp_rate_options = [1e6,5e6, 10e6, 20e6] + self._tx_samp_rate_labels = ["1 MHz", "5 MHz", "10 MHz", "20 MHz"] + self._tx_samp_rate_tool_bar = Qt.QToolBar(self) + self._tx_samp_rate_tool_bar.addWidget(Qt.QLabel("tx_samp_rate"+": ")) + self._tx_samp_rate_combo_box = Qt.QComboBox() + self._tx_samp_rate_tool_bar.addWidget(self._tx_samp_rate_combo_box) + for label in self._tx_samp_rate_labels: self._tx_samp_rate_combo_box.addItem(label) + self._tx_samp_rate_callback = lambda i: Qt.QMetaObject.invokeMethod(self._tx_samp_rate_combo_box, "setCurrentIndex", Qt.Q_ARG("int", self._tx_samp_rate_options.index(i))) + self._tx_samp_rate_callback(self.tx_samp_rate) + self._tx_samp_rate_combo_box.currentIndexChanged.connect( + lambda i: self.set_tx_samp_rate(self._tx_samp_rate_options[i])) + self.top_grid_layout.addWidget(self._tx_samp_rate_tool_bar) + self._tx_lo_offset_options = (0, 6e6, 11e6, ) + self._tx_lo_offset_labels = (str(self._tx_lo_offset_options[0]), str(self._tx_lo_offset_options[1]), str(self._tx_lo_offset_options[2]), ) + self._tx_lo_offset_tool_bar = Qt.QToolBar(self) + self._tx_lo_offset_tool_bar.addWidget(Qt.QLabel("tx_lo_offset"+": ")) + self._tx_lo_offset_combo_box = Qt.QComboBox() + self._tx_lo_offset_tool_bar.addWidget(self._tx_lo_offset_combo_box) + for label in self._tx_lo_offset_labels: self._tx_lo_offset_combo_box.addItem(label) + self._tx_lo_offset_callback = lambda i: Qt.QMetaObject.invokeMethod(self._tx_lo_offset_combo_box, "setCurrentIndex", Qt.Q_ARG("int", self._tx_lo_offset_options.index(i))) + self._tx_lo_offset_callback(self.tx_lo_offset) + self._tx_lo_offset_combo_box.currentIndexChanged.connect( + lambda i: self.set_tx_lo_offset(self._tx_lo_offset_options[i])) + self.top_grid_layout.addWidget(self._tx_lo_offset_tool_bar) + self._tx_gain_range = Range(0, 1, 0.01, 0.9, 200) + self._tx_gain_win = RangeWidget(self._tx_gain_range, self.set_tx_gain, "tx_gain", "counter_slider", float) + self.top_grid_layout.addWidget(self._tx_gain_win) + self._tx_freq_options = [2412000000.0, 2417000000.0, 2422000000.0, 2427000000.0, 2432000000.0, 2437000000.0, 2442000000.0, 2447000000.0, 2452000000.0, 2457000000.0, 2462000000.0, 2467000000.0, 2472000000.0, 2484000000.0, 5170000000.0, 5180000000.0, 5190000000.0, 5200000000.0, 5210000000.0, 5220000000.0, 5230000000.0, 5240000000.0, 5250000000.0, 5260000000.0, 5270000000.0, 5280000000.0, 5290000000.0, 5300000000.0, 5310000000.0, 5320000000.0, 5500000000.0, 5510000000.0, 5520000000.0, 5530000000.0, 5540000000.0, 5550000000.0, 5560000000.0, 5570000000.0, 5580000000.0, 5590000000.0, 5600000000.0, 5610000000.0, 5620000000.0, 5630000000.0, 5640000000.0, 5660000000.0, 5670000000.0, 5680000000.0, 5690000000.0, 5700000000.0, 5710000000.0, 5720000000.0, 5745000000.0, 5755000000.0, 5765000000.0, 5775000000.0, 5785000000.0, 5795000000.0, 5805000000.0, 5825000000.0, 5860000000.0, 5870000000.0, 5880000000.0, 5890000000.0, 5900000000.0, 5910000000.0, 5920000000.0] + self._tx_freq_labels = [' 1 | 2412.0 | 11g', ' 2 | 2417.0 | 11g', ' 3 | 2422.0 | 11g', ' 4 | 2427.0 | 11g', ' 5 | 2432.0 | 11g', ' 6 | 2437.0 | 11g', ' 7 | 2442.0 | 11g', ' 8 | 2447.0 | 11g', ' 9 | 2452.0 | 11g', ' 10 | 2457.0 | 11g', ' 11 | 2462.0 | 11g', ' 12 | 2467.0 | 11g', ' 13 | 2472.0 | 11g', ' 14 | 2484.0 | 11g', ' 34 | 5170.0 | 11a', ' 36 | 5180.0 | 11a', ' 38 | 5190.0 | 11a', ' 40 | 5200.0 | 11a', ' 42 | 5210.0 | 11a', ' 44 | 5220.0 | 11a', ' 46 | 5230.0 | 11a', ' 48 | 5240.0 | 11a', ' 50 | 5250.0 | 11a', ' 52 | 5260.0 | 11a', ' 54 | 5270.0 | 11a', ' 56 | 5280.0 | 11a', ' 58 | 5290.0 | 11a', ' 60 | 5300.0 | 11a', ' 62 | 5310.0 | 11a', ' 64 | 5320.0 | 11a', '100 | 5500.0 | 11a', '102 | 5510.0 | 11a', '104 | 5520.0 | 11a', '106 | 5530.0 | 11a', '108 | 5540.0 | 11a', '110 | 5550.0 | 11a', '112 | 5560.0 | 11a', '114 | 5570.0 | 11a', '116 | 5580.0 | 11a', '118 | 5590.0 | 11a', '120 | 5600.0 | 11a', '122 | 5610.0 | 11a', '124 | 5620.0 | 11a', '126 | 5630.0 | 11a', '128 | 5640.0 | 11a', '132 | 5660.0 | 11a', '134 | 5670.0 | 11a', '136 | 5680.0 | 11a', '138 | 5690.0 | 11a', '140 | 5700.0 | 11a', '142 | 5710.0 | 11a', '144 | 5720.0 | 11a', '149 | 5745.0 | 11a (SRD)', '151 | 5755.0 | 11a (SRD)', '153 | 5765.0 | 11a (SRD)', '155 | 5775.0 | 11a (SRD)', '157 | 5785.0 | 11a (SRD)', '159 | 5795.0 | 11a (SRD)', '161 | 5805.0 | 11a (SRD)', '165 | 5825.0 | 11a (SRD)', '172 | 5860.0 | 11p', '174 | 5870.0 | 11p', '176 | 5880.0 | 11p', '178 | 5890.0 | 11p', '180 | 5900.0 | 11p', '182 | 5910.0 | 11p', '184 | 5920.0 | 11p'] + self._tx_freq_tool_bar = Qt.QToolBar(self) + self._tx_freq_tool_bar.addWidget(Qt.QLabel("tx_freq"+": ")) + self._tx_freq_combo_box = Qt.QComboBox() + self._tx_freq_tool_bar.addWidget(self._tx_freq_combo_box) + for label in self._tx_freq_labels: self._tx_freq_combo_box.addItem(label) + self._tx_freq_callback = lambda i: Qt.QMetaObject.invokeMethod(self._tx_freq_combo_box, "setCurrentIndex", Qt.Q_ARG("int", self._tx_freq_options.index(i))) + self._tx_freq_callback(self.tx_freq) + self._tx_freq_combo_box.currentIndexChanged.connect( + lambda i: self.set_tx_freq(self._tx_freq_options[i])) + self.top_grid_layout.addWidget(self._tx_freq_tool_bar) + self._samp_rate_options = [1e6,5e6, 10e6, 20e6] + self._samp_rate_labels = ["1 MHz", "5 MHz", "10 MHz", "20 MHz"] + self._samp_rate_tool_bar = Qt.QToolBar(self) + self._samp_rate_tool_bar.addWidget(Qt.QLabel("samp_rate"+": ")) + self._samp_rate_combo_box = Qt.QComboBox() + self._samp_rate_tool_bar.addWidget(self._samp_rate_combo_box) + for label in self._samp_rate_labels: self._samp_rate_combo_box.addItem(label) + self._samp_rate_callback = lambda i: Qt.QMetaObject.invokeMethod(self._samp_rate_combo_box, "setCurrentIndex", Qt.Q_ARG("int", self._samp_rate_options.index(i))) + self._samp_rate_callback(self.samp_rate) + self._samp_rate_combo_box.currentIndexChanged.connect( + lambda i: self.set_samp_rate(self._samp_rate_options[i])) + self.top_grid_layout.addWidget(self._samp_rate_tool_bar) + self._rx_freq_options = [2412000000.0, 2417000000.0, 2422000000.0, 2427000000.0, 2432000000.0, 2437000000.0, 2442000000.0, 2447000000.0, 2452000000.0, 2457000000.0, 2462000000.0, 2467000000.0, 2472000000.0, 2484000000.0, 5170000000.0, 5180000000.0, 5190000000.0, 5200000000.0, 5210000000.0, 5220000000.0, 5230000000.0, 5240000000.0, 5250000000.0, 5260000000.0, 5270000000.0, 5280000000.0, 5290000000.0, 5300000000.0, 5310000000.0, 5320000000.0, 5500000000.0, 5510000000.0, 5520000000.0, 5530000000.0, 5540000000.0, 5550000000.0, 5560000000.0, 5570000000.0, 5580000000.0, 5590000000.0, 5600000000.0, 5610000000.0, 5620000000.0, 5630000000.0, 5640000000.0, 5660000000.0, 5670000000.0, 5680000000.0, 5690000000.0, 5700000000.0, 5710000000.0, 5720000000.0, 5745000000.0, 5755000000.0, 5765000000.0, 5775000000.0, 5785000000.0, 5795000000.0, 5805000000.0, 5825000000.0, 5860000000.0, 5870000000.0, 5880000000.0, 5890000000.0, 5900000000.0, 5910000000.0, 5920000000.0] + self._rx_freq_labels = [' 1 | 2412.0 | 11g', ' 2 | 2417.0 | 11g', ' 3 | 2422.0 | 11g', ' 4 | 2427.0 | 11g', ' 5 | 2432.0 | 11g', ' 6 | 2437.0 | 11g', ' 7 | 2442.0 | 11g', ' 8 | 2447.0 | 11g', ' 9 | 2452.0 | 11g', ' 10 | 2457.0 | 11g', ' 11 | 2462.0 | 11g', ' 12 | 2467.0 | 11g', ' 13 | 2472.0 | 11g', ' 14 | 2484.0 | 11g', ' 34 | 5170.0 | 11a', ' 36 | 5180.0 | 11a', ' 38 | 5190.0 | 11a', ' 40 | 5200.0 | 11a', ' 42 | 5210.0 | 11a', ' 44 | 5220.0 | 11a', ' 46 | 5230.0 | 11a', ' 48 | 5240.0 | 11a', ' 50 | 5250.0 | 11a', ' 52 | 5260.0 | 11a', ' 54 | 5270.0 | 11a', ' 56 | 5280.0 | 11a', ' 58 | 5290.0 | 11a', ' 60 | 5300.0 | 11a', ' 62 | 5310.0 | 11a', ' 64 | 5320.0 | 11a', '100 | 5500.0 | 11a', '102 | 5510.0 | 11a', '104 | 5520.0 | 11a', '106 | 5530.0 | 11a', '108 | 5540.0 | 11a', '110 | 5550.0 | 11a', '112 | 5560.0 | 11a', '114 | 5570.0 | 11a', '116 | 5580.0 | 11a', '118 | 5590.0 | 11a', '120 | 5600.0 | 11a', '122 | 5610.0 | 11a', '124 | 5620.0 | 11a', '126 | 5630.0 | 11a', '128 | 5640.0 | 11a', '132 | 5660.0 | 11a', '134 | 5670.0 | 11a', '136 | 5680.0 | 11a', '138 | 5690.0 | 11a', '140 | 5700.0 | 11a', '142 | 5710.0 | 11a', '144 | 5720.0 | 11a', '149 | 5745.0 | 11a (SRD)', '151 | 5755.0 | 11a (SRD)', '153 | 5765.0 | 11a (SRD)', '155 | 5775.0 | 11a (SRD)', '157 | 5785.0 | 11a (SRD)', '159 | 5795.0 | 11a (SRD)', '161 | 5805.0 | 11a (SRD)', '165 | 5825.0 | 11a (SRD)', '172 | 5860.0 | 11p', '174 | 5870.0 | 11p', '176 | 5880.0 | 11p', '178 | 5890.0 | 11p', '180 | 5900.0 | 11p', '182 | 5910.0 | 11p', '184 | 5920.0 | 11p'] + self._rx_freq_tool_bar = Qt.QToolBar(self) + self._rx_freq_tool_bar.addWidget(Qt.QLabel("rx_freq"+": ")) + self._rx_freq_combo_box = Qt.QComboBox() + self._rx_freq_tool_bar.addWidget(self._rx_freq_combo_box) + for label in self._rx_freq_labels: self._rx_freq_combo_box.addItem(label) + self._rx_freq_callback = lambda i: Qt.QMetaObject.invokeMethod(self._rx_freq_combo_box, "setCurrentIndex", Qt.Q_ARG("int", self._rx_freq_options.index(i))) + self._rx_freq_callback(self.rx_freq) + self._rx_freq_combo_box.currentIndexChanged.connect( + lambda i: self.set_rx_freq(self._rx_freq_options[i])) + self.top_grid_layout.addWidget(self._rx_freq_tool_bar) + self._lo_offset_options = (0, 6e6, 11e6, ) + self._lo_offset_labels = (str(self._lo_offset_options[0]), str(self._lo_offset_options[1]), str(self._lo_offset_options[2]), ) + self._lo_offset_tool_bar = Qt.QToolBar(self) + self._lo_offset_tool_bar.addWidget(Qt.QLabel("lo_offset"+": ")) + self._lo_offset_combo_box = Qt.QComboBox() + self._lo_offset_tool_bar.addWidget(self._lo_offset_combo_box) + for label in self._lo_offset_labels: self._lo_offset_combo_box.addItem(label) + self._lo_offset_callback = lambda i: Qt.QMetaObject.invokeMethod(self._lo_offset_combo_box, "setCurrentIndex", Qt.Q_ARG("int", self._lo_offset_options.index(i))) + self._lo_offset_callback(self.lo_offset) + self._lo_offset_combo_box.currentIndexChanged.connect( + lambda i: self.set_lo_offset(self._lo_offset_options[i])) + self.top_grid_layout.addWidget(self._lo_offset_tool_bar) + self._gain_range = Range(0, 1, 0.01, 0.95, 200) + self._gain_win = RangeWidget(self._gain_range, self.set_gain, "gain", "counter_slider", float) + self.top_grid_layout.addWidget(self._gain_win) + self._encoding_options = [0, 1, 2, 3, 4, 5, 6, 7] + self._encoding_labels = ["BPSK 1/2", "BPSK 3/4", "QPSK 1/2", "QPSK 3/4", "16QAM 1/2", "16QAM 3/4", "64QAM 2/3", "64QAM 3/4"] + self._encoding_group_box = Qt.QGroupBox("encoding") + self._encoding_box = Qt.QHBoxLayout() + class variable_chooser_button_group(Qt.QButtonGroup): + def __init__(self, parent=None): + Qt.QButtonGroup.__init__(self, parent) + @pyqtSlot(int) + def updateButtonChecked(self, button_id): + self.button(button_id).setChecked(True) + self._encoding_button_group = variable_chooser_button_group() + self._encoding_group_box.setLayout(self._encoding_box) + for i, label in enumerate(self._encoding_labels): + radio_button = Qt.QRadioButton(label) + self._encoding_box.addWidget(radio_button) + self._encoding_button_group.addButton(radio_button, i) + self._encoding_callback = lambda i: Qt.QMetaObject.invokeMethod(self._encoding_button_group, "updateButtonChecked", Qt.Q_ARG("int", self._encoding_options.index(i))) + self._encoding_callback(self.encoding) + self._encoding_button_group.buttonClicked[int].connect( + lambda i: self.set_encoding(self._encoding_options[i])) + self.top_grid_layout.addWidget(self._encoding_group_box) + self._chan_est_options = [ieee802_11.LS, ieee802_11.LMS, ieee802_11.STA, ieee802_11.COMB] + self._chan_est_labels = ["LS", "LMS", "STA", "Linear Comb"] + self._chan_est_group_box = Qt.QGroupBox("chan_est") + self._chan_est_box = Qt.QHBoxLayout() + class variable_chooser_button_group(Qt.QButtonGroup): + def __init__(self, parent=None): + Qt.QButtonGroup.__init__(self, parent) + @pyqtSlot(int) + def updateButtonChecked(self, button_id): + self.button(button_id).setChecked(True) + self._chan_est_button_group = variable_chooser_button_group() + self._chan_est_group_box.setLayout(self._chan_est_box) + for i, label in enumerate(self._chan_est_labels): + radio_button = Qt.QRadioButton(label) + self._chan_est_box.addWidget(radio_button) + self._chan_est_button_group.addButton(radio_button, i) + self._chan_est_callback = lambda i: Qt.QMetaObject.invokeMethod(self._chan_est_button_group, "updateButtonChecked", Qt.Q_ARG("int", self._chan_est_options.index(i))) + self._chan_est_callback(self.chan_est) + self._chan_est_button_group.buttonClicked[int].connect( + lambda i: self.set_chan_est(self._chan_est_options[i])) + self.top_grid_layout.addWidget(self._chan_est_group_box) + self.wifi_phy_hier_0 = wifi_phy_hier( + bandwidth=10e6, + chan_est=0, + encoding=encoding, + frequency=tx_freq, + sensitivity=0.56, + ) + self.uhd_usrp_source_0 = uhd.usrp_source( + ",".join(('', "")), + uhd.stream_args( + cpu_format="fc32", + channels=range(1), + ), + ) + self.uhd_usrp_source_0.set_clock_rate(200e6, uhd.ALL_MBOARDS) + self.uhd_usrp_source_0.set_samp_rate(samp_rate) + self.uhd_usrp_source_0.set_center_freq(uhd.tune_request(rx_freq, rf_freq = rx_freq - lo_offset, rf_freq_policy=uhd.tune_request.POLICY_MANUAL), 0) + self.uhd_usrp_source_0.set_normalized_gain(gain, 0) + self.uhd_usrp_source_0.set_antenna('RX2', 0) + self.uhd_usrp_source_0.set_auto_dc_offset(False, 0) + self.uhd_usrp_source_0.set_auto_iq_balance(False, 0) + self.uhd_usrp_sink_0 = uhd.usrp_sink( + ",".join(('', "")), + uhd.stream_args( + cpu_format="fc32", + channels=range(1), + ), + 'packet_len', + ) + self.uhd_usrp_sink_0.set_samp_rate(tx_samp_rate) + self.uhd_usrp_sink_0.set_time_now(uhd.time_spec(time.time()), uhd.ALL_MBOARDS) + self.uhd_usrp_sink_0.set_center_freq(uhd.tune_request(tx_freq, rf_freq = tx_freq - tx_lo_offset, rf_freq_policy=uhd.tune_request.POLICY_MANUAL), 0) + self.uhd_usrp_sink_0.set_normalized_gain(tx_gain, 0) + self.uhd_usrp_sink_0.set_antenna('TX/RX', 0) + self.qtgui_time_sink_x_0 = qtgui.time_sink_f( + 1024, #size + samp_rate, #samp_rate + "", #name + 1 #number of inputs + ) + self.qtgui_time_sink_x_0.set_update_time(0.10) + self.qtgui_time_sink_x_0.set_y_axis(-1, 1) + + self.qtgui_time_sink_x_0.set_y_label('Amplitude', "") + + self.qtgui_time_sink_x_0.enable_tags(-1, True) + self.qtgui_time_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "") + self.qtgui_time_sink_x_0.enable_autoscale(False) + self.qtgui_time_sink_x_0.enable_grid(False) + self.qtgui_time_sink_x_0.enable_axis_labels(True) + self.qtgui_time_sink_x_0.enable_control_panel(False) + self.qtgui_time_sink_x_0.enable_stem_plot(False) + + if not True: + self.qtgui_time_sink_x_0.disable_legend() + + labels = ['', '', '', '', '', + '', '', '', '', ''] + widths = [1, 1, 1, 1, 1, + 1, 1, 1, 1, 1] + colors = ["blue", "red", "green", "black", "cyan", + "magenta", "yellow", "dark red", "dark green", "blue"] + styles = [1, 1, 1, 1, 1, + 1, 1, 1, 1, 1] + markers = [-1, -1, -1, -1, -1, + -1, -1, -1, -1, -1] + alphas = [1.0, 1.0, 1.0, 1.0, 1.0, + 1.0, 1.0, 1.0, 1.0, 1.0] + + for i in xrange(1): + if len(labels[i]) == 0: + self.qtgui_time_sink_x_0.set_line_label(i, "Data {0}".format(i)) + else: + self.qtgui_time_sink_x_0.set_line_label(i, labels[i]) + self.qtgui_time_sink_x_0.set_line_width(i, widths[i]) + self.qtgui_time_sink_x_0.set_line_color(i, colors[i]) + self.qtgui_time_sink_x_0.set_line_style(i, styles[i]) + self.qtgui_time_sink_x_0.set_line_marker(i, markers[i]) + self.qtgui_time_sink_x_0.set_line_alpha(i, alphas[i]) + + self._qtgui_time_sink_x_0_win = sip.wrapinstance(self.qtgui_time_sink_x_0.pyqwidget(), Qt.QWidget) + self.top_grid_layout.addWidget(self._qtgui_time_sink_x_0_win) + self.qtgui_const_sink_x_0 = qtgui.const_sink_c( + 48*10, #size + "", #name + 1 #number of inputs + ) + self.qtgui_const_sink_x_0.set_update_time(0.10) + self.qtgui_const_sink_x_0.set_y_axis(-2, 2) + self.qtgui_const_sink_x_0.set_x_axis(-2, 2) + self.qtgui_const_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, "") + self.qtgui_const_sink_x_0.enable_autoscale(False) + self.qtgui_const_sink_x_0.enable_grid(False) + self.qtgui_const_sink_x_0.enable_axis_labels(True) + + if not True: + self.qtgui_const_sink_x_0.disable_legend() + + labels = ['', '', '', '', '', + '', '', '', '', ''] + widths = [1, 1, 1, 1, 1, + 1, 1, 1, 1, 1] + colors = ["blue", "red", "red", "red", "red", + "red", "red", "red", "red", "red"] + styles = [0, 0, 0, 0, 0, + 0, 0, 0, 0, 0] + markers = [0, 0, 0, 0, 0, + 0, 0, 0, 0, 0] + alphas = [1.0, 1.0, 1.0, 1.0, 1.0, + 1.0, 1.0, 1.0, 1.0, 1.0] + for i in xrange(1): + if len(labels[i]) == 0: + self.qtgui_const_sink_x_0.set_line_label(i, "Data {0}".format(i)) + else: + self.qtgui_const_sink_x_0.set_line_label(i, labels[i]) + self.qtgui_const_sink_x_0.set_line_width(i, widths[i]) + self.qtgui_const_sink_x_0.set_line_color(i, colors[i]) + self.qtgui_const_sink_x_0.set_line_style(i, styles[i]) + self.qtgui_const_sink_x_0.set_line_marker(i, markers[i]) + self.qtgui_const_sink_x_0.set_line_alpha(i, alphas[i]) + + self._qtgui_const_sink_x_0_win = sip.wrapinstance(self.qtgui_const_sink_x_0.pyqwidget(), Qt.QWidget) + self.top_grid_layout.addWidget(self._qtgui_const_sink_x_0_win) + self.ieee802_11_sync_short_0 = ieee802_11.sync_short(0.56, 2, False, False) + self.ieee802_11_sync_long_0 = ieee802_11.sync_long(sync_length, True, False) + self.ieee802_11_moving_average_xx_1 = ieee802_11.moving_average_ff(window_size + 16) + self.ieee802_11_moving_average_xx_0 = ieee802_11.moving_average_cc(window_size) + self.ieee802_11_mac_0 = ieee802_11.mac(([0x23, 0x23, 0x23, 0x23, 0x23, 0x23]), ([0x42, 0x42, 0x42, 0x42, 0x42, 0x42]), ([0xff, 0xff, 0xff, 0xff, 0xff, 255])) + self.ieee802_11_frame_equalizer_0 = ieee802_11.frame_equalizer(chan_est, rx_freq, samp_rate, False, False) + self.ieee802_11_decode_mac_0 = ieee802_11.decode_mac(True, True) + self.foo_packet_pad2_0 = foo.packet_pad2(False, False, 0.01, 100, 1000) + (self.foo_packet_pad2_0).set_min_output_buffer(96000) + self.fft_vxx_0 = fft.fft_vcc(64, True, (window.rectangular(64)), True, 1) + self.blocks_stream_to_vector_0 = blocks.stream_to_vector(gr.sizeof_gr_complex*1, 64) + self.blocks_pdu_to_tagged_stream_1 = blocks.pdu_to_tagged_stream(blocks.complex_t, 'packet_len') + self.blocks_null_source_0 = blocks.null_source(gr.sizeof_gr_complex*1) + self.blocks_multiply_xx_0 = blocks.multiply_vcc(1) + self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vcc((0.6, )) + (self.blocks_multiply_const_vxx_0).set_min_output_buffer(100000) + self.blocks_divide_xx_0 = blocks.divide_ff(1) + self.blocks_delay_0_0 = blocks.delay(gr.sizeof_gr_complex*1, 16) + self.blocks_delay_0 = blocks.delay(gr.sizeof_gr_complex*1, sync_length) + self.blocks_conjugate_cc_0 = blocks.conjugate_cc() + self.blocks_complex_to_mag_squared_0 = blocks.complex_to_mag_squared(1) + self.blocks_complex_to_mag_0 = blocks.complex_to_mag(1) + + + + ################################################## + # Connections + ################################################## + self.msg_connect((self.ieee802_11_decode_mac_0, 'out'), (self.ieee802_11_mac_0, 'app in')) + self.msg_connect((self.ieee802_11_frame_equalizer_0, 'symbols'), (self.blocks_pdu_to_tagged_stream_1, 'pdus')) + self.msg_connect((self.ieee802_11_mac_0, 'phy out'), (self.wifi_phy_hier_0, 'mac_in')) + self.msg_connect((self.wifi_phy_hier_0, 'mac_out'), (self.ieee802_11_mac_0, 'phy in')) + self.connect((self.blocks_complex_to_mag_0, 0), (self.blocks_divide_xx_0, 0)) + self.connect((self.blocks_complex_to_mag_squared_0, 0), (self.ieee802_11_moving_average_xx_1, 0)) + self.connect((self.blocks_conjugate_cc_0, 0), (self.blocks_multiply_xx_0, 1)) + self.connect((self.blocks_delay_0, 0), (self.ieee802_11_sync_long_0, 1)) + self.connect((self.blocks_delay_0_0, 0), (self.blocks_conjugate_cc_0, 0)) + self.connect((self.blocks_delay_0_0, 0), (self.ieee802_11_sync_short_0, 0)) + self.connect((self.blocks_divide_xx_0, 0), (self.ieee802_11_sync_short_0, 2)) + self.connect((self.blocks_divide_xx_0, 0), (self.qtgui_time_sink_x_0, 0)) + self.connect((self.blocks_multiply_const_vxx_0, 0), (self.foo_packet_pad2_0, 0)) + self.connect((self.blocks_multiply_xx_0, 0), (self.ieee802_11_moving_average_xx_0, 0)) + self.connect((self.blocks_null_source_0, 0), (self.wifi_phy_hier_0, 0)) + self.connect((self.blocks_pdu_to_tagged_stream_1, 0), (self.qtgui_const_sink_x_0, 0)) + self.connect((self.blocks_stream_to_vector_0, 0), (self.fft_vxx_0, 0)) + self.connect((self.fft_vxx_0, 0), (self.ieee802_11_frame_equalizer_0, 0)) + self.connect((self.foo_packet_pad2_0, 0), (self.uhd_usrp_sink_0, 0)) + self.connect((self.ieee802_11_frame_equalizer_0, 0), (self.ieee802_11_decode_mac_0, 0)) + self.connect((self.ieee802_11_moving_average_xx_0, 0), (self.blocks_complex_to_mag_0, 0)) + self.connect((self.ieee802_11_moving_average_xx_0, 0), (self.ieee802_11_sync_short_0, 1)) + self.connect((self.ieee802_11_moving_average_xx_1, 0), (self.blocks_divide_xx_0, 1)) + self.connect((self.ieee802_11_sync_long_0, 0), (self.blocks_stream_to_vector_0, 0)) + self.connect((self.ieee802_11_sync_short_0, 0), (self.blocks_delay_0, 0)) + self.connect((self.ieee802_11_sync_short_0, 0), (self.ieee802_11_sync_long_0, 0)) + self.connect((self.uhd_usrp_source_0, 0), (self.blocks_complex_to_mag_squared_0, 0)) + self.connect((self.uhd_usrp_source_0, 0), (self.blocks_delay_0_0, 0)) + self.connect((self.uhd_usrp_source_0, 0), (self.blocks_multiply_xx_0, 0)) + self.connect((self.wifi_phy_hier_0, 0), (self.blocks_multiply_const_vxx_0, 0)) + + def closeEvent(self, event): + self.settings = Qt.QSettings("GNU Radio", "reactive_jammer") + self.settings.setValue("geometry", self.saveGeometry()) + event.accept() + + def get_window_size(self): + return self.window_size + + def set_window_size(self, window_size): + self.window_size = window_size + self.ieee802_11_moving_average_xx_1.set_length(self.window_size + 16) + self.ieee802_11_moving_average_xx_0.set_length(self.window_size) + + def get_tx_samp_rate(self): + return self.tx_samp_rate + + def set_tx_samp_rate(self, tx_samp_rate): + self.tx_samp_rate = tx_samp_rate + self._tx_samp_rate_callback(self.tx_samp_rate) + self.uhd_usrp_sink_0.set_samp_rate(self.tx_samp_rate) + + def get_tx_lo_offset(self): + return self.tx_lo_offset + + def set_tx_lo_offset(self, tx_lo_offset): + self.tx_lo_offset = tx_lo_offset + self._tx_lo_offset_callback(self.tx_lo_offset) + self.uhd_usrp_sink_0.set_center_freq(uhd.tune_request(self.tx_freq, rf_freq = self.tx_freq - self.tx_lo_offset, rf_freq_policy=uhd.tune_request.POLICY_MANUAL), 0) + + def get_tx_gain(self): + return self.tx_gain + + def set_tx_gain(self, tx_gain): + self.tx_gain = tx_gain + self.uhd_usrp_sink_0.set_normalized_gain(self.tx_gain, 0) + + + def get_tx_freq(self): + return self.tx_freq + + def set_tx_freq(self, tx_freq): + self.tx_freq = tx_freq + self._tx_freq_callback(self.tx_freq) + self.wifi_phy_hier_0.set_frequency(self.tx_freq) + self.uhd_usrp_sink_0.set_center_freq(uhd.tune_request(self.tx_freq, rf_freq = self.tx_freq - self.tx_lo_offset, rf_freq_policy=uhd.tune_request.POLICY_MANUAL), 0) + + def get_sync_length(self): + return self.sync_length + + def set_sync_length(self, sync_length): + self.sync_length = sync_length + self.blocks_delay_0.set_dly(self.sync_length) + + def get_samp_rate(self): + return self.samp_rate + + def set_samp_rate(self, samp_rate): + self.samp_rate = samp_rate + self._samp_rate_callback(self.samp_rate) + self.uhd_usrp_source_0.set_samp_rate(self.samp_rate) + self.qtgui_time_sink_x_0.set_samp_rate(self.samp_rate) + self.ieee802_11_frame_equalizer_0.set_bandwidth(self.samp_rate) + + def get_rx_freq(self): + return self.rx_freq + + def set_rx_freq(self, rx_freq): + self.rx_freq = rx_freq + self._rx_freq_callback(self.rx_freq) + self.uhd_usrp_source_0.set_center_freq(uhd.tune_request(self.rx_freq, rf_freq = self.rx_freq - self.lo_offset, rf_freq_policy=uhd.tune_request.POLICY_MANUAL), 0) + self.ieee802_11_frame_equalizer_0.set_frequency(self.rx_freq) + + def get_out_buf_size(self): + return self.out_buf_size + + def set_out_buf_size(self, out_buf_size): + self.out_buf_size = out_buf_size + + def get_lo_offset(self): + return self.lo_offset + + def set_lo_offset(self, lo_offset): + self.lo_offset = lo_offset + self._lo_offset_callback(self.lo_offset) + self.uhd_usrp_source_0.set_center_freq(uhd.tune_request(self.rx_freq, rf_freq = self.rx_freq - self.lo_offset, rf_freq_policy=uhd.tune_request.POLICY_MANUAL), 0) + + def get_gain(self): + return self.gain + + def set_gain(self, gain): + self.gain = gain + self.uhd_usrp_source_0.set_normalized_gain(self.gain, 0) + + + def get_encoding(self): + return self.encoding + + def set_encoding(self, encoding): + self.encoding = encoding + self._encoding_callback(self.encoding) + self.wifi_phy_hier_0.set_encoding(self.encoding) + + def get_chan_est(self): + return self.chan_est + + def set_chan_est(self, chan_est): + self.chan_est = chan_est + self._chan_est_callback(self.chan_est) + self.ieee802_11_frame_equalizer_0.set_algorithm(self.chan_est) + + +def main(top_block_cls=reactive_jammer, options=None): + + from distutils.version import StrictVersion + if StrictVersion(Qt.qVersion()) >= StrictVersion("4.5.0"): + style = gr.prefs().get_string('qtgui', 'style', 'raster') + Qt.QApplication.setGraphicsSystem(style) + qapp = Qt.QApplication(sys.argv) + + tb = top_block_cls() + tb.start() + tb.show() + + def quitting(): + tb.stop() + tb.wait() + qapp.connect(qapp, Qt.SIGNAL("aboutToQuit()"), quitting) + qapp.exec_() + + +if __name__ == '__main__': + main() diff --git a/wifi_tx.grc b/wifi_tx.grc index 1f440f3b..1b866059 100644 --- a/wifi_tx.grc +++ b/wifi_tx.grc @@ -984,7 +984,7 @@ ant0 - TX/RX + bw0 @@ -1648,7 +1648,7 @@ _coordinate - (504, 540) + (808, 508) _rotation @@ -1664,7 +1664,7 @@ clock_source0 - + internal sd_spec0 @@ -1819,7 +1819,7 @@ _coordinate - (464, 400) + (472, 396) _rotation From a595be714d32c111f2299eb4c5553d57537e89c2 Mon Sep 17 00:00:00 2001 From: Geoff Twardokus Date: Fri, 13 Nov 2020 12:20:39 -0500 Subject: [PATCH 18/22] Update jammer --- reactive_jammer.grc | 221 +++++++++++++++++++++++++++++++++++++++----- 1 file changed, 200 insertions(+), 21 deletions(-) diff --git a/reactive_jammer.grc b/reactive_jammer.grc index 8415cd76..a1a7dee5 100644 --- a/reactive_jammer.grc +++ b/reactive_jammer.grc @@ -204,7 +204,7 @@ _coordinate - (1376, 44) + (1312, 4) gui_hint @@ -461,7 +461,7 @@ _coordinate - (1120, 44) + (1056, 4) _rotation @@ -717,7 +717,7 @@ _coordinate - (1592, 44) + (1496, 4) gui_hint @@ -816,7 +816,7 @@ _coordinate - (1232, 44) + (1168, 4) gui_hint @@ -879,7 +879,7 @@ _coordinate - (1896, 180) + (1864, 4) gui_hint @@ -978,7 +978,7 @@ _coordinate - (1784, 44) + (1680, 4) gui_hint @@ -1398,7 +1398,7 @@ _coordinate - (1320, 428) + (1352, 468) _rotation @@ -1500,7 +1500,7 @@ _coordinate - (1752, 456) + (1800, 456) _rotation @@ -1551,7 +1551,7 @@ _coordinate - (224, 788) + (360, 812) _rotation @@ -1578,6 +1578,65 @@ 0 + + blocks_socket_pdu + + alias + + + + comment + + + + affinity + + + + _enabled + 0 + + + _coordinate + (1000, 164) + + + _rotation + 0 + + + host + + + + id + blocks_socket_pdu_0 + + + mtu + 10000 + + + maxoutbuf + 0 + + + minoutbuf + 0 + + + port + 52001 + + + tcp_no_delay + False + + + type + "UDP_SERVER" + + blocks_stream_to_vector @@ -1598,7 +1657,7 @@ _coordinate - (784, 548) + (576, 572) _rotation @@ -1629,6 +1688,61 @@ 1 + + blocks_udp_sink + + alias + + + + comment + + + + affinity + + + + ipaddr + localhost + + + port + 52001 + + + _enabled + 0 + + + _coordinate + (1240, 772) + + + _rotation + 0 + + + id + blocks_udp_sink_0 + + + type + byte + + + psize + 2000 + + + eof + True + + + vlen + 1 + + fft_vxx @@ -1657,7 +1771,7 @@ _coordinate - (56, 660) + (104, 628) _rotation @@ -1724,7 +1838,7 @@ _coordinate - (1240, 500) + (1288, 540) _rotation @@ -1751,6 +1865,53 @@ 1000 + + foo_wireshark_connector + + alias + + + + comment + + + + affinity + + + + debug + False + + + _enabled + 0 + + + _coordinate + (896, 748) + + + _rotation + 0 + + + id + foo_wireshark_connector_0 + + + maxoutbuf + 0 + + + minoutbuf + 0 + + + tech + 127 + + ieee802_11_decode_mac @@ -1775,7 +1936,7 @@ _coordinate - (856, 628) + (896, 636) _rotation @@ -1834,7 +1995,7 @@ _coordinate - (336, 660) + (416, 628) _rotation @@ -1885,7 +2046,7 @@ _coordinate - (1312, 204) + (1288, 332) _rotation @@ -1975,7 +2136,7 @@ _coordinate - (432, 260) + (560, 260) _rotation @@ -2026,7 +2187,7 @@ _coordinate - (800, 284) + (848, 300) _rotation @@ -2136,7 +2297,7 @@ _coordinate - (224, 852) + (360, 876) gui_hint @@ -3494,7 +3655,7 @@ _coordinate - (1712, 636) + (1560, 588) _rotation @@ -4829,7 +4990,7 @@ _coordinate - (24, 268) + (16, 268) _rotation @@ -5004,7 +5165,7 @@ _coordinate - (1512, 348) + (1560, 404) _rotation @@ -5115,6 +5276,12 @@ 0 0 + + blocks_socket_pdu_0 + ieee802_11_mac_0 + pdus + app in + blocks_stream_to_vector_0 fft_vxx_0 @@ -5133,6 +5300,18 @@ 0 0 + + foo_wireshark_connector_0 + blocks_udp_sink_0 + 0 + 0 + + + ieee802_11_decode_mac_0 + foo_wireshark_connector_0 + out + in + ieee802_11_decode_mac_0 ieee802_11_mac_0 From 8df3f0c823955dadfe5a2af27369a7a0083cb065 Mon Sep 17 00:00:00 2001 From: Geoff Twardokus Date: Fri, 13 Nov 2020 12:25:19 -0500 Subject: [PATCH 19/22] new branch --- temp.txt | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 temp.txt diff --git a/temp.txt b/temp.txt new file mode 100644 index 00000000..e69de29b From df171040f7f008537f23e581dad1edc79f58c618 Mon Sep 17 00:00:00 2001 From: Geoff Twardokus Date: Fri, 13 Nov 2020 12:52:51 -0500 Subject: [PATCH 20/22] Restored basic GUI functionality --- Receiver.py | 27 ++++++++++++--------------- init.yml | 4 ++-- local_main.py | 21 ++++++--------------- 3 files changed, 20 insertions(+), 32 deletions(-) diff --git a/Receiver.py b/Receiver.py index 64555a47..7b7706c9 100644 --- a/Receiver.py +++ b/Receiver.py @@ -11,33 +11,33 @@ def __init__(self): self.verifier = Verifier() self.messageCounter = 1 - def runReceiver(self): - listener = Thread(target=self.listenForWSMs()) + def runReceiver(self, s, lock): + listener = Thread(target=self.listenForWSMs(s, lock)) listener.start() - def listenForWSMs(self): + def listenForWSMs(self, s, lock): # print a console message to confirm the network connection is active print("Listening on localhost:4444 for WSMs") # listen on localhost:4444 which is the UDP sink from GNURadio in wifi_rx.py # received packets are passed to processPacket() for data extraction - sniff(iface="lo", filter="dst port 4444", prn=lambda x: self.filterDuplicatePackets(str(binascii.hexlify(x.load))[130:])) + sniff(iface="lo", filter="dst port 4444", prn=lambda x: self.filterDuplicatePackets(str(binascii.hexlify(x.load))[130:], s, lock)) - def filterDuplicatePackets(self, payload): + def filterDuplicatePackets(self, payload, s, lock): if self.messageCounter % 2 == 1: - self.processPacket(payload) + self.processPacket(payload, s, lock) self.messageCounter += 1 # uses returned tuple from parseWSM to verify message and send to GUI - def processPacket(self, payload): + def processPacket(self, payload, s, lock): # extract the elements "(unsecuredData,r,s,time)" from the 1609.2 structure data = self.parseWSM(payload) - + """ if data == -1: return - """ + #BSMData = data[0].decode('hex').replace("\n","").split(",") BSMData = bytes.fromhex(data[0]).decode('ascii').replace("\n","").split(",") @@ -50,7 +50,7 @@ def processPacket(self, payload): decodedData['y'] = BSMData[2] decodedData['heading'] = BSMData[3] decodedData['speed'] = BSMData[4] - """ + # publicKey = keys.import_key("keys/" + decodedData['id'] + "/p256.pub",curve=curve.P256, public=True) publicKey = keys.import_key("keys/0/p256.pub",curve=curve.P256, public=True) @@ -59,8 +59,8 @@ def processPacket(self, payload): # verify the signature isValidSig = self.verifier.verifySignature(data[1],data[2],data[0],publicKey) - #elapsed, isRecent = self.verifier.verifyTime(data[3]) - """ + elapsed, isRecent = self.verifier.verifyTime(data[3]) + decodedData['sig'] = isValidSig decodedData['elapsed'] = elapsed decodedData['recent'] = isRecent @@ -70,9 +70,6 @@ def processPacket(self, payload): with lock: s.send(vehicleDataJSON.encode()) - """ - - print(isValidSig) # takes the hex payload from an 802.11p frame as an argument, returns tuple of extracted bytestrings def parseWSM(self, WSM): diff --git a/init.yml b/init.yml index 68e353ef..a8f197ea 100644 --- a/init.yml +++ b/init.yml @@ -10,7 +10,7 @@ remoteConfig: 6 localConfig: tracefile: - test_coords + coords_1 spoofer: traceFile: - test_coords \ No newline at end of file + test_coords diff --git a/local_main.py b/local_main.py index bf30f608..60878212 100644 --- a/local_main.py +++ b/local_main.py @@ -1,18 +1,13 @@ # this is the main execution file for the "local vehicle" import os -""" -import sys - - -print(os.getcwd()) -sys.path.append("/home/administrator/eclipse-workspace/v2verifier/v2verifier") -""" - import yaml from threading import Lock, Thread from socket import socket from Receiver import Receiver +from LocalVehicle import LocalVehicle +from GUI import GUI +import tkinter as tk #from LocalVehicle import LocalVehicle @@ -26,31 +21,27 @@ print("Error - you must be root! Try running with sudo") exit(1) - """ + root = tk.Tk() gui = GUI(root) gui.runGUIReceiver() print("GUI Initialized...") - s2 = socket() s2.connect(('127.0.0.1',6666)) - """ lock = Lock() receiver = Receiver() - listener = Thread(target=receiver.runReceiver()) + listener = Thread(target=receiver.runReceiver, args=(s2, lock,)) listener.start() print("Listener running...") - """ lv = LocalVehicle(config["localConfig"]["tracefile"]) local = Thread(target=lv.start, args=(s2,lock,)) local.start() - root.mainloop() - """ \ No newline at end of file + \ No newline at end of file From ad8446eb9099d215599eb4f84ce344d45a77df00 Mon Sep 17 00:00:00 2001 From: Geoff Twardokus Date: Fri, 13 Nov 2020 13:20:05 -0500 Subject: [PATCH 21/22] Verified remote functionality working as expected (without upgrades) --- Receiver.py | 86 ++++++++++++++++++----------------------- block_editing_notes.txt | 8 ---- local_main.py | 2 - 3 files changed, 37 insertions(+), 59 deletions(-) delete mode 100644 block_editing_notes.txt diff --git a/Receiver.py b/Receiver.py index 7b7706c9..a5b881f3 100644 --- a/Receiver.py +++ b/Receiver.py @@ -16,33 +16,25 @@ def runReceiver(self, s, lock): listener.start() def listenForWSMs(self, s, lock): - # print a console message to confirm the network connection is active + print("Listening on localhost:4444 for WSMs") - # listen on localhost:4444 which is the UDP sink from GNURadio in wifi_rx.py - # received packets are passed to processPacket() for data extraction - sniff(iface="lo", filter="dst port 4444", prn=lambda x: self.filterDuplicatePackets(str(binascii.hexlify(x.load))[130:], s, lock)) + # port 4444 corresponds to UDP interface in wifi_rx.grc + sniff(iface="lo", filter="dst port 4444", prn=lambda x: + self.filterDuplicatePackets(str(binascii.hexlify(x.load))[130:], s, lock)) def filterDuplicatePackets(self, payload, s, lock): if self.messageCounter % 2 == 1: self.processPacket(payload, s, lock) self.messageCounter += 1 - # uses returned tuple from parseWSM to verify message and send to GUI def processPacket(self, payload, s, lock): - # extract the elements "(unsecuredData,r,s,time)" from the 1609.2 structure data = self.parseWSM(payload) - """ - if data == -1: - return - """ #BSMData = data[0].decode('hex').replace("\n","").split(",") BSMData = bytes.fromhex(data[0]).decode('ascii').replace("\n","").split(",") - - # create a dictionary to pack and send decodedData = {} decodedData['id'] = BSMData[0] @@ -73,42 +65,38 @@ def processPacket(self, payload, s, lock): # takes the hex payload from an 802.11p frame as an argument, returns tuple of extracted bytestrings def parseWSM(self, WSM): - try: - # The first 8 bytes are WSMP N/T headers that do not change in size and can be discarded - ieee1609Dot2Data = WSM[8:] + # The first 8 bytes are WSMP N/T headers that do not change in size and can be discarded + ieee1609Dot2Data = WSM[8:] + + # First item to extract is the payload in unsecured data field - # First item to extract is the payload in unsecured data field - - # Note that the numbers for positions are double the byte value - # because this is a string of "hex numbers" so 1 byte = 2 chars - - unsecuredDataLength = int(ieee1609Dot2Data[14:16],16)*2 - unsecuredData = ieee1609Dot2Data[16:16+(unsecuredDataLength)] - timePostition = 16 + unsecuredDataLength + 6 - time = ieee1609Dot2Data[timePostition:timePostition+16] - - # the ecdsaNistP256Signature structure is 66 bytes - # r - 32 bytes - # s - 32 bytes - # field separators - 2 bytes - signature = ieee1609Dot2Data[len(ieee1609Dot2Data)-(2*66)-1:] - - # drop the two field identification bytes at the start of the block - signature = signature[4:] - - # split into r and s - - r = signature[:64] - s = signature[64:128] - - # convert from string into ten-bit integer - r = int(r,16) - s = int(s,16) - - r = int(str(r)) - s = int(str(s)) + # Note that the numbers for positions are double the byte value + # because this is a string of "hex numbers" so 1 byte = 2 chars + + unsecuredDataLength = int(ieee1609Dot2Data[14:16],16)*2 + unsecuredData = ieee1609Dot2Data[16:16+(unsecuredDataLength)] + timePostition = 16 + unsecuredDataLength + 6 + time = ieee1609Dot2Data[timePostition:timePostition+16] + + # the ecdsaNistP256Signature structure is 66 bytes + # r - 32 bytes + # s - 32 bytes + # field separators - 2 bytes + signature = ieee1609Dot2Data[len(ieee1609Dot2Data)-(2*66)-1:] + + # drop the two field identification bytes at the start of the block + signature = signature[4:] - return (unsecuredData,r,s,time) - except: - print("Not a WSM.") - return -1 + # split into r and s + + r = signature[:64] + s = signature[64:128] + + # convert from string into ten-bit integer + r = int(r,16) + s = int(s,16) + + r = int(str(r)) + s = int(str(s)) + + return (unsecuredData,r,s,time) diff --git a/block_editing_notes.txt b/block_editing_notes.txt deleted file mode 100644 index f0c49890..00000000 --- a/block_editing_notes.txt +++ /dev/null @@ -1,8 +0,0 @@ -To rebuild gr-foo: - -Make the changes to /home/gr-foo/lib/wireshark_connector_impl.cc - -cd ~/gr-foo/build -cmake ../ -make -sudo make install diff --git a/local_main.py b/local_main.py index 60878212..eb6333b1 100644 --- a/local_main.py +++ b/local_main.py @@ -1,5 +1,3 @@ -# this is the main execution file for the "local vehicle" - import os import yaml from threading import Lock, Thread From 4e9ac3a33845aadd5e7a9cc9e0cda815e5c24e17 Mon Sep 17 00:00:00 2001 From: Geoff Twardokus Date: Fri, 13 Nov 2020 13:21:00 -0500 Subject: [PATCH 22/22] Working properly --- RemoteVehicle.py | 2 +- init.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/RemoteVehicle.py b/RemoteVehicle.py index 0af63bdf..67508600 100644 --- a/RemoteVehicle.py +++ b/RemoteVehicle.py @@ -15,4 +15,4 @@ def start(self): print("Sending BSM") loader = subprocess.Popen(("echo","-n","-e",BSM), stdout=subprocess.PIPE) sender = subprocess.check_output(("nc","-w0","-u","localhost","52001"),stdin=loader.stdout) - time.sleep(3) \ No newline at end of file + time.sleep(0.1) diff --git a/init.yml b/init.yml index a8f197ea..c23f47ad 100644 --- a/init.yml +++ b/init.yml @@ -1,7 +1,7 @@ remoteConfig: numberOfVehicles: 1 traceFiles: - - test_coords + - coords_3 - coords_1 - coords_3 - coords_4