# Technical Documentation: HMBSbige/NatTypeTester

> ℹ️ **Provenance:** Multi-Tier Ingestion · [CodeWiki Reference](https://codewiki.google/github.com/HMBSbige/NatTypeTester)

### Overview (`README.md`)

# NatTypeTester

Package | NuGet
-|-
Stun.Net | [](https://www.nuget.org/packages/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

- [RFC 3489](https://datatracker.ietf.org/doc/html/rfc3489)
- [RFC 5780](https://datatracker.ietf.org/doc/html/rfc5780)
- [RFC 8489](https://datatracker.ietf.org/doc/html/rfc8489)

## Internet Protocol

- [x] IPv4
- [x] IPv6

## Transmission Protocol

- [x] UDP
- [x] TCP
- [x] TLS-over-TCP
- [x] 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`.

<details>

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

</details>

## 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

<details>
  <summary>Checking for UDP Connectivity with the STUN Server</summary>

```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
```

</details>

### Mapping Behavior

<details>
  <summary>Determining NAT Mapping Behavior</summary>

```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
```

</details>

### Filtering Behavior

<details>
  <summary>Determining NAT Filtering Behavior</summary>

```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
```

</details>

### Combining Tests

<details>

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

</details>

---

--- METRICS ---
- Files Extracted: 1
- Estimated Token Budget: ~1116 tokens
- Canonical Reference: https://codewiki.google/github.com/HMBSbige/NatTypeTester
