- Remote Capture Running Modes
- Configuring the Remote Daemon (rpcapd)
- Starting a capture on a remote machine
- Installing the Remote Capture Daemon in UNIX

WinPcap 3.1 comes with Remote Capture capabilities. This is an highly experimental feature that allows to interact to a remote machine and capture packets that are being transmitted on the remote network.

This requires a remote daemon (called `rpcapd`) which performs the capture and sends data back and a local client that sends the appropriate commands and receives the captured data.

WinPcap 3.1 extends the standard WinPcap code in such a way that all WinPcap-based tools can expoit remote capture capabilities. For instance, the capabillity to interact with a remote daemon are added to the client software without any explicit modification to it. Vice versa, the remote daemon must be explicitely installed (and configured) on the remote machine.

## Remote Capture Running Modes

The Remote Capture Protocol (RPCAP) can work in two modes:

- Passive Mode (default): the client (e.g. a network sniffer) connects to the remote daemon, it sends them the appropriate commands, and it starts the capture.
- Active Mode: the remote daemon try to establish a connection toward the client (e.g. the network sniffer); then, the client sends the appropriate commands to the daemon and it starts the capture. This name is due to the fact thet the daemon becomes active instead of waiting for new connections.

The Active Mode is useful in case the remote daemon is behind a firewall and it cannot receive connections from the external world. In this case, the daemon can be configured to establish the connection to a given host, which will have been configured in order to wait for that connection. After establishing the connection, the protocol continues its job in almost the same way in both Active and Passive Mode.

Analyzer (http://analyzer.polito.it/30alpha/) has a set of commands (in the Capture menu) that allows you to accept a remote connection and then start the capture on the remote device. Currently, Analyzer is the only tool that is able to work in active mode, since it requires some modifications to the application code.

## Configuring the Remote Daemon (rpcapd)

The Remote Daemon is a standard Win32 executable running either in console mode or as a service. The executable can be found in the `WinPcap` folder and it has the following syntax:

            rpcapd [-b <address>] [-p <port>] [-6] [-l <host_list>] [-a <host,port>]
                   [-n] [-v] [-d] [-s <file>] [-f <file>]

The daemon can be compiled and it is actually working on Linux as well.

Here there is a brief description of the allowed commands:

Switch | Description
--- | ---
    -b <address>
| It sets the address the daemon has to bind to (either numeric or literal). Default: it binds to all local IPv4 and IPv6 addresses.
    -p <port>
| It sets the port the daemon has to bind to. Default: it binds to port 2002.
    -4
| It binds only to IPv4 addresses. Default: both IPv4 and IPv6 waiting sockets are used.
    -l <host_list_file>
| It specifies a file that keeps the list of the hosts which are allowed to connect to this daemon (if more than one, the file keeps them one per line). We suggest to use literal names (instead of numeric ones) in order to avoid problems with different address families (IPv4 and IPv6).
    -n
| It permits NULL authentication (usually used with '-l', that guarantees that only the allowed hosts can connect to the daemon). Default: the username/password authentication mechanism is required.
    -a <host, port>
| It forces the daemon to run in active mode and to connect to 'host' on port 'port'. This does not exclude that the daemon is still able to accept passive connections.
    -v
| It forces the daemon to run in active mode only (default: the daemon always accepts active connections, even if the '-a' switch is specified).
    -d
| Forces the daemon to run in background, i.e. as a daemon (UNIX only) or as a service (Win32 only). Warning (Win32): this switch is provided automatically when WinPcap installs this daemon into the Win32 services (control panel - administrative tools - services).
    -s <file>
| It saves the current configuration to file.
    -f <file>
| It loads the current configuration from file; all the switches specified from the command line are ignored and the file settings are used instead.
    -h
| It prints an help screen.

### Installing the remote daemon

The remote daemon is installed automatically when installing WinPcap 3.1. The installation process places the `rpcapd` file into the `WinPcap` folder. This file can be executed either from the command line, or as a service. For instance, the installation process updates the list of available services list and it creates a new item (Remote Packet Capture Protocol v.0 (experimental) ). To avoid security problems, the service is inactive and it has to be started manually (control panel - administrative tools - services - start).

The service has a set of "standard" parameters, i.e. it it launched with the "`-d`" flag (in orde to make it running as a service) and the "`-f rpcapd.ini`" flag. The user can create a file called `rpcapd.ini` in the same folder of the executable, and put the configuration commands in there. In order for the service to execute the commands, you have to stop and restart it again (i.e. the initialization file is parsed only at the beginning). Viceversa, the UNIX version of `rpcapd` is able to read the configuration file when sending a kill -HUP signal to it. In that case, all the existing connections remain in place, while the new connections will be created according to the new parameters.

In case the user does not want to create the configuration file manually, it can launch `rpcapd` with the requested parameters plus the "`-s filename`" one. The daemon will parse all the parameters and save them into the specified configuration file.

### Starting the remote daemon as a standard executable

The `rpcapd` executable can be launched directly, i.e. it can run in the foreground as well (not as a daemon/service). The procedure is quite simple: you have to invoke the executable from the command line with all the requested parameters but the "`-d`" flag. The capture server will start in the foreground.

## Starting a capture on a remote machine

If you are using a tool that is already aware of the remote capture (like Analyzer), everything is simple. The capture wizard will help you to locate the appropriate interface on the remote machine.

If your preferred tool is not aware of the remote capture, you can still use the remote capture. In this case you have to read the next Section.

Be carefully: the capture server (`rpcapd`) must be up and running on the remote machine.

### New string specifiers for interface selection

If your preferred tool is not aware of the remote capture, the only thing you must do is to insert, as interface specifier, the indication of the remote machine you want to contact. The following forms are allowed:

Adapter String | Description
--- | ---
    file://filename
| It opens a local file.
    rpcap://host.foo.bar/adaptername
| It opens a remote adapter; the host is specified by means of the literal name, without port number (i.e. it uses the RPCAP default port).
    rpcap://host.foo.bar:1234/adaptername
| It is the same as before, but it uses a different port number.
    rpcap://10.11.12.13/adaptername
| It opens a remote adapter, but the host is specified by means of an IPv4 numeric address, without port number (i.e. it uses the RPCAP default port).
    rpcap://10.11.12.13:1234/adaptername
| It is the same as before, but it uses a different port number.
    rpcap://[10.11.12.13]:1234/adaptername
| It is the same as before, but the numeric address is specified within square brackets (like IPv6 addresses).
    rpcap://[1:2:3::4]/adaptername
| It opens a remote adapter, but the host is specified by means of an IPv6 numeric address, without port number (i.e. it uses the RPCAP default port). In case of IPv6 addresses you MUST use the square brackets.
    rpcap://[1:2:3::4]:1234/adaptername
| It is the same as before, but it uses a different port number.
    rpcap://adaptername
| It opens a local adapter, without using the RPCAP protocol.
    adaptername
| It opens a local adapter; it is kept for compability, but it is strongly discouraged.
    (NULL)
| It opens the first local adapter; it is kept for compability, but it is strongly discouraged.

The following formats are not allowed:

Adapter String | Description
--- | ---
    rpcap://
| It cannot be used to open the first local adapter.
    rpcap://hostname/
| It cannot be used to open the first remote adapter.

## Installing the Remote Capture Daemon in UNIX

The WinPcap source archive can be compiled in UNIX as well. Currently, remote capture has been tested on Linux and BSD. What you have to do is:

- download the WinPcap sources
- unpack the sources
  - we suggest to use the `unzip -a` command in order to convert DOS files to UNIX ones
- move to the `libpcap` folder
- type:
  - `./configure`
  - Warning: in case the previous step reports an error, please regenerate the `configure` file using `automake` (version 2.50 or higher required)
  - `make`
- move to the `rpcapd` folder
- type `make`

The remote capture capabilities are turned on by default on Linux and FreeBSD. In case you do not want remote capture capabilities in libpcap, you can type

        ./configure --disable-remote

at the "`configure`" step. All the possible flags are listed when typing `./configure --help`.

What you obtained right now, is:

- a library file (`libpcap.a`), which can be linked to other applications (like `tcpdump`) in order to enable the remote capture for them.
- an executable (`rpcapd`) that is the remote daemon

Warning: in order to run the `rpcapd` daemon, the program must either

- run as root (or)
- run as user, but it must be owned by root and must be SUID root (`chmod u+s rpcapd`)

### Known bugs

FreeBSD: the first time you call the `pcap_stat()`, the function takes several seconds to return. Therefore, programs like Analyzer seem to hang up for 20-30 seconds at the beginning of the capture (if this is done with BSD as a remote probe). We're investigating to solve this issue.

For any question, please refer to the WinPcap help page.