Skip to content

Instantly share code, notes, and snippets.

View hgn's full-sized avatar

Hagen Paul Pfeifer hgn

View GitHub Profile
@hgn
hgn / tcpdump IPv6 router advertisement
Created March 16, 2015 18:59
Capture of IPv6 advertisement message via tcpdump
@virgo:~ $ sudo tcpdump -vvvv -ttt -i eth1 icmp6 and 'ip6[40] = 134'
00:00:00.000000 IP6 (hlim 255, next-header ICMPv6 (58) payload length: 200) fe80::b675:eff:fefa:1cb > ip6-allnodes: [icmp6 sum ok] ICMP6, router advertisement, length 200
hop limit 0, Flags [managed, other stateful], pref medium, router lifetime 1800s, reachable time 0s, retrans time 0s
source link-address option (1), length 8 (1): b4:75:0e:fa:01:cb
0x0000: b475 0efa 01cb
mtu option (5), length 8 (1): 1280
0x0000: 0000 0000 0500
prefix info option (3), length 32 (4): 2a01:ffff:43f::/64, Flags [onlink, auto], valid time 7200s, pref. time 1800s
0x0000: 40c0 0000 1c20 0000 0708 0000 0000 2a01
0x0010: ffff 043f 0000 0000 0000 0000 0000
@hgn
hgn / example.conf
Last active February 27, 2021 01:11
Simple Python aiohttp Server with Configuration Parsing and Logging
server_addr = "127.0.0.1"
server_port = 8888
# debug level, can be debug, error, info, ...
loglevel = "debug"
paths = {
"route_set" : "/",
"interface_get" : "/",
@hgn
hgn / builddriver.py
Last active June 19, 2019 08:38
Python Builddriver API Brainstorming
import builddriver
result = builddriver.execute("make debug")
result.status()
# can be True or False
result.log()
# return a path where the output is captured (/tmp/foo.log)
#define N 1024
int mul1[N][N];
int mul2[N][N];
int res[N][N];
void calculate(void)
{
int i, j, k;
@hgn
hgn / ping-rtt-to-gnuplot
Last active March 26, 2018 08:39
Ping based RTT Measurement with Gnuplot for IPv4 and IPv6
ping heise.de -c 300 -ni 0.5 | awk -F '[= ]' {'print $(NF-1)'} | grep -E '[0-9]' > /tmp/ipv4.dat
ping6 heise.de -c 300 -ni 0.5 | awk -F '[= ]' {'print $(NF-1)'} | grep -E '[0-9]' > /tmp/ipv6.dat
cat << EOF > /tmp/ping-rtt.gpi
#!/usr/bin/gnuplot
set terminal svg size 1000,600 fname "Gill Sans" fsize 14 rounded dashed
set style line 80 lt 0
set style line 80 lt rgb "#808080"
set style line 81 lt 3
set style line 81 lt rgb "#808080" lw 0.5
function alex_hash() {
var hash = 0;
if (this.length == 0) return hash;
for (i = 0; i < this.length; i++) {
char = this.charCodeAt(i);
hash1 = ((char)-hash)+char;
hash2 = ((char<<8)-hash)+char;
hash3 = ((char<<16)-hash)+char;
hash4 = ((char<<24)-hash)+char;
hash = (hash1 ^ hash2 ^ hash3 ^ hash4) & 0xFFFFFF;
@hgn
hgn / python-json-types.py
Created August 25, 2016 11:19 — forked from NelsonMinar/python-json-types.py
Testing various dict wrappers for Python JSON
"""
Various options for a JSON type for Python.
My best effort at using these libraries naturally for reading and writing JSON.
https://nelsonslog.wordpress.com/2016/01/08/a-better-python-object-for-json/
"""
import json, copy
import dotmap, attrdict, easydict, addict
@hgn
hgn / captcp-constantly-graph
Created January 24, 2014 09:52
captcp-constantly-graph
#!/usr/bin/env python
# remember to edit /etc/sudoers file and grant tcpdump without
# password access to work in a scripting environment. sudo visudo
# username ALL=NOPASSWD:ALL,/sbin/tcpdump,/usr/bin/kill
import os
import signal
import subprocess
#!/bin/sh
# aptitude install bridge-utils
if1=eth0
if2=eth1
ifconfig $if1 down
ifconfig $if2 down
ifconfig $if1 0.0.0.0 up
@hgn
hgn / gist:5094345
Created March 5, 2013 21:15
Parse /proc/interrupts
/*
* Copyright (C) 2006, Intel Corporation
* Copyright (C) 2012, Neil Horman <nhorman@tuxdriver.com>
*
* This file is part of irqbalance
*
* This program file 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; version 2 of the License.
*