Skip to content

Instantly share code, notes, and snippets.

View shun159's full-sized avatar
☁️
In da cloud

Eishun Kondoh shun159

☁️
In da cloud
View GitHub Profile
@shun159
shun159 / fib.erl
Last active December 15, 2022 06:33
Comparision of Program for Fibonacci numbers. Implement using Dynamic Programming and Conventional Implementation.
%
% timer:tc(fun() -> fib:fib(41) end).
% {1398640,165580141}
%
% timer:tc(fun() -> fib:fib_dp1(41) end).
% {84,165580141}
%
% timer:tc(fun() -> fib:fib_dp2(41) end).
% {5,165580141}
%
[ 86.717334] Hardware name: Dell Inc. XPS 13 9360/0MM5PT, BIOS 2.13.0 11/14/2019
[ 86.717335] RIP: 0010:vr_htable_get_address+0x9/0x30 [vrouter]
[ 86.717350] Code: 02 48 8b 57 28 48 85 d2 74 09 0f b7 4a 04 0f af 0a 01 c8 5d c3 66 66 2e 0f 1f 84 00 00 00 00 00 90 0f 1f 44 00 00 55 48 89 f8 <48> 8b 7f 20 0f b7 57 04 0f af 17 48 89 e5 48 39 d6 72 07 48 8b 78
[ 86.717352] RSP: 0000:ffffa15b82f4fce8 EFLAGS: 00010246
[ 86.717353] RAX: 0000000000000000 RBX: ffffa15b82f4fde8 RCX: ffff9631be580000
[ 86.717355] RDX: 0000000000000025 RSI: 0000000000000000 RDI: 0000000000000000
[ 86.717356] RBP: ffffa15b82f4fcf8 R08: 000000000002f678 R09: 0000000000000025
[ 86.717357] R10: 0000000000000293 R11: ffff9631be5af588 R12: ffffa15b82f4fde8
[ 86.717358] R13: ffff9630d401c708 R14: 00007f8a850b2058 R15: 000000018bd3d067
[ 86.717360] FS: 00007f8a8ea72740(0000) GS:ffff9631be580000(0000) knlGS:0000000000000000
#include <stdio.h>
#include <unistd.h>
#include <signal.h>
#include <stdlib.h>
#include <string.h>
#include <pthread.h>
#define NUMSIGS 64
#define MULTIPLE_OF_(x, i) (i % x == 0)
@shun159
shun159 / bridge.erl
Last active November 26, 2019 13:24
内容はテキトーなんで許してちょんまげ
-module(bridge).
-export([start/2]).
-define(SIOCGIFINDEX, 16#8933).
-define(ETH_P_ALL, 16#0300).
start(Iface1, Iface2) ->
S1 = bind(Iface1),
S2 = bind(Iface2),
OFPST_FLOW reply (OF1.3) (xid=0x2):
 cookie=0x0, duration=99508.198s, table=0, n_packets=0, n_bytes=0, priority=100,in_port=1 actions=set_field:0x1->reg13,set_field:0x1->metadata,set_field:0x1->reg14,resubmit(,16)
 cookie=0x0, duration=99508.191s, table=0, n_packets=0, n_bytes=0, priority=100,in_port=2 actions=set_field:0x2->reg13,set_field:0x1->metadata,set_field:0x2->reg14,resubmit(,16)
 cookie=0x0, duration=99508.159s, table=0, n_packets=0, n_bytes=0, priority=100,in_port=3 actions=move:NXM_NX_TUN_ID[0..23]->OXM_OF_METADATA[0..23],move:NXM_NX_TUN_METADATA0[16..30]->NXM_NX_REG14[0..14],move:NXM_NX_TUN_METADATA0[0..15]->NXM_NX_REG15[0..15],resubmit(,33)
 cookie=0x0, duration=99508.203s, table=16, n_packets=0, n_bytes=0, priority=100,metadata=0x1,dl_src=01:00:00:00:00:00/01:00:00:00:00:00 actions=drop
 cookie=0x0, duration=99508.200s, table=16, n_packets=0, n_bytes=0, priority=100,metadata=0x1,vlan_tci=0x1000/0x1000 actions=drop
 cookie=0x0, duration=99508.209s, table=16, n_packets=0, n_bytes=0, priority
OFPST_FLOW reply (OF1.3) (xid=0x2):
 cookie=0x0, duration=9671.715s, table=0, n_packets=0, n_bytes=0, priority=100,in_port=1 actions=set_field:0x1->reg13,set_field:0x1->metadata,set_field:0x1->reg14,resubmit(,16)
 cookie=0x0, duration=9671.698s, table=0, n_packets=0, n_bytes=0, priority=100,in_port=2 actions=set_field:0x2->reg13,set_field:0x1->metadata,set_field:0x2->reg14,resubmit(,16)
 cookie=0x0, duration=9671.671s, table=0, n_packets=0, n_bytes=0, priority=100,in_port=3 actions=set_field:0x3->reg13,set_field:0x1->metadata,set_field:0x3->reg14,resubmit(,16)
 cookie=0x0, duration=9671.727s, table=16, n_packets=0, n_bytes=0, priority=100,metadata=0x1,dl_src=01:00:00:00:00:00/01:00:00:00:00:00 actions=drop
 cookie=0x0, duration=9671.718s, table=16, n_packets=0, n_bytes=0, priority=100,metadata=0x1,vlan_tci=0x1000/0x1000 actions=drop
 cookie=0x0, duration=9671.749s, table=16, n_packets=0, n_bytes=0, priority=50,reg14=0x3,metadata=0x1,dl_src=00:00:00:00:00:03 actions=resubmit(,17)
 cookie=0x0, d
table=0, n_packets=0, n_bytes=0, idle_age=6072, priority=100,in_port=4 actions=load:0x1->OXM_OF_METADATA[],load:0x1->NXM_NX_REG14[],resubmit(,16)
table=0, n_packets=0, n_bytes=0, idle_age=6072, priority=100,in_port=3 actions=load:0x2->OXM_OF_METADATA[],load:0x1->NXM_NX_REG14[],resubmit(,16)
table=0, n_packets=0, n_bytes=0, idle_age=6072, priority=100,in_port=2 actions=load:0x3->OXM_OF_METADATA[],load:0x1->NXM_NX_REG14[],resubmit(,16)
table=0, n_packets=0, n_bytes=0, idle_age=6072, priority=100,in_port=1 actions=load:0x1->OXM_OF_METADATA[],load:0x2->NXM_NX_REG14[],resubmit(,16)
table=16, n_packets=0, n_bytes=0, idle_age=6072, priority=100,metadata=0x2,vlan_tci=0x1000/0x1000 actions=drop
table=16, n_packets=0, n_bytes=0, idle_age=6072, priority=100,metadata=0x1,vlan_tci=0x1000/0x1000 actions=drop
table=16, n_packets=0, n_bytes=0, idle_age=6072, priority=100,metadata=0x3,vlan_tci=0x1000/0x1000 actions=drop
table=16, n_packets=0, n_bytes=0, idle_age=6072, priority=100,metadata=0x2,dl_src=01:00:00:
require 'socket'
require 'pio'
class RawSocket
include Pio
ETH_P_ALL = 0x0300
SIOCGIFINDEX = 0x8933
def initialize(interface)
ovs-ofctl dump-flows br1                               
NXST_FLOW reply (xid=0x4):
 cookie=0x900000000000000, duration=681.331s, table=0, n_packets=0, n_bytes=0, idle_age=681, priority=2,in_port=LOCAL actions=set_field:0x40000000000/0xc0000000000->metadata,resubmit(,6)
 cookie=0x900000000000000, duration=681.331s, table=0, n_packets=0, n_bytes=0, idle_age=681, priority=2,in_port=CONTROLLER actions=set_field:0x4040000000000/0x40c0000000000->metadata,resubmit(,7)
 cookie=0x900000000000000, duration=681.367s, table=0, n_packets=0, n_bytes=0, idle_age=681, priority=1,tun_id=0 actions=drop
 cookie=0x900000000000000, duration=681.333s, table=0, n_packets=0, n_bytes=0, idle_age=681, priority=0 actions=set_field:0x40000000000/0xc0000000000->metadata,resubmit(,3)
 cookie=0x900000000000000, duration=681.368s, table=3, n_packets=0, n_bytes=0, idle_age=681, priority=0 actions=drop
 cookie=0x900000000000000, duration=681.368s, table=4, n_packets=0, n_bytes=0, idle_age=681, priority=0 actions=drop
 cookie=0
-module(calculate_port_mask).
-export([calc/2]).
calc(Min, Max) when Min < Max->
calc(Min, Max, 0, 16);
calc(_, _) ->
[].
calc(Min, Max, Length0, BitSize) ->