Skip to content

Instantly share code, notes, and snippets.

#!/usr/bin/env python3
'''
Basic IPv4 router (static routing) in Python.
'''
import sys
import os
import time
from switchyard.lib.packet import *
@smihir
smihir / notes.txt
Created November 27, 2015 03:21
BuddyAllocator Analysis Scripts
- Data to be collected on Ubuntu vm running on VirtualBox. (2 GB RAM)
#uname -a
Linux adminuser-VirtualBox 3.13.0-24-generic #46-Ubuntu SMP Thu Apr 10 19:08:14 UTC 2014 i686 i686 i686 GNU/Linux
- The 'heart' of the zoned buddy allocator is the following function(in mm/page_alloc.c)
struct page *
__alloc_pages_nodemask(gfp_t gfp_mask, unsigned int order,
struct zonelist *zonelist, nodemask_t *nodemask)
- The following tracepoint is present in this function:
@smihir
smihir / myswitch.py
Last active April 16, 2016 23:40
cs640 assignment 1
#!/usr/bin/env python3
'''
Ethernet learning switch in Python: HW3.
Note that this file currently has the code to implement a "hub"
in it, not a learning switch. (I.e., it's currently a switch
that doesn't learn.)
'''
from switchyard.lib.address import *
@smihir
smihir / skb_dump.c
Created January 30, 2015 12:48
code to dump a skb, so that with minimum postprocessing it can be fed to text2pcap for converting into a pcap
// This code snippet can be used to dump a skb, so that with minimum postprocessing
// it can be fed to text2pcap for converting into a pcap file which can be analyzed
// in wireshark
do {
int i;
printk("\n");
printk("000000 ");
for (i = 0 ; i < skb->len; i++) {
printk("%02x ", ((u8*)skb->data)[i]);