Coder Social home page Coder Social logo

rabbitwhite1 / vhost Goto Github PK

View Code? Open in Web Editor NEW
1.0 2.0 1.0 39 KB

A tool to provide virtual hosts, so that we can use the Barefoot Tofino model switch. This tool aims to make the hosts look like directly connected to Tofino model switch.

License: MIT License

Python 100.00%
tofino p4

vhost's Introduction

VHost

License: MIT

This project aims to provide virtual hosts for testing Barefoot Tofino Switches running on the Tofino Model.

Requirements

  • packages:
sudo apt-get install mininet openssh-client openssh-server openvswitch-testcontroller
sudo ln /usr/bin/ovs-testcontroller /usr/bin/controller 
pip3 install mininet

VHost

Run 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 host
  • mac: is the MAC address of this host
  • sw_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.

  1. switch s1 will be created as a central switch connecting hosts and veth.
  2. host h1 with ip and mac specified in config.json will be created
  3. h1 will be connected to interface on s1 (call it s1-eth1, and its mac is sw_mac specified in config.json)
  4. take h1 as an example. s1 sniffs on veth1 and s1-eth1.
    • when a packet is received from veth1, it will be forwarded to s1-eth1
    • when a packet is received from s1-eth1, it will be forwarded to veth1
    • if the dst of packet[Ether] is ff:ff:ff:ff:ff:ff, for now, I broadcast this packet.
---------------+                            +---------------------+
     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
               |                            |                     |
---------------+                            +---------------------+

secdev/scapy#896

l2switch

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

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.