LiveCD
From NetFPGAWiki
We have created a Live CD based on openSuSE 10.3 that has OpenFlow and NetFPGA utilities installed. It can be used with or without NetFPGA as the following:
- OpenFlow Switch
- IPv4 Router
- Ethernet learning switch
Having a NetFPGA card present accelerates the above solution and allows the box to be used as a packet generator that can send packets out of all 4 1DidE ports at line-rate.
Contents |
Instructions
- Download the iso.
- Burn to CD or use as cdrom in virtual machine
- Boot using CD
- The openSuSE Welcome splash screen comes up and you are then presented with a menu with a few choices
- Select the first choice (live-cd)
- If you have more than 2 NetFPGA cards, change the "vmalloc=256M" line in boot options to "vmalloc=512M".
- Add 256 for each additional card.
- You don't need to do anything if you don't have a NetFPGA card installed
- After the boot process, if you have a NetFPGA card, the system will automatically reprogram the PCI controller to the latest version.
- KDE will starts afterwards
- You can also install the LiveCD to a hard disk to preserve changes.
Download
CD: Live CD
Usage
All the commands below are issued as root user. The following utilities are provided:
- regwrite : write to a NetFPGA register. Some register defines can be found in the Register Map. Others in the header files in /usr/include/netfpga
- regread : read a NetFPGA register.
- nf2_download : download a bitfile to the board
- cpci_reprogram : load new CPCI firmware on the PCI FPGA controller
IPv4 Router
You can use the system as an IPv4 router. There are is no routing software installed, so you will need to install something like XoRP or Quagga in order to get the maximum benefit. Without such software you will need to manually configure the linux routing tables using the route command.
Without NetFPGA
1. Decide which interfaces you will use to forward. The following command will bringup a list of available interfaces.
# ifconfig -a -s
2. Type the following command for each interface you wish to allow forwarding over (replace <interface_name> with the name of the interface):
# echo 1 > /proc/sys/net/ipv4/conf/<interface_name>/forwarding
You can also setup other options in the same directory.
3. Manually configure your routing table (if you are not running any routing software). For example, to add an entry to forward all packets to subnet IP 192.168.3.0/24 out of interface eth1 with next hop 192.168.3.1:
# route add -net 192.168.3.0/24 gw 192.168.3.1 eth1
With NetFPGA
Currently the router kit supports only a single NetFPGA card.
1. To enable NetFPA hardware acceleration, the router kit daemon must be enabled.
# rcnetfpga.rkd restart
2. Add nf2c0, nf2c1, nf2c2, nf2c3 and any other interfaces you wish to forward on using the commands from the section above.
3. You can manipulate the routing table using the route</command> as in the previous section.
4. Also available are the following commands that can interact directly with the hardware:
- nf_rr_cli : starts a command-line interface (cli) that can modify hardware entries directly. Note that this does not modify the Linux forwarding table entries.
- nf_rr_regdump : dumps all registers, including counters and table entries. See Register Map for more info.
- nf_rr_show_stats : shows a set of stats that are refreshed every second.
The bitfile is located as /usr/share/netfpga/bitfiles/reference_router.bit
OpenFlow Switch
The System can be configured as an OpenFlow switch with or without NetFPGA hardware acceleration.
Without NetFPGA
The installed package has an implementation for a simple OpenFlow controller and two implementations for an OpenFlow switchm one as a kernel module and one as a user-space program. There is also a hardware acceleration module for the NetFPGA which requires the OpenFlow kernel module implementation. The following programs are installed along with their man pages:
- controller : Starts a simple OpenFlow controller that implements a learning switch or hub
- secchan : Implements the secure channel that communicates with the controller. Used for the kernel implementation.
- dpctl : Similar to Linux's bridging brctl utility, this program is used to add interfaces to the kernel switch implementation.
- switch : User-space implementation of an OpenFlow switch (not recommended)
- vlogconf : logging utility
- ofp-pki : used to setup a public key infrastructure
More documentation can be found under /usr/share/doc/packages/openflow/ The name of the kernel module is called openflow_mod.ko To install the kernel module:
# modprobe openflow_mod
With NetFPGA
To run with hardware acceleration using NetFPGA, you will need to be running the kernel switch implementation. Ensure that no datapaths currently exist using dpctl, then do the following:
1. Download the OpenFlow bitfile
# nf2_download /usr/share/netfpga/bitfiles/openflow_switch.bit
2. Load the NetFPGA OpenFlow module
# modprobe hwtable_nf2_mod
3. Create a datapath (only 1 datapath is supported with the NetFPGA hardware acceleration)
# dpctl adddp nl:0
4. Add the interfaces using dpctl
# dpctl addif nl:0 nf2c0 # dpctl addif nl:0 nf2c1 # dpctl addif nl:0 nf2c2 # dpctl addif nl:0 nf2c3
The following program is installed:
* nf_of_regdump : dumps the registers in the hardware switch and the wildcard table.
Packet Generator/Capture
The LiveCD also contains a bitfile to generate packets/capture a trace using NetFPGA at line-rate through 4-ports. The basic idea is that a trace is collected in pcap format, and downloaded to NetFPGA. The packet generator can be configured to send the packets at arbitrary delays (or even 0 delays for line-rate) or follow the delays in the pcap file. The pcap file can be collected using wireshark or tcpdump (both on the CD). To use the generator, do the following:
1. Download the bitfile
# nf2_download /usr/share/netfpga/bitfiles/packet_generator.bit
2. Assuming you have a trace file named trace.pcap and you wish to load all packets in this file to all output ports:
# nf_packet_generator.pl -q0 trace.pcap -q2 trace.pcap -q4 trace.pcap -q6 trace.pcap -d0 -i100000
THIS IS CURRENTLY STILL BEING PACKAGED AND WILL BE AVAILABLE IN THE NEXT UPDATE OF THE LIVECD. It will complain of missing libraries. See FAQ for a workaround.
Ethernet Switch
The system can be stup to work as a learning switch with or without NetFPGA.
Without NetFPGA
There are many tutorials on using the bridge-utils package, so we won't go through them here.
With NetFPGA
1. Download the bitfile
# nf2_download /usr/share/netfpga/bitfiles/reference_switch.bit
2. By default the host is not included when the bridge broadcasts out of all ports. To enable sending of packets to the host, you need to initiate packet sends through the nf2cX interfaces.
The following programs are also provided:
- nf_rs_show_stats : Display various statistics about the switch on NetFPGA
- nf_rs_regdump : Dump the MAC table and various other registers and stats about NetFPGA.
Selftest
The Live CD contains the utilities needed to run selftest. The installed program is called nf_selftest and the bitfile can be found as /usr/share/netfpga/bitfiles/selftest.bit
For more info see Selftest.
FAQ
- Where is the source code for all this stuff?
- The NetFPGA reference projects' source code (router and NIC) can be found by downloading the NetFPGA release tarball from the official website
- Due to popular demand, you can find the Verilog source code for the OpenFLow switch here. Word of warning. The code might undergo a major facelift to make it easier to understand and modify soon.
- The Packet Generator code does not work
- That's because I haven't gone through the pain of packaging up the Perl libraries to get it to work. You can manually install them from this tarball
- Where is the software source code?
- For the OpenFlow switch go here
- The NetFPGA source code can be found in the release tarballs.
- Where/What is NOX?
- NOX is an OpenFlow controller that has many many feature. It is not on the LiveCD and has not been released yet.
- Something is not working, what do I do?
- Join the NetFPGA forums, and post your question there.
