If you are looking for a ready-made open-source simulator that models a cloud data center using a spine-leaf network fabric, there is no single canonical package that matches that exact description; what exists instead is a small set of tools you combine. The usual practical answer is to use a discrete-event network simulator such as ns-3 (or, for flow-level work, the OMNeT++/INET framework), define a two-tier spine-leaf Clos topology in its topology API, generate east-west traffic between hosts, and attach a cloud workload model on top. The phrase "sim cloud source code" itself is ambiguous — it can mean a cloud simulator (a tool for simulating cloud computing systems) or a simulated cloud network (a network topology study) — and the spine-leaf requirement is a networking concern, so the second interpretation is usually what people actually want.
This article explains what spine-leaf means in a simulation context, which open-source codebases are realistic starting points, how a minimal spine-leaf topology is actually specified in code, and where the common mismatches between "cloud simulator" tools and "network simulator" tools will trip you up.
Two Kinds of "Cloud Simulator" and Why the Distinction Matters
The search phrase conflates two families of tools that solve different problems.
Cloud computing simulators model the compute side of a cloud: virtual machines, containers, task scheduling, resource allocation, service-level objectives, energy consumption, and cost. The best-known open-source examples are CloudSim (Java, from the Cloud Computing and Distributed Systems lab at the University of Melbourne), its descendants such as CloudSim Plus, and the broader family of CloudSim-based extensions. These tools typically model data-center resources as abstract entities (hosts, VMs, brokers, allocation policies) and do not include a packet-level network fabric. Their "network" is usually a simplified latency or bandwidth cost between entities.
Network simulators model the fabric: links, switches, queues, routing, congestion, and protocol behavior. ns-3, OMNeT++ with the INET framework, and Mininet (which runs real Linux networking rather than simulating packets) are the standard open-source choices. These have no built-in notion of a cloud scheduler or VM lifecycle, but they are exactly the right tools for studying spine-leaf topologies, oversubscription ratios, equal-cost multipath (ECMP) load balancing, and east-west traffic patterns.
Spine-leaf is a network topology concept, so a request that combines "cloud" and "spine-leaf" is almost always asking for the second kind of tool — a simulated cloud data-center network — or for a hybrid that models both compute placement and fabric behavior.
| Tool family | Examples | Models spine-leaf directly? | Models cloud workloads/scheduling? |
|---|---|---|---|
| Cloud simulators | CloudSim, CloudSim Plus | No (abstract network) | Yes, in detail |
| Network simulators | ns-3, OMNeT++/INET | Yes, via topology construction | Only what you add |
| Emulation | Mininet, Containerlab | Yes, using real switch/routing behavior | Not natively |
If your goal is to study how a scheduler's placement decisions interact with fabric congestion, you will end up writing glue code regardless of which base you pick. Choosing the base depends on whether the research question is primarily about scheduling or primarily about the network.
What Spine-Leaf Architecture Actually Means
Spine-leaf (also called a two-tier Clos fabric) is a data-center network design in which every leaf switch connects to every spine switch, and hosts or racks connect only to leaf switches. There are no leaf-to-leaf or spine-to-spine links, and no host connects directly to a spine.
The consequences are the reason the design is popular:
Uniform, predictable latency. Any host-to-host path traverses at most leaf → spine → leaf, so the number of hops is bounded and independent of where the endpoints sit. This matters for the tail latency that distributed applications care about. High and consistent bisection bandwidth. Because every leaf reaches every spine, the fabric can carry full cross-sectional traffic if the spine layer is provisioned to match. In practice, designers choose an oversubscription ratio — the ratio of leaf downlink capacity to uplink capacity toward the spines — and simulation is a common way to evaluate what a given ratio costs under realistic traffic. Scale-out by adding switches. Adding a spine increases aggregate bandwidth; adding a leaf adds access ports. This is why the topology is described as non-blocking or near-non-blocking at the fabric level. Equal-cost multipath. With many parallel paths of identical cost, routing uses ECMP to spread flows across spines. How well that spreading works — and how badly it degrades under hash collisions or elephant flows — is a classic simulation study.
In code, the structure is a complete bipartite graph: each leaf connects to each spine, hosts hang off leaves, and the links are typically uniform (same capacity, same delay). A fabric with L leaves, S spines, and H hosts per leaf has L × S spine-facing links plus L × H host links.
Building a Spine-Leaf Topology in ns-3
ns-3 is the most common open-source choice for this kind of study, and its point-to-point helper makes the bipartite structure straightforward to express. The essential pattern — not a complete runnable program, but the topology core — looks like this in ns-3's C++ API:
After installing the devices, you assign IP addresses (a common convention is one subnet per leaf, with hosts and that leaf's spine-facing interfaces in it), install an Internet stack, and populate routing. The critical detail is that ECMP must actually be enabled and exercised, or your simulated fabric will use a single path and you will be measuring the wrong thing. ns-3's global routing and the available ECMP support require deliberate configuration; treating the topology as a plain shortest-path network silently collapses your multipath fabric into a tree.
Traffic generation then follows the workload you care about. East-west traffic — host-to-host within the data center — is the realistic default for cloud workloads, and ns-3's OnOffHelper or bulk-send applications can approximate it. For a more defensible study, drive traffic from a workload model (for example, a synthetic mix of latency-sensitive small flows and bandwidth-hungry large flows) rather than a single uniform flow pattern.
The OMNeT++/INET and Mininet Alternatives
OMNeT++ with the INET framework is the other major open-source simulation route. INET provides TCP/IP, Ethernet, and routing models, and building a spine-leaf fabric means instantiating switch modules and connecting them according to the same bipartite rule. INET's configuration files (NED topology descriptions plus ini configuration) make the fabric pattern readable, and the framework has more built-in support for some higher-layer protocols than a bare ns-3 installation.
Mininet takes a different approach: it does not simulate packets but creates real virtual hosts and switches (typically Open vSwitch) on a single Linux machine, using network namespaces. A spine-leaf fabric in Mininet uses real routing protocols or static routes with ECMP, so what you observe is closer to real switch behavior — at the cost of scaling to far fewer nodes than a packet simulator can reach. If your question is "does my ECMP configuration distribute flows sensibly," Mininet is often the faster path. Containerlab plays a similar role with containerized network operating systems.
Neither INET nor Mininet includes a cloud scheduler. If you need VM placement or service-level modeling, you add it: a script that assigns workload roles to hosts, or a co-simulation where a cloud simulator's decisions feed the network model.
Where CloudSim-Style Tools Fall Short for This Question
A reader searching for "sim cloud source code that includes spine leaf architecture" may have started with CloudSim and found no fabric model. That is expected, not a defect. CloudSim's network model is intentionally abstract: it supports modeling network latency and bandwidth between entities and can represent topology in a limited way, but it is not a packet-level simulator and does not model switches, queues, or routing protocols. You cannot meaningfully study ECMP behavior or oversubscription in CloudSim.
The honest options are therefore:
1: Use a network simulator and add a lightweight workload model if the fabric is the subject of study. 2: Use a cloud simulator and accept an abstract network if scheduling and resource allocation are the subject, with latency represented as a parameter rather than simulated. 3: Co-simulate — feed placement decisions from a cloud model into a fabric model — which is real work but is the only way to study the interaction rigorously.
Anyone promising a single turnkey open-source package that does both well is describing something that, in the open-source ecosystem, generally does not exist as a maintained, ready-to-run product.
Getting the Details Right
Several common mistakes make spine-leaf simulations misleading:
Forgetting oversubscription. If leaf uplinks and host links have equal capacity, you have built an idealized non-blocking fabric. Real designs trade cost against bandwidth, and the ratio you choose determines the congestion your results will show. State the ratio explicitly. Collapsing ECMP. As noted, without correct multipath configuration the fabric behaves as a single-path tree. Verify that different flows actually traverse different spines. Uniform traffic only. A fabric that looks healthy under uniform all-to-all traffic can still suffer under the bursty, skewed east-west patterns real cloud workloads produce. Vary the traffic model. Ignoring the compute layer. If your question involves cloud behavior — placement, migration, tenant isolation — a pure network simulation will not answer it. Be clear about which layer your results describe. Scale mismatch. Packet simulators slow dramatically as node counts grow. A 4×4 spine-leaf with 32 hosts is comfortable; a fabric with hundreds of switches requires a flow-level or analytical model instead.
FAQ
Is there a single open-source repository I can clone that simulates a cloud with spine-leaf networking?
No widely maintained turnkey package matches that description exactly. ns-3 or OMNeT++/INET topologies plus your own workload code, or Mininet with real routing, are the realistic starting points.
Can CloudSim model spine-leaf?
Not at the fabric level. CloudSim models compute resources and abstract network costs; it does not simulate switches, queues, ECMP, or packet-level congestion.
What is the minimum code to represent spine-leaf?
A complete bipartite connection between leaf and spine switch objects, plus host-to-leaf links, with uniform link attributes. The snippet in the ns-3 section above shows the structural core.
Do I need ECMP enabled?
Yes, if you want results that reflect a real fabric. Without multipath routing, parallel spine links go unused and your latency and throughput numbers will be pessimistic in an unrealistic way.
Which tool should I pick?
Choose ns-3 or INET when you need packet-level detail and protocol behavior; choose Mininet when you want real routing/switch behavior at smaller scale; choose a cloud simulator when scheduling and resource allocation are the question and the network can stay abstract.
The short version: the source code you want is a spine-leaf topology you construct in a network simulator, not a downloadable product with that name — and knowing which layer of the cloud you are actually studying is what determines which simulator to start from.