| Crates.io | packet_parser |
| lib.rs | packet_parser |
| version | 0.9.0 |
| created_at | 2025-02-14 13:38:53.592244+00 |
| updated_at | 2025-07-21 09:48:18.955743+00 |
| description | A powerful and modular Rust crate for network packet parsing. |
| homepage | https://github.com/Akmot9/Packet-parser |
| repository | https://github.com/Akmot9/Packet-parser |
| max_upload_size | |
| id | 1555593 |
| size | 306,931 |

Packet Parser is a powerful and modular Rust crate designed for analyzing and decoding network frames. It provides tools to extract information from various network layers (Data Link, Network, Transport, and Application) and offers an extensible architecture for network monitoring and packet analysis.
✅ Multi-layer Support: Analyze Data Link, Network, Transport, and Application layers.
✅ Data Validation: Validation mechanisms at every processing stage.
✅ Precise Error Handling: Specific error types for better debugging.
✅ Performance Optimization: Integrated benchmarks using Criterion.
✅ Extensibility: Modular architecture for easily adding new protocols.
Documentation
For full documentation and explanations, check out the Packet Parser Book.
Add the dependency to your Cargo.toml:
[dependencies]
packet_parser = "0.7.0"
Then, import the crate in your project:
use packet_parser::parse::data_link::DataLink;
let raw_packet: [u8; 18] = [
0x2C, 0xFD, 0xA1, 0x3C, 0x4D, 0x5E, // Destination MAC
0x64, 0x6E, 0xE0, 0x12, 0x34, 0x56, // Source MAC (Intel OUI)
0x08, 0x00, // Ethertype (IPv4)
0x45, 0x00, 0x00, 0x54, // Payload (IPv4 Header fragment)
];
let datalink = DataLink::try_from(raw_packet.as_ref()).expect("Failed to parse valid packet");
println!("{:?}", datalink);
use packet_parser::parse::data_link::mac_addres::{MacAddress, Oui};
let mac = MacAddress([0x64, 0x6E, 0xE0, 0x12, 0x34, 0x56]);
assert_eq!(mac.get_oui(), Oui::Intel);
println!("OUI: {}", mac.get_oui()); // Expected output: Intel
parsed_packeterrorsProvides structured error handling for each network layer.
validationsEnsures data integrity and validity when parsing packets.
displaysTools for formatting and presenting parsed data in a human-readable way.
Unit and integration tests are available in the tests/ directory. Run all tests using:
cargo test
Benchmarks are available in the benches/ directory and use Criterion. Execute them with:
cargo bench
Contributions are welcome! If you find a bug or want to suggest an enhancement, feel free to open an issue or submit a pull request on GitHub.
git checkout -b feature/your-feature-name
git commit -m "Add feature X"
git push origin feature/your-feature-name
This crate is distributed under the MIT license. See the LICENSE file for more information.
Packet Parser is designed to make network frame analysis efficient and extensible in complex environments. If you have any suggestions or feedback, feel free to reach out! 🚀