Ports
One way that forks can deliberately separate themselves is by using a different TCP port number for network communications.
Currency |
Port |
Bitcoin |
8333 |
Litecoin |
9333 |
Handshake
When two Bitcoin-like programs communicate with one another, there is an expected initial pattern to the communication, an expected form of data exchanged and some expected data values. We call this a handshake. Programs can use this to identify whether the other program they are communicating with looks sufficiently like themselves (whether their handshake feels right). See protocol documentation, especially version message details and protocol-version number.
Discovery
Another route for separation might be differences in the peer-discovery process. It would be natural for dissenting groups creating new forks to replace the seed nodes with ones they run themselves.
Shunning
Another mechanism is that BTC nodes reject "bad" data provided by BCH or BSV nodes on port 8333, and vice versa. This is because of consensus rule conflicts. That would eventually cause each set of nodes to blacklist the other. As Pieter Wuille commented: "Relaying an invalid block is a protocol violation (in most cases; there are exceptions), and (in Bitcoin Core) will cause the peer to be considered misbehaving. Misbehaving peers are eventually put on a "discouraged" list, which means their connection slot will be dropped and replaced by another when a non-discouraged IP connects. Bitcoin Core further has a mechanism to temporarily actively seek out extra connections when it appears none of its peers have a recent valid block".