ns-3 Key Abstracitons
- Node
- Host (end system), switch, router in the Internet
- Basic computing device abstraction
- Application
- A user program that generates some activities to be simulated
- NS-3 applications run on ns-3 Nodes to drive simulations
- Channel
- Medium connected by nodes over which data flows transmitted
- New device
- Like a specific kind of network cable and a hardware device, Network Interface Cards
- NICs are controlled using the software driver, net devices
- Provides mothods for managing connection to Node and Channel
- Topology helpers
- Topology helpers make ns-3 core operations as easy as possible
- Create a NetDevice, add an address, install that net device on a Node, configure the node's protocol stack and connect the NetDevice to a Channel
- NodeContainer: Provide a convenient way to create, manage and access any Node object
- PoinToPointHelper: Configure and connect PointToPointNetDevice and PointToPointChannel objects. Set DataRate on NetDevices and Delay on Channel
- NetDeviceContainer: To install NetDevice at the nodes and create Channel between the nodes
- InternetStackHelper: To install an Internet Stack (TCP, UDP, IP, etc.) on each of the nodes in the node container
- Ipv4AddressHelper: Manage the allocation of IP address and assign addresses to the devices using Ipv4InterfaceContainer
ns-3 Script
- Module Includes
- Namespace declaration
- Node Creation
- Set Device & Channel Attribute
- Install Net Device
- Install Network Stack
- Assigning IP Address
- Creating Application
- Creating Application Container
- Running and Stopping Simulator
- Destroying Simulator
- 아래의 명령어로 scratch directory에 있는 myfirst.cc simulator를 실행시킨 결과
./waf --run scratch/myfirst
- ./waf를 할 때는 ns-3.29 directory에서 실행해야함 (build directory가 있는 경로에서)
Logging Modules
- 아래와 같은 형식으로 Logging component를 정의함
NS_LOG_COMPONENT_DEFINE ("ScratchSimulator") //예시
- 아래의 명령어를 통해 logging을 enable 해줘야함
./waf configure --build-profile=debug
Running a Simulation
cd ns-allinone-3.29/ns-3.29
./waf --run <simulation scenario(script) filename>
Other Way for Enabling Log Components
export NS_LOG=UdpEchoClientApplication=level_all
./waf --run scratch/myfirst
Set Log Prefix
export 'NS_LOG=UdpEchoClientApplication=level_all|prefix_time'
./waf --run scratch/myfirst
Store Logs in a File
export 'NS_LOG=*=level_all|prefix_func|prefix_time'
./waf --run scratch/myfirst > log.out 2>&1
Initializing Logging Module
export NS_LOG=
./waf --run scratch/myfirst
Adding Logging to code
LogComponentEnable ("FirstScriptExample", LOG_LEVEL_INFO);
LogComponentEnable ("UdpEchoClientApplication", LOG_LEVEL_INFO);
LogComponentEnable ("UdpEchoServeerApplication", LOG_LEVEL_INFO);
NS_LOG_INFO ("Creating Topology");
NodeContainer nodes;
nodes.Create(2);
./waf --run scratch/myfirst