NatTypeTester Documentation

C# nat & rfc3489 repository by @HMBSbige. Desktop release binaries & installers with 4.9k stars.

4,888 stars C# C# 1 file ยท ~1,199 tokens #nat#rfc3489#rfc5389#rfc5780#rfc8489#stun
RAW Doc

Technical Documentation: HMBSbige/NatTypeTester

โ„น๏ธ Provenance: Multi-Tier Ingestion ยท CodeWiki Reference

Overview (`README.md`)

NatTypeTester

Package NuGet
Stun.Net

Architecture

mermaid
flowchart TD
    Console["Console"] --> Application["Application"]
    Desktop["Desktop"] --> Views["Views"]
    Android["Android"] --> Views

    Views --> Application
    Views --> Configuration["Configuration"]
    Views --> ViewModels["ViewModels"]

    Application --> ApplicationContracts["Application.Contracts"]
    Application --> Domain["Domain"]
    Configuration --> Domain
    ViewModels --> ApplicationContracts
    ViewModels --> Domain

    ApplicationContracts --> DomainShared["Domain.Shared"]
    Domain --> DomainShared

RFC

Internet Protocol

  • IPv4
  • IPv6

Transmission Protocol

  • UDP
  • TCP
  • TLS-over-TCP
  • DTLS-over-UDP

RFC3489

The STUN server has two IP addresses (IP1, IP2), each listening on two ports (Port1, Port2).
Send to X, request from Y means the request is sent to endpoint X, asking the server to reply from endpoint Y.

text
/* Detailed source-code truncated for AI context efficiency. */

RFC5389

The STUN server has two IP addresses (IP1, IP2), each listening on two ports (Port1, Port2).
Send to X, request from Y means the request is sent to endpoint X, asking the server to reply from endpoint Y.

Binding Test

Checking for UDP Connectivity with the STUN Server

mermaid
flowchart TD
    T1["Send to IP1:Port1<br>request from IP1:Port1"] --> R1{"Received?"}
    R1 -->|No| B1["Fail"]:::bad
    R1 -->|Yes| R2{"Received<br>MappedEndpoint?"}
    R2 -->|No| B2["Unsupported Server"]:::bad
    R2 -->|Yes| G1["Success"]:::good

    classDef bad fill:#f4756b,stroke:#c0392b,color:#000
    classDef good fill:#7fe57f,stroke:#38761d,color:#000

Mapping Behavior

Determining NAT Mapping Behavior

mermaid
flowchart TD
    T1["Test 1:<br>Send to IP1:Port1<br>request from IP1:Port1"] --> R1{"Received<br>MappedEndpoint1?"}
    R1 -->|No| B1["Failed"]:::bad
    R1 -->|Yes| R2{"Received<br>IP2:Port2?"}
    R2 -->|No| B2["Unsupported Server"]:::bad
    R2 -->|Yes| D1{"MappedEndpoint1 is<br>link's IP endpoint?"}
    D1 -->|Yes| G1["Direct"]:::good
    D1 -->|No| T2["Test 2:<br>Send to IP2:Port1<br>request from IP2:Port1"]
    T2 --> R3{"Received<br>MappedEndpoint2?"}
    R3 -->|No| B1
    R3 -->|Yes| D2{"MappedEndpoint2<br>is MappedEndpoint1?"}
    D2 -->|Yes| G2["Endpoint-Independent"]:::good
    D2 -->|No| T3["Test 3:<br>Send to IP2:Port2<br>request from IP2:Port2"]
    T3 --> R4{"Received<br>MappedEndpoint3?"}
    R4 -->|No| B1
    R4 -->|Yes| D3{"MappedEndpoint3<br>is MappedEndpoint2?"}
    D3 -->|No| M1["Address and Port-Dependent"]:::mild
    D3 -->|Yes| M2["Address-Dependent"]:::mild

    classDef bad fill:#f4756b,stroke:#c0392b,color:#000
    classDef good fill:#7fe57f,stroke:#38761d,color:#000
    classDef mild fill:#d9ead3,stroke:#93c47d,color:#000

Filtering Behavior

Determining NAT Filtering Behavior

mermaid
flowchart TD
    T1["Test 1:<br>Send to IP1:Port1<br>request from IP1:Port1"] --> R1{"Received<br>MappedEndpoint1?"}
    R1 -->|No| B1["Failed"]:::bad
    R1 -->|Yes| R2{"Received<br>IP2:Port2?"}
    R2 -->|No| B2["Unsupported Server"]:::bad
    R2 -->|Yes| T2["Test 2:<br>Send to IP1:Port1<br>request from IP2:Port2"]
    T2 --> R3{"Received?"}
    R3 -->|Yes| R4{"Received from<br>IP2:Port2?"}
    R4 -->|No| B3["Unsupported Server"]:::bad
    R4 -->|Yes| G1["Endpoint-Independent"]:::good
    R3 -->|No| T3["Test 3:<br>Send to IP1:Port1<br>request from IP1:Port2"]
    T3 --> R5{"Received?"}
    R5 -->|No| M1["Address and Port-Dependent"]:::mild
    R5 -->|Yes| R6{"Received from<br>IP1:Port2?"}
    R6 -->|No| B4["Unsupported Server"]:::bad
    R6 -->|Yes| M2["Address-Dependent"]:::mild

    classDef bad fill:#f4756b,stroke:#c0392b,color:#000
    classDef good fill:#7fe57f,stroke:#38761d,color:#000
    classDef mild fill:#d9ead3,stroke:#93c47d,color:#000

Combining Tests

text
/* Detailed source-code truncated for AI context efficiency. */

--- METRICS ---