n2n/doc/Building.md

114 lines
3.7 KiB
Markdown
Raw Normal View History

2020-08-15 22:01:35 +02:00
# n2n on macOS
In order to use n2n on macOS, you first need to install support for TUN/TAP interfaces:
```bash
brew tap homebrew/cask
brew cask install tuntap
```
If you are on a modern version of macOS (i.e. Catalina), the commands above will ask you to enable the TUN/TAP kernel extension in System Preferences → Security & Privacy → General.
For more information refer to vendor documentation or the [Apple Technical Note](https://developer.apple.com/library/content/technotes/tn2459/_index.html).
# Build on Windows
2019-03-01 20:16:24 +01:00
## Requirements
2019-03-01 20:16:24 +01:00
In order to build on Windows the following tools should be installed:
2019-03-01 20:16:24 +01:00
- Visual Studio. For a minimal install, the command line only build tools can be
downloaded and installed from https://visualstudio.microsoft.com/downloads/#build-tools-for-visual-studio-2017
- Cmake
- (optional) The OpenSSL library. Prebuild binaries can be downloaded from https://slproweb.com/products/Win32OpenSSL.html .
The full version is required (not the "Light" version). The Win32 version of it is usually required for a standard build.
2019-03-01 20:16:24 +01:00
NOTE: in order to skip OpenSSL compilation, edit CMakeLists.txt and replace
2019-03-01 20:16:24 +01:00
```plaintext
OPTION(N2N_OPTION_AES "USE AES" ON)
with
OPTION(N2N_OPTION_AES "USE AES" OFF)
```
2019-03-01 20:16:24 +01:00
NOTE: to static link OpenSSL, add the `-DOPENSSL_USE_STATIC_LIBS=true` option to the cmake command
2019-03-01 20:16:24 +01:00
In order to run n2n:
- The TAP drivers should be installed into the system. They can be installed from
http://build.openvpn.net/downloads/releases (search for "tap-windows")
- If OpenSSL has been linked dynamically, the corresponding .dll file should be available
into the target computer
2019-03-01 20:16:24 +01:00
## Build (CLI)
2019-03-01 20:16:24 +01:00
In order to build from the command line, open a terminal window and run the following commands:
```batch
2019-03-01 20:16:24 +01:00
md build
cd build
cmake ..
MSBuild edge.vcxproj /t:Build /p:Configuration=Release
MSBuild supernode.vcxproj /t:Build /p:Configuration=Release
```
NOTE: if cmake has problems finding the installed OpenSSL library, try to download the official cmake and invoke it with:
`C:\Program Files\CMake\bin\cmake`
2019-03-01 20:16:24 +01:00
The compiled exe files should now be available under the Release directory.
## Run
The `edge.exe` program reads the `edge.conf` file located into the current directory if no option is provided.
Here is an example `edge.conf` file:
```plaintext
-c=mycommunity
-k=mysecretkey
# supernode IP address
-l=1.2.3.4:5678
# edge IP address
-a=192.168.100.1
```
The `supernode.exe` program reads the `supernode.conf` file located into the current directory if no option is provided.
Here is an example `supernode.conf` file:
```plaintext
-l=5678
```
See `edge.exe --help` and `supernode.exe --help` for a list of supported options.
2020-08-15 22:01:35 +02:00
# General Building Options
## Compiler Optimizations
2020-08-15 22:01:35 +02:00
The easiest way to boosting speed is by allowing the compiler to apply optimization to the code. To let the compiler know, the configuration process can take in the optionally specified compiler flag `-O3`:
2020-08-15 22:01:35 +02:00
`./configure CFLAGS="-O3"`
2020-08-15 22:01:35 +02:00
The `tools/n2n-benchmark` tool reports speed-ups of 200% or more! There is no known risk in terms of instable code or so.
## Hardware Features
Some parts of the code can be compiled to benefit from available hardware acceleration. It needs to be decided at compile-time. So, if compiling for a specific platform with known features (maybe the local one), it should be specified to the compiler, for example through the `-march=sandybridge` (you name it) or just `-march=native` for local use.
So far, the following portions of n2n's code benefit from hardware acceleration:
```
AES: AES-NI
ChaCha20: SSE2, SSSE3
SPECK: SSE4.2, AVX2, NEON
Pearson Hashing: AES-NI
```
The compilations flags could easily be combined:
`./configure CFLAGS="-O3 -march=native"`.