
2 Software Architecture
This chapter provides an introductory software architectural overview of ns-3, including use cases, architecture for reusable
components, design for configuration, memory management policy, and strategy for integrating outside and legacy code.
2.1 Basics
ns-3 is a user-space program that runs on Unix- and Linux-based systems and on Windows (currently via Cygwin and possibly
via native win32 APIs in the future). It is written in C++, with a planned Python scripting interface(s) for users. The focus is
on IPv4 and IPv6-based networks, but other non-IP architectures such as sensors or DTNs are to be supported. ns-3 is meant
to be modifiable and extendable by users; some users will be able to use example scripts that are provided, but it is expected
that most (research) users will want to either write new scripts or modify or add to the simulator models in some way. Source
code distributions are therefore expected to be the preferred means for distributing ns-3.
ns-3 contains support for the following:
• construction of virtual networks (nodes, channels, applications) and support for items such as event schedulers, topol-
ogy generators, timers, random variables, and other objects to support discrete-event network simulation focused on
Internet-based and possibly other packet network systems.
• support for network emulation; the ability for simulator processes to emit and consume real network packets
• distributed simulation support; the ability for simulations to be distributed across multiple processors or machines
• support for animation of network simulations
• support for tracing, logging, and computing statistics on the simulation output
ns-3 has a modular implementation containing a core library supporting generic aspects of the simulator (debugging objects,
random number generators, smart pointers, callbacks, unit tests, reference list), and a simulator library defining simulation
time objects, schedulers, and events. A common library defines objects that are independent of specific network architectures,
such as generic packets and tracing objects. Finally, the node library defines abstract base classes for fundamental base
objects in the simulator, such as nodes, channels, and network devices. Internet-related models (IP and transport protocols)
are found in the internet-node library. Specific devices such as Ethernet are in device libraries. Users may write and
link their own libraries. The modular implementation allows for smaller compilation units. ns-3 executable programs may be
built to either statically or dynamically link the libraries.
2.2 Use cases
To introduce the design of ns-3 we first review design issues and usage models that have arisen with ns-2, and mention trends
in simulation use within the networking research community.
• Model extensibility. Most research users want to extend the simulator by writing new simulation scripts, modifying
existing models, or writing new models. To facilitate model modification, ns-3 continues the use of object-oriented
design with polymorphic classes, allowing users to subclass the aspects that they wish to modify. To facilitate the
addition of new models, ns-3 adopts a component-based architecture for compile-time or run-time addition of new
models, interface aggregation, and encapsulation, without requiring modification of the base models of ns-3.
5