VPN applications (for example, take hamachi, tungle, evolve) create a local adapter with which they emulate a local network.

  1. How is this emulation? Why is the computer starting to perceive the remote virtual adapter as a local machine?

  2. How to do something similar in C #

    • With an existing virtual adapter (no routines are configured, only the driver has been installed).
    • Conditions take the "laboratory": connect 2-3 machines with white IP addresses. (machines are behind routers).

UPDATE for implementation

WireShark-ohm looked at what packets come on the virtual adapter.

This is mainly SSDP and IPv6 traffic ( I will attach screenshots ... maybe ).

SSDP and IPv6 are most likely liming the PNRP protocol.
PNRP is used when creating P2P connections.

Theoretical confirmation that P2P can be used to emulate a local network:

  1. Open the console and enter netsh p2p pnrp peer add registration 0.NAME
  2. Without closing the 1 console, open the second and write netsh p2p pnrp peer resolve 0.NAME
  3. In the second console, all IP addresses associated with this peering name will be displayed.

First console

Second console

Now, for starters, you need to establish a p2p connection using the PNRP protocol between computers on the same subnet (connected to 1 router).

I was looking for how to implement P2P communication in C #. Found the System.Net.PeerToPeer library
System.Net.PeerToPeer.Collaboration
And software framework:
Windows Communication Foundation ( WCF ).
He studied it from the book Fundamentals of WCF (2008). Do not mind what newer

I tried through the library. All that happened is to programmatically register peer. ( what was done in the console )
( perhaps with the help of PeerToPeer.collaboration, you can do something else but I'm lazy / stupid ).

WCF is more interesting in this respect. After several attempts, it seems that I managed to connect 2 computers with Frankenstein bindings from and (the standard NetPeerTcpBinding did not fit. I do not know how to connect 2 computers with it even if they are from the same subnet).
PC1 - ip 10.17.17.17
PC2 - ip 10.17.17.16

But there is still no response to ping requests ( in Evolve there is ). Later I will throw a link to Github, I will drop the virtual adapter driver there and what I did in WCF.

There are suspicions that the error in the contract (1) ( one-way communication, and ping is based, as far as I know, on TCP. I will correct it ).

As a result, the second point of the question can be divided into 2 similar questions.

  1. How to create a private global PNRP cloud using C #.
  2. How to use WCF to create a P2P connection, similar to the one created by the VPN applications listed at the very beginning ( I myself do not understand what is written in this clause ).

Useful links: Chat made using WCF and custom resolver
- I will say straight away that we do not need to do, but is a good example. I think to try to incorporate Frankenstein into this code (I will check for an error in the contract (1) ).

  • one
    The first part of the question is quite simple. A real adapter has some kind of physical connection to the rest of the network (wire, radio channel) and uses this connection to receive / transmit packets. For a virtual adapter, the VPN tunnel channel performs the functions of a physical connection. VPN server - performs the role of a normal switch, connecting all the clients connected to it just as a normal switch or WiFi-point connects its physically connected clients (with the proviso that the VPN switch looks immediately into the virtual and physical networks of the server). I did not try to do the implementation, so I will not tell you here. - rdorn

0