This project aims to provide virtual hosts for testing Barefoot Tofino Switches running on the Tofino Model.
- packages:
sudo apt-get install mininet openssh-client openssh-server openvswitch-testcontroller
sudo ln /usr/bin/ovs-testcontroller /usr/bin/controller
pip3 install mininetRun vhost.py will create hosts according to config.json, whose format is as following:
{
"hosts": {
"h1": {
"ip": "10.1.0.1",
"mac": "aa:00:00:00:00:01",
"sw_mac": "cc:00:00:00:00:01",
"veth": "veth1"
},
"h2": {
"ip": "10.1.0.2",
"mac": "aa:00:00:00:00:02",
"sw_mac": "cc:00:00:00:00:02",
"veth": "veth3"
}
}
}Each host is a dict, whose key is the host's name. Inside the dict:
ip: is the IP address of this hostmac: is the MAC address of this hostsw_mac: is the MAC address used in this mininet switch (for now it can be any valid MAC address)veth: is the tofino model veth, to which the host's packets will be forward
With this configuration, vhost will do as following.
- switch
s1will be created as a central switch connecting hosts and veth. - host
h1with ip and mac specified inconfig.jsonwill be created h1will be connected to interface ons1(call its1-eth1, and its mac issw_macspecified inconfig.json)- take
h1as an example.s1sniffs onveth1ands1-eth1.- when a packet is received from
veth1, it will be forwarded tos1-eth1 - when a packet is received from
s1-eth1, it will be forwarded toveth1 - if the
dstofpacket[Ether]isff:ff:ff:ff:ff:ff, for now, I broadcast this packet.
- when a packet is received from
---------------+ +---------------------+
Model | | vhost |
===== | | ===== |
| veth0 veth1 | | s1-eth1 h1-eth0
Port 0 +----------------------------+---------------------+------------------------+ h1
| | |
| veth2 veth3 | | s2-eth1 h2-eth0
Port 1 +----------------------------+---------------------+------------------------+ h2
| | |
| veth4 veth5 | | s3-eth1 h3-eth0
Port 2 +----------------------------+---------------------+------------------------+ h3
| | |
. . . . . .
| veth16 veth17 | | s8-eth1 h8-eth0
Port 8 +----------------------------+---------------------+------------------------+ h8
| | |
. . . . . .
| veth250 veth251 | | ens33
Port 64 (CPU) +----------------------------+---------------------+------------------------+ controller
| | |
---------------+ +---------------------+
Files in l2switch are to test the feasibility of my idea. I will later build the real virtual hosts for the target mentioned above.
r --size 2 --rank 0 --redis-host 10.0.1.1 --redis-port 6379 --prefix 377 --transport udp send_any r --size 2 --rank 1 --redis-host 10.0.1.1 --redis-port 6379 --prefix 377 --transport udp send_any