Skip to content

Instantly share code, notes, and snippets.

@kirk91
Created December 7, 2016 16:30
Show Gist options
  • Save kirk91/d4bd89f20907bc695bbf6e002b890cff to your computer and use it in GitHub Desktop.
Save kirk91/d4bd89f20907bc695bbf6e002b890cff to your computer and use it in GitHub Desktop.
#! /usr/bin/env bash
# emulate network latency in etcd cluster.
# set 30ms delay before sending packet that comes from source port 2380
sudo tc qdisc add dev eth0 root handle 1: htb default 1
sudo tc class add dev eth0 parent 1: classid 1:1 htb rate 1000kbps
sudo tc class add dev eth0 parent 1: classid 1:2 htb rate 1000kbps
sudo tc qdisc add dev eth0 parent 1:2 handle 10: netem delay 30ms
sudo tc filter add dev eth0 protocol ip parent 1: prio 1 u32 match ip sport 2380 0xffff flowid 1:2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment