mosh icon indicating copy to clipboard operation
mosh copied to clipboard

Regarding chosing network interfaces

Open shivubs opened this issue 9 years ago • 1 comments

I am a university student. I have a dumb question. I was going through the code in https://github.com/boutier/mosh especially the Network.cc file.

I am unable to find any code which will switch network interfaces in case there are multiple paths (flows) between client and server. Was looking for any references in the code like below:-

ioctl(SIOCGIFCONF), getifaddrs() or RTNETLINK

Could you please guide me where this is implemented?? if there are multiple flows between 2 end points, if one flow is down, how does mosh automatically switch to another flow.

Forgive me if this doesnt make much sense.

Thanks in Advance, Shiva

shivubs avatar Aug 16 '16 12:08 shivubs

Hi Shiva,

I am unable to find any code which will switch network interfaces in case there are multiple paths (flows) between client and server.

In principle, addresses are bound to interfaces, such that there is no need to specify both an address and an interface: an address is enough. Though, you can specify the interface used to send packets with the sin6_scope_id field (I use it for link-local addresses — network.cc:230). This field is then used in sendmsg. (Remark that it's used when specifying the destination — network.cc:731.)

(by the way, you're right, I should replace all "flow" by "path".)

ioctl(SIOCGIFCONF), getifaddrs() or RTNETLINK

Search for getifaddrs in addresses.cc. It's quite portable, so there is no need for netlink nor ioctl.

if there are multiple flows between 2 end points, if one flow is down, how does mosh automatically switch to another flow.

You hit the point: when the best path is down, the SRTT of that path can't be updated (no new message). We basically estimate the "idle_time" of the path (RTO…). Then, the value used to compare paths is not SRTT but SRTT + idle_time (network.h: 169).

This mechanism is explained in Section 3.4 of:

https://www.irif.univ-paris-diderot.fr/~boutier/papiers/mpmosh.pdf

Now, there is some optimizations (mmm, I must rewrite that paper).

  • If there is an error when sending the message: put idle_time at its maximum value (network.cc:672,850).
  • Always send the data on an active path (network.cc:827). This optimisation introduces duplicates.

Matthieu

boutier avatar Aug 17 '16 09:08 boutier