Download presentation
Presentation is loading. Please wait.
Published byRandolf Rogers Modified over 9 years ago
1
NETWORK SIMULATOR 3 Reporter: Chechieh Lin
2
O UTLINE Introduction NS3 vs. NS2 NS-3 Modules Key Abstractions A First ns-3 Script
3
I NTRODUCTION NS-3 is a new simulator, written from scratch Programming languages: C++, Python Manage: Mercurial Compile: Waf Project started around mid 2006
4
ns-3 tutorial March 2008 4 WAF KEY CONCEPTS For those familiar with autotools: configure ->./waf -d [optimized|debug] configure make ->./waf make test ->./waf check (run unit tests) Can run programs through a special waf shell./waf --run simple-point-to-point
5
NS3 VS. NS2(1)
6
NS3 VS. NS2(2)
7
NS-3 M ODULES
8
R ANDOM V ARIABLES Currently implemented distributions Uniform: values uniformly distributed in an interval Constant: value is always the same (not really random) Exponential: exponential distribution (poisson process)... Example import pylab import ns3 rng = ns3.NormalVariable(10.0, 5.0) x = [rng.GetValue() for t in range(100000)] pylab.hist(x, 100) pylab.show()
9
S MART P OINTERS Reduce bugs caused by the misuse of pointers while retaining efficiency Memory Leak
10
C ALLBACK Allow one piece of code to call a function without any specific inter-module dependency Example int (*pfi)(int arg) = 0 int MyFunction (int arg) {} pfi = MyFunction int result = (*pfi) (1234) int result = pfi (1234)
11
T RACING ns-3 provides a simple mechanism for logging and providing some control over output via Log Components only get the information which from core system required without having to change and recompile the core system.
12
P ACKET Packet objects used vertically in NS-3 to represent: Units of information sent and received by applications Information chunks of what will become a real packet Basic Usage Create empty packet Ptr packet = Create (); Create packet with 10 ”dummy” bytes Ptr packet = Create (10); Create packet with user data Ptr packet = Create (”hello”, 5); Copy a packet Ptr packet2 = packet1->Copy ()
13
S IMULATOR Time is not manipulated directly: the Time class Time class supports high precision 128 bit time values(nanosecond precision) Example Time t1 = Seconds (10); Time t2 = t1 + MilliSeconds (100); std::cout << t2.GetSeconds () << std::endl; // t2 = 10.1 Time now = Simulator::Now (); void MyCallback (T1 param1, T2 param2) {...}[...] Simulator::Schedule (Seconds (3), MyCallback, param1, param2);
14
K EY A BSTRACTIONS Node basic computing device abstraction Application acquires and uses the resources controlled run on ns-3 Nodes to drive simulations Channel provides methods for managing communication subnetwork objects and connecting nodes Net Device provides methods for managing connections to Node and Channel objects Topology Helpers combine many distinct operations into an easy to use model for your convenience
15
Application T HE BASIC MODEL Application Protocol stack Node NetDevice Application Protocol stack Node NetDevice Sockets-like API Channel Packet(s)
16
A F IRST NS -3 S CRIPT
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.