Advanced Features ================= This section covers advanced nEdge Lite features and optimization techniques for experienced users. Multi-Queue Processing ----------------------- nEdge Lite supports distributing packet processing across multiple CPU cores using multiple NFQUEUE instances. Configuring Multiple Queues ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ **iptables Configuration:** .. code-block:: console # Configure 4 queues with CPU fanout sudo iptables -t mangle -A PREROUTING -j CONNMARK --restore-mark sudo iptables -t mangle -A PREROUTING -m mark --mark 2 -j DROP sudo iptables -t mangle -A PREROUTING -m mark --mark 0 \ -j NFQUEUE --queue-balance 0:3 --queue-cpu-fanout sudo iptables -t mangle -A POSTROUTING -j CONNMARK --save-mark **Start nEdge Lite:** .. code-block:: console sudo nedgelite -q 0:4 -z tcp://127.0.0.1:1234 This creates 4 threads, each handling one queue (0, 1, 2, 3). Performance Benefits ~~~~~~~~~~~~~~~~~~~~ - **Parallel Processing**: Distributes packet inspection across CPU cores - **Higher Throughput**: Scales linearly with number of queues (up to available cores) - **Lower Latency**: Reduces per-packet processing time Optimal Queue Count ~~~~~~~~~~~~~~~~~~~ **Recommended**: .. code-block:: console # Use number of CPU cores CORES=$(nproc) sudo nedgelite -q 0:$CORES -z tcp://127.0.0.1:1234 **Considerations**: - More queues = more threads = higher CPU usage - Diminishing returns beyond physical core count - Consider hyperthreading and other workloads CPU Affinity ~~~~~~~~~~~~ Pin nEdge Lite threads to specific CPU cores for better cache locality: .. code-block:: console # Pin to cores 0-3 sudo taskset -c 0-3 nedgelite -q 0:4 -z tcp://127.0.0.1:1234 Performance Optimization ------------------------ System Tuning ~~~~~~~~~~~~~ **Increase Conntrack Table Size:** .. code-block:: console # For high connection counts sudo sysctl -w net.netfilter.nf_conntrack_max=1048576 # Make persistent echo "net.netfilter.nf_conntrack_max=1048576" | \ sudo tee -a /etc/sysctl.conf **Adjust Conntrack Timeouts:** .. code-block:: console # Reduce TCP established timeout sudo sysctl -w net.netfilter.nf_conntrack_tcp_timeout_established=3600 # Reduce TCP close-wait timeout sudo sysctl -w net.netfilter.nf_conntrack_tcp_timeout_close_wait=30 **Increase NFQUEUE Buffer:** .. code-block:: console # In iptables rule sudo iptables -t mangle -A PREROUTING -m mark --mark 0 \ -j NFQUEUE --queue-num 0 --queue-bypass --queue-size 4096 Memory Management ~~~~~~~~~~~~~~~~~ **Monitor Memory Usage:** .. code-block:: console # Check nEdge Lite memory usage ps aux | grep nedgelite pmap $(pidof nedgelite) **Flow Hash Size**: The flow hash table is fixed at compile time. For very high flow counts, consider increasing the hash table size in the source code. IPv6 Support ------------ nEdge Lite supports IPv6 packet inspection alongside IPv4. Enabling IPv6 ~~~~~~~~~~~~~ The sample scripts described in the Quick Start Guide already support IPv6, it can be enabled by adding the -6 parameter. **Load IPv6 Conntrack Module:** .. code-block:: console sudo modprobe nf_conntrack_ipv6 **Configure ip6tables:** .. code-block:: console sudo ip6tables -t mangle -A PREROUTING -j CONNMARK --restore-mark sudo ip6tables -t mangle -A PREROUTING -m mark --mark 2 -j DROP sudo ip6tables -t mangle -A PREROUTING -m mark --mark 0 -j NFQUEUE --queue-num 0 sudo ip6tables -t mangle -A POSTROUTING -j CONNMARK --save-mark **Start nEdge Lite:** No special options needed. nEdge Lite automatically handles both IPv4 and IPv6. .. code-block:: console sudo nedgelite -q 0 -z tcp://127.0.0.1:1234 IPv6 Considerations ~~~~~~~~~~~~~~~~~~~ - **Flow Export**: IPv6 flows are exported to ntopng like IPv4 - **Policy Rules**: IP pools can include IPv6 CIDR ranges Custom nDPI Configuration -------------------------- nDPI supports custom protocol definitions through the nDPI API. Refer to the nDPI documentation for details. Detection Sensitivity ~~~~~~~~~~~~~~~~~~~~~ Some protocols have configurable detection thresholds. These are typically set in nDPI's protocol-specific detection functions. Traffic Shaping Integration ---------------------------- While nEdge Lite itself doesn't perform traffic shaping, it can integrate with Linux tc (traffic control). Using CONNMARK for tc ~~~~~~~~~~~~~~~~~~~~~ nEdge Lite's CONNMARK values can be used by tc to apply QoS policies: .. code-block:: console # Create tc classes sudo tc qdisc add dev eth0 root handle 1: htb default 30 sudo tc class add dev eth0 parent 1: classid 1:1 htb rate 100mbit sudo tc class add dev eth0 parent 1:1 classid 1:10 htb rate 80mbit sudo tc class add dev eth0 parent 1:1 classid 1:20 htb rate 20mbit # Use connmark to classify traffic sudo tc filter add dev eth0 parent 1: protocol ip prio 1 \ handle 1 fw classid 1:10 # High priority (mark=1) sudo tc filter add dev eth0 parent 1: protocol ip prio 2 \ handle 2 fw classid 1:20 # Low priority (mark=2) .. _connection-labels: Connection Labels ----------------- In addition to the pass/drop mark, nEdge Lite can tag each connection with conntrack labels (connlabels) describing what nDPI detected: protocols, categories and flow risks. Labels are stored in the conntrack entry, so any iptables rule can match on them with the ``connlabel`` match, for example to drop, log or mark traffic of a given application independently of the nEdge Lite policies. The kernel provides 128 label bits per connection, while nDPI detects several hundred protocols. A label map file selects the protocols, categories and risks of interest and assigns each of them a label bit. Label Map File ~~~~~~~~~~~~~~ The label map is a text file with one mapping per line; ``#`` starts a comment: .. code-block:: text protocol [