NS internals
Velibor Markovski
Communication Networks Laboratory
School of Engineering Science
Simon Fraser University

Software architecture
Split programming model
(C++ and OTcl)
Simulation kernel ® C++
Simulation definition,
configuration and control ® OTcl
Tradeoff: performance vs. flexibility

Class mirroring
OTcl class hierarchy
C++ class hierarchy

Simple script
Two nodes
CBR traffic from source to destination
UDP used as transport protocol

Simple script

Simple script - initialization

Simple script - initialization

Simple script - initialization

Simple script - initialization

Simple script - initialization

Simple script - initialization

Simple script – node creation

Simple script – link creation

Simple script – setting up source

Simple script – setting up sink

Simple script – connecting nodes

Simple script – schedule “at” events

Event scheduler

Initial events

Initial and follow-up events

Initial and follow-up events

Scheduler’s main functions
Schedule events at certain time
Insert events in the list
Deque events from the list
Dispatch dequed events
Call appropriate event handler

Back to our example

Back to our example

Back to our example

Back to our example

Even more details…

Slide 28

Complex software structure
Approximate numbers:
27K lines of C++ code (ns-2.1b5)
12K lines of OTcl code
18K lines of test suites and examples

Why simulators at all?
Inexpensive
Flexible:
with scenario generation
with link speeds
with topologies
Access to ALL data

Alternatives to simulation
Testbeds
Emulation (testbed-simulator mix)
Live Internet tests

Slide 32