The Threading Building Blocks pipeline

The three stages described earlier are implemented in a Threading Building Blocks pipeline with five filters. An input filter to simulate packets coming into the pipeline comes first. An output filter has been added at the end to simulate packets going back out through the device. The three packet processing stages between the input and output filters are the network_address_translator filter, application_level_ gateway filter, and packet_forwarding filter.

The Response requires a NAT lookup to finish delivery

Figure 11-21. The Response requires a NAT lookup to finish delivery

FTP port mapping from inside the home to the server

Figure 11-22. FTP port mapping from inside the home to the server

Inbound FTP data returned to the proper laptop inside the home

Figure 11-23. Inbound FTP data returned to the proper laptop inside the home

In the main routine, the five pipeline filters are plugged together in a straightforward way:

	tbb::pipeline pipeline;
	// Stage 0: InputPacket get_next_packet receive_packet (in_file); pipeline.add_filter (receive_packet); // Stage 1: Network Address Translator translator network_address_translator (router_ip, router_nic, mapped_ports); pipeline.add_filter (network_address_translator); // Stage 2: Application Level Gateway gateway application_level_gateway (router_ip, router_nic, mapped_ports); ...

Get Intel Threading Building Blocks now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.