├── Fixed Frequency Barrage Jamming ├── Fixed Frequency Sweep Jamming ├── 2.4 GHz band Sweep Jamming ├── Random Frequency Selecting Barrage Jamming └── Sequential Frequency Increment Barrage Jamming /Fixed Frequency Barrage Jamming: -------------------------------------------------------------------------------- 1 | from packaging.version import Version as StrictVersion 2 | from PyQt5 import Qt 3 | from gnuradio import qtgui 4 | from gnuradio import analog 5 | from gnuradio import filter 6 | from gnuradio.filter import firdes 7 | from gnuradio import gr 8 | from gnuradio.fft import window 9 | import sys 10 | import signal 11 | from PyQt5 import Qt 12 | from argparse import ArgumentParser 13 | from gnuradio.eng_arg import eng_float, intx 14 | from gnuradio import eng_notation 15 | from gnuradio import iio 16 | from gnuradio.qtgui import Range, RangeWidget 17 | from PyQt5 import QtCore 18 | import sip 19 | 20 | class Barrage24(gr.top_block, Qt.QWidget): 21 | def __init__(self, BW=20000000, samp_rate=2000000, uri='ip:pluto.local'): 22 | gr.top_block.__init__(self, "Barrage24", catch_exceptions=True) 23 | Qt.QWidget.__init__(self) 24 | self.setWindowTitle("Barrage24") 25 | qtgui.util.check_set_qss() 26 | try: 27 | self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc')) 28 | except BaseException as exc: 29 | print(f"Qt GUI: Could not set Icon: {str(exc)}", file=sys.stderr) 30 | self.top_scroll_layout = Qt.QVBoxLayout() 31 | self.setLayout(self.top_scroll_layout) 32 | self.top_scroll = Qt.QScrollArea() 33 | self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame) 34 | self.top_scroll_layout.addWidget(self.top_scroll) 35 | self.top_scroll.setWidgetResizable(True) 36 | self.top_widget = Qt.QWidget() 37 | self.top_scroll.setWidget(self.top_widget) 38 | self.top_layout = Qt.QVBoxLayout(self.top_widget) 39 | self.top_grid_layout = Qt.QGridLayout() 40 | self.top_layout.addLayout(self.top_grid_layout) 41 | self.settings = Qt.QSettings("GNU Radio", "Barrage24") 42 | 43 | try: 44 | if StrictVersion(Qt.qVersion()) < StrictVersion("5.0.0"): 45 | self.restoreGeometry 46 | (self.settings.value("geometry").toByteArray()) 47 | else: 48 | self.restoreGeometry(self.settings.value("geometry")) 49 | except BaseException as exc: 50 | print(f"Qt GUI: Could not restore geometry: {str(exc)}", 51 | file=sys.stderr) 52 | ################################################## 53 | # Parameters 54 | ################################################## 55 | self.BW = BW 56 | self.samp_rate = samp_rate 57 | self.uri = uri 58 | ################################################## 59 | # Variables 60 | ################################################## 61 | self.attenuation = attenuation = 10 62 | ################################################## 63 | # Blocks 64 | ################################################## 65 | self._attenuation_range = Range(-40, 10, 1, 10, 200) 66 | self._attenuation_win = RangeWidget 67 | (self._attenuation_range, self.set_attenuation, "'attenuation'", 68 | "counter_slider", float, QtCore.Qt.Horizontal) 69 | self.top_layout.addWidget(self._attenuation_win) 70 | self.qtgui_sink_x_0_0 = qtgui.sink_c( 71 | 1024, #fftsize 72 | window.WIN_BLACKMAN_hARRIS, #wintype 73 | 2440000000, #fc 74 | BW, #bw 75 | 'Emission', #name 76 | True, #plotfreq 77 | True, #plotwaterfall 78 | True, #plottime 79 | True, #plotconst 80 | None # parent 81 | ) 82 | self.qtgui_sink_x_0_0.set_update_time(1.0/10) 83 | self._qtgui_sink_x_0_0_win = sip.wrapinstance 84 | (self.qtgui_sink_x_0_0.qwidget(), Qt.QWidget) 85 | self.qtgui_sink_x_0_0.enable_rf_freq(False) 86 | self.top_layout.addWidget(self._qtgui_sink_x_0_0_win) 87 | self.low_pass_filter_0 = filter.fir_filter_ccf( 88 | 1, 89 | firdes.low_pass( 90 | 1, 91 | samp_rate, 92 | (samp_rate/3), 93 | (samp_rate/12), 94 | window.WIN_HAMMING, 95 | 6.76)) 96 | self.iio_pluto_sink_0 = iio.fmcomms2_sink_fc32(uri if uri 97 | else iio.get_pluto_uri(), [True, True], 32768, False) 98 | self.iio_pluto_sink_0.set_len_tag_key('') 99 | self.iio_pluto_sink_0.set_bandwidth(BW) 100 | self.iio_pluto_sink_0.set_frequency(2440000000) 101 | self.iio_pluto_sink_0.set_samplerate(samp_rate) 102 | self.iio_pluto_sink_0.set_attenuation(0, attenuation) 103 | self.iio_pluto_sink_0.set_filter_params('Auto', '', 0, 0) 104 | self.analog_noise_source_x_0 = analog.noise_source_c 105 | (analog.GR_GAUSSIAN, 1, 0) 106 | ################################################## 107 | # Connections 108 | ################################################## 109 | self.connect((self.analog_noise_source_x_0, 0), 110 | (self.low_pass_filter_0, 0)) 111 | self.connect((self.low_pass_filter_0, 0), (self.iio_pluto_sink_0, 0)) 112 | self.connect((self.low_pass_filter_0, 0), (self.qtgui_sink_x_0_0, 0)) 113 | 114 | def closeEvent(self, event): 115 | self.settings = Qt.QSettings("GNU Radio", "Barrage24") 116 | self.settings.setValue("geometry", self.saveGeometry()) 117 | self.stop() 118 | self.wait() 119 | event.accept() 120 | 121 | def get_BW(self): 122 | return self.BW 123 | 124 | def set_BW(self, BW): 125 | self.BW = BW 126 | self.iio_pluto_sink_0.set_bandwidth(self.BW) 127 | self.qtgui_sink_x_0_0.set_frequency_range(2440000000, self.BW) 128 | 129 | def get_samp_rate(self): 130 | return self.samp_rate 131 | 132 | def set_samp_rate(self, samp_rate): 133 | self.samp_rate = samp_rate 134 | self.iio_pluto_sink_0.set_samplerate(self.samp_rate) 135 | self.low_pass_filter_0.set_taps(firdes.low_pass 136 | (1, self.samp_rate, (self.samp_rate/3), (self.samp_rate/12), 137 | window.WIN_HAMMING, 6.76)) 138 | 139 | def get_uri(self): 140 | return self.uri 141 | 142 | def set_uri(self, uri): 143 | self.uri = uri 144 | 145 | def get_attenuation(self): 146 | return self.attenuation 147 | 148 | def set_attenuation(self, attenuation): 149 | self.attenuation = attenuation 150 | self.iio_pluto_sink_0.set_attenuation(0,self.attenuation) 151 | 152 | def argument_parser(): 153 | parser = ArgumentParser() 154 | parser.add_argument( 155 | "--uri", dest="uri", type=str, default='ip:pluto.local', 156 | help="Set URI [default=%(default)r]") 157 | return parser 158 | 159 | def main(top_block_cls=Barrage24, options=None): 160 | if options is None: 161 | options = argument_parser().parse_args() 162 | 163 | if StrictVersion("4.5.0") <= StrictVersion(Qt.qVersion()) < 164 | StrictVersion("5.0.0"): 165 | style = gr.prefs().get_string('qtgui', 'style', 'raster') 166 | Qt.QApplication.setGraphicsSystem(style) 167 | qapp = Qt.QApplication(sys.argv) 168 | tb = top_block_cls(uri=options.uri) 169 | tb.start() 170 | tb.show() 171 | 172 | def sig_handler(sig=None, frame=None): 173 | tb.stop() 174 | tb.wait() 175 | Qt.QApplication.quit() 176 | 177 | signal.signal(signal.SIGINT, sig_handler) 178 | signal.signal(signal.SIGTERM, sig_handler) 179 | timer = Qt.QTimer() 180 | timer.start(500) 181 | timer.timeout.connect(lambda: None) 182 | qapp.exec_() 183 | 184 | if __name__ == '__main__': 185 | main() 186 | -------------------------------------------------------------------------------- /Fixed Frequency Sweep Jamming: -------------------------------------------------------------------------------- 1 | from packaging.version import Version as StrictVersion 2 | from PyQt5 import Qt 3 | from gnuradio import qtgui 4 | from gnuradio import analog 5 | from gnuradio import blocks 6 | from gnuradio import gr 7 | from gnuradio.filter import firdes 8 | from gnuradio.fft import window 9 | import sys 10 | import signal 11 | from PyQt5 import Qt 12 | from argparse import ArgumentParser 13 | from gnuradio.eng_arg import eng_float, intx 14 | from gnuradio import eng_notation 15 | from gnuradio import iio 16 | import sip 17 | 18 | class sweepjammer(gr.top_block, Qt.QWidget): 19 | 20 | def __init__(self, uri='ip:pluto.local'): 21 | gr.top_block.__init__(self, "Sweep jammer", catch_exceptions=True) 22 | Qt.QWidget.__init__(self) 23 | self.setWindowTitle("Sweep jammer") 24 | qtgui.util.check_set_qss() 25 | try: 26 | self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc')) 27 | except BaseException as exc: 28 | print(f"Qt GUI: Could not set Icon: {str(exc)}", file=sys.stderr) 29 | self.top_scroll_layout = Qt.QVBoxLayout() 30 | self.setLayout(self.top_scroll_layout) 31 | self.top_scroll = Qt.QScrollArea() 32 | self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame) 33 | self.top_scroll_layout.addWidget(self.top_scroll) 34 | self.top_scroll.setWidgetResizable(True) 35 | self.top_widget = Qt.QWidget() 36 | self.top_scroll.setWidget(self.top_widget) 37 | self.top_layout = Qt.QVBoxLayout(self.top_widget) 38 | self.top_grid_layout = Qt.QGridLayout() 39 | self.top_layout.addLayout(self.top_grid_layout) 40 | self.settings = Qt.QSettings("GNU Radio", "sweepjammer") 41 | 42 | try: 43 | if StrictVersion(Qt.qVersion()) < StrictVersion("5.0.0"): 44 | self.restoreGeometry(self.settings.value("geometry"). 45 | toByteArray()) 46 | else: 47 | self.restoreGeometry(self.settings.value("geometry")) 48 | except BaseException as exc: 49 | print(f"Qt GUI: Could not restore geometry: {str(exc)}", 50 | file=sys.stderr) 51 | ################################################## 52 | # Parameters 53 | ################################################## 54 | self.uri = uri 55 | ################################################## 56 | # Variables 57 | ################################################## 58 | self.samp_rate = samp_rate = 2000000 59 | ################################################## 60 | # Blocks 61 | ################################################## 62 | self.qtgui_sink_x_1 = qtgui.sink_c( 63 | 1024, #fftsize 64 | window.WIN_BLACKMAN_hARRIS, #wintype 65 | 1575420000, #fc 66 | samp_rate, #bw 67 | "", #name 68 | True, #plotfreq 69 | True, #plotwaterfall 70 | True, #plottime 71 | True, #plotconst 72 | None # parent 73 | ) 74 | self.qtgui_sink_x_1.set_update_time(1.0/10) 75 | self._qtgui_sink_x_1_win = sip.wrapinstance 76 | (self.qtgui_sink_x_1.qwidget(), Qt.QWidget) 77 | self.qtgui_sink_x_1.enable_rf_freq(False) 78 | self.top_layout.addWidget(self._qtgui_sink_x_1_win) 79 | self.qtgui_sink_x_0 = qtgui.sink_c( 80 | 1024, #fftsize 81 | window.WIN_BLACKMAN_hARRIS, #wintype 82 | 0, #fc 83 | samp_rate, #bw 84 | "", #name 85 | True, #plotfreq 86 | True, #plotwaterfall 87 | True, #plottime 88 | True, #plotconst 89 | None # parent 90 | ) 91 | self.qtgui_sink_x_0.set_update_time(1.0/10) 92 | self._qtgui_sink_x_0_win = sip.wrapinstance 93 | (self.qtgui_sink_x_0.qwidget(), Qt.QWidget) 94 | self.qtgui_sink_x_0.enable_rf_freq(False) 95 | self.top_layout.addWidget(self._qtgui_sink_x_0_win) 96 | self.iio_pluto_source_0 = iio.fmcomms2_source_fc32(uri if uri 97 | else iio.get_pluto_uri(), [True, True], 32768) 98 | self.iio_pluto_source_0.set_len_tag_key('packet_len') 99 | self.iio_pluto_source_0.set_frequency(2420000000) 100 | self.iio_pluto_source_0.set_samplerate(samp_rate) 101 | self.iio_pluto_source_0.set_gain_mode(0, 'slow_attack') 102 | self.iio_pluto_source_0.set_gain(0, 64) 103 | self.iio_pluto_source_0.set_quadrature(True) 104 | self.iio_pluto_source_0.set_rfdc(True) 105 | self.iio_pluto_source_0.set_bbdc(True) 106 | self.iio_pluto_source_0.set_filter_params('Auto', '', 0, 0) 107 | self.iio_pluto_sink_0 = iio.fmcomms2_sink_fc32(uri if uri 108 | else iio.get_pluto_uri(), [True, True], 32768, False) 109 | self.iio_pluto_sink_0.set_len_tag_key('') 110 | self.iio_pluto_sink_0.set_bandwidth(20000000) 111 | self.iio_pluto_sink_0.set_frequency(2420000000) 112 | self.iio_pluto_sink_0.set_samplerate(samp_rate) 113 | self.iio_pluto_sink_0.set_attenuation(0, 10.0) 114 | self.iio_pluto_sink_0.set_filter_params('Auto', '', 0, 0) 115 | self.blocks_vco_c_0 = blocks.vco_c(samp_rate, (6.282*102400), 1) 116 | self.analog_sig_source_x_0 = analog.sig_source_f 117 | (samp_rate, analog.GR_SAW_WAVE, 100, 2, (-1), 0) 118 | ################################################## 119 | # Connections 120 | ################################################## 121 | self.connect((self.analog_sig_source_x_0, 0), 122 | (self.blocks_vco_c_0, 0)) 123 | self.connect((self.blocks_vco_c_0, 0), (self.iio_pluto_sink_0, 0)) 124 | self.connect((self.blocks_vco_c_0, 0), (self.qtgui_sink_x_0, 0)) 125 | self.connect((self.iio_pluto_source_0, 0), (self.qtgui_sink_x_1, 0)) 126 | 127 | def closeEvent(self, event): 128 | self.settings = Qt.QSettings("GNU Radio", "sweepjammer") 129 | self.settings.setValue("geometry", self.saveGeometry()) 130 | self.stop() 131 | self.wait() 132 | event.accept() 133 | 134 | def get_uri(self): 135 | return self.uri 136 | 137 | def set_uri(self, uri): 138 | self.uri = uri 139 | 140 | def get_samp_rate(self): 141 | return self.samp_rate 142 | 143 | def set_samp_rate(self, samp_rate): 144 | self.samp_rate = samp_rate 145 | self.analog_sig_source_x_0.set_sampling_freq(self.samp_rate) 146 | self.iio_pluto_sink_0.set_samplerate(self.samp_rate) 147 | self.iio_pluto_source_0.set_samplerate(self.samp_rate) 148 | self.qtgui_sink_x_0.set_frequency_range(0, self.samp_rate) 149 | self.qtgui_sink_x_1.set_frequency_range(1575420000, self.samp_rate) 150 | 151 | def argument_parser(): 152 | parser = ArgumentParser() 153 | parser.add_argument( 154 | "--uri", dest="uri", type=str, default='ip:pluto.local', 155 | help="Set URI [default=%(default)r]") 156 | return parser 157 | 158 | def main(top_block_cls=sweepjammer, options=None): 159 | if options is None: 160 | options = argument_parser().parse_args() 161 | 162 | if StrictVersion("4.5.0") <= StrictVersion(Qt.qVersion()) < 163 | StrictVersion("5.0.0"): 164 | style = gr.prefs().get_string('qtgui', 'style', 'raster') 165 | Qt.QApplication.setGraphicsSystem(style) 166 | qapp = Qt.QApplication(sys.argv) 167 | tb = top_block_cls(uri=options.uri) 168 | tb.start() 169 | tb.show() 170 | 171 | def sig_handler(sig=None, frame=None): 172 | tb.stop() 173 | tb.wait() 174 | Qt.QApplication.quit() 175 | 176 | signal.signal(signal.SIGINT, sig_handler) 177 | signal.signal(signal.SIGTERM, sig_handler) 178 | 179 | timer = Qt.QTimer() 180 | timer.start(500) 181 | timer.timeout.connect(lambda: None) 182 | 183 | qapp.exec_() 184 | 185 | if __name__ == '__main__': 186 | main() 187 | -------------------------------------------------------------------------------- /2.4 GHz band Sweep Jamming: -------------------------------------------------------------------------------- 1 | from packaging.version import Version as StrictVersion 2 | from PyQt5 import Qt 3 | from gnuradio import qtgui 4 | from gnuradio import analog 5 | from gnuradio import blocks 6 | from gnuradio import gr 7 | from gnuradio.filter import firdes 8 | from gnuradio.fft import window 9 | import sys 10 | import signal 11 | from PyQt5 import Qt 12 | from argparse import ArgumentParser 13 | from gnuradio.eng_arg import eng_float, intx 14 | from gnuradio import eng_notation 15 | from gnuradio import iio 16 | import sip 17 | 18 | class sweepjammer(gr.top_block, Qt.QWidget): 19 | 20 | def __init__(self, uri='ip:pluto.local'): 21 | gr.top_block.__init__(self, "Sweep jammer", catch_exceptions=True) 22 | Qt.QWidget.__init__(self) 23 | self.setWindowTitle("Sweep jammer") 24 | qtgui.util.check_set_qss() 25 | try: 26 | self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc')) 27 | except BaseException as exc: 28 | print(f"Qt GUI: Could not set Icon: {str(exc)}", file=sys.stderr) 29 | self.top_scroll_layout = Qt.QVBoxLayout() 30 | self.setLayout(self.top_scroll_layout) 31 | self.top_scroll = Qt.QScrollArea() 32 | self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame) 33 | self.top_scroll_layout.addWidget(self.top_scroll) 34 | self.top_scroll.setWidgetResizable(True) 35 | self.top_widget = Qt.QWidget() 36 | self.top_scroll.setWidget(self.top_widget) 37 | self.top_layout = Qt.QVBoxLayout(self.top_widget) 38 | self.top_grid_layout = Qt.QGridLayout() 39 | self.top_layout.addLayout(self.top_grid_layout) 40 | self.settings = Qt.QSettings("GNU Radio", "sweepjammer") 41 | 42 | try: 43 | if StrictVersion(Qt.qVersion()) < StrictVersion("5.0.0"): 44 | self.restoreGeometry(self.settings.value("geometry") 45 | .toByteArray()) 46 | else: 47 | self.restoreGeometry(self.settings.value("geometry")) 48 | except BaseException as exc: 49 | print(f"Qt GUI: Could not restore geometry: {str(exc)}", 50 | file=sys.stderr) 51 | ################################################## 52 | # Parameters 53 | ################################################## 54 | self.uri = uri 55 | ################################################## 56 | # Variables 57 | ################################################## 58 | self.samp_rate = samp_rate = 1000000 59 | ################################################## 60 | # Blocks 61 | ################################################## 62 | self.qtgui_sink_x_0 = qtgui.sink_c( 63 | 1024, # fftsize 64 | window.WIN_BLACKMAN_hARRIS, # wintype 65 | 0, # fc 66 | samp_rate, # bw 67 | "", # name 68 | True, # plotfreq 69 | True, # plotwaterfall 70 | True, # plottime 71 | True, # plotconst 72 | None # parent 73 | ) 74 | self.qtgui_sink_x_0.set_update_time(1.0 / 10) 75 | self._qtgui_sink_x_0_win = sip.wrapinstance 76 | (self.qtgui_sink_x_0.qwidget(), Qt.QWidget) 77 | 78 | self.qtgui_sink_x_0.enable_rf_freq(False) 79 | self.top_layout.addWidget(self._qtgui_sink_x_0_win) 80 | self.iio_pluto_source_0 = iio.fmcomms2_source_fc32 81 | (uri if uri else iio.get_pluto_uri(), [True, True], 32768) 82 | self.iio_pluto_source_0.set_len_tag_key('packet_len') 83 | self.iio_pluto_source_0.set_frequency(2420000000) 84 | self.iio_pluto_source_0.set_samplerate(samp_rate) 85 | self.iio_pluto_source_0.set_gain_mode(0, 'slow_attack') 86 | self.iio_pluto_source_0.set_gain(0, 64) 87 | self.iio_pluto_source_0.set_quadrature(True) 88 | self.iio_pluto_source_0.set_rfdc(True) 89 | self.iio_pluto_source_0.set_bbdc(True) 90 | self.iio_pluto_source_0.set_filter_params('Auto', '', 0, 0) 91 | self.iio_pluto_sink_0 = iio.fmcomms2_sink_fc32(uri if uri 92 | else iio.get_pluto_uri(), [True, True], 32768, False) 93 | self.iio_pluto_sink_0.set_len_tag_key('') 94 | self.iio_pluto_sink_0.set_bandwidth(20000000) 95 | self.iio_pluto_sink_0.set_frequency(2420000000) 96 | self.iio_pluto_sink_0.set_samplerate(samp_rate) 97 | self.iio_pluto_sink_0.set_attenuation(0, 10.0) 98 | self.iio_pluto_sink_0.set_filter_params('Auto', '', 0, 0) 99 | self.blocks_vco_c_0 = blocks.vco_c(samp_rate, (6.282 * 102400), 1) 100 | self.analog_sig_source_x_0 = analog.sig_source_f(samp_rate, 101 | analog.GR_SAW_WAVE, 100, 2, (-1), 0) 102 | ################################################## 103 | # Connections 104 | ################################################## 105 | self.connect((self.analog_sig_source_x_0, 0), 106 | (self.blocks_vco_c_0, 0)) 107 | self.connect((self.blocks_vco_c_0, 0), (self.iio_pluto_sink_0, 0)) 108 | self.connect((self.blocks_vco_c_0, 0), (self.qtgui_sink_x_0, 0)) 109 | ################################################## 110 | # Frequency Sweep 111 | ################################################## 112 | self.start_freq = 2410000000 113 | self.stop_freq = 2475000000 114 | self.step_freq = 2000000 115 | self.bandwidth = 20000000 116 | self.current_freq = self.start_freq 117 | self.update_frequency() 118 | self.timer = Qt.QTimer() 119 | self.timer.timeout.connect(self.update_frequency) 120 | self.timer.start(1000) # Change frequency every 1000 ms (1 second) 121 | 122 | def update_frequency(self): 123 | if self.current_freq > self.stop_freq: 124 | self.current_freq = self.start_freq 125 | lower_freq = self.current_freq - self.bandwidth / 2 126 | upper_freq = self.current_freq + self.bandwidth / 2 127 | self.iio_pluto_sink_0.set_frequency(self.current_freq) 128 | print(f"Processing frequency: {self.current_freq} Hz") 129 | print(f"Processing frequency range: {lower_freq} Hz - 130 | {upper_freq} Hz") 131 | self.current_freq += self.step_freq 132 | 133 | def closeEvent(self, event): 134 | self.settings = Qt.QSettings("GNU Radio", "sweepjammer") 135 | self.settings.setValue("geometry", self.saveGeometry()) 136 | self.stop() 137 | self.wait() 138 | event.accept() 139 | 140 | def get_uri(self): 141 | return self.uri 142 | 143 | def set_uri(self, uri): 144 | self.uri = uri 145 | 146 | def get_samp_rate(self): 147 | return self.samp_rate 148 | 149 | def set_samp_rate(self, samp_rate): 150 | self.samp_rate = samp_rate 151 | self.analog_sig_source_x_0.set_sampling_freq(self.samp_rate) 152 | self.iio_pluto_sink_0.set_samplerate(self.samp_rate) 153 | self.iio_pluto_source_0.set_samplerate(self.samp_rate) 154 | self.qtgui_sink_x_0.set_frequency_range(0, self.samp_rate) 155 | 156 | def argument_parser(): 157 | parser = ArgumentParser() 158 | parser.add_argument( 159 | "--uri", dest="uri", type=str, default='ip:pluto.local', 160 | help="Set URI [default=%(default)r]") 161 | return parser 162 | 163 | def main(top_block_cls=sweepjammer, options=None): 164 | if options is None: 165 | options = argument_parser().parse_args() 166 | 167 | if StrictVersion("4.5.0") <= StrictVersion(Qt.qVersion()) < 168 | StrictVersion("5.0.0"): 169 | style = gr.prefs().get_string('qtgui', 'style', 'raster') 170 | Qt.QApplication.setGraphicsSystem(style) 171 | qapp = Qt.QApplication(sys.argv) 172 | tb = top_block_cls(uri=options.uri) 173 | tb.start() 174 | tb.show() 175 | 176 | def sig_handler(sig=None, frame=None): 177 | tb.stop() 178 | tb.wait() 179 | Qt.QApplication.quit() 180 | 181 | signal.signal(signal.SIGINT, sig_handler) 182 | signal.signal(signal.SIGTERM, sig_handler) 183 | timer = Qt.QTimer() 184 | timer.start(500) 185 | timer.timeout.connect(lambda: None) 186 | 187 | qapp.exec_() 188 | 189 | if __name__ == '__main__': 190 | main() 191 | -------------------------------------------------------------------------------- /Random Frequency Selecting Barrage Jamming: -------------------------------------------------------------------------------- 1 | import sys 2 | import signal 3 | from PyQt5 import Qt 4 | from argparse import ArgumentParser 5 | from packaging.version import Version as StrictVersion 6 | from gnuradio import qtgui 7 | from gnuradio import analog 8 | from gnuradio import filter 9 | from gnuradio.filter import firdes 10 | from gnuradio import gr 11 | from gnuradio.fft import window 12 | from gnuradio import iio 13 | from gnuradio.qtgui import Range, RangeWidget 14 | from PyQt5 import QtCore 15 | import sip 16 | import random 17 | 18 | class Barrage24(gr.top_block, Qt.QWidget): 19 | 20 | def __init__(self, BW=15000000, samp_rate=20000000, 21 | uri='ip:pluto.local', freq=2420000000): 22 | gr.top_block.__init__(self, "Barrage24", catch_exceptions=True) 23 | Qt.QWidget.__init__(self) 24 | self.setWindowTitle("Barrage24") 25 | qtgui.util.check_set_qss() 26 | try: 27 | self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc')) 28 | except BaseException as exc: 29 | print(f"Qt GUI: Could not set Icon: {str(exc)}", file=sys.stderr) 30 | self.top_scroll_layout = Qt.QVBoxLayout() 31 | self.setLayout(self.top_scroll_layout) 32 | self.top_scroll = Qt.QScrollArea() 33 | self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame) 34 | self.top_scroll_layout.addWidget(self.top_scroll) 35 | self.top_scroll.setWidgetResizable(True) 36 | self.top_widget = Qt.QWidget() 37 | self.top_scroll.setWidget(self.top_widget) 38 | self.top_layout = Qt.QVBoxLayout(self.top_widget) 39 | self.top_grid_layout = Qt.QGridLayout() 40 | self.top_layout.addLayout(self.top_grid_layout) 41 | self.settings = Qt.QSettings("GNU Radio", "Barrage24") 42 | 43 | try: 44 | if StrictVersion(Qt.qVersion()) 45 | < StrictVersion("5.0.0"): 46 | self.restoreGeometry(self.settings.value 47 | ("geometry").toByteArray()) 48 | else: 49 | self.restoreGeometry(self.settings.value("geometry")) 50 | except BaseException as exc: 51 | print(f"Qt GUI: Could not restore geometry: {str(exc)}", 52 | file=sys.stderr) 53 | ################################################## 54 | # Parameters 55 | ################################################## 56 | self.BW = BW 57 | self.samp_rate = samp_rate 58 | self.uri = uri 59 | self.freq = freq 60 | ################################################## 61 | # Variables 62 | ################################################## 63 | self.attenuation = attenuation = 0 64 | ################################################## 65 | # Blocks 66 | ################################################## 67 | self._attenuation_range = Range(-40, 10, 1, 10, 200) 68 | self._attenuation_win = RangeWidget(self._attenuation_range, 69 | self.set_attenuation, 70 | "'attenuation'", "counter_slider", float, QtCore.Qt.Horizontal) 71 | self.top_layout.addWidget(self._attenuation_win) 72 | self.qtgui_sink_x_0_0 = qtgui.sink_c( 73 | 1024, # fftsize 74 | window.WIN_BLACKMAN_hARRIS, # wintype 75 | self.freq, # fc 76 | BW, # bw 77 | 'Emission', # name 78 | True, # plotfreq 79 | True, # plotwaterfall 80 | True, # plottime 81 | True, # plotconst 82 | None # parent 83 | ) 84 | self.qtgui_sink_x_0_0.set_update_time(1.0/10) 85 | self._qtgui_sink_x_0_0_win = sip.wrapinstance 86 | (self.qtgui_sink_x_0_0.qwidget(), Qt.QWidget) 87 | self.qtgui_sink_x_0_0.enable_rf_freq(False) 88 | self.top_layout.addWidget(self._qtgui_sink_x_0_0_win) 89 | self.low_pass_filter_0 = filter.fir_filter_ccf( 90 | 1, 91 | firdes.low_pass( 92 | 1, 93 | samp_rate, 94 | (samp_rate/3), 95 | (samp_rate/12), 96 | window.WIN_HAMMING, 97 | 6.76)) 98 | self.iio_pluto_sink_0 = iio.fmcomms2_sink_fc32(uri if uri 99 | else iio.get_pluto_uri(), [True, True], 32768, False) 100 | self.iio_pluto_sink_0.set_len_tag_key('') 101 | self.iio_pluto_sink_0.set_bandwidth(BW) 102 | self.iio_pluto_sink_0.set_frequency(self.freq) 103 | self.iio_pluto_sink_0.set_samplerate(samp_rate) 104 | self.iio_pluto_sink_0.set_attenuation(0, attenuation) 105 | self.iio_pluto_sink_0.set_filter_params('Auto', '', 0, 0) 106 | self.analog_noise_source_x_0 = analog.noise_source_c 107 | (analog.GR_GAUSSIAN, 1, 0) 108 | ################################################## 109 | # Connections 110 | ################################################## 111 | self.connect((self.analog_noise_source_x_0, 0), 112 | (self.low_pass_filter_0, 0)) 113 | self.connect((self.low_pass_filter_0, 0), (self.iio_pluto_sink_0, 0)) 114 | self.connect((self.low_pass_filter_0, 0), (self.qtgui_sink_x_0_0, 0)) 115 | 116 | def closeEvent(self, event): 117 | self.settings = Qt.QSettings("GNU Radio", "Barrage24") 118 | self.settings.setValue("geometry", self.saveGeometry()) 119 | self.stop() 120 | self.wait() 121 | event.accept() 122 | 123 | def get_BW(self): 124 | return self.BW 125 | 126 | def set_BW(self, BW): 127 | self.BW = BW 128 | self.iio_pluto_sink_0.set_bandwidth(self.BW) 129 | self.qtgui_sink_x_0_0.set_frequency_range(self.freq, self.BW) 130 | 131 | def get_samp_rate(self): 132 | return self.samp_rate 133 | 134 | def set_samp_rate(self, samp_rate): 135 | self.samp_rate = samp_rate 136 | self.iio_pluto_sink_0.set_samplerate(self.samp_rate) 137 | self.low_pass_filter_0.set_taps(firdes.low_pass 138 | (1, self.samp_rate, (self.samp_rate/3), (self.samp_rate/12), 139 | m window.WIN_HAMMING, 6.76)) 140 | 141 | def get_uri(self): 142 | return self.uri 143 | 144 | def set_uri(self, uri): 145 | self.uri = uri 146 | 147 | def get_freq(self): 148 | return self.freq 149 | 150 | def set_freq(self, freq): 151 | self.freq = freq 152 | self.iio_pluto_sink_0.set_frequency(self.freq) 153 | self.qtgui_sink_x_0_0.set_frequency_range(self.freq, self.BW) 154 | 155 | def get_attenuation(self): 156 | return self.attenuation 157 | 158 | def set_attenuation(self, attenuation): 159 | self.attenuation = attenuation 160 | self.iio_pluto_sink_0.set_attenuation(0,self.attenuation) 161 | 162 | def argument_parser(): 163 | parser = ArgumentParser() 164 | parser.add_argument( 165 | "--uri", dest="uri", type=str, default='ip:pluto.local', 166 | help="Set URI [default=%(default)r]") 167 | return parser 168 | 169 | def main(top_block_cls=Barrage24, options=None): 170 | if options is None: 171 | options = argument_parser().parse_args() 172 | 173 | if StrictVersion("4.5.0") <= StrictVersion(Qt.qVersion()) < 174 | StrictVersion("5.0.0"): 175 | style = gr.prefs().get_string('qtgui', 'style', 'raster') 176 | Qt.QApplication.setGraphicsSystem(style) 177 | qapp = Qt.QApplication(sys.argv) 178 | center_freqs = [2410000000, 2425000000, 2440000000, 2455000000, 179 | 2470000000] 180 | bandwidth = 20000000 181 | # Create an instance of Barrage24 182 | tb = top_block_cls(uri=options.uri, freq=center_freqs[0], BW=bandwidth) 183 | tb.start() 184 | tb.show() 185 | 186 | def update_frequency(): 187 | freq = random.choice(center_freqs) 188 | lower_freq = freq - bandwidth / 2 189 | upper_freq = freq + bandwidth / 2 190 | tb.set_freq(freq) 191 | print(f"Processing frequency: {freq} Hz") 192 | print(f"Processing frequency range: {lower_freq} Hz - 193 | {upper_freq} Hz") 194 | 195 | # Set up a timer to call update_frequency at regular intervals 196 | timer = QtCore.QTimer() 197 | timer.timeout.connect(update_frequency) 198 | timer.start(5000) # Change frequency every 10000 ms (10 seconds) 199 | 200 | 201 | def sig_handler(sig=None, frame=None): 202 | tb.stop() 203 | tb.wait() 204 | qapp.quit() 205 | 206 | signal.signal(signal.SIGINT, sig_handler) 207 | signal.signal(signal.SIGTERM, sig_handler) 208 | 209 | # Run the Qt event loop 210 | qapp.exec_() 211 | 212 | if __name__ == '__main__': 213 | main() 214 | -------------------------------------------------------------------------------- /Sequential Frequency Increment Barrage Jamming: -------------------------------------------------------------------------------- 1 | import sys 2 | import signal 3 | from PyQt5 import Qt 4 | from argparse import ArgumentParser 5 | from packaging.version import Version as StrictVersion 6 | from gnuradio import qtgui 7 | from gnuradio import analog 8 | from gnuradio import filter 9 | from gnuradio.filter import firdes 10 | from gnuradio import gr 11 | from gnuradio.fft import window 12 | from gnuradio import iio 13 | from gnuradio.qtgui import Range, RangeWidget 14 | from PyQt5 import QtCore 15 | import sip 16 | class Barrage24(gr.top_block, Qt.QWidget): 17 | 18 | def __init__(self, BW=15000000, samp_rate=20000000, uri='ip:pluto.local', 19 | freq=2420000000): 20 | gr.top_block.__init__(self, "Barrage24", 21 | catch_exceptions=True) 22 | Qt.QWidget.__init__(self) 23 | self.setWindowTitle("Barrage24") 24 | qtgui.util.check_set_qss() 25 | try: 26 | self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc')) 27 | except BaseException as exc: 28 | print(f"Qt GUI: Could not set IconF: {str(exc)}", 29 | file=sys.stderr) 30 | self.top_scroll_layout = Qt.QVBoxLayout() 31 | self.setLayout(self.top_scroll_layout) 32 | self.top_scroll = Qt.QScrollArea() 33 | self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame) 34 | self.top_scroll_layout.addWidget(self.top_scroll) 35 | self.top_scroll.setWidgetResizable(True) 36 | self.top_widget = Qt.QWidget() 37 | self.top_scroll.setWidget(self.top_widget) 38 | self.top_layout = Qt.QVBoxLayout(self.top_widget) 39 | self.top_grid_layout = Qt.QGridLayout() 40 | self.top_layout.addLayout(self.top_grid_layout) 41 | self.settings = Qt.QSettings("GNU Radio", "Barrage24") 42 | 43 | try: 44 | if StrictVersion(Qt.qVersion()) < StrictVersion("5.0.0"): 45 | self.restoreGeometry(self.settings.value 46 | ("geometry").toByteArray()) 47 | else: 48 | self.restoreGeometry(self.settings.value("geometry")) 49 | except BaseException as exc: 50 | print(f"Qt GUI: Could not restore geometry: {str(exc)}", 51 | file=sys.stderr) 52 | ################################################## 53 | # Parameters 54 | ################################################## 55 | self.BW = BW 56 | self.samp_rate = samp_rate 57 | self.uri = uri 58 | self.freq = freq 59 | ################################################## 60 | # Variables 61 | ################################################## 62 | self.attenuation = attenuation = 0 63 | ################################################## 64 | # Blocks 65 | ################################################## 66 | self._attenuation_range = Range(-40, 10, 1, 10, 200) 67 | self._attenuation_win = RangeWidget(self._attenuation_range, 68 | self.set_attenuation, "'attenuation'", 69 | "counter_slider", float, QtCore.Qt.Horizontal) 70 | self.top_layout.addWidget(self._attenuation_win) 71 | self.qtgui_sink_x_0_0 = qtgui.sink_c( 72 | 1024, # fftsize 73 | window.WIN_BLACKMAN_hARRIS, # wintype 74 | self.freq, # fc 75 | BW, # bw 76 | 'Emission', # name 77 | True, # plotfreq 78 | True, # plotwaterfall 79 | True, # plottime 80 | True, # plotconst 81 | None # parent 82 | ) 83 | self.qtgui_sink_x_0_0.set_update_time(1.0/10) 84 | self._qtgui_sink_x_0_0_win = sip.wrapinstance 85 | (self.qtgui_sink_x_0_0.qwidget(), Qt.QWidget) 86 | self.qtgui_sink_x_0_0.enable_rf_freq(False) 87 | self.top_layout.addWidget(self._qtgui_sink_x_0_0_win) 88 | self.low_pass_filter_0 = filter.fir_filter_ccf( 89 | 1, 90 | firdes.low_pass( 91 | 1, 92 | samp_rate, 93 | (samp_rate/3), 94 | (samp_rate/12), 95 | window.WIN_HAMMING, 96 | 6.76)) 97 | self.iio_pluto_sink_0 = iio.fmcomms2_sink_fc32 98 | (uri if uri else iio.get_pluto_uri(), [True, True], 32768, False) 99 | self.iio_pluto_sink_0.set_len_tag_key('') 100 | self.iio_pluto_sink_0.set_bandwidth(BW) 101 | self.iio_pluto_sink_0.set_frequency(self.freq) 102 | self.iio_pluto_sink_0.set_samplerate(samp_rate) 103 | self.iio_pluto_sink_0.set_attenuation(0, attenuation) 104 | self.iio_pluto_sink_0.set_filter_params('Auto', '', 0, 0) 105 | self.analog_noise_source_x_0 = analog.noise_source_c 106 | (analog.GR_GAUSSIAN, 1, 0) 107 | ################################################## 108 | # Connections 109 | ################################################## 110 | self.connect((self.analog_noise_source_x_0, 0), 111 | (self.low_pass_filter_0, 0)) 112 | self.connect((self.low_pass_filter_0, 0), (self.iio_pluto_sink_0, 0)) 113 | self.connect((self.low_pass_filter_0, 0), (self.qtgui_sink_x_0_0, 0)) 114 | 115 | def closeEvent(self, event): 116 | self.settings = Qt.QSettings("GNU Radio", "Barrage24") 117 | self.settings.setValue("geometry", self.saveGeometry()) 118 | self.stop() 119 | self.wait() 120 | event.accept() 121 | 122 | def get_BW(self): 123 | return self.BW 124 | 125 | def set_BW(self, BW): 126 | self.BW = BW 127 | self.iio_pluto_sink_0.set_bandwidth(self.BW) 128 | self.qtgui_sink_x_0_0.set_frequency_range(self.freq, self.BW) 129 | 130 | def get_samp_rate(self): 131 | return self.samp_rate 132 | 133 | def set_samp_rate(self, samp_rate): 134 | self.samp_rate = samp_rate 135 | self.iio_pluto_sink_0.set_samplerate(self.samp_rate) 136 | self.low_pass_filter_0.set_taps(firdes.low_pass(1, self.samp_rate, 137 | (self.samp_rate/3), (self.samp_rate/12), window.WIN_HAMMING, 6.76)) 138 | 139 | def get_uri(self): 140 | return self.uri 141 | 142 | def set_uri(self, uri): 143 | self.uri = uri 144 | 145 | def get_freq(self): 146 | return self.freq 147 | 148 | def set_freq(self, freq): 149 | self.freq = freq 150 | self.iio_pluto_sink_0.set_frequency(self.freq) 151 | self.qtgui_sink_x_0_0.set_frequency_range(self.freq, self.BW) 152 | 153 | def get_attenuation(self): 154 | return self.attenuation 155 | 156 | def set_attenuation(self, attenuation): 157 | self.attenuation = attenuation 158 | self.iio_pluto_sink_0.set_attenuation(0,self.attenuation) 159 | 160 | def argument_parser(): 161 | parser = ArgumentParser() 162 | parser.add_argument( 163 | "--uri", dest="uri", type=str, default='ip:pluto.local', 164 | help="Set URI [default=%(default)r]") 165 | return parser 166 | 167 | def main(top_block_cls=Barrage24, options=None): 168 | if options is None: 169 | options = argument_parser().parse_args() 170 | 171 | if StrictVersion("4.5.0") <= StrictVersion(Qt.qVersion()) < 172 | StrictVersion("5.0.0"): 173 | style = gr.prefs().get_string('qtgui', 'style', 'raster') 174 | Qt.QApplication.setGraphicsSystem(style) 175 | qapp = Qt.QApplication(sys.argv) 176 | start_freq = 2410000000 177 | stop_freq = 2475000000 178 | step_freq = 15000000 179 | bandwidth = 20000000 180 | # Create an instance of Barrage24 181 | tb = top_block_cls(uri=options.uri, freq=start_freq, BW=bandwidth) 182 | tb.start() 183 | tb.show() 184 | 185 | def update_frequency(): 186 | nonlocal start_freq 187 | if start_freq >= stop_freq: 188 | start_freq = 2410000000 # Reset to the initial start 189 | frequency to loop again 190 | lower_freq = start_freq - bandwidth / 2 191 | upper_freq = start_freq + bandwidth / 2 192 | tb.set_freq(start_freq) 193 | print(f"Processing frequency: {start_freq} Hz") 194 | print(f"Processing frequency range: 195 | {lower_freq} Hz - {upper_freq} Hz") 196 | start_freq += step_freq 197 | 198 | # Set up a timer to call update_frequency at regular intervals 199 | timer = QtCore.QTimer() 200 | timer.timeout.connect(update_frequency) 201 | timer.start(5000) # Change frequency every 1000 ms (1 second) 202 | 203 | def sig_handler(sig=None, frame=None): 204 | tb.stop() 205 | tb.wait() 206 | qapp.quit() 207 | 208 | signal.signal(signal.SIGINT, sig_handler) 209 | signal.signal(signal.SIGTERM, sig_handler) 210 | 211 | # Run the Qt event loop 212 | qapp.exec_() 213 | 214 | if __name__ == '__main__': 215 | main() 216 | --------------------------------------------------------------------------------