Mentions légales du service

Skip to content
Snippets Groups Projects
Commit c0f87740 authored by Autodistries's avatar Autodistries
Browse files

add support for producing and retrieving the gps pos file (uses a script that is pre-sent)

parent 711b3463
No related branches found
No related tags found
1 merge request!1Refactoring, new features
...@@ -11,8 +11,8 @@ ss2 ...@@ -11,8 +11,8 @@ ss2
; s4 ansible_host=192.168.1.100 ; s4 ansible_host=192.168.1.100
[ss2] [ss2]
# s5 ansible_host=192.168.1.248 ; s5 ansible_host=192.168.1.248
s6 ansible_host=192.168.1.246 s6 ansible_host=192.168.1.244
# rp4 ansible_host=192.168.1.248 # rp4 ansible_host=192.168.1.248
......
- hosts: s5 - hosts: all
become: yes become: yes
tasks: tasks:
- debug: - name: transfer location finder
msg: "{{ansible_user_id}}" copy:
src: ../files/positionGetter.sh
dest: "/home/{{ansible_ssh_user}}/positionGetter.sh"
mode: 0755
...@@ -56,6 +56,7 @@ Multiple configuration scripts, here called microstasks, have been put into a si ...@@ -56,6 +56,7 @@ Multiple configuration scripts, here called microstasks, have been put into a si
The playbook `start_sens_sniffer.yml` asks parameters to run mitik-sens : The playbook `start_sens_sniffer.yml` asks parameters to run mitik-sens :
- The folder of mitik-sens on the nodes. Defaults to `/home/tribe/mitik-sens-mod/` - The folder of mitik-sens on the nodes. Defaults to `/home/tribe/mitik-sens-mod/`
- hour and minute at which to start the experiment. Defaults to current time +15m - hour and minute at which to start the experiment. Defaults to current time +15m
- The format of the name of the output pcap file. Defaults to mitik_experiment-%post, with %post being replaced at mitik-sens level
- Timeout after which to stop the experiment in seconds. Defaults to 3600 (1h) - Timeout after which to stop the experiment in seconds. Defaults to 3600 (1h)
- The interfaces on which to run the experiment, separated by commas (e.g. `wifi5,wifi6`). Defaults to `wifi5`. Order matters. - The interfaces on which to run the experiment, separated by commas (e.g. `wifi5,wifi6`). Defaults to `wifi5`. Order matters.
- The channels on which to start the interface, separated by commas. (e.g. `6,11`). Defaults to `1`. Order matters. - The channels on which to start the interface, separated by commas. (e.g. `6,11`). Defaults to `1`. Order matters.
...@@ -64,8 +65,9 @@ Multiple configuration scripts, here called microstasks, have been put into a si ...@@ -64,8 +65,9 @@ Multiple configuration scripts, here called microstasks, have been put into a si
- The hashing function. Defaults to SHA256, can be MD5 and None - The hashing function. Defaults to SHA256, can be MD5 and None
- The fields to anonymize. All MACs and ssids is 15; not ssid is 14; nothing is 0. Defaults to 15 - The fields to anonymize. All MACs and ssids is 15; not ssid is 14; nothing is 0. Defaults to 15
Then it checks if the length of interfaces and channels is the same. Then it translates the csv interfaces and channels into lists, and finds out the prefix to use for the gps file. It is {{ _pcap_name | replace('%post', '') }}-location-YYYYMMDD-ddmmss.gps
If they are, we set up a crontab to run the sniffer when planned. it checks if the length of interfaces and channels is the same.
If they are, we set up a crontab to run the sniffer when planned, and a crontab for the location of the device.
**`stop_sens_sniffer.yml`** **`stop_sens_sniffer.yml`**
This playbook interrupts any running `sniffer.py`, and cancels planned crontabs. This playbook interrupts any running `sniffer.py`, and cancels planned crontabs.
......
#!/bin/bash #!/bin/bash
# script.sh 900 30 "~/mitik-sens-mod/" "experiment-identifier"
# run with arg 1 the sleep TO, and $2 the waiting time before doing things # run with arg 1 the sleep TO, and $2 the waiting time before doing things
if [ $2 ]; then if [ $2 ]; then
sleep $2 sleep $2
fi fi
rm ~/locations.log # files in /temp will get deleted on reboot
gpsLocations=$(mktemp /tmp/locations-XXXXXX.gps)
while echo $(pgrep -a "sniffer.py" >/dev/null; echo $?); do gpsPresenceTest=$(mktemp /tmp/test-XXXXXX.gps)
timeout 1s sudo gpiomon 4 15 > $gpsPresenceTest
if [ $(cat $gpsPresenceTest | wc -l) -eq 0 ]; then
echo "no gps found !"
exit 1
fi
data=$(gpspipe --nmea -n 10 | awk -F, '$1 == "$GPGGA"' | awk -F, '{print $3, $5, $10}') while echo $(pgrep -a "sniffer.py" >/dev/null; echo $?); do
# $GPGGA,124226.00,4842.8648,N,00212.3549,E,1,07,1.30,160.28,M,46.512,M,,*63
# │ Latitude: 48.71441340 N │
# │ Longitude: 2.20591520 E │
# │ Alt (HAE, MSL): 206.490, 160.283 m
echo $data >> ~/locations.log data=$(gpspipe --nmea -n 10 | awk -F, '$1 == "$GPGGA"' | awk -F, '{print $3, $5, $10}')
# $GPGGA,124226.00,4842.8648,N,00212.3549,E,1,07,1.30,160.28,M,46.512,M,,*63
# │ Latitude: 48.71441340 N │
# │ Longitude: 2.20591520 E │
# │ Alt (HAE, MSL): 206.490, 160.283 m
if [ $1 ]; then echo $data >> $gpsLocations
sleep $1 if [ $1 ]; then
else sleep $1
sleep 900 #15m else
fi sleep 900 #15m
fi
done done
if [ $(ls ~/locations.log; echo $?) ]; do awk -F',' '
# faut moyenner toutes les potitions imo {
done lat += $1;
\ No newline at end of file lon += $2;
alt += $3;
}
END {
print lat/NR/100,lon/NR/100,alt/NR;
}' $gpsLocations > $3"/location-"$4".log"
# will write eg as ~/mitik-sens-mod/location-MM-DD-HH-MM-wifiX-chan6.log
...@@ -5,9 +5,9 @@ ...@@ -5,9 +5,9 @@
- name: find files to copy - name: find files to copy
find: find:
paths: "~/termporary-transfer-sniffer/hopping-time-tests/" # top folder to search from/in paths: "~/mitik-sens-mod/" # top folder to search from/in
recurse: yes # yes|no recursive file search ? recurse: no # yes|no recursive file search ?
patterns: "*.pcap" # what your target files look like patterns: "*.pcap, *.gps" # what your target files look like
register: files_to_copy register: files_to_copy
- name: Copy files - name: Copy files
......
- hosts: sniffers - hosts: sniffers
user: tribe
become: yes become: yes
become_user: root become_user: root
tasks: tasks:
...@@ -76,3 +75,11 @@ ...@@ -76,3 +75,11 @@
src: ../files/chrony.conf src: ../files/chrony.conf
dest: /etc/chrony/chrony.conf dest: /etc/chrony/chrony.conf
- name: transfer location finder
become: y
copy:
src: ../files/positionGetter.sh
dest: "/home/{{ansible_ssh_user}}/positionGetter.sh"
mode: 0755
...@@ -26,6 +26,11 @@ ...@@ -26,6 +26,11 @@
default: "{{ lookup('pipe', 'date -d \"+15 minutes\" +%M') }}" default: "{{ lookup('pipe', 'date -d \"+15 minutes\" +%M') }}"
private: no private: no
- name: _pcap_name
prompt: "Name of the PCAP file. %post will get replaced by a bunch of context info (date and params) and .pcap"
default: "mitik_experiment-%post"
private: no
- name: _timeout - name: _timeout
prompt: Please specify the runtime duration in sec prompt: Please specify the runtime duration in sec
default: 3600 default: 3600
...@@ -62,11 +67,17 @@ ...@@ -62,11 +67,17 @@
default: 15 default: 15
private: no private: no
- name: _gps_poll_timeout
prompt: time in seconds between each location polling
default: 900
private: no
tasks: tasks:
- set_fact: - set_fact:
_interfaces: "{{ _interfaces_csv.split(',') }}" _interfaces: "{{ _interfaces_csv.split(',') }}"
_channels: "{{ _channels_csv.split(',') }}" _channels: "{{ _channels_csv.split(',') }}"
_location_prefix: "{{_pcap_name | replace('%post', '')}}"
delegate_to: 127.0.0.1 delegate_to: 127.0.0.1
run_once: True run_once: True
...@@ -78,12 +89,21 @@ ...@@ -78,12 +89,21 @@
- name: start sens-sniffer
- name: setup future start of sens-sniffer
cron: cron:
name: "ansible_sens_sniffer {{ _hour }} {{ _minute }} {{ item }}" name: "ansible_sens_sniffer {{ _hour }} {{ _minute }} {{ item }}"
minute: "{{ _minute }}" minute: "{{ _minute }}"
hour: "{{ _hour }}" hour: "{{ _hour }}"
job: "cd {{_workdir}}; sudo python ./sniffer.py -s {{_timeout}} -i {{item}} -c {{_channels[my_idx]}} -j {{_channel_hopping}} -sf {{_filter}} -p {{_hash_pattern}} -e {{_hash_function}}" job: "cd {{_workdir}}; sudo python ./sniffer.py -s {{_timeout}} -i {{item}} -c {{_channels[my_idx]}} -j {{_channel_hopping}} -sf {{_filter}} -p {{_hash_pattern}} -e {{_hash_function}}" -w "{{_pcap_name}}"
loop: "{{_interfaces}}" loop: "{{_interfaces}}"
loop_control: loop_control:
index_var: my_idx index_var: my_idx
- name: setup future start of location querier
cron:
name: "ansible_sens_gps {{ _hour }} {{ _minute }}"
minute: "{{ _minute }}"
hour: "{{ _hour }}"
job: "/home/{{ansible_ssh_user}}/positionGetter.sh {{_gps_poll_timeout}} 10 '{{_workdir}}' '{{_location_prefix}}-location$(date +%Y%m%d_%H%M%S).gps'"
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
tasks: tasks:
- name: List active snifing crontabs - name: List active snifing crontabs
tags: device-setup config nodes tags: device-setup config nodes
shell: "crontab -l | grep ansible_sens_sniffer | sed 's/#Ansible: //g'" shell: "crontab -l | grep ansible_sens_ | sed 's/#Ansible: //g'"
register: crontabs register: crontabs
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment