Skip to content

Instantly share code, notes, and snippets.

View fuji246's full-sized avatar

Jiantao Fu fuji246

View GitHub Profile
@fuji246
fuji246 / screencapture.applescript
Created March 19, 2020 18:39
screen capture script using QuickTime Player
#!/usr/bin/osascript
# helper function for command parameters
on stringSplit(str, delimiters)
# save delimiters to restore old settings
set oldDelimiters to AppleScript's text item delimiters
# set delimiters to delimiter to be used
set AppleScript's text item delimiters to delimiters
# create the array
set splitedArray to every text item of str
@fuji246
fuji246 / mtr.sh
Created March 19, 2020 00:50
dump mtr result to log file
#!/bin/bash
> mtr.log
for (( ; ; ))
do
mtr $1 -u -r >> mtr.log
done
@fuji246
fuji246 / psk.py
Created March 10, 2020 19:21
wpa_passphrase replacement that supports unicode and space in SSID
#! /usr/bin/env python
# coding=utf8
# modified from https://github.com/SwordYork/NetworkTool/blob/master/WPA-PSK/TKIP/psk.py
# alternatively, you can refer https://github.com/lomorage/pi-gen/blob/lomorage/stage2/02-net-tweaks/files/wifi_switch.sh#L12
# and use wpa_passphrase, and then replace ssid with hex binary of the SSID
import hmac
import hashlib
@fuji246
fuji246 / wireshark_tcptrace_colors.md
Last active October 23, 2019 23:50
Wireshark tcptrace colors

Wireshark tcptrace colors

#725000 ack numbers from reverse packets

#CC0000 highest number (most recent) SACK block

#A40000 subsequent SACK blocks

@fuji246
fuji246 / ubuntu_netem_mod.md
Last active September 26, 2019 18:17
ubuntu netem module compile
  1. uncomment the “deb-src” lines in /etc/apt/sources.list.

  2. install packages and source

sudo apt update
sudo apt-get build-dep linux linux-image-$(uname -r)
sudo apt-get install libncurses-dev flex bison openssl libssl-dev dkms libelf-dev libudev-dev libpci-dev libiberty-dev autoconf
sudo apt-get install git
sudo apt-get source linux-image-$(uname -r)
@fuji246
fuji246 / pi-image-backup.md
Created September 6, 2019 23:56
backup raspberry pi image

on OSX:

  1. backup whole disk
# check micro sd card disk

$ diskutil list

# copy whole disk, /dev/disk2 is the sd card devcie, the size is 16G
@fuji246
fuji246 / boxplot-tcpperf.png
Last active August 9, 2019 19:07
Linux tcp performance test
boxplot-tcpperf.png
@fuji246
fuji246 / tcp_cubic_memo.md
Last active May 10, 2024 10:52
TCP cubic memo

Paper

use a cubic function to replace the linear window growth to improve performance in high BDP network, also achieved RTT fairness.

tcp-cubic is succssor of tcp-bic, tcp-bic use binary search to find the avialble bandwidth when congestion happens, and MAY enter an lieaner increasing state (Additive Increase)if it dropped too low, if it passed the maximum window, it goes into max probing state and will do the reverse and grow slowly initially and switch to additive increase if it can't find new maximum window nearby.

$ uname -a
Linux pi3 3.6.11+ #538 PREEMPT Fri Aug 30 20:42:08 BST 2013 armv6l GNU/Linux
$ zgrep "* firmware as of" /usr/share/doc/raspberrypi-bootloader/changelog.Debian.gz | head -1 |
awk '{ print $5 }'
d4f5315cfac4e
On the build host fetch the equivalent R-PI firmware.
$ mkdir -p /embedded/raspbian/build/
@fuji246
fuji246 / boxplot-example.py
Last active July 10, 2019 00:14
box plot example
'''
server, direction, bitrate, case, buftune, frto_response, tcp_abc
HZ, uplink, 15, 150 ms, 0, 0, 0
HZ, uplink, 22.1, 150 ms, 0, 0, 0
HZ, uplink, 20.6, 150 ms, 0, 0, 0
HZ, uplink, 11.5, 150 ms, 0, 0, 0
HZ, uplink, 9.83, 150 ms, 0, 0, 0
HZ, uplink, 7.8, 150 ms, 0, 0, 0
HZ, uplink, 14.4, 150 ms, 0, 0, 0
HZ, uplink, 12.7, 150 ms, 0, 0, 0