# mansourm61/netperftester architecture

> Architecture diagram of the GitHub repository mansourm61/netperftester, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-04-05). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/mansourm61/netperftester
- Repository: https://github.com/mansourm61/netperftester

## Overview

##### Main Components
- Main Application (Controller):
- NetPerfTester.py – the entry point that ties together the GUI, process management, and data handling.
- GUI Layer:
- Built with Python’s tkinter (as indicated in the README) and includes elements such as the bandwidth gauge widget, log display, and other interactive components.
- Helper/Supporting Modules:
- ModuleMeter.py – likely supports the meter widgets for visualizing network performance metrics.
- OS-Dependent Utilities:
- Executable scripts in the “bin” folder (KillPortProcessLinux.sh and KillPortProcessWindows.bat) – these scripts handle terminating processes that are interfering with port usage.
- Measurement Handling:
- “measurements” directory – although not detailed, it appears to contain logs or supplementary data for performance tests, as evidenced by its own README file.

##### Relationships and Interactions
- User Interaction: The user launches the application and interacts with the GUI.
- GUI to Controller: User inputs trigger events in NetPerfTester.py, which interacts with the underlying logic.
- Controller to External Tools: Depending on the OS, the application calls the installed iperf (as well as the provided kill scripts) using system calls (via the subprocess module). Note that the GUI does not directly interact with iperf outputs; instead, it handles file-based outputs due to buffering issues.
- Data Flow: After running iperf, the generated output is written to a temporary file. The controller then reads this file, parses the performance metrics (Transfer Bytes, Bandwidth, Jitter, PER), and updates the GUI accordingly.
- Logging/Measurement: Results are logged into CSV files for record-keeping, and the “measurements” directory potentially stores or organizes this historical data.
- Helper Modules interact with both the GUI (for dynamic visual updates) and possibly debugging/logging output.

##### Architectural Patterns and Important Design Principles
- OS-Awareness: The design accommodates cross-OS compatibility by using specific scripts and mechanisms tailored for Windows and Linux.
- Loose Coupling via File I/O: Because direct stdout handling wasn’t fully reliable, the application uses file-based communication to decouple iperf’s output generation from its analysis, which enables a clearer separation of concerns.
- Reusability: The use of external modules (e.g., the bandwidth gauge widget from an external source) demonstrates how the application leverages reusability and external libraries.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% High-Level Application Flow
    User("User"):::user
    User -->|"launches"| GUI

    subgraph "GUI Layer"
        GUI("GUI Layer (Tkinter)"):::gui
    end

    GUI -->|"triggers events"| Controller

    subgraph "Core Application"
        Controller("Controller (NetPerfTester.py)"):::controller
    end

    %% External Tools & Data Flow
    subgraph "External Tools and Data"
        External("External iperf Tools (iperf2/iperf3)"):::external
        TempOutput("Temporary Output File"):::data
        Logging("Measurement Logging (CSV)"):::data
    end

    Controller -->|"initiates"| External
    External -->|"writes output"| TempOutput
    TempOutput -->|"parsed by"| Controller
    Controller -->|"logs data"| Logging

    %% OS-Dependent Utilities Subgraph
    subgraph "OS-Dependent Utilities"
        LinuxKill("Linux Kill Script"):::os
        WindowsKill("Windows Kill Script"):::os
    end

    Controller -->|"callsLinux"| LinuxKill
    Controller -->|"callsWindows"| WindowsKill

    %% Helper Modules Subgraph
    subgraph "Helper Modules"
        Helper1("Colored Text Module (ModuleColoredText.py)"):::helper
        Helper2("Meter Display Module (ModuleMeter.py)"):::helper
    end

    Controller -->|"formats output"| Helper1
    Controller -->|"updates display"| Helper2

    %% Click Events
    click Controller "https://github.com/mansourm61/netperftester/blob/master/NetPerfTester.py"
    click GUI "https://github.com/mansourm61/netperftester/blob/master/NetPerfTester.py"
    click Helper1 "https://github.com/mansourm61/netperftester/blob/master/ModuleColoredText.py"
    click Helper2 "https://github.com/mansourm61/netperftester/blob/master/ModuleMeter.py"
    click LinuxKill "https://github.com/mansourm61/netperftester/blob/master/bin/KillPortProcessLinux.sh"
    click WindowsKill "https://github.com/mansourm61/netperftester/blob/master/bin/KillPortProcessWindows.bat"
    click Logging "https://github.com/mansourm61/netperftester/tree/master/measurements"

    %% Styling Classes
    classDef user fill:#f9c,stroke:#333,stroke-width:2px,color:#000;
    classDef gui fill:#bbf,stroke:#333,stroke-width:2px,color:#000;
    classDef controller fill:#fb8,stroke:#333,stroke-width:2px,color:#000;
    classDef external fill:#afa,stroke:#333,stroke-width:2px,color:#000;
    classDef data fill:#ddd,stroke:#333,stroke-width:2px,color:#000;
    classDef os fill:#f88,stroke:#333,stroke-width:2px,color:#000;
    classDef helper fill:#8ff,stroke:#333,stroke-width:2px,color:#000;
```
