2

My following question is on a very beginners level and I might lack significant knowledge about network basics. Although the question is somehow related to server/client concepts, the main issue behind is definitely not programming. So I try here and hope not to be completely off-topic. I don't know where the question would have been better placed...Please don't close the question without giving a hint about what's wrong.

Given a single machine (in my case a PC), it could have more than one network card installed, providing, lets say, two physical interfaces A, B. According to a previous question those two interfaces (Layer-1) can be assigned to two different IP adresses (Layer-3):

The layer-3 module registered with the layer-2 module for an interface will be assigned the layer-3 address for that interface.

For example, IP(A) = 192.168.1.10 and IP(B) = 192.168.2.10; both assigned by the properties of TCP/IP for the particular interface card.

The question:

Lets say, a server process, running on the same machine is started by registering itself to IP(B) and some port before it starts listening for incoming connections. So it is listening for any incoming requests arriving over interface B.

Now, I have a TCP client on the same machine, and I want to open a TCP connection to the server on IP(B). So I naively connect A and B with an external loopback cable and expect the traffic to go over that cable when a connection to B is requested. But there is no way to tell the client, Which interface X it shall use... Will it use A or B? I even guess, that it would utilize B, because A and B are different networks according to the chosen subnet mask and therefore a request to an end address in B will be issued over interface B ? As a side question: What is the way of packages now, because the cable is not needed. Is there an internal loopback?

But what if I want to force the traffic over the loopback cable (for whatever reason)? Is that possible at all? How can I acchieve, that a client is using A as outgoing interface when adressing IP(B). To come to an end: I just want to ensure, that all sent packets between client and server are transported over the cable.

When A and B and also server and client would be on different machines each having a single network interface I would have no problem to understand. But here?

Why do I need that?

In reality, as a next step I want to replace the cable between A and B with an experimental setup, where bit error rates can be changed by intentionally adding some kinds of noise and statistical errors to simulate/emulate a very bad channel. I could put each side on a different machine, but would prefer to have both on the same.

1

2 Answers 2

3

Most OSes' network stacks will see that the destination address you're sending to is an address that the local machine itself owns, and will use an internal software loopback mechanism so that the traffic doesn't incur the cost of leaving the host or even hitting the Ethernet hardware. In fact, most of the time networking folks talk about loopback, they're talking about these loopback mechanisms that are completely internal to the networking software stack. "loopback" almost never means "go out one NIC and across an external loop of networking cable and back into another NIC".

Ways to force traffic out one NIC and back in another may vary from OS to OS. For example, some members of the BSD family of Unixes, such as FreeBSD and macOS, have a sysctl called net.link.ether.inet.useloopback, which defaults to being set to 1 (enabled), but can be cleared to 0 (disabled) to force traffic to go out the NIC even when it's destined for another IP address on the same machine.

0

I think we need your operating system or the devices mark to give more detailed solution but you can achieve this setting a default route for the networks.

This means that you are going to define that all trafic from network 192.168.1.0/24 are going to be out from x.x.x.x ip address or some specific port as lo.

You must have a routing table where you have defined the route to get the traffic thru that port/address.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .