Skip to content

Instantly share code, notes, and snippets.

View ethercflow's full-sized avatar
🎯
Focusing

Wenbo Zhang ethercflow

🎯
Focusing
  • SmartX
  • China
View GitHub Profile
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#define NEW_BASE_ADDR 98765
void *mymalloc(size_t size) {
return (void *)size;
}
@ethercflow
ethercflow / delay.sh
Created May 23, 2018 08:37 — forked from digilist/delay.sh
Delaying network traffic to a specific IP
#!/bin/bash
interface=lo
ip=10.0.0.1
delay=100ms
tc qdisc add dev $interface root handle 1: prio
tc filter add dev $interface parent 1:0 protocol ip prio 1 u32 match ip dst $ip flowid 2:1
tc qdisc add dev $interface parent 1:1 handle 2: netem delay $delay
global inject, delay_cnt
probe begin {
println("injdect diskio delay begin.\n");
}
probe procfs("cnt").read {
$value = sprintf("%d\n", delay_cnt);
}
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import argparse
import logging
import os
import threading
def parse_opts():
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import argparse
import logging
import os
import signal
import threading
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import argparse
import os
import threading
def uplink(ucycle, uspeed, ustep):
os.system('sudo tc qd del dev eno1 root handle 1')
os.system('sudo tc qdisc replace dev eno1 root handle 1: htb default 20')
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import argparse
import os
import threading
def uplink(ucycle, uspeed, ustep):
os.system('sudo tc qd del dev em1 root handle 1')
os.system('sudo tc qdisc replace dev em1 root handle 1: htb default 20')
int main(void) {
int i = 0;
for (; i < 10; i++) {
vfork();
}
while(1);
}
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>
#define BLOCKSIZE 1048576
#define N 200
#define BUSYTIME 1000
int main(int argc, char *argv[]) {
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>
#include <fcntl.h>
#define BLOCKSIZE 1048576
#define N 200
#define BUSYTIME 1000