Load Balance Testing with OpenVSwitch
From tutorial ovs-conntrack
Testing performed on OS10 v
ip netns add leftip netns add rightip link add veth_l0 type veth peer name veth_l1ip link set veth_l1 netns leftip link add veth_r0 type veth peer name veth_r1ip link set veth_r1 netns rightovs-vsctl add-br br0ip a s | lessovs-vsctl add-port br0 veth_l0ovs-vsctl add-port br0 veth_r0ip netns exec left sudo ip link set lo upip netns exec right sudo ip link set lo upGenerate TCP segments
Section titled “Generate TCP segments”ip netns exec left sudo `which scapy`ip netns exec right sudo `which scapy`Matching TCP packets
Section titled “Matching TCP packets”Simple flows for port to port
Section titled “Simple flows for port to port”ovs-ofctl add-flow br0 "table=0, priority=10, in_port=veth_l0, actions=veth_r0"ovs-ofctl add-flow br0 "table=0, priority=10, in_port=veth_r0, actions=veth_l0"Flow matching
Section titled “Flow matching”ovs-ofctl add-flow br0 "table=0, priority=50, ct_state=-trk, tcp, in_port=veth_l0, actions=ct(table=0)"ovs-ofctl add-flow br0 "table=0, priority=50, ct_state=+trk+new, tcp, in_port=veth_l0, actions=ct(commit),veth_r0"ovs-ofctl add-flow br0 "table=0, priority=50, ct_state=-trk, tcp, in_port=veth_r0, actions=ct(table=0)"ovs-ofctl add-flow br0 "table=0, priority=50, ct_state=+trk+est, tcp, in_port=veth_r0, actions=veth_l0"ovs-ofctl add-flow br0 "table=0, priority=50, ct_state=+trk+est, tcp, in_port=veth_l0, actions=veth_r0"End result
Section titled “End result”You can do cool stuff, but it won’t work/wouldn’t be a great way to do this.