Crate nasoone_lib

source ·
Expand description

Nasoone-lib is a library for the NASOONE project.

It provides an easy way for analyzing network traffic using pcap.

The output is a CSV file with the following columns separated by a semicolon:

  • Source IP
  • Source port
  • Destination IP
  • Destination port
  • List of observed protocols
  • Timestamp of the first packet
  • Timestamp of the last packet
  • Number of bytes
  • Number of packets

Example usage:

use std::thread::sleep;
use std::time::Duration;
use nasoone_lib::Nasoone;

let mut naso = Nasoone::new();
// set the capture device from a physical interface
naso.set_capture_device("en0").unwrap();
naso.set_output("./report.csv").unwrap();
// set the timeout between report updates (in seconds)
naso.set_timeout(1).unwrap();
// start the capture (non-blocking)
naso.start().unwrap();
sleep(Duration::from_secs(10));
// pause the capture
naso.pause().unwrap();
sleep(Duration::from_secs(2));
// resume the capture
naso.resume().unwrap();
sleep(Duration::from_secs(10));
// stop the capture and get the stats
let stats = naso.stop().unwrap();
println!("{:?}", stats);

Structs

A struct for capturing network traffic.
Represents the pcap statistics about a capture (from https://docs.rs/pcap/latest/pcap/index.html.)
A network interface that can be used for capturing.

Enums

An error that can occur while using the library.
Represents in which state the capture is.