mirror of
https://github.com/jmcorgan/fips.git
synced 2026-08-09 16:24:45 +00:00
Move examples/docker-network/ to testing/static/ and add testing/chaos/ as a new stochastic simulation harness. testing/static/ — Static 5-node test harness: - Fixed mesh, chain, and mesh-public topologies with docker compose - Manual test scripts (ping, iperf, netem) - Build script, config generation, key derivation testing/chaos/ — Stochastic network simulation: - Python orchestrator generating N-node FIPS meshes with dynamic network conditions, driven by reproducible YAML scenarios - Topology generation: random geometric, Erdos-Renyi, or chain graphs with BFS connectivity guarantee - Per-link netem: HTB classful qdiscs with u32 filters for per-peer impairment (delay, loss, jitter), stochastic mutation across configurable policy profiles - Per-link bandwidth pacing: HTB rate limiting with configurable tiers (1/10/100/1000 mbps) randomly assigned per edge - Link flaps: tc netem 100% loss with graph connectivity protection - Node churn: docker stop/start with netem re-application on restart, shared down_nodes tracking across all managers - Traffic generation: random iperf3 sessions between node pairs - Down-node guards: all docker exec callers check container liveness, auto-detect crashed containers via is_container_running() safety net - Log collection and post-run analysis (panics, errors, sessions, MMP metrics, tree reconvergence) - chaos.sh wrapper with --seed, --duration, --verbose, --list options - Four scenarios: smoke-10, chaos-10, churn-10, churn-20
62 lines
1.6 KiB
Python
62 lines
1.6 KiB
Python
"""CLI entry point: python -m sim <scenario.yaml>"""
|
|
|
|
import argparse
|
|
import logging
|
|
import sys
|
|
|
|
from .runner import SimRunner
|
|
from .scenario import load_scenario
|
|
|
|
|
|
def main():
|
|
parser = argparse.ArgumentParser(
|
|
prog="sim",
|
|
description="FIPS stochastic network simulation",
|
|
)
|
|
parser.add_argument("scenario", help="Path to scenario YAML file")
|
|
parser.add_argument(
|
|
"-v", "--verbose", action="store_true", help="Enable debug logging"
|
|
)
|
|
parser.add_argument(
|
|
"--seed", type=int, default=None,
|
|
help="Override scenario seed",
|
|
)
|
|
parser.add_argument(
|
|
"--duration", type=int, default=None,
|
|
help="Override scenario duration in seconds",
|
|
)
|
|
args = parser.parse_args()
|
|
|
|
level = logging.DEBUG if args.verbose else logging.INFO
|
|
logging.basicConfig(
|
|
level=level,
|
|
format="%(asctime)s %(levelname)-5s %(name)s: %(message)s",
|
|
datefmt="%H:%M:%S",
|
|
)
|
|
|
|
try:
|
|
scenario = load_scenario(args.scenario)
|
|
except (FileNotFoundError, ValueError) as e:
|
|
print(f"Error loading scenario: {e}", file=sys.stderr)
|
|
sys.exit(1)
|
|
|
|
# Apply CLI overrides
|
|
if args.seed is not None:
|
|
scenario.seed = args.seed
|
|
if args.duration is not None:
|
|
if args.duration < 1:
|
|
print("Error: --duration must be >= 1", file=sys.stderr)
|
|
sys.exit(1)
|
|
scenario.duration_secs = args.duration
|
|
|
|
runner = SimRunner(scenario)
|
|
result = runner.run()
|
|
|
|
if result and result.panics:
|
|
sys.exit(2)
|
|
sys.exit(0)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|