cflowd-2-0 design: cflowdmux

Next Previous Contents

## 2. cflowdmux

`cflowdmux` accepts Cisco flow-export packets arriving on UDP sockets and saves the packets in shared memory buffers. `cflowdmux` toggles between two packet buffers when writing packets, and clients may read the buffer that is not currently being written. A semaphore is used as the read/write mutex for each buffer, so that clients can avoid reading a buffer while it's being written by `cflowdmux`. Figure 2 is a diagram of the basic functions of `cflowdmux`.

Figure 2: cflowdmux

As UDP flow-export packets arrive, `cflowdmux` writes them into one of the shared memory packet buffers. Before writing into a share memory buffer, `cflowdmux` gets the semaphore for the buffer to prevent writing a buffer that's being read by a client like `cflowd`. When `cflowdmux` reaches the end of the buffer or 2 seconds transpires without coming to the end of the buffer, it releases the semaphore for the buffer and toggles to the other buffer.

The motivation for the use of shared memory for inter-process communication: performance. A bottleneck at this interface in the system is important to avoid because it will affect all downstream processing.

Currently `cflowdmux` is a standalone program, and can be run alone without clients. There's no particularly good reason to do so, since `cflowdmux` does not analyze the contents of the data. However, it does mean that it's fairly safe to start `cflowdmux` at boot time even if you will not be running clients all of the time.

Next Previous Contents