Skip to content

mwcorley79/MPL

Repository files navigation

Message Passing Library (MPL)

This repository provides a reusable C++ message passing library (MPL) framework for developing TCP/IP network (client/server) applications by wrapping full duplex TCP socket communucation on Linux and Windows.

One goal is to enable cross-platform portability (TCP socket level compatibility between Linux and Windows) by providing a TCPSocket class that encapsulates the (basic) differences between the low-level (C-based) Windows and Linux APIs.

See TCPSocket.h/.cpp for details of the TCP socket wrapper code.

This project uses CMake to manage the build process for Linux and Windows.

The current objective is to provide an efficient C++ network communication facility for a joint experiment with Dr. James Fawcett (https://github.com/JimFawcett) to compare various (initially performance related) aspects of modern C++ and the Rust programming language.


Prerequisites for getting started on Linux:
  1. Download and install CMake (Debian-based distros): sudo apt-get install cmake
  2. Download and install git: sudo apt-get install git
  3. Download and install gcc/g++ (compiler toolchain): sudo apt-get install g++
  4. Open a terminal/console and type command: git clone https://github.com/mwcorley79/MPL.git

Prerequisites for getting started on Windows:
  1. Download and install CMake: https://cmake.org/download/
  2. Download and install git: https://git-scm.com/download/win
  3. Note: If Visual Studio 2019 is not installed, then download and install Microsoft C++ Build Tools (MSVC compiler tools): https://visualstudio.microsoft.com/visual-cpp-build-tools/
    1. Run vs_buildtools (Visual Studio) installer. Check the workload for C++ build tools (as shown below)
  4. Open a windows command prompt (cmd.exe) and type command: git clone https://github.com/mwcorley79/MPL.git

Option 1: Building the CMake targets from the command line -- Debug and Release Mode (these steps apply to both Windows and Linux)

  1. Open a command line terminal (i.e. bash in Linux) and (cmd.exe in Windows)
    • Building in Debug Mode
      1. cd MPL
      2. mkdir debug
      3. cd debug
      4. cmake .. -DCMAKE_INSTALL_PREFIX=../install -DCMAKE_BUILD_TYPE=Debug
    • Building in Release Mode
      1. cd MPL
      2. mkdir release
      3. cd release
      4. cmake .. -DCMAKE_INSTALL_PREFIX=../install -DCMAKE_BUILD_TYPE=Release
    • Building CMake Project Targets
      • *** Building on Windows only ***
        1. If you have Visual Studio 2019 IDE installed, you may opt to stop at this point and open the MPL.sln solution in the IDE (located in the Debug or Release subfolder corresponding with the chosen build configuration)
    • Note: You can append --config Release or --config Debug to each target build command (below) to ensure the intended build mode: (Release or Debug)
    • cmake --build . --config Release <- build all project targets
    • cmake --build . --target MPL <- build the (static) Message Passing Library (MPL)
    • cmake --build . --target PerfTestCombinedFixedSizeMsg <- builds the fixed size message performance test
    • cmake --build . --target PerfTestCombinedVariableSizeMsg <- builds the variable size message performance test
    • cmake --build . --target BQueueTest <- builds the BlockingQueue test
    • cmake --build . --target MessageTest <- builds the Message test
    • cmake --build . --target TCPSocketsTest <- builds the TCPSocketsTest
  2. Running the Targets
    • From a command terminal, type the name of target to run, followed by the Enter key
    • e.g. On Windows: cd Debug or cd Release (depends build configuration) and type PerfTestCombinedFixedSizeMsg.exe
    • e.g. On Linux: ./PerfTestCombinedFixedSizeMsg

Build a Docker MPL comm test image: (assumes Docker is installed on the host: https://docs.docker.com/get-docker/ and existence of a Docker Hub account: https://www.docker.com/products/docker-hub)

  • Build local MPL image: "docker build -t mpl:latest ."
  • Run local MPL container: "docker run -ti mpl"
  • Build MPL image for registry (Docker Hub) repo: "docker build -t username/mpl:latest ."
  • Log in to registry: "docker login --username=username"
  • Push image to repo: "docker push username/mpl:latest"
  • Now MPL comm test can be distributed/deployed to anywhere/anyone: "docker run -ti username/mpl:latest"

Option 2: Building the CMake targets using Visual Studio Code Editor: VScode (these steps apply to both Windows and Linux)

  1. Download and install Visual Studio Code editor (VScode): https://code.visualstudio.com/download
    1. Start VScode and install "Microsoft C/C++ VScode" extension (ms-vscode.cpptools)
    2. Install "CMake Tools: Extended CMake support in Visual Studion Code" extension (ms-vscode.cmake-tools)
  2. Start VScode: click File -> Open Folder and Select the project MPL folder
  3. As illustrated (below): Select a compiler kit: (i.e. gcc/g++ for Linux, and Visual Studio Build Tools 2019 Release for Windows) ... on Linux ... ... and on Windows ...
  4. As illustrated (below): Build the MPL (library) by selecting the MPL STATIC_LIBARY target and clicking "Build". On Windows this generates library: MPL.lib, and on Linux: libMPL.a
  5. In similar fashion, build and run the included MPL performance test. Select and Build the TCPConnectorPerfTest EXECUTABLE target, and TCPResponderTest EXECULABLE target
  6. As illustrated( below): run the MPL performace test on Windows by clicking the TERMINAL tab, and splitting the terminal into two separate panes (as shown in the output).
    Run the MPL performance exemplar by using the commands shown in the output.
    The exemplar provides throughput/latency measurements for 1024 byte message sizes running on a Windows 10 virtual machine (VMWARE).
  7. Run the MPL performace test on Linux by clicking the TERMINAL tab, and splitting the terminal into two seperate panes (as shown in the output).
    Run MPL performance exemplar by using the commands shown in the output.
    The exemplar provides throughput/latency measurements for 1024 byte message sizes running on a Linux Mint virtual machine (VMWARE).

Running the combined test target (PerfTestCombined) is complementary to Dr. Fawcett's testing of the same in Rust (located here: https://jimfawcett.github.io/RustCommWithThreadPool.html)

  1. Start VScode: click File -> Open Folder and Select the project MPL folder
  2. Build the MPL (library) by selecting the MPL STATIC_LIBARY target and clicking "Build". On Windows this generates library: MPL.lib, and on Linux: libMPL.a
  3. Build the PerfTestCombined target by selecting the PerfTestCombined EXECUTABLE target and clicking "Build".
  4. Finally, Run the PerfTestCombined target by clicking Run (shown below)

MPL class diagram

About

Cross-Platform (Linux and Windows) message passing library/framework that wraps full duplex TCP sockets.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages