Skip to content

Instantly share code, notes, and snippets.

View hwchiu's full-sized avatar
🏠
Working from home

HungWei Chiu hwchiu

🏠
Working from home
View GitHub Profile
@hwchiu
hwchiu / gist:9062966
Last active August 29, 2015 13:56
Openflow Controller redirect icmp
  1. Controller:sudo java -jar target/floodlight.jar

  2. Mininet:sudo mn --mac --controller=remote,ip=127.0.0.1 --topo tree,2

  3. Controller:curl -d '{"switch": "00:00:00:00:00:00:00:02", "name":"flow-mod-1", "priority":"32768", "ingress-port":"1" , "src-mac":"00:00:00:00:00:01", "dst-mac":"00:00:00:00:00:02", "active":"true","actions":"set-dst-ip=10.0.0.4,set-dst-mac=00:00:00:00:00:04,output=3"}' http://127.0.0.1:8080/wm/staticflowentrypusher/json

  4. Mininet:h1 ping h2

Result:
mininet> h1 ping h2

@hwchiu
hwchiu / gist:9204284
Last active August 29, 2015 13:56
You can say 11 [10460]
#include<stdlib.h>
#include<stdio.h>
#include<string.h>
int main(void)
{
char buf[1010];
int sumo,sume,i,result;
while(fgets(buf,sizeof(buf),stdin)){
if(strlen(buf)==2 && buf[0]=='0')
return 0;

Flow path highlight

  • 定期透過 restful api 從controller那邊取得每個switch上面的flow entry資訊
  • 使用者輸入其想要觀察的封包特徵與進入點的switch
  • 根據flow entry去模擬match的結果,然後把封包的流向給顯示

Detail flow statistics

  • 使用者輸入想要觀察的流量特徵
  • 加入一筆完全符合該特徵的flow entry到switch的table 0,並且把actions設為 "goto table 1"
  • table 1裡面的flow entry就放本來routing相關的rule
@hwchiu
hwchiu / gist:11318638
Created April 26, 2014 12:15
for amy
#!/usr/bin/perl
select(STDOUT);
$| = 2;
while (<>) {
print "[".localtime()."] $_"
}
@hwchiu
hwchiu / nat.py
Created May 6, 2014 10:47
Nat.py supports remote controller
#!/usr/bin/python
"""
Example to create a Mininet topology and connect it to the internet via NAT
through eth0 on the host.
Glen Gibb, February 2011
(slight modifications by BL, 5/13)
"""
@hwchiu
hwchiu / gist:63d8469ffba148464c87
Last active August 29, 2015 14:01
OVS releated paper
#include<iostream>
using namespace std;
int rightLine,leftLine,upperLine,downLine;
int t1,t2,t3,t4;
int main(){
int times;
int count;
cin >> times;
for(int i=0;i<times;i++){
cin >> count;
@hwchiu
hwchiu / gist:ecb6c0bc7acfe6b0d41e
Last active August 29, 2015 14:02
畢業致詞
各位師長、家長以及在座所有的畢業生們大家好,
今天,是個特別的日子
為什麼特別?
是因為一群人穿者碩士袍聚在一起?
還是因為你父母從遠方而來參加這場畢業典禮?
亦或是你等等準備上台接受撥穗?
都不是
真正的特別的是,過了今天以後,你還是不能畢業

Create topology

sudo mn --topo single,3 --mac

Configuration

  • In the mininet prompt
    1. h3 ifconfig h3-eth0 30.0.0.3
    2. h1 route add default gw 10.0.0.254 h1-eth0
  1. h3 route add default gw 30.0.0.254 h3-eth0
@hwchiu
hwchiu / gist:8b7bab91b5ec56f43380
Created June 12, 2014 11:25
DeviceManagerImpl.java
protected Command processPacketInMessage(IOFSwitch sw, OFPacketIn pi,
FloodlightContext cntx) {
Ethernet eth =
IFloodlightProviderService.bcStore.
get(cntx,IFloodlightProviderService.CONTEXT_PI_PAYLOAD);
logger.error("ethernet:{}",eth.toString());
....
....
...