|
| 1 | +Packetcapture service |
| 2 | +===================== |
| 3 | + |
| 4 | +Packetcapture is a transparent service that allows to capture packets flowing through the interface it is attached to, apply (simple) filters and obtain capture in *.pcap* format. In particular, the service supports either saving captured packets in the local filesystem (e.g., useful in case of high network traffic) or it can interact and deliver packets to a remote client that stores them in the remote filesystem. |
| 5 | + |
| 6 | +An example of a client that uses the REST api of the packetcapture service is available in '*Packetcapture_Client*' directory. |
| 7 | + |
| 8 | +Features |
| 9 | +-------- |
| 10 | +- Transparent service, can be attached to any interface of any Polycube service |
| 11 | +- Support for (simple) IPv4 filters: source prefix, destination prefix, source port, destination port and layer 4 protocol. |
| 12 | +- Support partial capture of packets (i.e., snaplen) |
| 13 | +- Support localmode (store data locally) or network mode (send packets to a remote client) operations |
| 14 | + |
| 15 | +Limitations |
| 16 | +----------- |
| 17 | +- No IPv6 filtering |
| 18 | +- Traffic is returned as is, without any anonimization primitive. |
| 19 | + |
| 20 | +How to use |
| 21 | +---------- |
| 22 | +The packetcapture service is a transparent service, it can be attached to a cube port. |
| 23 | + |
| 24 | +Create the service |
| 25 | +^^^^^^^^^^^^^^^^^^ |
| 26 | + |
| 27 | +:: |
| 28 | + |
| 29 | + #create the packetcapture service |
| 30 | + polycubectl packetcapture add sniffer capture=bidirectional |
| 31 | + |
| 32 | +This service can operate in four working modes (actually, the forth mode is just to turn the capture off): |
| 33 | + |
| 34 | +- capture only incoming packets: **capture=ingress** |
| 35 | +- capture only outgoing packets: **capture=egress** |
| 36 | +- capture both incoming and outgoing packets: **capture=bidirectional** |
| 37 | +- turn packet capture off: **capture=off** |
| 38 | + |
| 39 | +*capture* option indicates the direction of the packets that the service must capture. |
| 40 | +The direction of the captured packets is independent of the operation in "nework mode" or "non network mode". |
| 41 | + |
| 42 | +In this example the service named '*mysniffer*' will work in bidirectional mode. |
| 43 | + |
| 44 | + |
| 45 | +Attach to a cube port |
| 46 | +^^^^^^^^^^^^^^^^^^^^^ |
| 47 | +:: |
| 48 | + |
| 49 | + # Attach the service to a cube port |
| 50 | + polycubectl attach mysniffer br1:toveth1 |
| 51 | + |
| 52 | +Now the packetcapture service is attached to the port *toveth1* of the bridge *br1* |
| 53 | + |
| 54 | + +----------+ |
| 55 | + veth1 ---**x**-| br1 |------ veth2 |
| 56 | + +----------+ |
| 57 | + |
| 58 | + |
| 59 | +Filters |
| 60 | +------- |
| 61 | +Traffic can be selected by means of the following filters: |
| 62 | + |
| 63 | +- source prefix |
| 64 | +- destination prefix |
| 65 | +- source port |
| 66 | +- destination port |
| 67 | +- later 4 protocol |
| 68 | + |
| 69 | +Source prefix filter |
| 70 | +^^^^^^^^^^^^^^^^^^^^ |
| 71 | +:: |
| 72 | + |
| 73 | + # Example of the source prefix filter |
| 74 | + polycubectl mysniffer filters set src=10.10.10.10/24 |
| 75 | + |
| 76 | +Destination prefix filter |
| 77 | +^^^^^^^^^^^^^^^^^^^^^^^^^ |
| 78 | +:: |
| 79 | + |
| 80 | + # Example of the destination prefix filter |
| 81 | + polycubectl mysniffer filters set dst=10.10.10.10/24 |
| 82 | + |
| 83 | +Source port filter |
| 84 | +^^^^^^^^^^^^^^^^^^ |
| 85 | +:: |
| 86 | + |
| 87 | + # Example of the source port filter |
| 88 | + polycubectl mysniffer filters set sport=80 |
| 89 | + |
| 90 | +Destination port filter |
| 91 | +^^^^^^^^^^^^^^^^^^^^^^^ |
| 92 | +:: |
| 93 | + |
| 94 | + # Example of the destination port filter |
| 95 | + polycubectl mysniffer filters set dport=80 |
| 96 | + |
| 97 | +Layer 4 protocol filter |
| 98 | +^^^^^^^^^^^^^^^^^^^^^^^ |
| 99 | +:: |
| 100 | + |
| 101 | + # Example of the layer 4 protocol filter |
| 102 | + polycubectl mysniffer filters set l4proto=tcp |
| 103 | + |
| 104 | +Snaplen filter |
| 105 | +^^^^^^^^^^^^^^ |
| 106 | +:: |
| 107 | + |
| 108 | + # Example of the snaplen filter |
| 109 | + # In this case we capture only the first 80 bytes of each packet |
| 110 | + polycubectl mysniffer filters set snaplen=80 |
| 111 | + |
| 112 | + |
| 113 | +Filters can be viewed using the command **polycubectl mysniffer filters show** |
| 114 | + |
| 115 | +Get the capture dump |
| 116 | +-------------------- |
| 117 | +When the service is not set in *networkmode*, the dump is automatically written in a resilient way in the current working directory. |
| 118 | + |
| 119 | +The path of the capture file can be shown using the command: **polycubectl mysniffer show dump** |
| 120 | + |
| 121 | +Otherwise, if the service is set in network mode, the capture file can be requested through the use of the provided Python client, or queried simply through the service API. |
| 122 | + |
| 123 | +How to use the demo client |
| 124 | +^^^^^^^^^^^^^^^^^^^^^^^^^^ |
| 125 | +:: |
| 126 | + |
| 127 | + # Start the client script |
| 128 | + python3 client.py <IPv4 address> <file destination name> |
| 129 | + |
| 130 | + |
| 131 | +Set network mode |
| 132 | +^^^^^^^^^^^^^^^^ |
| 133 | +:: |
| 134 | + |
| 135 | + # Start sniffer in network mode |
| 136 | + polycubectl mysniffer set networkmode=true |
| 137 | + |
| 138 | + # Start sniffer in local model |
| 139 | + polycubectl mysniffer set networkmode=false |
0 commit comments