Skip to content
gschullPublic

About

Network Discovery Tool - WPF application with MVVM architecture for discovering and analyzing upstream network devices

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

NetMap - Network Discovery Tool

A powerful C# WPF application for network device discovery and upstream analysis using MVVM architecture.

Features

Network Discovery

  • Subnet Scanning: Scan entire subnets (e.g., 192.168.1.0/24) with configurable timeout
  • Real-time Progress: Live percentage-based progress reporting during scans with device count
  • Device Detection: Automatic device type identification (Router, Computer, Printer, IoT, etc.)
  • Cancellation Support: Stop long-running scans at any time
  • CSV Export: Export discovered devices to timestamped CSV files

Device Information

  • IP Address and Hostname resolution
  • MAC Address discovery via ARP
  • Response time measurement (ping latency)
  • Device type determination via port scanning (HTTP, HTTPS, SSH, Telnet, SNMP, SMB, AFP, IPP)
  • Last seen timestamp

Network Analysis

  • Trace Route: Trace the path to any destination with hop-by-hop details
  • Hop Analysis: See detailed information about each network hop with latency
  • Ping Testing: Test individual device connectivity with refresh capability
  • Interface Enumeration: View all network interfaces with IP, MAC, Gateway information

Logging & Data Management

  • File Logging: Comprehensive logging to logs/netmap.log with millisecond timestamps
  • Log Viewer: Built-in UI to view recent log entries (latest 500, newest first)
  • Log Rotation: Automatic rotation when log file exceeds 5MB (keeps 3 backups: .1, .2, .3)
  • Clear Logs: Clear log file from UI with confirmation
  • Auto-load: Logs automatically loaded on application startup

Upstream Device Information

The application can discover and display:

  • IP Addresses: IPv4 addresses of upstream devices
  • MAC Addresses: Physical addresses from ARP tables
  • Hostnames: DNS names and device identifiers
  • Device Types: Routers, switches, access points, servers
  • Response Times: Network latency measurements
  • Routing Paths: Complete paths to destinations
  • Gateway Information: Default gateways and routing tables

Architecture

Built using MVVM (Model-View-ViewModel) pattern with strict separation of concerns:

  • Models: NetworkDevice, NetworkInterface, RouteEntry, NetworkTrace, TraceHop, ScanProgress
  • ViewModels: MainViewModel with RelayCommand/AsyncRelayCommand binding and ObservableCollections
  • Views: MainWindow.xaml with tabbed interface (Network Scan, Trace Route, Network Information, Logs)
  • Services:
    • NetworkDiscoveryService: Async network operations with cancellation and progress reporting
    • Logger: Thread-safe file logging with automatic rotation

Technologies

  • .NET 8.0 WPF (net8.0-windows)
  • CommunityToolkit.Mvvm 8.2.2 for MVVM implementation
  • System.Management 8.0.0 for system queries
  • System.Net.NetworkInformation for network operations

Code Quality

  • Warning-Free: All projects configured with TreatWarningsAsErrors=true
  • Async/Await: All network operations are asynchronous
  • Thread-Safe: Logger uses locking for concurrent access
  • Error Handling: Comprehensive try-catch blocks with logging

Requirements

  • .NET 8.0 SDK or higher
  • Windows operating system (WPF application)
  • Administrator privileges (recommended for full functionality)

Build & Run

Build

dotnet build NetMap.csproj

Run WPF Application

dotnet run --project NetMap.csproj

Run CLI Tool

cd tools/NetMapCli
dotnet run scan

Usage

Network Scan Tab

  1. Select your network interface from the dropdown
  2. Review the auto-populated subnet (e.g., 192.168.1.0/24)
  3. Click "Scan Network" to discover devices
  4. Watch real-time progress: "Scanning... 125/254 hosts (49.2%) - Found 8 devices"
  5. Click "Cancel" to stop scan at any time
  6. Click "Export to CSV" to save results to timestamped file

Trace Route Tab

  1. Enter a destination IP or hostname (e.g., 8.8.8.8)
  2. Click "Trace Route" to see the network path
  3. View hop-by-hop details with latency information in the data grid

Network Information Tab

  • View all network interfaces with detailed information (IP, MAC, Gateway, Speed)
  • Click "Refresh Interfaces" to update interface status

Logs Tab

  • View recent log entries (latest 500, newest first) in monospace font
  • Click "Refresh Logs" to reload from disk
  • Click "Clear Logs" to empty the log file (new log entry confirms action)

Network Discovery Capabilities

What Information Can Be Acquired About Upstream Devices:

  1. Basic Network Info:

    • IP addresses and subnets
    • MAC addresses from ARP tables
    • Default gateways and routing information
    • Network interface details (Type, Speed, Status)
  2. Device Identification:

    • Hostnames via DNS lookups
    • Device types through port scanning (80, 443, 22, 23, 161, 135, 445, 548, 631)
    • Response time measurements (milliseconds)
    • Online/Offline status
  3. Connectivity Analysis:

    • Ping response times and reachability
    • Network path visualization via traceroute
    • Hop-by-hop latency analysis
    • Interface configuration and gateway discovery
  4. Topology Mapping:

    • Network hop discovery with detailed routing paths
    • Distance to upstream devices (hop count)
    • Complete path visualization to any destination

Output Files

  • Application Logs: bin/Debug/net8.0-windows/logs/netmap.log
    • Rotated backups: .log.1, .log.2, .log.3 (when file exceeds 5MB)
    • Format: YYYY-MM-DD HH:mm:ss.fff [message]
  • Exported Data: bin/Debug/net8.0-windows/exports/network_devices_YYYYMMDD_HHMMSS.csv
    • CSV format with headers: IPAddress, MacAddress, HostName, DeviceType, Vendor, ResponseTime, Status, LastSeen
  • CLI Logs: tools/NetMapCli/bin/Debug/net8.0/logs/netmap-cli.log

Project Structure

NetMap/
├── Models/
│   └── NetworkModels.cs         # Data models (NetworkDevice, NetworkInterface, etc.)
├── ViewModels/
│   └── MainViewModel.cs         # Main ViewModel with all commands and collections
├── Views/
│   ├── MainWindow.xaml          # Main UI window with tabs
│   └── MainWindow.xaml.cs       # Code-behind
├── Services/
│   ├── NetworkDiscoveryService.cs  # Network operations (scan, ping, traceroute)
│   └── Logger.cs                # File logging with rotation
├── tools/
│   └── NetMapCli/               # Command-line tool for testing
│       ├── Program.cs           # CLI entry point
│       ├── Services/            # CLI-specific NetworkDiscoveryService
│       └── Models/              # CLI-specific models
├── Properties/
│   └── AssemblyInfo.cs          # Manual assembly metadata
├── .github/
│   └── copilot-instructions.md  # Development guidelines
├── NetMap.csproj                # Main WPF project file
└── README.md                    # This file

Development Guidelines

Adding New Features

  1. Add models to Models/NetworkModels.cs
  2. Add service methods to Services/NetworkDiscoveryService.cs
  3. Add commands and properties to ViewModels/MainViewModel.cs
  4. Update UI in Views/MainWindow.xaml
  5. Build and verify warning-free compilation: dotnet build NetMap.csproj

Coding Standards

  • Follow MVVM pattern strictly - no business logic in Views
  • Use async/await for all network operations
  • Implement proper error handling with try-catch blocks
  • Log all significant operations to Logger
  • Use CancellationToken for long-running operations
  • Report progress via IProgress for user feedback
  • All code must compile with zero warnings (TreatWarningsAsErrors=true)

Troubleshooting

Build Issues

  • Ensure .NET 8.0 SDK is installed: dotnet --version
  • Clean and rebuild: dotnet clean; dotnet build
  • Check that GenerateAssemblyInfo=false is set in both project files
  • Verify tools/** folder is excluded in NetMap.csproj to avoid assembly conflicts

Runtime Issues

  • Check logs/netmap.log for detailed error information
  • Ensure you have network interface access permissions
  • Some features may require administrator privileges (ARP table access, port scanning)
  • Firewall may block ICMP (ping) or traceroute packets

Application Not Responding

  • Long scans can be cancelled using the "Cancel" button
  • Progress bar shows real-time scan percentage
  • Check Task Manager if application appears frozen (background network operations may be running)

License

This project is provided as-is for network discovery and analysis purposes.


Built with ❤️ using .NET 8.0, WPF, and MVVM architecture

  • Route path analysis
  • Gateway identification

Building and Running

dotnet build
dotnet run

Or open in Visual Studio and press F5 to debug.

License

This project is for educational and network administration purposes.

About

Network Discovery Tool - WPF application with MVVM architecture for discovering and analyzing upstream network devices

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages