3 NetFlow Probe On FPGA
3 NetFlow Probe On FPGA
Introduction
With ever-growing volume of data being transferred over the Internet, the need for reliable monitoring becomes
more urgent. Monitoring devices should be able to provide accurate information such as traffic patterns,
statistics and various anomalies. This technical report describes an implementation of a network flow monitoring
system using a dedicated hardware platform cooperating with the host PC. By exploiting the hardware-software
codesign principle, we implemented time-critical functions in hardware and the rest in software. This way, the
NetFlow probe offers good performance at low cost.
NetFlow as a protocol for flow monitoring, first implemented in Cisco routers, is the most widely used
measurement solution in a form of NetFlow v5. Statistics on IP traffic flows provide information about who
communicates with whom, how long, how often, using what protocol and service and also how much data was
transfered.
Following part of this report describes the implementation of NetFlow v5 probe firmware itself.
System Architecture
Hardware of NetFlow probe consits of host computer and NetFPGA network card. The measurement process is
completely implemented on the NetFPGA whereas control, configuration and collecting process are implemented
as a user software running in the host computer.
The main parameters of the probe are as follows:
Application Firmware
The firmware part of NetFlow probe is composed of several units chained in a pipeline (see Fig. 1). The
pipeline is instantiated as a user data path module into NetFPGA firmware. Each unit in the pipeline has its
specific task which usually consists of processing of arriving data and adding the result in the output data. The
interconnection of units is provided by netfpga interconnection protocol, i.e., data bus, control bus, write and
ready signals.
64
in(0)
64
in(1)
Input Arbiter
64
64 L3L4 64 Time 64 Hash 64 Flow Flow 64 Record 64
64
Extract Stamp Gen LookUp Proc Wrapper
.
.
.
64
in(7)
CESNET, z.s.p.o. 1
NetFlow probe on NetFPGA
NetFlow probe on NetFPGA Verze #1.00, 2008-12-12
• TCP/IPv4
• UDP/IPv4
• ICMP
Other packets are discarded as not relevant to NetFlow measurement. The unit consists of two independent
processes, one is to parse the packet header and the second one is to create correct output stream.
CTRL DATA L3L4extract
LABEL
Extract
Timestamp Unit
Timestamp unit inserts current timestamp value from the timestamp counter into the packet record. The
timestamp represents SysUpTime – time from the start of the NetFlow monitoring. The timestamp is held in
milliseconds. The timestamp counter is 32 bit and overflows after 49 days and 17 hours. The timestamp is
inserted in the packet record, see Fig. 3. The speed of Timestamp counter is adjusted by the increment value.
The increment value represents the number of clock cycles in one millisecond, i.e., the length of one millisecond.
This value can be set by software in order to speed up or slow down the counter which allows to synchronize
time domain of the firmware with the time domain of local host.
Timestamp
INCREMENT
SrcPort DstPort input Proto. SrcIPAddr DstIPAddr
CESNET, z.s.p.o. 2
NetFlow probe on NetFPGA
NetFlow probe on NetFPGA Verze #1.00, 2008-12-12
Hash Generator
Hash Generator computes a 64-bit hash value (CRC-64) and inserts it into the packet record, Fig 4. The hash
value is computed only from following fields:
• SrcIPAddr
• DstIPAddr
• SrcPort
• DstPort
• Protocol
Timestamp 64 64 Hash
Hash
The probability that two different flows share the same hash result (supposing the uniform distribution of
hash) is:
m! n2
− 2×m
pcollision (n) = 1 − ≈ 1 − e (1)
mn (m − n)!
where in our case c = 248 (only 48 bits of CRC-64) which is the number of possible CRC-64 values and
n = 4000 is number of active flows. The probability of collision is very low, pcollision = 10−13 .
CESNET, z.s.p.o. 3
NetFlow probe on NetFPGA
NetFlow probe on NetFPGA Verze #1.00, 2008-12-12
FlowLookUp Unit
FlowLookUp splits the hash value into two parts. First part is used to address a line which contains 8 hash
values of 8 different flow records (8 fingerprints). These fingerprints are compared to the second part of the
splitted hash. If there is a match with one of the hash values in the line then the flow record is already in the
flow memory. Its address is acquired as the join of first part of the hash and the rank of the matched fingerprint.
If there is no match and number of flow records in the set is lower than 8 then the free space is used to enter new
fingerprint. If there is no match and no space then an arbitrary flowrecord in the set is expired and replaced
with new one.
FlowLookUp
from FlowProc to FlowProc
64 HASH(11:0)
CMD Address MEMORY CMD Address
MODULE 64
DECODER
HASH MEMORY CMD & ADDR Timestamp
MODULE
from Hash
MEMORY TTL TCP f. Pkt Length
64 MODULE
Hash
HASH SrcIPAddr DstIPAddr
Timestamp
SINGLE LINE OF MEMORY Src Port Dst Port input Proto. ToS
SrcIPAddr DstIPAddr
When a flow record is about to be expired the FlowLookUp receives command from FlowProc unit to delete
the corresponding fingerprint from the hash table. Immidiately after this command is executed it is send back
to a FlowProc unit.
1. When the expiration process identifies inactive flow record then it sends a delete command to the
FlowLookUp unit.
2. The FlowLookUp unit deletes the index of the flow record and sends the delete command back to the
FlowProc unit.
3. The FlowProc unit retrieves and deteles correspoding flow record from its memory and send the expired
flow record to its output.
FlowProc
CESNET, z.s.p.o. 4
NetFlow probe on NetFPGA
NetFlow probe on NetFPGA Verze #1.00, 2008-12-12
The computation of values in flow record depends on the previous values of the flow record and command
issued by the FlowLookUp process. Following commands are specified:
• Create (Init) flow record
• Update flow record
• Delete flow record – no operation is performed upon values
The FlowALU implements following operations to support Init and Update commands:
fr.StartTimestamp = init ? pr.TimeStamp : fr.StartTimestamp ;
fr.EndTimestamp = pr.TimeStamp;
fr.dOctets = init ? pr.PktByteLen : ( fr.dOctets + pr.PktByteLen ) ;
fr.dPkts = init ? 1 : ( fr.dPkts + 1 ) ;
fr.ttl = pr.ttl;
fr.TCPflags = init ? pr.TCPflags : ( fr.TCPflags | pr.TCPflags ) ;
fr.srcipaddr = pr.srcipaddr;
fr.dstipaddr = pr.dstipaddr;
fr.srcport = pr.srcport;
fr.dstport = pr.dstport;
fr.input = pr.input;
fr.proto = pr.proto;
fr.tos = pr.tos;
Record Wrapper
The released flow records are temporarily stored in a Record Wrapper module. As soon as the following
conditions are met the stored flow records are reformated to NetFlow v5 format and wrapped into NetFlow v5
protocola and and written into output queue module of NetFPGA platform.
• 15 records arrived in the buffer
• The first record in the buffer is more than 20 ms old
The NetFlow v5 datagram is sent to the output interface specified by software register. There could be more
output interfaces specified as the output interface is one-hot encoded.
CESNET, z.s.p.o. 5
NetFlow probe on NetFPGA
NetFlow probe on NetFPGA Verze #1.00, 2008-12-12
Application Software
The application software of NetFlow probe consists primarily of configuration and statistical interface and a
simple collector.
The concept is displayed on Fig. 7.
NetFPGA driver
NetFlow v5
NetFPGA card
Conclusion
The goal of NetFPGA NetFlow probe is to show a potential of network FPGA cards to gather NetFlow data.
It allows further improvement for example increasing the memory (using SSRAM or DRAM modules). Next
the timestamp could be enhanced to 64 bits or the indexing scheme could be modified.
CESNET, z.s.p.o. 6
NetFlow probe on NetFPGA
NetFlow probe on NetFPGA Verze #1.00, 2008-12-12
References
CESNET, z.s.p.o. 7