awk

awk = Aho, Weinberger, and Kernighan

$0 = whole line
$1 = first field
$2 = second field
[...]
$NF = last field
FS = field separator, default FS=\s+
OFS = output field seperator
RS = record (line) separator
ORS = output record seperator
NR = number of records (counter from 1 to n)
NF = total number of fields
FILENAME = name of the current input file
FNR = number of records relative to the current input file
match()
  -> RSTART = where the pattern starts
  -> RLENGTH = the length of the pattern

Starters

Awk – A Tutorial and Introduction – by Bruce Barnett
Awk Introduction Tutorial – 7 Awk Print Examples
10 Awk Tips, Tricks and Pitfalls

BEGIN and END

gawk Manual – Startup and Cleanup Actions
AWK scripting: 10 BEGIN and END block examples

BEGIN { just once }
{ every record by itself }
END { just once }

Built-In Variables

8 Powerful Awk Built-in Variables – FS, OFS, RS, ORS, NR, NF, FILENAME, FNR

String Functions

gawk Manual – String-Manipulation Functions

String concatenate

awk – concatenate two string variable and assign to a third
gawk Manual – String Concatenation

$ awk '{b=$1$2; print b}' file
$ awk '{b=$1" "$2; print b}' file
$ awk '{b=$1 FS $2; print b}' file

Regex

gawk Manual – Using Dynamic Regexps
gawk Manual – Using Regular Expression Constants
Pass shell variable as a /pattern/ to awk
How to use awk variables in regular expressions?
Passing variable to awk and using that in a regular expression

Shell Variables

Can we use shell variables in awk?

Internet of Things (IoT) Protocols & Standards

  • SX1276 = 868 MHz ?!
  • SX1278 = 410/450/470 MHz ?!
sx127x

Internet of Things Protocols & Standards
IEEE 802.15.4
6LoWPAN
Yaler.net – Access devices from the Web
LORIOT | LoRaWAN Services and Software

LoRa Technology
Semtech Corporation SX1276MB1MAS, LORA BI-BAND 433/868 MBED SHIELD
Extreme Range Links: LoRa 868 / 900MHz SX1272 LoRa module for Arduino Waspmote and Raspberry Pi

LoRa Gateway

SX127X LoRa Product Family
Lora-net/lora_gateway
Lora-net/packet_forwarder
Lora-net/LoRaMac-node
mirakonta: Run lora_gateway and packet_forwarder on OpenWrt
mirakonta: MAKE your own 200€ LoRa gateway

IBM Research Lab Zurich: IBM Long-Range Signaling and Control (LRSC) – LoRa WAN in C
github: devttys0/libmpsse, Open source library for SPI/I2C control via FTDI chips

TTN ZH: From zero to LoRaWAN in a weekend

LoRa Gateways and Concentrators
iC880A – LoRaWAN Concentrator 868MHz
Webshop: iC880A-SPI – LoRaWAN Concentrator 868MHz

LoRa Nodes

Modtronix inAir9, Sydney
Modtronix SX1276Lib
Microchip RN2483, over UART

Multi-Tech

Multi-Tech git Repository
digikey: Multi-Tech Systems MTAC-LORA-868
digikey: Multi-Tech Systems MTAC-LORA-915
Multi-Tech Systems AN868-915A-10HRA

OpenLORA

IMST iC880A, Photo with USB connection
Raspberry Pi and Multitech LoRa mCard
MultiTech MultiConnect mCard in mini-PCIe slot on ALIX6 or APU from PC Engines

TheThingsNetwork

TheThingsNetwork
The Things Network Shop
Gateway Test

Wiki

TheThingsNetwork Wiki
Getting STarted with The Things Network
Software Overview
Hardware Overview – Gateways
Hardware Overview – Nodes
Installing your Multitech mLinux Conduit
Architecture
Current Network

github

TheThingsNetwork/lora_gateway
TheThingsNetwork/packet_forwarder

Forum

Gateway IMST IC880A / RBPI
TTN Gateway

Networks

LPWAN Map
Meiland TTN Map
TTN Zurich

EVK & Dev Kits

The AirBoard
The AirBoard – Quick Start

  • Low Power Network (LPN)
  • Low Power Wide Area Network (LPWAN)
  • Long Range (Rate?) Wide-area network (LoRaWAN)
  • IPv6 over Low power Wireless Personal Area Network (6LoWPAN)
  • machine-to-machine M2M
  • Smart City

The Things Network

The Things Network
The Things Network Wiki
Hardware Overview – Nodes
Microchip RN2483
IMST iM880a

Wikipedia Technology

SIGFOX

SIGFOX
Let’s start playing with sigfox technology, 20.03.2014
Using Telecom Design’s TD120x as a SIGFOX gateway with a Z1 mote
Wireless Garden sensing Prototype A and B (Intel Galileo, Spark Core and Grove)
A simple WiFi power cord switch with the OLIMEX ESP8266 evaluation board
Transceivers

  • Silicon Labs SI446x
  • Texas Instruments CC112x

SoC

  • Atmel ATA 8520
  • On Semiconductors AX-SIGFOX SoC

Modules

  • Adeunis Si 828 25mW
  • Atim ARM Nano
  • Nemeus MM002-xx-EU
  • Radiocrafts RC 1682-SIG
  • TD Next TD1208
  • Telit Le51-868S

EVK & Dev Kits

  • AXEL Elettronica Smart Everything
  • Adeunis Demonstrator
  • AirThings The AirBoard
  • Connit Live black USB
  • Embeblue
  • Radiocrafts RC 1682-SIG DK
  • SNOC RPISIGFOX
  • Snootlab Akeru
  • TD Next TD1208 EVK
  • TST Sistemas Smart expansion board
  • Telit LE51-868SEVK

RPMA

Ingenu’s RPMA Technology
Wikipedia: Random phase multiple access (RPMA)

FLEXlm

mgcld (Mentor Graphics -> ModelSim / QuestaSim):
xilinxd (Xilinx):
snpslmd (Synopsys):
alterad (Altera Quartus):
$ lmutil.exe lmstat -a
or
$ lmstat -a

lmutil - Copyright (c) 1989-2013 Flexera Software LLC. All Rights Reserved.
Flexible License Manager status on Wed 9/16/2015 16:03

License server status: 27005@srv-fpgalic.xxx.com
    License file(s) on srv-fpgalic.xxx.com: /usr/local/flexlm/altera/license.dat:

srv-fpgalic.xxx.com: license server UP (MASTER) v9.5

Vendor daemon status (on srv-fpgalic.xxx.com):

   alterad: UP v10.8
Feature usage info:
Users of quartus:  (Total of 7 licenses issued;  Total of 1 license in use)
  "quartus" v2015.08, vendor: alterad
  floating license

   alterad: UP v10.8
Feature usage info:
Users of 6AF8_00B9:  (Total of 15 licenses issued;  Total of 0 licenses in use)
Users of 6AF7_00B9:  (Total of 15 licenses issued;  Total of 0 licenses in use)
Users of 6AF8_00CB:  (Total of 7 licenses issued;  Total of 0 licenses in use)
Users of 6AF7_00CB:  (Total of 7 licenses issued;  Total of 0 licenses in use)
Users of 6AF8_00D4:  (Total of 7 licenses issued;  Total of 0 licenses in use)
Users of 6AF8_00EC:  (Total of 7 licenses issued;  Total of 0 licenses in use)
Users of 6AF7_00D4:  (Total of 7 licenses issued;  Total of 0 licenses in use)
Users of 6AF7_00EC:  (Total of 7 licenses issued;  Total of 0 licenses in use)
Users of 6AF7_00E8:  (Total of 7 licenses issued;  Total of 0 licenses in use)
Users of 6AF8_00D5:  (Total of 7 licenses issued;  Total of 0 licenses in use)
Users of 6AF7_00D5:  (Total of 7 licenses issued;  Total of 0 licenses in use)
Users of 6AF8_00A2:  (Total of 7 licenses issued;  Total of 0 licenses in use)
Users of 6AF7_00A2:  (Total of 7 licenses issued;  Total of 0 licenses in use)
Users of 6AF7_D013:  (Total of 7 licenses issued;  Total of 0 licenses in use)
Users of ip_base:  (Total of 25 licenses issued;  Total of 0 licenses in use)
Users of 6AF7_00AE:  (Total of 7 licenses issued;  Total of 0 licenses in use)
Users of 6AF7_00E6:  (Total of 7 licenses issued;  Total of 0 licenses in use)
Users of 6AF8_00BD:  (Total of 7 licenses issued;  Total of 0 licenses in use)
Users of 6AF7_00BD:  (Total of 7 licenses issued;  Total of 0 licenses in use)
Users of maxplus2:  (Total of 25 licenses issued;  Total of 0 licenses in use)
Users of maxplus2verilog:  (Total of 25 licenses issued;  Total of 0 licenses in use)
Users of maxplus2vhdl:  (Total of 25 licenses issued;  Total of 0 licenses in use)
Users of quartus_stratixiigx:  (Total of 25 licenses issued;  Total of 0 licenses in use)
Users of quartus_stratixgx_2:  (Total of 25 licenses issued;  Total of 0 licenses in use)
Users of quartus_nonvolatile_encryption:  (Total of 25 licenses issued;  Total of 0 licenses in use)
Users of quartus:  (Total of 25 licenses issued;  Total of 1 license in use)
  "quartus" v2016.09, vendor: alterad
  floating license
Users of 6AF7_00C2:  (Total of 25 licenses issued;  Total of 0 licenses in use)
Users of 6AF7_00D8:  (Total of 25 licenses issued;  Total of 0 licenses in use)
Users of 6AF7_0014:  (Total of 25 licenses issued;  Total of 0 licenses in use)
Users of 6AF7_0034:  (Total of 25 licenses issued;  Total of 0 licenses in use)

SELinux on Fedora

SELinux User’s and Administrator’s Guide (PDF)

Wikipedia: SELinux
CentOS Wiki: SELinux
Introduction to SELinux: Don’t let complexity scare you off
Practical SELinux for the beginner: Contexts and labels

Security-Enhanced Linux – User Guide
2.1. Benefits of running SELinux
5.4.2. Disabling SELinux

TFTP

Problem

$ tftp 10.20.30.40 -c get /app-nand.bin
Error code 0: Permission denied

Solution

$ cd /var/lib/tftpboot
$ ls -alZ 
drwxrwxrwx. root root system_u:object_r:tftpdir_rw_t:s0 .
drwxr-xr-x. root root system_u:object_r:var_lib_t:s0   ..
-rwxrwxrwx. root root system_u:object_r:user_home_t:s0 app-nand.bin

$ cd ..
$ restorecon -Rv tftpboot
restorecon reset /var/lib/tftpboot/app-nand.bin context system_u:object_r:user_home_t:s0->system_u:object_r:tftpdir_rw_t:s0
restorecon set context /var/lib/tftpboot/app-nand.bin->system_u:object_r:tftpdir_rw_t:s0 failed:'Operation not permitted'

$ sudo restorecon -Rv tftpboot
restorecon reset /var/lib/tftpboot/app-nand.bin context system_u:object_r:user_home_t:s0->system_u:object_r:tftpdir_rw_t:s0

$ cd tftpboot
$ ls -alZ 
drwxrwxrwx. root root system_u:object_r:tftpdir_rw_t:s0 .
drwxr-xr-x. root root system_u:object_r:var_lib_t:s0   ..
-rwxrwxrwx. root root system_u:object_r:tftpdir_rw_t:s0 app-nand.bin

$ tftp 172.21.6.53 -c get /app-nand.bin
$

Configuration examples
SELinux Contexts – Labeling Files

Discretionary Access Control (DAC), bei allen Linux Systemen für Files/Directories
Role Based Access Control (RBAC), bei SELinux für Prozesse

$ ls -Z file1
-rw-rw-r--  user1  group1  unconfined_u:object_r:user_home_t:s0  file1
       DAC: <user> <group> <user>       <role>   <type>    <level>

[code]
$ cat /etc/selinux/targeted/contexts/files/file_contexts.homedirs
# User-specific file contexts, generated via libsemanage
# use semanage command to manage system users to change the file_context

# Home Context for user unconfined_u
/home/[^/]*/.+ unconfined_u:object_r:user_home_t:s0
/home/[^/]*/.maildir(/.*)? unconfined_u:object_r:mail_home_rw_t:s0
/home/[^/]* -d unconfined_u:object_r:user_home_dir_t:s0
/home/[^/]* -l unconfined_u:object_r:user_home_dir_t:s0
/home/[^/]*/abc — unconfined_u:object_r:mozilla_home_t:s0
/home/[^/]*/tmp -d unconfined_u:object_r:user_tmp_t:s0

$ system-config-selinux

$ yum install policycoreutils-devel
$ yum install policycoreutils-gui
$ sepolicy gui

Fedora UART Serial Permission

$ usermod -a -G dialout andreas

$ strace gtkterm
[...]
stat("/var/lock/lockdev", {st_mode=S_IFDIR|0775, st_size=40, ...}) = 0
open("/var/lock/lockdev/LCK..ttyUSB0", O_RDONLY) = -1 ENOENT (No such file or directory)
umask(022)                              = 02
open("/var/lock/lockdev/LCK..ttyUSB0", O_WRONLY|O_CREAT|O_EXCL, 0666) = -1 EACCES (Permission denied)
write(2, "Cannot create lockfile: Permissi"..., 42Cannot create lockfile: Permission denied) = 42
[...]

$ usermod -a -G lock andreas