Fun with Crossbow
The Crossbow project is probably the most exciting new feature in OpenSolaris 2009.06. It a nutshell, project Crossbow brings virtualization to the networking layer. In this quick example I'm going to create a virtual network interface card (VNIC) and dynamically alter it's maximum bandwidth as traffic is flowing over it.
The VNIC must be linked to an actual network interface device. To see the existing devices on the system:
bleonard@opensolaris:~$ dladm show-phys LINK MEDIA STATE SPEED DUPLEX DEVICE e1000g0 Ethernet up 1000 full e1000g0 iwh0 WiFi down 0 unknown iwh0 vboxnet0 Ethernet unknown 0 unknown vboxnet0
The current device in use is e1000g0, so I'll create my VNIC over that device:
pfexec dladm create-vnic -l e1000g0 vnic0
View the new VNIC:
bleonard@opensolaris:~$ dladm show-vnic LINK OVER SPEED MACADDRESS MACADDRTYPE VID vnic0 e1000g0 1000 2:8:20:e2:77:62 random 0
Note its speed matches that of the physical link. Let's reduce this from 1000 megabits/second to 2 megabits/second:
pfexec dladm set-linkprop -p maxbw=2 vnic0
Before the VNIC can be used, it must be plumbed:
pfexec ifconfig vnic0 plumb
And assigned an IP address. If you're using DHCP, the following will work:
pfexec ifconfig vnic0 dhcp start
Now you can see vnic0 using ifconfig:
bleonard@opensolaris:~$ ifconfig vnic0 vnic0: flags=1104843<UP,BROADCAST,RUNNING,MULTICAST,DHCP,ROUTER,IPv4> mtu 1500 index 7 inet 10.0.1.16 netmask ffffff00 broadcast 10.0.1.255
The VNIC has been assigned IP address 10.0.1.16 and is now ready for use. To test it out, we'll copy a large file from one host to another, over the VNIC. To test this on a single machine, use a virtual machine configured with bridged networking or a zone. From the other host:
bleonard@os200906:~$ mkfile 100M big-file bleonard@os200906:~$ scp big-file bleonard@10.0.1.16:bile-file The authenticity of host '10.0.1.16 (10.0.1.16)' can't be established. RSA key fingerprint is f7:1d:2c:d7:24:e3:1c:57:53:0f:59:75:31:4a:0f:7d. Are you sure you want to continue connecting (yes/no)? yes Warning: Permanently added '10.0.1.16' (RSA) to the list of known hosts. Password: big-file 0% | | 128 KB 13:22 ETA
Notice it's estimated to take over 13 minutes to copy this file. While the file is being copied, back on the host machine, change the maxbw property to 1000 megabits / second:
pfexec dladm set-linkprop -p maxbw=1000 vnic0
Immedially you'll notice the copy operation speed up and quickly complete:
big-file 100% |*****************************| 100 MB 00:37
Very cool!
Awesome!
Posted by Glynn Foster on June 30, 2009 at 05:28 AM GMT #
Er, great. But why?
Posted by 213.202.132.205 on July 20, 2009 at 01:02 PM GMT #
I really like these small info notes you create to get started quickly on these things that show up in the new releases.
So today I was trying to simulate some network delays.. basically wanted to simulate the behavior of a WAN and couldn't get the speed to be lower than 1.2M, so maxbw=2 was the smallest I could use.
I read somewhere that it would be implemented in Crossbow v2 so I'm keeping my fingers crossed.
Posted by Sergio Schvezov on August 05, 2009 at 05:22 PM GMT #