|
| 1 | +# Integrate virtual switch and fubuki |
| 2 | + |
| 3 | +## Abstraction |
| 4 | + |
| 5 | +`vproxy` provides a sound virtual switch implementation, which supports the TCP/IP stack; |
| 6 | +`fubuki` is a network mesh based on tun interfaces written in rust. |
| 7 | + |
| 8 | +We can combine them by converting fubuki tun interfaces into rx/tx APIs and hooking them into vproxy virtual switch. |
| 9 | + |
| 10 | +## Commands descriptions |
| 11 | + |
| 12 | +After launching vproxy, we can get detailed into about the commands used in this article: |
| 13 | + |
| 14 | +* `man switch` |
| 15 | +* `man vpc` |
| 16 | +* `man fubuki` |
| 17 | +* `man iface` |
| 18 | +* `man switch add` |
| 19 | +* `man vpc add-to` |
| 20 | +* `man fubuki add-to` |
| 21 | +* `man iface list-detail` |
| 22 | +* `man iface remove-from` |
| 23 | + |
| 24 | +## Configuring |
| 25 | + |
| 26 | +1. Launching vproxy |
| 27 | + |
| 28 | +``` |
| 29 | +make jar-with-lib |
| 30 | +java --enable-preview -Dvfd=posix -jar build/libs/vproxy.jar |
| 31 | +``` |
| 32 | + |
| 33 | +2. Creating virtual switch |
| 34 | + |
| 35 | +``` |
| 36 | +add switch sw0 |
| 37 | +``` |
| 38 | + |
| 39 | +3. Creating virtual network |
| 40 | + |
| 41 | +``` |
| 42 | +add vpc 1 to switch sw0 v4network 10.99.88.0/24 |
| 43 | +``` |
| 44 | + |
| 45 | +Descriptions: |
| 46 | + |
| 47 | +* `add vpc 1` means creating vpc `1`, whose vni is 1 |
| 48 | +* `to switch sw0` means it's added into `sw0` |
| 49 | +* `v4network $.$.$.$/$` means the v4 network range limit of this vpc |
| 50 | + |
| 51 | +4. Creating fubuki interface |
| 52 | + |
| 53 | +``` |
| 54 | +add fubuki fbk0 to switch sw0 vni 1 mac 00:11:22:33:44:55 ip 10.99.88.199/24 address $.$.$.$:$ password $ |
| 55 | +``` |
| 56 | + |
| 57 | +Descriptions: |
| 58 | + |
| 59 | +* `add fubuki fbk0` means create a fubuki interface, named as `fbk0` |
| 60 | +* `to switch sw0` means it's added into `sw0` |
| 61 | +* `vni 1` means the interface by default belongs to the vpc whose vni is 1 (in other words, `vpc 1`) |
| 62 | +* `mac $:$:$:$:$:$` means the mac address allocated for the interface. Since fubuki runs in tun mode, the switch has to simulate the layer 2 frames |
| 63 | +* `ip $.$.$.$/$` means the ip address and mask for this interface to use. You may omit this option, in this case, fubuki will automatically allocate an ip instead |
| 64 | +* `address $.$.$.$:$` means the address and port of the remote fubuki server |
| 65 | +* `password $` means the password used by fubuki to communicate |
| 66 | + |
| 67 | +## Viewing |
| 68 | + |
| 69 | +``` |
| 70 | +ll iface in switch sw0 |
| 71 | +``` |
| 72 | + |
| 73 | +## Testing |
| 74 | + |
| 75 | +Use a standard fubuki client and connect to the same server, then ping the ip address bond by `fbk0` |
| 76 | + |
| 77 | +``` |
| 78 | +PING 10.99.88.199 (10.99.88.199): 56 data bytes |
| 79 | +Request timeout for icmp_seq 0 |
| 80 | +64 bytes from 10.99.88.199: icmp_seq=1 ttl=64 time=92.467 ms |
| 81 | +64 bytes from 10.99.88.199: icmp_seq=2 ttl=64 time=90.040 ms |
| 82 | +64 bytes from 10.99.88.199: icmp_seq=3 ttl=64 time=92.859 ms |
| 83 | +^C |
| 84 | +--- 10.99.88.199 ping statistics --- |
| 85 | +4 packets transmitted, 3 packets received, 25.0% packet loss |
| 86 | +round-trip min/avg/max/stddev = 90.040/91.789/92.859/1.247 ms |
| 87 | +``` |
| 88 | + |
| 89 | +Note: vproxy virtual switch must lookup the dst mac address, so the first responding packet cannot be transmitted. |
| 90 | +All other packets after the first one should be transmitted normally. |
| 91 | + |
| 92 | +> For tun devices, arp/ns will be transformed into special icmp packets. |
| 93 | +
|
| 94 | +## Deleting |
| 95 | + |
| 96 | +``` |
| 97 | +remove iface fubuki:fbk0 from switch sw0 |
| 98 | +``` |
0 commit comments