Skip to content
Go to file

Latest commit


Git stats


Failed to load latest commit information.
Latest commit message
Commit time


C++ Implementation of Flow-Based Programming (FBP)

General web site on Flow-Based Programming: .


In computer programming, flow-based programming (FBP) is a programming paradigm that defines applications as networks of "black box" processes, which exchange data across predefined connections by message passing, where the connections are specified externally to the processes. These black box processes can be reconnected endlessly to form different applications without having to be changed internally. FBP is thus naturally component-oriented.

FBP is a particular form of dataflow programming based on bounded buffers, information packets with defined lifetimes, named ports, and separate definition of connections.

One interesting aspect of this implementation is that it supports the scripting language Lua, so large parts of your networks can be written in a scripting language if desired.

This implementation is based on an older C implementation called THREADN, which used longjmp and setjmp to control process scheduling. The scheduling parts of CppFBP now use BOOST instead of longjmp and setjmp. Much of the rest of the overall THREADN architecture has been incorporated into CppFBP - in particular, THREADN allowed networks to be defined dynamically or statically - this has been preserved in CppFBP. See the description of "static" vs. "dynamic" in .

Web sites for FBP:

Sample Component, Component API and Network Definitions

Services supported by Lua interface, and some sample CppFBP/Lua scripts


Download and install Microsoft Visual Studio

Download and install Boost -

Download and install Lua -

Update following macros with correct version numbers: BOOST_INCLUDE, BOOST_LIB, LUA_INCLUDE, LUA_LIB, as follows:

  • Go to View/Other Windows/Property Manager/SolutionSettings
  • Expand, showing Debug
  • Expand, showing UserMacros
  • Select UserMacros
  • Go to UserMacros under Common Properties
  • Click on that, revealing the 4 macros; change version numbers if necessary
  • Leave the set this macro as an environment variable in the build environment option set to selected

or, more simply, in Windows Explorer, just go to SolutionSettings, open it, open UserMacros.props, and make, apply and save your changes.

Build FBP Project

Create empty cppfbp directory in your local GitHub directory

Do git clone

Now go into Visual C++, and Open/Project/Solution CppFBP.sln (in the just cloned directory)

There will be a "solution" line, followed by a number of "projects" - two of which are CppFBPCore and CppFBPComponents.

Do these builds in this order:

  • Right click on CppFBPCore and do a Build
  • Right click on CppFBPComponents and do a Build
  • Right click on TestSubnets and do a Build

Right click on the "solution" line, and do Build Solution

If you get errors, you may have to build individual projects (sometimes this will require more than one try); if you only get warnings, you can proceed.

If you get a message saying "unknown compiler version", try reinstalling Boost.

"Dynamic" Networks

The projects whose names are of the form xxxDyn are "dynamic" versions of the projects named xxx - they start by scanning off the .fbp network definitions (via the CppFBP module with the DYNAM parameter set to true), and then run the resulting network structures.

Testing Thxgen

This program takes .fbp file and generates a .cpp network definition. If you want to try it, run Thxgen on your cloned repository - in debug mode... To change the file being scanned, change Command Arguments in Debugging Properties...

Testing "TimingTest1" (console application)

This test case has 5 Generate/Drop process pairs, over each of which 1,000,000 IPs travel concurrently. This means 5,000,000 each of create IP, send, receive, and drop.

To run it, right click on TimingTest1 in Solution Explorer; Debug/Start new instance

You should see something like

Elapsed time in seconds: 180.000
Press any key to continue . . .

The elapsed time will of course depend on your machine processing speed, number of cores, etc.

Installing Lua (under VS 2015)

  • Download latest version of Lua from; install in C:Program Files [(x86)]
  • If Lua version is not 5.3.2,
    • Copy all files from C:Program Files [(x86)]\Lua\5.3\src, except lua.c and luac.c, to CppFBPLua\src folder
    • Go into VS 2015
    • Do Add/Existing Item with the files just added to CppFBPLua\src of type .c to CppFBPLua/Source Files
    • Do Add/Existing Item with the files just added to CppFBPLua\src of type .h to CppFBPLua/Header Files
    • Rebuild CppFBPLua project
  • Run tests


This runs a simple network, where every process is a Lua script being executed by the general ThLua component.

This test case only has 10,000 IPs travelling through the network, where half are generated by each Generate process. The network in free-form notation is as follows:

Gen(ThLua), Gen2(ThLua), 
Concat(ThLua), Repl(ThLua), Drop(ThLua),

Gen OUT -> IN[0] Concat, Gen2 OUT -> IN[1] Concat,
Concat OUT -> IN Repl OUT -> IN Drop,

'5000' -> COUNT Gen,
'5000' -> COUNT Gen2,
'gen.lua' -> PROG Gen, 
'gen.lua' -> PROG Gen2,
'concat.lua' -> PROG Concat,
'repl.lua' -> PROG Repl,
'drop.lua' -> PROG Drop;

To run it, right click on TryLua in Solution Explorer; Debug/Start new instance

You should see something like

Elapsed time in seconds: 19.000
Press any key to continue . . .

(where the 10000 is generated by drop.lua for debugging purposes)


C++ implementation of FBP, supporting Lua, using Boost




No releases published


No packages published
You can’t perform that action at this time.