# netreceive **Repository Path**: mirrors_kontron/netreceive ## Basic Information - **Project Name**: netreceive - **Description**: No description available - **Primary Language**: Unknown - **License**: BSD-2-Clause - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2020-09-25 - **Last Updated**: 2025-09-20 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # Netreceive [![Build Status](https://img.shields.io/travis/kontron/netreceive/master.svg)](https://travis-ci.org/kontron/netreceive) The netreceive tool can be used to measure the bandwidth of specified traffic classes. Each traffic class to measure can be defined by using [PCAP filters](https://www.tcpdump.org/manpages/pcap-filter.7.html "PCAP filter manual"). ## Synopsis Usage: netreceive [OPTION...] [ ] Traffic Analyzer Tool - counts received packets on a interface. If no filter is specified all packets are counted. Help Options: -h, --help Show help options Application Options: -c, --config=file-name Read the filter from specified configuration file. -f, --filter=filter Set filter as :. Multiply filter allowed. -i, --interval=interval Interval for counting in milliseconds. -s, --socket=name Write result to a socket with specified name instead of stdout ### Output { "type" : "bandwidth-data" , "object" : { "timestamp-start" : "" , "timestamp-end" : "" , "data" : [ { "filter-name" : " , "filter-expression : ", "byte-count" : "bandwidth" : }, ..., { "filter-name" : " , "filter-expression : ", "byte-count" : "bandwidth" : } ] } } is the name specified in '-f' option or 'all' if no filter is specified. is the PCAP filter rule specified in '-f' or 'all' if no filter rule is specified. is the UTC time in ISO format, e.g. "2018-03-14T14:27:20.476312Z" ### Configuration File The filter can also be set by a configuration file (multiple filter allowed). [] filter-expression= An example configuration exists in "configs/filters.conf". ## Usage Examples ### Set some filters by parameters $ ./netreceive -f "total:all" -f "tsn:ether proto 0x0808" -f "video:udp port 1234" -f "bulk:ether proto 0x080a" tia0369fa230a5 ### Set the filters by a configuration file $ ./netreceive -c configs/filters.conf tia0369fa230a5 ### Set no filter (default is counting all packets) and output to socket instead of STDOUT $ ./netreceive -s /tmp/netreceive.sock tia0369fa230a5 ## Filter output with tool 'jq' get 'pretty' output $ ./netreceive ... | jq Output: see section 'Output' above extract 'timestamp-start' values $ ./netreceive ... | jq '.object["timestamp-start"]' Output: "2018-03-14T10:04:11.163273Z" "2018-03-14T10:04:12.163466Z" extract 'byte-count' values for first filter (in example the total counter) $ ./netreceive ... | jq '.object| .data[0] | ."byte-count"' (or) $ ./netreceive ... | jq '.object| .data[0]."byte-count"' (or) $ ./netreceive ... | jq '.object.data[0]."byte-count"' Output: 6120 6180 extract 'byte-count' values for all filters (each listed in a separate line) $ ./netreceive ... | jq '.object.data[]."byte-count"' Output: 6120 6120 0 0 6180 6180 0 0 extract 'byte-count' values for 'TSN' counter $ ./netreceive ... | jq '.object.data[] | if ."filter-name" == "TSN" then ."byte-count" else empty end' Output: 6120 6180 extrace 'byte-count' values for all counter (above) and combine in a string $ ./netreceive ... | jq 'reduce (.object.data[]."byte-count" | tostring) as $item ("counter"; . + "," + $item)' Output: "counter,6120,6120,0,0" "counter,6180,6180,0,0" extract 'timestamp-end' and 'byte-count' values for first filter (Note: each value is printed in separate line) $ ./netreceive ... | jq '.object["timestamp-end"] , .object.data[0]."byte-count"' Output: "2018-03-14T10:04:11.163273Z" 6120 "2018-03-14T10:04:12.163466Z" 6180 extract 'timestamp-end' and 'byte-count' values for first filter and generate new object $ ./netreceive ... | jq '{ "time" : .object["timestamp-end"] , "count": .object.data[0]."byte-count" }' Output: { "time": "2018-03-14T10:04:11.163273Z", "count": 6120 } { "time": "2018-03-14T10:04:12.163466Z", "count": 6180 } you may also manipulate the result string and use internal functions, e.g. extract the timestamp values (are in ISO format), delete the milliseconds and transform in seconds since UNIX epoch. Note, that the function 'fromdate' doesn't support milliseconds in the ISO format currently. $ ./netreceive ... | jq '.object["timestamp-start"] | gsub("[.][0-9]+"; "") | fromdate' Output: 1521108599 1521108600