The open source Thread wireless mesh networking stack OpenThread contains a nice option to build simulated Thread nodes than can run on your PC. This Google codelabs exercise explains in more detail how this can be used to simulate a very simple Thread network consisting of 2 nodes. A Linux VM is used to run the simulated nodes. Now wouldn’t it be great to just run your simulated nodes directly in Windows 10 as .exe executables? One way to get there is to build openthread in the Cygwin environment.

In Cygwin, the following packages need to be installed first:

automake
autoconf
python2
pip for Python 2
gcc
g++
libtool

Note that pip can be named “pip2” or “pip”. For Python you need the package “pexpect”. Install it from bash using:

pip2 install pexpect

If you don’t have the openthread repo from Github already, clone it into a directory of choice:

git clone https://github.com/openthread/openthread.git
cd openthread

To make sure that line endings are UNIX style, cd to your openthread repo and use the below. Don’t use this if your openthread repo contains local changes!

git config core.autocrlf false
git rm --cached -r . && git reset --hard

The repository can be prepared for building using the bootstrap script.

./bootstrap

Have a look at the output. It should complete without errors. (Errors may point to some missing tool/dependency or presence of Windows style line endings.) Now the POSIX example programs can be built using:

make -f examples/Makefile-posix

After building, the codelabs exercise to start 2 simulated nodes in separate shell windows can be followed. Using a command like below the first Full Thread Device (FTD) can be started:

./output/x86_64-unknown-cygwin/bin/ot-cli-ftd.exe 1

and in another window a second one:

./output/x86_64-unknown-cygwin/bin/ot-cli-ftd.exe 2

the default Thread network can be started by a sequence of commands, to be run in both shell windows:

ifconfig up
panid 0x1234
thread start

To confirm the nodes are attached to the network the ‘state’ command can be used. And finally scan the virtual airwaves and wonder where the developers did get their lunch!

> scan
| J | Network Name | Extended PAN | PAN | MAC Address | Ch | dBm | LQI |
+---+------------------+------------------+------+------------------+----+-----+-----+
| 0 | OpenThread | dead00beef00cafe | 1234 | fa5b112e46122b2f | 11 | -20 | 0 |
Done