This project implements p2p application named Hello Peer!
that allows message exchange between two nodes on a local Ethernet network. Application uses custom protocol based on UDP (User Datagram Protocol) to transfer data and maintain a connection between two devices both acting as senders and receivers.
The program is written in C++ and uses CMake for building. A CMakeLists.txt
file is included with all the settings needed to compile the program. If any dependencies are missing, CMake will prompt you.
Before building, make sure you have these installed:
-
CMake (v3.22+)
- Configure and generate build files:
sudo apt-get install cmake
- Configure and generate build files:
-
C/C++ Compiler
- Required for compilation:
sudo apt-get install gcc
- Required for compilation:
-
pthread Library
- POSIX thread library (usually part of
build-essential
):sudo apt-get install build-essential
- POSIX thread library (usually part of
-
readline Library
- For command-line editing and history:
sudo apt-get install libreadline-dev
- For command-line editing and history:
-
spdlog Library
- Fast logging library for C++:
sudo apt-get install libspdlog-dev
- Fast logging library for C++:
Use an IDE like CLion with built-in CMake support for easy configuration (Recommended).
To build manually, run these commands:
mkdir build
cd build
cmake ..
make
CMake will notify you of missing dependencies. To install them:
sudo apt-get update
sudo apt-get install <package-name>
Replace <package-name>
with the required dependency.
After building, start the app in two terminals:
./p2p
After launching, type help
for available commands.
Node 1:
proc node port 5000
proc node dest 127.0.0.1:5001
Node 2:
proc node port 5001
proc node dest 127.0.0.1:5000 # i use loopback for testing
To connect:
proc node connect
To send a message:
send text Hello Peer!
send file /home/admtrv/file.txt
To disconnect:
proc node disconnect
Use exit
to quit the application.
Navigate through command history using the up (↑
) and down (↓
) arrows.
Logs provide information for debugging and are available at different levels (trace, debug, info, etc.). Set the log level with:
set log level <level>
View logs during runtime with show log
, or check the .logs
file after termination.
Detailed documentation and explanations are available in the doc/
directory.