An application that simulates a firewall and checks packets with filters, deciding whether to allow the packet to continue to its destination or not. The model is using the producer --- consumer scenario.
In our case, the packets are provided in a binary file and inserted by the producer in a circular buffer, from where the consumers take and process them. The consumers are notified by a semaphore each time the producer has put an item in the buffer. After the processing, is done the packets are inserted in order of their timestamp in an output file.
The sorting is done by using a barrier to wait for all threads to finish processing. Next, each thread inserts its packet in a min-heap and waits at another barrier (to make sure all the threads have introduced their respective packet), after which each extracts a packet from the min-heap and puts it in the output file.
# Installation
git clone https://github.com/amir-FM/parallel_firewall [installation directory]
cd [installation directory]/src
make
# Generating packets
cd [installation directory]/tests
./gen_packets.py generate [filename] [count]
# Running
cd [installation directory]/src
./firewall [input-file] [output-file] [num-consumers:1-32]