# Flow Direction Swapping Explained | ntop

[Blog](https://www.ntop.org/blog/)[ntopng](https://www.ntop.org/category/ntopng/)

# Flow Direction Swapping Explained

October 17, 20252 min read

A flow is a set of traffic packets sharing the same tuple (IP src, IP dst, port src, port dst, protocol, VLAN, …). When a flow is observed from the beginning, the first packet is sent by the client towards the server. Unfortunately, sometimes the flow was already in place when monitoring tools (e.g. ntopng or nProbe) started, and thus there is a chance that the flow direction is wrong simply because the first observed packet was from server to client. In this case, the flow is reported as if the real server contacted the client instead of the other way round. This is called swapped flow, as its real direction is not the one observed from the wire.

In order to detect the real flow direction, ntop tools implement some heuristics that include:

-   DNS, NTP, ICMP (echo): the first flow packet is a response.
-   RDP: if the client port is 3389, the flow is swapped.
-   TCP: the SYN packet arrived after other packets (e.g. SYN|ACK). This is likely a packet out-of-order.
-   TCP: the client port is less than the server port. This is not necessarily true, but it is true for known services as HTTP, HTTPS, SSH, telnet.

The above techniques work better with packet-based interfaces as through nDPI it’s possible to go deep into the packet payload. With flow-based interfaces (e.g. when NetFlow/IPFIX flows are collected), only port-based heuristics can be used.

By default, ntopng implements flow swap heuristics. However, in some cases (e.g. during forensics traffic analysis), swapping cannot be a good idea as often hackers use non-standard ports (e.g., use HTTP requests using 80 as client port) to overcome security checks.

![FlowSwapHeuristics](/images/2025/10/FlowSwapHeuristics.webp)

For this reason, we have introduced the ability to disable flow swapping heuristics in case this is incompatible with your traffic analysis policies. Just select Settings -> Preferences -> Cache Settings to set your cache settings policy.

Note that flow swapping is also enabled in nProbe (both in probe and flow collection mode) and it can ben disabled as follows:

```
--disable-flow-swapping   | By default nProbe swaps reverted flows
                          | (e.g. a flow server->client,
                          | or a flow with the first packet as a DNS response), and this
                          | behaviour can be disabled using this flag
```

This means that for completely disable swapping in an nProbe-ntopng pipeline, you need to disable it in both tools.

Enjoy !

**Related:**[NetFlow, sFlow and IPFIX collector guide](https://www.ntop.org/netflow-sflow-ipfix-collector-analyzer/), [nProbe](https://www.ntop.org/products/netflow-probes/nprobe/)

## Keep reading

nDPINov 7, 2026

### [Detecting CVE-2026-98432 using nDPI/ntopng](https://www.ntop.org/detecting-cve-2026-98432-using-ndpi-ntopng/)

CVE-2026-98432 is a critical, 9.8-severity use-after-free (UAF) vulnerability in the Linux kernel’s IPv4 TCP networking stack. It allows an unauthenticated remote attacker to potentially cause system crashes, memory corruption, or execute arbitrary commands with root privileges. From a network stand

[![](/images/2026/09/Screenshot-2026-09-09-151028-1.webp)](https://www.ntop.org/october-20th-join-us-for-the-ntopng-7-0-webinar/)

AnnounceOct 5, 2026

### [October 20th: Join us for the ntopng 7.0 Webinar](https://www.ntop.org/october-20th-join-us-for-the-ntopng-7-0-webinar/)

Is your network monitoring keeping pace with AI, larger infrastructures, and the growing need for real observability? We’re excited to introduce ntopng 7.0, alongside new releases of the rest of the ntop…

[![](/images/2026/09/Screenshot-2026-09-09-163410-1.webp)](https://www.ntop.org/ntopng-user-interface-introducing-the-new-navigation-bar/)

ntopngSep 21, 2026

### [ntopng User Interface: Introducing the New Navigation Bar](https://www.ntop.org/ntopng-user-interface-introducing-the-new-navigation-bar/)

In our continuous effort to improve user experience and make network monitoring more intuitive, we have completely redesigned the ntopng Navigation Bar. As our feature set expands—with crucial additions like the nAnalyst…

## Try it on your own network

Download the free Community edition and see your first flows in five minutes.

[Download ntopng free](https://www.ntop.org/support/documentation/software-installation/)[Talk to an engineer](https://www.ntop.org/support/need-help/contacts/)
Source: https://www.ntop.org/flow-direction-swapping-explained/