phast
is a high-performance, C++20-based library for decoding network packets. Designed for speed and efficiency, it leverages modern C++ features to deliver a robust and scalable solution for network data processing.
- Quick Start
- Benchmark
- About phast
- CMake Integration
- Building, Testing, and Installing
- Supported Toolchains
- Contributing
- License
To quickly test phast
, follow these steps:
# Clone the repository
git clone https://github.com/m-peko/phast
cd phast
# Build the example
cd examples/basic
mkdir build && cd build
cmake -GNinja ..
ninja
# Run the example
./example <path-to-PCAP-file>
Here’s an example of how packets are processed using phast
:
auto const decoded{phast::decode(data, header->caplen)};
if (decoded.is_error()) {
std::fprintf(stdout, "Error decoding the packet\n");
} else {
for (auto const &pdu : decoded.value()) {
std::visit(
phast::Overloaded{
[](phast::Ethernet const ð) {
// EthernetII PDU decoded
},
[](phast::IPv4 const &ipv4) {
// IPv4 PDU decoded
},
[](phast::IPv6 const &ipv6) {
// IPv6 PDU decoded
},
[](phast::TCP const &tcp) {
// TCP PDU decoded
}},
pdu
);
}
}
The performance benchmarks for phast
demonstrate its ability to handle network packet decoding at high throughput with minimal latency.
Benchmarks are run regularly on supported toolchains, and detailed results can be found here.
phast
is built to simplify and accelerate the process of network packet decoding. Key features include:
- High Performance: Optimized decoding routines for efficient packet parsing.
- Modern C++20 Design: Fully utilizes C++20 language features and the standard library.
- Extensibility: Easily integrate and extend for custom protocol decoding.
- Cross-Platform Support: Tested on modern Linux distributions with GCC and Clang compilers.
Integrating phast
into your CMake project is simple. Use the following configuration:
cmake_minimum_required(VERSION 3.14)
project( my_project )
# Fetch the latest phast library
include( FetchContent )
FetchContent_Declare(
phast
GIT_REPOSITORY https://github.com/m-peko/phast.git
GIT_TAG main
)
FetchContent_MakeAvailable( phast )
add_executable( my_project main.cpp )
target_link_libraries( my_project phast )
This setup ensures phast
is automatically fetched and built as part of your project.
- C++20 Compiler: GCC (>= 10) or Clang (>= 12). Not tested on MSVC.
- CMake: Version 3.14 or higher.
- Build System: Ninja (recommended).
-
Clone the Repository:
git clone https://github.com/m-peko/phast cd phast
-
Build the Library:
mkdir build && cd build cmake -GNinja -DPHAST_ENABLE_TESTS=ON .. ninja
-
Run Tests:
ctest
-
Install the Library:
ninja install
phast
has been tested with the following configurations:
- Ubuntu 22.04:
- GCC 10+
- Clang 12+ (tested up to Clang 14)
Other platforms or compilers may work but have not been officially tested.
We welcome contributions from the community! If you’d like to contribute, please:
- Fork the repository.
- Create a feature branch.
- Submit a pull request.
For detailed guidelines, see CONTRIBUTING.md.
This project is licensed under the MIT License. See the LICENSE file for details.