> For the complete documentation index, see [llms.txt](https://docs.cennso.com/cennso/netcap/latest/llms.txt) (all documentation: [llms.txt](https://docs.cennso.com/llms.txt)). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.cennso.com/cennso/netcap/latest/technical-reference/cli.md).

# CLI commands

This document lists CLI commands that you may find useful when working with NetCap.

## List captures

You can list captures created on a specific IMSI or interface.

### List captures (IMSI)

### IMSI

To see traffic streams created for a specific IMSI on a UPG pod, use:

```bash
vppctl show upf netcap
```

See the output example:

```
Captures: 3
  901406000520000: track-imsi, max_bytes: 9000
  901406000520001: track-imsi, max_bytes: 9000
  901406000520002: track-imsi, max_bytes: 9000
```

### List captures (Interface)

### Interface

To see traffic streams created on an interface (FPP or UPG pod), use:

```bash
vppctl show interface netcap
```

See the output example:

```
Interface "left" [1] streams: 1
- target "dp" max_bytes 100 netcap id 3 rx tx jit_fn 0x0
Interface "right" [2] streams: 1
- target "dp" max_bytes 100 netcap id 2 rx tx jit_fn 0x0
Interface "sx" [3] streams: 3
- target "sx" max_bytes 9000 netcap id 0 rx tx jit_fn 0x7ffff7ffb000
  filter: {arp or icmp}
- target "sx-ipv6" max_bytes 9000 netcap id 1 tx jit_fn 0x7ffff7fc8000
  filter: { ip6 }
- target "sx-ipv4" max_bytes 9000 netcap id 8 rx tx jit_fn 0x7ffff7fc7000
  filter: { ip }
```

## List all streams

To see all created NetCap streams on an FPP or UPG pod, run:

```bash
vppctl show netcap streams
```

See the output example:

```
DBGvpp# show netcap streams
Streams: 7
 [0] "sx" class: [0]hw_iface_l2 target: "sx" state: stopped
 [1] "left" class: [0]hw_iface_l2 target: "dp" state: stopped
 [2] "right" class: [0]hw_iface_l2 target: "dp" state: stopped
 [3] "imsi 001010100000000" class: [1]upf_session_ip target: "ue-1" state: stopped
```

## Check NetCap status

To verify the NetCap VPP Plugin's connection to NetCap Collector, run on FPP or UPG:

```bash
vppctl show netcap status
```

FPP sample output:

```
Name: "fpp-node-qjdlj"
Connection:
  Path: /run/vppswitch/sink.sock
  State: sink active
  FD: 8
  Remote Name: "netcap-collector-rwgc5"
  Memory region
    Size: 0x801000
    Address: 0x5cba3000
    MemFD: 18
Registered classes:
  [0] hw_iface_l2 (packet metadata: 0)
```

UPG sample output:

```
Name: "upg-prox01-849d869577-svw8n"
Connection:
  Path: /var/run/netcap/sink.sock
  State: sink active
  FD: 4
  Remote Name: "netcap-collector-rwgc5"
  Memory region
    Size: 0x801000
    Address: 0x1b782000
    MemFD: 13
Registered classes:
  [0] hw_iface_l2 (packet metadata: 0)
  [1] upf_session_ip (packet metadata: 0)
```

## Enable traffic capturing

Use these commands to enable traffic capturing on a specific IMSI or interface.

### Enable traffic capturing (IMSI)

### IMSI

To enable traffic capturing on a specific IMSI, use the command:

```bash
vppctl upf netcap session imsi ${IMSI} target ${TARGET_NAME} [packet_max_bytes 9000]
```

The `packet_max_bytes` parameter is optional and it allows you to limit the size of collected data to reduce memory usage of a traffic capture.

### Enable traffic capturing (Interface)

### Interface

To enable traffic capturing on a specific interface, use this command:

```bash
vppctl set interface netcap {INTERFACE_NAME} target {TARGET_NAME} [filter {tcpdump filter}][packet_max_bytes 9000] [rx] [tx]
```

- `filter {tcpdump filter}` - defines a libpcap-compatible filter, similar to those used with the `tcpdump` utility. See [`man pcap-filter`](https://www.tcpdump.org/manpages/pcap-filter.7.html) for full syntax. Examples: `filter {arp or icmp}`, `filter {src net 192.0.2.0/24 and port 2020}`.
- `packet_max_bytes` - optional parameter that allows you to limit the size of collected data to reduce the memory usage of a traffic capture
- `rx` and `tx` - specifies the direction in which traffic should be collected. If omitted, traffic in both directions is captured.

You can configure multiple captures on the same interface by using different target names. This is useful when you need to apply different filters and store the output in separate files.

> [!CAUTION]
> Each active traffic stream may degrade interface performance. To minimize impact, reduce the number of attached streams. Where possible, combine filters using the `or` operator (for example, `arp` or `icmp`) to cover multiple cases in a single stream.

## Disable traffic capturing

Use these commands to disable traffic capturing on a specific IMSI or interface.

### Disable traffic capturing (IMSI)

### IMSI

To disable traffic capturing on a specific IMSI, use this command:

```bash
vppctl upf netcap session imsi {IMSI} disable
```

### Disable traffic capturing (Interface)

### Interface

To disable traffic capturing on an interface, use this command:

```bash
vppctl set interface netcap {INTERFACE_NAME} target {TARGET_NAME} disable
```
