Skip to content

Instantly share code, notes, and snippets.

View khooi8913's full-sized avatar

Xin Zhe Khooi khooi8913

View GitHub Profile
@khooi8913
khooi8913 / vf-mapper.py
Created August 24, 2026 21:04
Map SR-IOV VF PCI addresses to their PF network interface and back.
#!/usr/bin/env python3
"""Map SR-IOV VF PCI addresses to their PF network interface and back."""
from __future__ import annotations
import argparse
import json
import re
import subprocess
import sys
#!/bin/bash
#
# Copyright 2018 The Outline Authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
#!/bin/bash
#
# Copyright 2018 The Outline Authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
@khooi8913
khooi8913 / demo.p4
Created October 9, 2023 14:55
CS5229 W8 Tutorial demo.p4
/* -*- P4_16 -*- */
#include <core.p4>
#include <v1model.p4>
// https://en.wikipedia.org/wiki/EtherType
const bit<16> ETHERTYPE_IPV4 = 0x0800;
const bit<16> ETHERTYPE_IPV6 = 0X86DD;
// https://en.wikipedia.org/wiki/List_of_IP_protocol_numbers
const bit<8> IP_PROTO_TCP = 0x06;
# Copyright 2012 James McCauley
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at:
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
@khooi8913
khooi8913 / of_tutorial.py
Created June 1, 2022 16:30
Solution for Learning Switch
# Copyright 2012 James McCauley
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at:
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
from mininet.node import Host, OVSSwitch, Controller
from mininet.link import Link
from mininet.net import Mininet
from mininet.cli import CLI
net = Mininet()
h1 = net.addHost('h1')
s1 = net.addSwitch('s1')
c0 = net.addController('c0')
# Your code here
@khooi8913
khooi8913 / topo-isif.py
Last active May 31, 2022 07:40
topo-isif.py
"""
Create the following topology with 6 switches.
Each switch should have 2 two hosts.
s1 ----- s2 ----- s3
|
|
|
s4 ----- s5 ----- s6
@khooi8913
khooi8913 / diff_wandswireless
Created December 19, 2021 04:52
ATH9K driver difference between Linux Kernel v4.1.10 and the Wands-Wireless Atheros CSI Tool
Only in /home/xzk/wands-wireless/Atheros-CSI-Tool/drivers/net/wireless/ath/ath9k/: ar9003_csi.c
Only in /home/xzk/wands-wireless/Atheros-CSI-Tool/drivers/net/wireless/ath/ath9k/: ar9003_csi.h
diff -r drivers/net/wireless/ath/ath9k/ar9003_mac.c /home/xzk/wands-wireless/Atheros-CSI-Tool/drivers/net/wireless/ath/ath9k/ar9003_mac.c
19a20
> #include "ar9003_csi.h"
33c34,35
<
---
> u_int8_t rate1,rate2,rate3,rate4;
>
@khooi8913
khooi8913 / setup.sh
Last active June 10, 2020 12:43
eBPF/ XDP development dependencies
# the following steps adds necessary header files to /usr/include/bpf/
git clone https://github.com/libbpf/libbpf/
cd libbpf/src/
sudo make install