Skip to content

Instantly share code, notes, and snippets.

View tudang's full-sized avatar

Tu Dang tudang

View GitHub Profile
@tudang
tudang / disable_ipv6_example.py
Created November 16, 2016 13:00
How to disable ipv6 in Mininet
#!/usr/bin/python
from mininet.topo import Topo
from mininet.net import Mininet
from mininet.node import CPULimitedHost, Controller, RemoteController, OVSSwitch, Ryu
from mininet.link import TCLink
from mininet.util import dumpNodeConnections
from mininet.log import setLogLevel
from mininet.cli import CLI
from functools import partial
@tudang
tudang / open_flow_rules.txt
Last active August 26, 2021 16:58
An input P4 program for PISCES
ovs-ofctl --protocols=OpenFlow15 del-flows br0
ovs-ofctl --protocols=OpenFlow15 add-flow br0 "table=0,priority=32768,ethernet_dstAddr=0x0CC47AA32534 \
actions=set_field:1->reg0, \
resubmit(,1)"
ovs-ofctl --protocols=OpenFlow15 add-flow br0 "table=0,priority=32768,ethernet_dstAddr=0x0CC47AA32535 \
actions=set_field:2->reg0, \
resubmit(,1)"
ovs-ofctl --protocols=OpenFlow15 add-flow br0 "table=0,priority=0 actions=set_field:2->reg0, \
deparse,output:NXM_NX_REG0[]"
ovs-ofctl --protocols=OpenFlow15 add-flow br0 "table=1,priority=0 actions=set_field:1->header_0_field_0, \
@tudang
tudang / pop_all.txt
Created June 27, 2016 13:24
"Semantic error: Error when calling primitive pop (my_table -> untag -> pop) line 20: argument 1 has type field, but formal count has type integer value"
// Metadata to count number of labels
header_type ingress_metadata_t {
fields {
count : 32;
}
}
// Count number of labels in the stack
parser parse_label {
extract(label_stack[next]);
@tudang
tudang / port_to_port_map_str.patch
Created November 6, 2015 09:46
A fix for bmv2 adding multicast node with a list of ports
diff --git a/targets/simple_switch/sswitch_CLI.py b/targets/simple_switch/sswitch_CLI.py
index f67fc5f..eb0165c 100644
--- a/targets/simple_switch/sswitch_CLI.py
+++ b/targets/simple_switch/sswitch_CLI.py
@@ -41,6 +41,8 @@ class SimpleSwitchAPI(runtime_CLI.RuntimeAPI):
def main():
args = runtime_CLI.get_parser().parse_args()
+ args.pre = runtime_CLI.PreType.SimplePreLAG
+
@tudang
tudang / udp_checksum
Last active October 28, 2015 07:41
header fields for udp checksum
header_type udp_t {
fields {
srcPort : 16;
dstPort : 16;
length_ : 16;
checksum : 16;
}
}
header udp_t udp;
@Test
public void testNewVM() {
Model model = new DefaultModel();
Assert.assertNotEquals(model.newVM().id(), createNewVm(model).id());
Assert.assertEquals(model.getVMs().size(), 2);
Assert.assertNotEquals(model.newNode().id(), createNewNode(model).id());
Assert.assertEquals(model.getMapping().getAllNodes().size(), 2);
Assert.assertEquals(model.getMapping().getAllVMs().size(), 2);
}
@Test
public void testOverbook() throws SolverException {
Model model = new DefaultModel();
ShareableResource cpu = new ShareableResource("cpu", 8, 1);
model.attach(cpu);
int NODE = 256;
for (int i = 0; i < NODE; i++) {
model.getMapping().addOnlineNode(model.newNode());
}
@tudang
tudang / SpreadEvaluation.java
Created May 17, 2013 13:41
Solution should be: 0:1 Migrate(vm2, n1, n4); 0:1 Migrate(vm3, n2, n4); 1:2 Migrate(vm4, n2, n1); 2:3 Shutdown(n2);
@Test
public void spreadBasicEvaluation() {
Mapping map = new MappingBuilder().on(n1, n2, n3, n4)
.run(n1, vm1, vm2)
.run(n2, vm3, vm4)
.run(n3, vm5, vm6).build();
ShareableResource cpu = new ShareableResource("cpu", 1);
cpu.set(n1, 4);
cpu.set(n2, 4);
@tudang
tudang / AmongEvaluation.java
Last active December 17, 2015 10:59
This test includes: Among, Spread, and SingleRunningCapacity and it should have a solution
@Test
public void amongTest1() {
Mapping map = new MappingBuilder().on(n1, n2, n3)
.run(n1, vm1, vm2)
.run(n2, vm3)
.run(n3, vm4).build();
Model model = new DefaultModel(map);
Set<UUID> vms = new HashSet<UUID>(Arrays.asList(vm1, vm2, vm4));
@Test
public void testWeird3() throws SolverException {
ShareableResource resources = new ShareableResource("vcpu", 1);
resources.set(n1, 2);
resources.set(n2, 2);
Mapping map = new MappingBuilder().on(n1, n2).off(n3).run(n1, vm1, vm2).build();
Model model = new DefaultModel(map);