Lanbench
@app.post("/api/v1/start_test") async def start_test(config: TestConfig, background_tasks: BackgroundTasks): """Start a network test""" test_id = generate_test_id() background_tasks.add_task(run_network_test, test_id, config) return {"test_id": test_id, "status": "started"}
@app.websocket("/ws/live") async def websocket_endpoint(websocket: WebSocket): """WebSocket for real-time updates""" await websocket.accept() while True: data = await websocket.receive_text() # Process real-time data await websocket.send_json({"status": "updating", "data": data}) # requirements.txt fastapi==0.104.1 uvicorn==0.24.0 dash==2.14.0 plotly==5.17.0 psutil==5.9.5 numpy==1.24.3 pandas==2.1.0 scapy==2.5.0 redis==5.0.1 websockets==12.0 python-socketio==5.10.0 reportlab==4.0.4 jinja2==3.1.2 Quick Start Example # main.py from fastapi import FastAPI import asyncio async def main(): # Initialize LANBench with all features dashboard = LiveDashboard() api_server = FastAPI() distributed_tester = DistributedTester() LANBench
@staticmethod def test_bufferbloat(host: str, duration: int = 60): """Test router bufferbloat""" # Measure latency under load idle_latency = AdvancedNetworkTests.measure_latency(host) # Generate high load AdvancedNetworkTests.generate_background_load(host, duration) # Measure loaded latency loaded_latency = AdvancedNetworkTests.measure_latency(host) return { 'idle_latency': idle_latency, 'loaded_latency': loaded_latency, 'bufferbloat_ms': loaded_latency - idle_latency } <!-- templates/dashboard.html --> <!DOCTYPE html> <html> <head> <title>LANBench Control Panel</title> <script src="https://cdn.socket.io/4.5.0/socket.io.min.js"></script> <script src="https://cdn.jsdelivr.net/npm/chart.js"></script> </head> <body> <div class="container"> <h1>LANBench Network Testing Suite</h1> <div class="control-panel"> <select id="test-type"> <option value="bandwidth">Bandwidth Test</option> <option value="latency">Latency Test</option> <option value="packet-loss">Packet Loss Test</option> <option value="jitter">Jitter Test</option> </select> <input type="text" id="target-host" placeholder="Target IP/Hostname"> <input type="number" id="duration" placeholder="Duration (seconds)" value="30"> <button onclick="startTest()">Start Test</button> </div> <canvas id="real-time-chart"></canvas> <div id="results"></div> </div> config) return {"test_id": test_id
# Implement throughput measurement pass

