Académique Documents
Professionnel Documents
Culture Documents
Week 1 Linux, vi editor command Introduction and install of NS-3 Structure of NS-3 Output system of NS-3 Week 2 Transport layer (TCP, UDP) Transport layer model in NS-3 Multiple levels of tracing system System performance analysis using tracing system Week 3 MAC protocol simulation (CSMA) LAN topology with switch Week 4 Wireless LAN model in NS-3 Analysis of wired and wireless network topology Week 5 Wireless LAN link adaptation Rate adaptation in NS-3
Environment
Server: 5 servers ID: Check ID table in next page Default password: last 4 numbers of your student number 5 times Submit: main file, simulation result, report Submit homework to TAs e-mail (Title: [NS-3]) Based on preparation for class Every week
Attendance (10%), Quiz (20%), In-class (30%), Homework (40%)
Homework
Quiz
Assessment
ID Table
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 2011-23360 2002-12318 2003-11993 2003-12060 2003-12832 2005-11823 2007-11707 2007-11816 2007-15611 2007-11547 2007-11548 2007-11549 2008-11585 2008-11632 2008-11969 ID ns23360 ns12318 ns11993 ns12060 ns12832 ns11823 ns11707 ns11816 ns15611 ns11547 ns11548 ns11549 ns11585 ns11632 ns11969 cwpark auditor1 auditor2 auditor3 auditor4 auditor5 Server 1 1 1 1 2 2 2 2 3 3 3 3 4 4 4 4 5 5 5 5 5
Server1: 147.46.143.236 Server2: 147.46.143.237 Server3: 147.46.143.238 Server4: 147.46.143.239 Server5: 147.46.243.250
Requisitions
Basic usage of Linux and understanding of C++ Basic knowledge about network
Contents
For NS-3 beginners Basic structure of NS-3 Usage of NS-3 functions and evaluating network topology
Analytical model
Unrealistic - Requires a lot of assumptions Hard to solve and validate (ex. NP hard problem). Cheap Relatively short run time depending on the algorithm Realistic Expensive Hard to implement the proposed scheme Relatively realistic Relatively cheap (needs only one simulation machine) Easy to implement compared to real measurement Run time depends on the proposed protocol
Real measurement
Simulation
Simulation Good
Very cheap Easy
Bad
Very cheap Hard
Week 1
- Introduction to NS-3 -
NS-3
Ns-3 is targeted at networking research.
Discrete event simulator
Layered architecture
NS-3 status
Periodic update
Supporting platform
NS-3 components
Ns-3 simulator Pre-processing
Traffic / topology generation Alignment with real systems (sockets, device driver interfaces)
Post-processing
Ns-3 output file (trace file) analysis Throughput, delay, jitter, drop Various tracing system Graph xgraph, gnuplot
ns-3.12.1
nsc-0.5.2
Pybindgen0.15.0.795
... ...
bindings
build
examples
...
src
error-model
csma
mobility
network
...
...
Vi setting
set nu syntax on set autoindent set cindent set hls set showmatch set smartindent set tabstop=4
ns-allinone-3.12.1.tar.bz2
Building
Done !
Setting environment
vi vi vi vi
Simple Example
cd ns-allinone-3.12.1/ns-3.12.1 /ns-3.12.1$ ./waf --run scratch/scratch-simulator Output
Key Abstractions
1.Node
Host, end system in the Internet Basic computing device abstraction Represented in C++ by the class Node
2.Application
A User program that generates some activity to be simulated Ns-3 applications run on ns-3 Nodes to drive simulations Represented in C++ by the class Application
3.Channel
Medium connected by nodes over which data flows Represented in C++ by the class Channel Ex) CsmaChannel, PointToPointChannel, WifiChannel
Key Abstractions
4. Net device
Like a specific kind of network cable and a hardware device (Network Interface Cards; NICs) NICs are controlled using the software driver, net devices Represented in C++ by the class NetDevice Provide methods for managing connections to Node and Channel Ex) CsmaNetDevice (work with CsmaChannel) WifiNetDevice (work with WifiChannel)
5. 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 nodes protocol stack and connet the NetDevice to a Channel
Key Abstractions
5. Topology Helpers
any Node object
I. NodeContainer: Provide a convenient way to create, manage and access II.PointToPointHelper: Configure and connect PointToPointNetDevice
Protocol stack
Packet(s)
Protocol stack
Node
NetDevice NetDevice
Channel
Channel
Simulation procedure
1. Turning on logging
4. Running simulator
Simulation procedure
-1. Turning on logging -
NS_LOG_COMPONENT_DEFINE ( name )
Simulation procedure
- 2.Creating Network Topology -
Topology Helpers
NodeContainer
n: # of Nodes
Simulation procedure
- 2.Creating Network Topology PointToPointHelper
void PointToPointHelper::SetDeviceAttribute (name, value) void PointToPointHelper::SetChannelAttribute (name, value) NetDeviceContainer PointToPointHelper::Install (NodeContainer c)
NetDeviceContainer
NetDeviceContainer Ptr<NetDevice>
Example
PointToPointHelper pointToPoint; pointToPoint.SetDeviceAttribute ("DataRate", StringValue ("5Mbps")); pointToPoint.SetChannelAttribute ("Delay", StringValue ("2ms")); NetDeviceContainer devices; devices = pointToPoint.Install (nodes);
Simulation procedure
- 3.Creating application (traffic) UdpEchoServerHelper
UdpEchoServerHelper::UdpEchoServerHelper ( port ) ApplicationContainer UdpEchoServerHelper::Install (NodeContainer c ) UdpEchoClientHelper::UdpEchoClientHelper ( ip, port ) void UdpEchoClientHelper::Setattribute ( name, value ) ApplicationContainer UdpEchoClientHelper::Install (NodeContainer c )
UdpEchoServerHelper echoServer (9); ApplicationContainer serverApps = echoServer.Install (nodes.Get (1)); serverApps.Start (Seconds (1.0)); serverApps.Stop (Seconds (10.0)); UdpEchoClientHelper echoClient (interfaces.GetAddress (1), 9); echoClient.SetAttribute ("MaxPackets", UintegerValue (1)); echoClient.SetAttribute ("Interval", TimeValue (Seconds (1.))); echoClient.SetAttribute ("PacketSize", UintegerValue (1024)); ApplicationContainer clientApps = echoClient.Install (nodes.Get (0)); clientApps.Start (Seconds (2.0)); clientApps.Stop (Seconds (10.0));
UdpEchoClientHelper
Example
Simulation procedure
- 4.Running simulator-
Start Simulator
Simulator::Run ();
Destroy Simulator
Simulator::Destroy ();
using namespace ns3; NS_LOG_COMPONENT_DEFINE ("FirstScriptExample"); int main (int argc, char *argv[]) { LogComponentEnable("UdpEchoClientApplication", LOG_LEVEL_INFO); LogComponentEnable("UdpEchoServerApplication", LOG_LEVEL_INFO); NodeContainer nodes; nodes.Create (2); PointToPointHelper pointToPoint; pointToPoint.SetDeviceAttribute ("DataRate", StringValue ("5Mbps")); pointToPoint.SetChannelAttribute ("Delay", StringValue ("2ms")); NetDeviceContainer devices; devices = pointToPoint.Install (nodes);
UdpEchoClientHelper echoClient (interfaces.GetAddress (1), 9); echoClient.SetAttribute ("MaxPackets", UintegerValue (1)); echoClient.SetAttribute ("Interval", TimeValue (Seconds (1.))); echoClient.SetAttribute ("PacketSize", UintegerValue (1024));
ApplicationContainer clientApps = echoClient.Install (nodes.Get (0)); clientApps.Start (Seconds (2.0)); clientApps.Stop (Seconds (10.0)); Simulator::Run (); Simulator::Destroy (); return 0; }
Output Systems
1. Logging Modules 2. Command Line Arguments 3. Tracing System
Logging Module
Output messages from modules Useful when debugging NS_LOG environment variable NS_LOG_FUNCTION level information Verbosity level
NS NS NS NS NS NS NS NS
ERROR Log error messages; WARN Log warning messages; DEBUG Log relatively rare debugging messages; INFO Log informational messages about program progress; FUNCTION Log a message describing each function called; LOGIC Log messages describing logical flow within a function; ALL Log everything. UNCOND Log the associated message unconditionally.
Logging Module
Example 1
Output:
build finished successfully (0.404s) UdpEchoClientApplication:UdpEchoClient() UdpEchoClientApplication:SetDataSize(1024) UdpEchoClientApplication:StartApplication() UdpEchoClientApplication:ScheduleTransmit() UdpEchoClientApplication:Send() Sent 1024 bytes to 10.1.1.2 Received 1024 bytes from 10.1.1.1 UdpEchoClientApplication:HandleRead(0x6241e0, 0x624a20) Received 1024 bytes from 10.1.1.2 UdpEchoClientApplication:StopApplication() UdpEchoClientApplication:DoDispose() UdpEchoClientApplication:~UdpEchoClient()
Logging Module
Example 2
Output:
0s UdpEchoClientApplication:UdpEchoClient() 0s UdpEchoClientApplication:SetDataSize(1024) 2s UdpEchoClientApplication:StartApplication() 2s UdpEchoClientApplication:ScheduleTransmit() 2s UdpEchoClientApplication:Send() 2s UdpEchoClientApplication:Send(): Sent 1024 bytes to 10.1.1.2 Received 1024 bytes from 10.1.1.1 2.00737s UdpEchoClientApplication:HandleRead(0x9aead30, 0x9aeb378) 2.00737s UdpEchoClientApplication:HandleRead(): Received 1024 bytes from 10.1.1.2 10s UdpEchoClientApplication:StopApplication() UdpEchoClientApplication:DoDispose() UdpEchoClientApplication:~UdpEchoClient()
Logging Module
Example 3
It prints out all of the logging ./waf -run scratch/myfirst > log.out 2>&1 2>&1 : stderr > stdout
Example
Example
./waf --run "scratch/myfirst PrintHelp ./waf -run scratch/myfirst PrintAttributes=ns3::PointToPointNetDevice ./waf --run scratch/myfirst -ns3::PointToPointNetDevice::DataRate=5Mbps ns3::PointToPointChannel::Delay=2ms
Example
int main (int argc, char *argv[]) { uint32_t nPackets =1; CommandLine cmd; cmd.AddValue("nPackets", "Number of packets to echo", nPackets); Cmd.Parse (argc, argv);
Tracing System
Tracing is a structured form of simulation output
Tracing System
ASCII Tracing
Output (myfirst.tr)
+ 2 /NodeList/0/DeviceList/0/$ns3::PointToPointNetDevice/TxQueue/Enqueue ns3::PppHeader (Point-to-Point Protocol: IP (0x0021)) ns3::Ipv4Header (tos 0x0 ttl 64 id 0 protocol 17 offset 0 flags [none] length: 1052 10.1.1.1 > 10.1.1.2) ns3::UdpHeader (length: 1032 49153 > 9) Payload (size=1024) - 2 /NodeList/0/DeviceList/0/$ns3::PointToPointNetDevice/TxQueue/Dequeue ns3::PppHeader (Point-to-Point Protocol: IP (0x0021)) ns3::Ipv4Header (tos 0x0 ttl 64 id 0 protocol 17 offset 0 flags [none] length: 1052 10.1.1.1 > 10.1.1.2) ns3::UdpHeader (length: 1032 49153 > 9) Payload (size=1024)
Tracing System
Trace file format
00 01 02 03 04 05 06 07 08 09 10 + 2 /NodeList/0/DeviceList/0/$ns3::PointToPointNetDevice/TxQueue/Enqueue ns3::PppHeader ( Point-to-Point Protocol: IP (0x0021)) ns3::Ipv4Header ( tos 0x0 ttl 64 id 0 protocol 17 offset 0 flags [none] length: 1052 10.1.1.1 > 10.1.1.2) ns3::UdpHeader ( length: 1032 49153 > 9) Payload (size=1024)
Tracing System
PCAP Tracing
1024 1024
1024 1024
Tracing System
Reading output with Wireshark http://www.wireshark.org/download.html
3. Tracing System
Used to generate output for checking the operation and measure the system performance Use trace source and trace sink (we study the tracing system further in the 2nd class)
In-Class Assignment
1. Type the code from page 29 to 31 into scratch
folder using vi editor (its form should be ~.cc)
You have to 1. print out all of the logging into .out file 2. use AsciiTraceHelper 3. use PCAP Trace and 1. Check .pcap file both TCPDUMP and Wireshark
Homework
1. Checking the Protocol: PCAP Tracing
1.
2.
Example code should be latest version that contains all the contents we covered in the class Using the logging will be helpful
Report: _hw1.doc(or hwp) E-mail: jhkoo@mwnl.snu.ac.kr Dead line: 10 17 () 23:59 Delay is not allowed
References
Network Simulator
http://www.nsnam.org
NS-3 tutorial
http://www.nsnam.org/tutorials.html
NS-3 manual
Appendix
ls short listing of directory contents mkdir <directory name> make directory cd <path> - change directory rm r <directory name> - remove directory rm <filename> -remove file cp <filename1> <filename2> - copy grep search for a pattern in a file find - find a file
Reference: http://www.debianhelp.co.uk/commands.htm
i : enter insert mode escape : enter command mode dd : delete a line y : copy v : mark p: paste /: search :wq : save and quit
Reference http://www.eng.hawaii.edu/Tutor/vi.html