The tun-ping-responder.py file is a standalone Python script which contains all the code you need to use tun on Windows.

Overview

The file should be self-explanatory. Here are some keys and gotchas for understanding it:

Setup

Running the Script

Start the script. You will see that the script (in fact the WriteThread thread) sends period echo requests.

componentId = {A9A413D7-4D1C-47BA-A3A9-92F091828881}
tuntap      = 208
Press enter to stop...
Transmitting IPv6 echo request
Received IPv6 echo reply
Transmitting IPv4 echo request
Received IPv4 echo reply
Transmitting IPv6 echo request
Received IPv6 echo reply
Transmitting IPv4 echo request
Received IPv4 echo reply
Transmitting IPv6 echo request
Received IPv6 echo reply

Start Wireshark on your tun interface to see the packets:

Open a command prompt and ping any IP address in the 10.2.0.xx and bbbb:/64 address ranges. The script will answer those.

Microsoft Windows [Version 6.0.6002]
Copyright (c) 2006 Microsoft Corporation.  All rights reserved.


C:\Users\Thomas>ping 10.2.0.55


Pinging 10.2.0.55 with 32 bytes of data:
Reply from 10.2.0.55: bytes=32 time=1ms TTL=128
Reply from 10.2.0.55: bytes=32 time=1ms TTL=128
Reply from 10.2.0.55: bytes=32 time=1ms TTL=128
Reply from 10.2.0.55: bytes=32 time=1ms TTL=128


Ping statistics for 10.2.0.55:
    Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
    Minimum = 1ms, Maximum = 1ms, Average = 1ms


C:\Users\Thomas>ping bbbb::21


Pinging bbbb::21 from bbbb::1 with 32 bytes of data:
Reply from bbbb::21: time=1ms
Reply from bbbb::21: time=1ms
Reply from bbbb::21: time=1ms
Reply from bbbb::21: time=1ms


Ping statistics for bbbb::21:
    Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
    Minimum = 1ms, Maximum = 1ms, Average = 1ms