Skip to content

Commit 43ae1d2

Browse files
committed
Split README into mdbook documentation
README was getting really long. This change moves specific information about building and using PacketStreamer to separate mdbook subpages. It also adds information about using PacketStreamer with Suricata. Fixes: #4 Signed-off-by: Michal Rostecki <[email protected]>
1 parent d6d9a23 commit 43ae1d2

15 files changed

+349
-242
lines changed

.github/workflows/mdbook.yml

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
name: mdBook
2+
3+
on:
4+
push:
5+
branches: [ main ]
6+
pull_request:
7+
branches: [ main ]
8+
9+
jobs:
10+
build-and-deploy:
11+
runs-on: ubuntu-latest
12+
steps:
13+
- uses: actions/checkout@v2
14+
- name: Build book
15+
run: |
16+
cargo install mdbook
17+
pushd docs
18+
mdbook build
19+
mdbook test
20+
popd
21+
- name: Deploy website
22+
if: github.event_name == 'push'
23+
uses: JamesIves/[email protected]
24+
with:
25+
branch: gh-pages
26+
folder: book

.gitignore

+3
Original file line numberDiff line numberDiff line change
@@ -25,3 +25,6 @@ go.work
2525

2626
# Binary
2727
packetstreamer
28+
29+
# Documentation
30+
docs/book/

README.md

+40-242
Original file line numberDiff line numberDiff line change
@@ -1,278 +1,76 @@
1+
[![Book](https://img.shields.io/website?url=https%3A%2F%2Fdeepfence.github.io%2FPacketStreamer%2F)](https://deepfence.github.io/PacketStreamer/)
12
[![GitHub license](https://img.shields.io/github/license/deepfence/PacketStreamer)](https://github.com/deepfence/PacketStreamer/blob/master/LICENSE)
23
[![GitHub stars](https://img.shields.io/github/stars/deepfence/PacketStreamer)](https://github.com/deepfence/PacketStreamer/stargazers)
34
[![GitHub issues](https://img.shields.io/github/issues/deepfence/PacketStreamer)](https://github.com/deepfence/PacketStreamer/issues)
45
[![Slack](https://img.shields.io/badge/[email protected]?logo=slack)](https://join.slack.com/t/deepfence-community/shared_invite/zt-podmzle9-5X~qYx8wMaLt9bGWwkSdgQ)
56

6-
77
# PacketStreamer
88

9-
Deepfence PacketStreamer is a high-performance remote packet capture and collection tool. It is used by Deepfence's [ThreatStryker](https://deepfence.io/threatstryker/) security observability platform to gather network traffic on demand from cloud workloads for forensic analysis.
9+
Deepfence PacketStreamer is a high-performance remote packet capture and
10+
collection tool. It is used by Deepfence's [ThreatStryker](https://deepfence.io/threatstryker/)
11+
security observability platform to gather network traffic on demand from cloud
12+
workloads for forensic analysis.
1013

1114
Primary design goals:
1215

1316
* Stay light, capture and stream, no additional processing
14-
* Portability, works across virtual machines, Kubernetes and AWS Fargate. Linux and Windows.
15-
16-
PacketStreamer **sensors** are started on the target servers. Sensors capture traffic, apply filters, and then stream the traffic to a central reciever. Traffic streams may be compressed and/or encrypted using TLS.
17-
18-
The PacketStreamer **reciever** accepts PacketStreamer streams from multiple remote sensors, and writes the packets to a local `pcap` capture file
19-
20-
<p align="center"><img src="/images/readme/packetstreamer.png" width="66%"/><p>
21-
22-
PacketStreamer sensors collect raw network packets on remote hosts. It selects packets to capture using a BPF filter, and forwards them to a central reciever process where they are written in pcap format. Sensors are very lightweight and impose little performance impact on the remote hosts. PacketStreamer sensors can be run on bare-metal servers, on Docker hosts, and on Kubernetes nodes.
23-
24-
The PacketStreamer receiver accepts network traffic from multiple sensors, collecting it into a single, central `pcap` file. You can then process the pcap file or live feed the traffic to the tooling of your choice, such as `Zeek`, `Wireshark` `Suricata`, or as a live stream for Machine Learning models.
25-
26-
### When to use PacketStreamer
27-
28-
PacketStreamer meets more general use cases than existing alternatives. For example, [PacketBeat](https://github.com/elastic/beats/tree/master/packetbeat) captures and parses the packets on multiple remote hosts, assembles transactions, and ships the processed data to a central ElasticSearch collector. [ksniff](https://github.com/eldadru/ksniff) captures raw packet data from a single Kubernetes pod.
29-
30-
Use PacketStreamer if you need a lightweight, efficient method to collect raw network data from multiple machines for central logging and analysis.
31-
32-
### Who uses PacketStreamer?
33-
34-
* Deepfence [ThreatStryker](https://deepfence.io/threatstryker/) uses PacketStreamer to capture traffic from production platforms for forensics and anomaly detection.
35-
36-
37-
# Quickstart: Build and Run PacketStreamer
38-
39-
## Building PacketStreamer
40-
41-
Build the `packetstreamer` binary using the `go` toolchain as follows:
42-
43-
```bash
44-
make
45-
```
46-
47-
## Run a PacketStreamer receiver
48-
49-
```bash
50-
packetstreamer receiver --config [configuration_file]
51-
```
52-
53-
You can use an example configuration file:
54-
55-
```bash
56-
packetstreamer receiver --config ./contrib/config/receiver-local.yaml
57-
```
58-
59-
You can process the `pcap` output in a variety of ways:
60-
61-
```bash
62-
# pass the output file /tmp/dump_file to tcpdump:
63-
tail -c +1 -f /tmp/dump_file | tcpdump -r -
64-
```
65-
66-
```bash
67-
# Edit the configuration to write to the special name 'stdout', and pipe output to tcpdump:
68-
./packet-streamer receiver --config ./contrib/config/receiver-stdout.yaml | tcpdump -r -
69-
```
70-
71-
## Run a PacketStreamer sensor
72-
73-
```bash
74-
sudo packetstreamer sensor --config [configuration_file]
75-
```
76-
77-
You can use an example configuration file:
78-
79-
```bash
80-
sudo packetstreamer sensor --config ./contrib/config/sensor-local.yaml
81-
```
82-
83-
When running the sensor remotely, edit the configuration file to target the remote receiver.
84-
85-
## Testing PacketStreamer
86-
87-
You can generate some test traffic using your favorite load generator - `ab`, `wrk`, `httperf`, `vegeta`. For example, to use vegeta:
88-
89-
```bash
90-
# install vegeta
91-
go install github.com/tsenart/vegeta@latest
92-
93-
echo 'GET http://some_ip:80' | vegeta attack -rate 100 -duration 5m | tee results.bin | vegeta report
94-
```
95-
96-
# Advanced Build Options
97-
98-
Use the `RELEASE` parameter to strip the binary for a production environment:
99-
100-
```bash
101-
make RELEASE=1
102-
```
103-
104-
Use the `STATIC` parameter to statically-link the binary:
105-
106-
```bash
107-
make STATIC=1
108-
```
109-
110-
## Build using Docker
111-
112-
Use the `docker-bin` target to build `packetstreamer` with Docker. The binary will be statically linked with `musl` and `libpcap`, making it portable across Linux distributions:
113-
114-
```bash
115-
make docker-bin
116-
117-
# Alternatively, build a stripped release binary
118-
make docker-bin RELEASE=1
119-
```
120-
121-
## Build a Container Image
122-
123-
Use the `docker-image` target to build a container image:
124-
125-
```bash
126-
make docker-image
127-
128-
# Alternatively, build a stripped release binary
129-
make docker-image RELEASE=1
130-
```
131-
132-
## Deploy on Kubernetes
133-
134-
PacketStreamer can be deployed on Kubernetes using Helm:
135-
136-
```bash
137-
kubectl apply -f ./contrib/kubernetes/namespace.yaml
138-
helm install packetstreamer ./contrib/helm/ --namespace packetstreamer
139-
```
140-
141-
By default, the Helm chart deploys a DaemonSet with sensor on all nodes and one receiver instance. For the custom configuration values, please refer to the [values.yaml file](/contrib/helm/values.yaml).
142-
143-
# Advanced Test Scenarios
144-
145-
## Testing on Docker
146-
147-
PacketStreamer container images can be tested locally on Docker.
148-
149-
### Receiver side
150-
151-
```bash
152-
docker run --rm -it \
153-
-v $(pwd)/contrib/config:/etc/packetstreamer \
154-
-v $HOME/container_tmp:/tmp \
155-
-p 8081:8081 \
156-
deepfenceio/deepfence_packetstreamer \
157-
receiver --config /etc/packetstreamer/receiver.yaml
158-
```
159-
160-
### Sensor side
161-
162-
```bash
163-
docker run --rm -it \
164-
--cap-add=NET_ADMIN --net=host \
165-
-v $(pwd)/contrib/config:/etc/packetstreamer \
166-
deepfenceio/deepfence_packetstreamer \
167-
sensor --config /etc/packetstreamer/sensor-local.yaml
168-
```
169-
170-
The sensor requires `--net=host` and `NET_ADMIN` capability in order to capture all of the packets on the host.
171-
172-
```bash
173-
echo 'GET http://some_ip:80' | vegeta attack -rate 100 -duration 5m | tee results.bin | vegeta report
174-
```
175-
176-
The `pcap` dump file is available in `$HOME/container_tmp/dump_file`.
177-
178-
## Testing on Vagrant
179-
180-
On a single host, you may use [Vagrant](https://www.vagrantup.com) to run sensor and receiver hosts easily:
181-
182-
Install Vagrant according to [the official instructions](https://www.vagrantup.com/downloads). By default, Vagrant uses Virtualbox; you should install [vagrant-libvirt](https://github.com/vagrant-libvirt/vagrant-libvirt), using `vagrant plugin install vagrant-libvirt`.
183-
184-
Start the two Vagrant VMs, `receiver` and `sensor`:
185-
186-
```bash
187-
vagrant up
188-
189-
vagrant status
190-
# Current machine states:
191-
#
192-
# receiver running (libvirt)
193-
# sensor running (libvirt)
194-
```
195-
196-
SSH to those VMs (in separate terminals) by using the following commands:
197-
198-
```bash
199-
vagrant ssh receiver
200-
```
201-
202-
```bash
203-
vagrant ssh sensor
204-
```
205-
206-
On each, enter the source code directory:
17+
* Portability, works across virtual machines, Kubernetes and AWS Fargate. Linux
18+
and Windows.
20719

208-
### Receiver side
20+
PacketStreamer **sensors** are started on the target servers. Sensors capture
21+
traffic, apply filters, and then stream the traffic to a central reciever.
22+
Traffic streams may be compressed and/or encrypted using TLS.
20923

210-
```bash
211-
cd PacketStreamer
212-
./packetstreamer receiver --config ./contrib/config/receiver-vagrant.yaml
213-
```
24+
The PacketStreamer **receiver** accepts PacketStreamer streams from multiple
25+
remote sensors, and writes the packets to a local `pcap` capture file
21426

215-
### Sensor side
27+
<p align="center"><img src="https://raw.githubusercontent.com/deepfence/PacketStreamer/main/images/readme/packetstreamer.png"/><p>
21628

217-
```bash
218-
cd PacketStreamer
219-
sudo ./packetstreamer --config ./contrib/config/sensor-vagrant.yaml
220-
```
29+
PacketStreamer sensors collect raw network packets on remote hosts. It selects packets
30+
to capture using a BPF filter, and forwards them to a central reciever process
31+
where they are written in pcap format. Sensors are very lightweight and impose
32+
little performance impact on the remote hosts. PacketStreamer sensors can be
33+
run on bare-metal servers, on Docker hosts, and on Kubernetes nodes.
22134

222-
Generate some live traffic
35+
The PacketStreamer receiver accepts network traffic from multiple sensors,
36+
collecting it into a single, central `pcap` file. You can then process the
37+
pcap file or live feed the traffic to the tooling of your choice, such as
38+
`Zeek`, `Wireshark` `Suricata`, or as a live stream for Machine Learning models.
22339

224-
```bash
225-
echo 'GET http://some_ip:80' | vegeta attack -rate 100 -duration 5m | tee results.bin | vegeta report
226-
```
40+
## When to use PacketStreamer
22741

228-
# PacketStreamer Configuration
42+
PacketStreamer meets more general use cases than existing alternatives. For
43+
example, [PacketBeat](https://github.com/elastic/beats/tree/master/packetbeat)
44+
captures and parses the packets on multiple remote hosts, assembles
45+
transactions, and ships the processed data to a central ElasticSearch
46+
collector. [ksniff](https://github.com/eldadru/ksniff) captures raw packet
47+
data from a single Kubernetes pod.
22948

230-
`packetstreamer` is configured using a yaml-formatted configuration file.
49+
Use PacketStreamer if you need a lightweight, efficient method to collect raw
50+
network data from multiple machines for central logging and analysis.
23151

232-
```yaml
233-
input: # required in 'receiver' mode
234-
address: _ip-address_
235-
port: _listen-port_
236-
output:
237-
server: # required in 'sensor' mode
238-
address: _ip-address_
239-
port: _listen-port_
240-
file: # required in 'receiver' mode
241-
path: _filename_|stdout # 'stdout' is a reserved name. Receiver will write to stdout
242-
tls: # optional
243-
enable: _true_|_false_
244-
certfile: _filename_
245-
keyfile: _filename_
246-
auth: # optional; receiver and sensor must use same shared key
247-
enable: _true_|_false_
248-
key: _string_
249-
compressBlockSize: _integer_ # optional; default: 65
250-
inputPacketLen: _integer_ # optional; default: 65535
251-
logFilename: _filename_ # optional
252-
pcapMode: _Allow_|_Deny_|_All_ # optional
253-
capturePorts: _list-of-ports_ # optional
254-
captureInterfacesPorts: _map: interface-name:port_ # optional
255-
ignorePorts: _list-of-ports_ # optional
256-
```
52+
## Who uses PacketStreamer?
25753

258-
You can find example configuration files in the [`/contrib/config/`](contrib/config/) folder.
54+
* Deepfence [ThreatStryker](https://deepfence.io/threatstryker/) uses
55+
PacketStreamer to capture traffic from production platforms for forensics
56+
and anomaly detection.
25957

260-
# Get in touch
58+
## Get in touch
26159

26260
Thank you for using PacketStreamer.
26361

26462
* [<img src="https://img.shields.io/badge/[email protected]?logo=slack">](https://join.slack.com/t/deepfence-community/shared_invite/zt-podmzle9-5X~qYx8wMaLt9bGWwkSdgQ) Got a question, need some help? Find the Deepfence team on Slack
265-
* https://github.com/deepfence/PacketStreamer/issues: Got a feature request or found a bug? Raise an issue
266-
* [productsecurity at deepfence dot io](SECURITY.md): Found a security issue? Share it in confidence
63+
* https://github.com/deepfence/PacketStreamer/issues: Got a feature request or found a bug? Raise an issue
64+
* [productsecurity *at* deepfence *dot* io](SECURITY.md): Found a security issue? Share it in confidence
26765
* Find out more at [deepfence.io](https://deepfence.io/)
26866

269-
# Security and Support
67+
## Security and Support
27068

27169
For any security-related issues in the PacketStreamer project, contact [productsecurity *at* deepfence *dot* io](SECURITY.md).
27270

27371
Please file GitHub issues as needed, and join the Deepfence Community [Slack channel](https://join.slack.com/t/deepfence-community/shared_invite/zt-podmzle9-5X~qYx8wMaLt9bGWwkSdgQ).
27472

275-
# License
73+
## License
27674

27775
The Deepfence PacketStreamer project (this repository) is offered under the [Apache2 license](https://www.apache.org/licenses/LICENSE-2.0).
27876

docs/book.toml

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
[book]
2+
authors = ["Michal Rostecki"]
3+
language = "en"
4+
multilingual = false
5+
src = "src"
6+
title = "PacketStreamer"

docs/src/README.md

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../../README.md

docs/src/SUMMARY.md

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# Summary
2+
3+
- [Introduction](./README.md)
4+
- [Quickstart](./quickstart/README.md)
5+
- [Building](./quickstart/building.md)
6+
- [Using locally](./quickstart/local.md)
7+
- [Using with Docker](./quickstart/docker.md)
8+
- [Using on Kubernetes](./quickstart/kubernetes.md)
9+
- [Using on Vagrant](./quickstart/vagrant.md)
10+
- [Using with other tools](./tools/README.md)
11+
- [Suricata](./tools/suricata.md)
12+
- [Configuration](./configuration.md)

0 commit comments

Comments
 (0)