ns-3를 이용한 네트워크 시뮬레이션 응용 단기 강좌

Session 6. DCE를 활용한 실제 시스템과 NS-3 연동 이규진 [email protected] Multimedia and Wireless Networking Lab. (MWNL) Seoul National University

1

Overview

2

NS-3 DCE • DCE (Direct Code Execution) – A framework provides facilities to execute within NS-3 without modifying source code • Existing user-space applications/protocols • Kernel-space network protocols

– Instead of using pseudo applications provided NS-3, we can use existing application used in real environment • OnoffApplication (by NS-3)  iperf

– https://www.nsnam.org/overview/projects/direct-code-execution/

3

NS-3 DCE • Why use DCE? – To create a miniature network in a single node – To debug and test your code within a controlled environment – Not to maintain multiple implementations of a single protocol, or re-implement complicated protocols

4

NS-3 Basic Simulation Model Node

Node

Application Application

Application Application

Protocol stack

Protocol stack

Packet(s)

Node NetDevice NetDevice

Channel Channel

5

NetDevice NetDevice

DCE Simulation Model Node

Node Application Application

Real Application or NS-3 Application Application Application POSIX Socket or NS-3 Socket API

Protocol stack

Linux Kernel or NS-3 TCP/IP Stack

Protocol stack

NS-3 NetDevice & Channel NetDevice NetDevice

Channel Channel

6

NetDevice NetDevice

Features • Functional realism – Run real code – POSIX apps, kernel network stacks

• Timing realism – Ns-3 integration (virtual clock)

• Debug ability – All in user-space – Single-process virtualization 7

DCE Architecture

8

Possible Combinations with DCE User-space application

Network protocol

application

application

ns3::application

POSIX socket

POSIX socket

NS-3 socket

DCE

DCE

DCE

ns3 TCP/IP stack

Linux kernel

Linux kernel

ns3::Netdevice

ns3::Netdevice

ns3::Netdevice

(b) DCE-Linux

(c) DCE-cradle

(a) DCE-NS3 Application Application Protocol stack NetDevice NetDevice

Application Application Protocol stack

Packet(s) Channel Channel 9

NetDevice NetDevice

Class • Class::DceManagerHelper – Tool to set parameter and to install DceManager on the NS-3 nodes where you plan to run real application

• Class::LinuxStackHelper – Configure parameters of Linux kernel when we are using DCE-Linux or DCE-cradle

• Class::DceApplicationHelper – Define which application will run within NS-3 by setting name of binary executable file 10

Supported Features • Simulation under – NS-3 TCP/IP stack + NS-3 socket-based application (Default NS-3) – NS-3 TCP/IP stack + POSIX socket-based application (DCE-NS3) – Linux kernel + POSIX socket-based application (DCE-Linux) – Linux kernel + NS-3 socket-based application (DCE-cradle)

• Tested Environment – Ubuntu 13.10 / 13.04 / 12.10 / 12.04 / 10.04 64bit – Fedora 18 32bit / CentOS 6.2 64bit

11

Supported Features • Tested Application – iperf – ping/ping6 – ip (iproute2 package) – http server (thttpd) – torrent (libtorrent from rasterbar + opentracker) – CCNx, Quagga, Mobilt IPv6 daemon, etc.

12

Install NS-3 DCE

13

Installation • Prerequisites – $ sudo apt-get install mercurial

• Download Bake using Mercurial and set some variables – $ hg clone http://code.nsnam.org/bake bake – $ export BAKE_HOME=`pwd`/bake – $ export PATH=$PATH:$BAKE_HOME – $ export PYTHONPATH=$PYTHONPATH:$BAKE_HOME

14

Installation • Check required modules – $ bake.py check • If some modules are NOT OK, install them (e.g., sudo apt-get install cvs)

• Create a directory for DCE and install it using bake – $ mkdir dce – $ cd dce – $ bake.py configure -e dce-linux-1.7 • dce-linux-1.7 is the DCE version 1.7 module

– $ bake.py download – $ bake.py build

15

Simulation Example

16

How To Do Simulation • Where to put your NS-3 script ‘example.cc’ workspace

– /dce/source/ns-3-dce/myscripts/example.cc bake

dce

• How to run script ‘example.cc’ source

– ./waf --run example (Under /dce/source/ns-3-dce/)

ns-3-dce

• How to see the standard output of node xx – cat files-xx/var/log/*/stdout (Under /dce/source/ns-3-dce/)

17

myscripts

Iperf • Tool to measure TCP and UDP bandwidth – Report bandwidth, delay, jitter, datagram loss – https://iperf.fr

• Command line option – -c: client (e.g., iperf –c [destination IP address]) – -s: server (e.g., iperf -s) – -p: port number (e.g., iperf –p 54321) – -u: use udp (e.g., iperf -u) – -b: bandwidth (e.g., iperf –c –u –b 1m) – -i: report interval in second (e.g., iperf –i 1) – -t: operating duration in second (e.g., iperf –t 10) 18

Iperf • E.g., tuning a UDP connection

Node 2: Server

Node 1: Client

19

Example 1 • Example 1: DCE-NS3 – ex1-dce-ns3-sol.cc – ./waf --run ex1-dce-ns3-sol (Under /dce/source/ns-3-dce/) application

application POSIX socket

DCE ns3 TCP/IP stack ns3::Netdevice

POSIX socket

UDP 10Mb/s

Node 1: Client IP: 10.1.1.1

Point to Point 20Mb/s, 2ms

20

DCE

Node 2: Server IP: 10.1.1.2

ns3 TCP/IP stack ns3::Netdevice

Example 1 Code (1/5) • Node creation NodeContainer nodes; nodes.Create (2);

• P2P channel creation PointToPointHelper pointToPoint; pointToPoint.SetDeviceAttribute ("DataRate", StringValue ("20Mbps")); pointToPoint.SetChannelAttribute ("Delay", StringValue ("2ms"));

• Netdevice creation NetDeviceContainer devices; devices = pointToPoint.Install (nodes);

• DceManager creation DceManagerHelper dceManager; dceManager.Install (nodes);

21

Example 1 Code (2/5) • NS-3 stack creation InternetStackHelper stack; stack.Install (nodes);

• IP address setting Ipv4AddressHelper address; address.SetBase ("10.1.1.0", "255.255.255.0"); Ipv4InterfaceContainer interfaces = address.Assign (devices);

• DceApplicationHelper creation ApplicationContainer apps; DceApplicationHelper dce; dce.SetStackSize (1<<20);

22

Example 1 Code (3/5) • Iperf application for STA 1 dce.SetBinary ("iperf"); dce.ResetArguments (); dce.ResetEnvironment (); dce.AddArgument ("-c"); dce.AddArgument ("10.1.1.2"); dce.AddArgument ("-p"); dce.AddArgument ("54321"); dce.AddArgument ("-u"); dce.AddArgument ("-b"); dce.AddArgument ("10m"); dce.AddArgument ("-t"); dce.AddArgument ("10"); dce.AddArgument ("-i"); dce.AddArgument ("1"); apps = dce.Install (nodes.Get (0)); apps.Start (Seconds (1.5));

23

Example 1 Code (4/5) • Iperf application for STA 2 dce.SetBinary ("iperf"); dce.ResetArguments (); dce.ResetEnvironment (); dce.AddArgument ("-s"); dce.AddArgument ("-p"); dce.AddArgument ("54321"); dce.AddArgument ("-u"); dce.AddArgument ("-i"); dce.AddArgument ("1"); apps = dce.Install (nodes.Get (1)); apps.Start (Seconds (1.0));

24

Example 1 Code (5/5) • Enable pcap pointToPoint.EnablePcapAll ("ex1-dce-ns3", false);

• Simulator run Simulator::Stop (Seconds(20.0)); Simulator::Run (); Simulator::Destroy ();

25

Example 1 • Result UDP 10Mb/s

Node 1: Client IP: 10.1.1.1

Point to Point 20Mb/s, 2ms

cat files-0/var/log/*/stdout

Node 2: Server IP: 10.1.1.2

cat files-1/var/log/*/stdout 26

Example 2 • Example 2: DCE-Linux – ex2-dce-linux-sol.cc – ./waf --run ex2-dce-linux-sol (Under /dce/source/ns-3-dce/)

application

UDP 10Mb/s

POSIX socket

DCE Linux kernel

application

Node 1: Client IP: 10.1.1.1

Point to Point 20Mb/s, 2ms

POSIX socket

Node 2: Server IP: 10.1.1.2

DCE Linux kernel ns3::Netdevice

ns3::Netdevice

27

Example 2 Code (1/6) • Node creation NodeContainer nodes; nodes.Create (2);

• P2P channel creation PointToPointHelper pointToPoint; pointToPoint.SetDeviceAttribute ("DataRate", StringValue ("20Mbps")); pointToPoint.SetChannelAttribute ("Delay", StringValue ("2ms"));

• Netdevice creation NetDeviceContainer devices; devices = pointToPoint.Install (nodes);

28

Example 2 Code (2/6) • DceManager creation DceManagerHelper dceManager; dceManager.SetNetworkStack ("ns3::LinuxSocketFdFactory", "Library", StringValue ("liblinux.so")); dceManager.Install (nodes);

• Linux stack LinuxStackHelper stack; stack.Install (nodes);

• IP address setting Ipv4AddressHelper address; address.SetBase ("10.1.1.0", "255.255.255.0"); Ipv4InterfaceContainer interfaces = address.Assign (devices);

29

Example 2 Code (3/6) • DceApplicationHelper creation ApplicationContainer apps; DceApplicationHelper dce; dce.SetStackSize (1<<20);

30

Example 2 Code (4/6) • Iperf application for STA 1 dce.SetBinary ("iperf"); dce.ResetArguments (); dce.ResetEnvironment (); dce.AddArgument ("-c"); dce.AddArgument ("10.1.1.2"); dce.AddArgument ("-p"); dce.AddArgument ("54321"); dce.AddArgument ("-u"); dce.AddArgument ("-b"); dce.AddArgument ("10m"); dce.AddArgument ("-t"); dce.AddArgument ("10"); dce.AddArgument ("-i"); dce.AddArgument ("1"); apps = dce.Install (nodes.Get (0)); apps.Start (Seconds (1.5));

31

Example 2 Code (5/6) • Iperf application for STA 2 dce.SetBinary ("iperf"); dce.ResetArguments (); dce.ResetEnvironment (); dce.AddArgument ("-s"); dce.AddArgument ("-p"); dce.AddArgument ("54321"); dce.AddArgument ("-u"); dce.AddArgument ("-i"); dce.AddArgument ("1"); apps = dce.Install (nodes.Get (1)); apps.Start (Seconds (1.0));

32

Example 2 Code (6/6) • Enable pcap pointToPoint.EnablePcapAll ("ex2-dce-linux", false);

• Simulator run Simulator::Stop (Seconds(20.0)); Simulator::Run (); Simulator::Destroy ();

33

Example 2 • Result UDP 10Mb/s

Node 1: Client IP: 10.1.1.1

Point to Point 20Mb/s, 2ms

cat files-0/var/log/*/stdout

Node 2: Server IP: 10.1.1.2

cat files-1/var/log/*/stdout 34

Example 3 • Example 3: DCE-cradle – ex3-dce-cradle-sol.cc – ./waf --run ex3-dce-cradle-sol (Under /dce/source/ns-3-dce/)

ns3::application

UDP 10Mb/s

NS-3 socket

DCE Linux kernel

ns3::application

Node 1: Client IP: 10.1.1.1

Point to Point 20Mb/s, 2ms

ns3::Netdevice

NS-3 socket

Node 2: Server IP: 10.1.1.2

DCE Linux kernel ns3::Netdevice

35

Example 3 Code (1/5) • Node creation NodeContainer nodes; nodes.Create (2);

• P2P channel creation PointToPointHelper pointToPoint; pointToPoint.SetDeviceAttribute ("DataRate", StringValue ("20Mbps")); pointToPoint.SetChannelAttribute ("Delay", StringValue ("2ms"));

• Netdevice creation NetDeviceContainer devices; devices = pointToPoint.Install (nodes);

36

Example 3 Code (2/5) • DceManager creation DceManagerHelper dceManager; dceManager.SetNetworkStack ("ns3::LinuxSocketFdFactory", "Library", StringValue ("liblinux.so")); dceManager.Install (nodes);

• Linux stack LinuxStackHelper stack; stack.Install (nodes);

• IP address setting Ipv4AddressHelper address; address.SetBase ("10.1.1.0", "255.255.255.0"); Ipv4InterfaceContainer interfaces = address.Assign (devices);

37

Example 3 Code (3/5) • Application container ApplicationContainer apps;

• OnOff application for STA1 OnOffHelper onoff = OnOffHelper ("ns3::LinuxUdpSocketFactory", InetSocketAddress (interfaces.GetAddress (1), 54321)); onoff.SetAttribute ("OnTime", StringValue ("ns3::ConstantRandomVariable[Constant=1]")); onoff.SetAttribute ("OffTime", StringValue ("ns3::ConstantRandomVariable[Constant=0]")); onoff.SetAttribute ("DataRate", StringValue ("10Mbps")); apps = onoff.Install (nodes.Get (0)); apps.Start (Seconds (1.0)); apps.Stop (Seconds (11.0));

38

Example 3 Code (4/5) • PacketSink application for STA 2 PacketSinkHelper sink = PacketSinkHelper ("ns3::LinuxUdpSocketFactory", InetSocketAddress (Ipv4Address::GetAny (), 54321)); apps = sink.Install (nodes.Get (1)); apps.Start (Seconds (0.5));

• Enable pcap pointToPoint.EnablePcapAll ("ex3-dce-cradle", false);

• Simulator run Simulator::Stop (Seconds(20.0)); Simulator::Run ();

39

Example 3 Code (5/5) • Print result Ptr pktsink; pktsink = apps.Get (0)->GetObject (); std::cout << "Total Rx(0) = " << pktsink->GetTotalRx () << " bytes"; std::cout << std::endl;

• Destroy simulator Simulator::Destroy ();

40

Example 3 • Result UDP 10Mb/s

Node 1: Client IP: 10.1.1.1

Point to Point 20Mb/s, 2ms

Node 2: Server IP: 10.1.1.2

Total Rx(0) = 12499968 bytes

41

Example 4 • Example 4: DCE-NS3 – Skeleton code: ex4-dce-ns3-skel.cc – Solution code: ex4-dce-ns3-sol.cc AP application

10.1.1.1 (0,0,0) application

UDP 10Mb/s

POSIX socket

POSIX socket

DCE ns3 TCP/IP stack ns3::Netdevice

STA 1 10.1.1.2 (-15,15,0)

802.11g JakesPropagation 6Mb/s

42

DCE

STA 2 10.1.1.3 (-15,-15,0)

ns3 TCP/IP stack ns3::Netdevice

Example 4 • Result UDP 10Mb/s

STA 1: Client IP: 10.1.1.2

802.11g 6Mb/s

cat files-1/var/log/*/stdout

STA 2: Server IP: 10.1.1.3

cat files-2/var/log/*/stdout 43

Example 5 • Example 5: DCE-Linux – Skeleton code: ex5-dce-linux-skel.cc – Solution code: ex5-dce-linux-sol.cc AP

10.1.1.1 (0,0,0)

UDP 10Mb/s application

application

POSIX socket

POSIX socket

DCE Linux kernel ns3::Netdevice

STA 1 10.1.1.2 (-15,15,0)

802.11g JakesPropagation 6Mb/s

44

DCE

STA 2 10.1.1.3 (-15,-15,0)

Linux kernel ns3::Netdevice

Example 5 • Result UDP 10Mb/s

STA 1: Client IP: 10.1.1.2

802.11g 6Mb/s

cat files-1/var/log/*/stdout

STA 2: Server IP: 10.1.1.3

cat files-2/var/log/*/stdout 45

Example 6 • Example 6: DCE-cradle – Skeleton code: ex6-dce-cradle-skel.cc – Solution code: ex6-dce-cradle-sol.cc AP ns3::application

10.1.1.1 (0,0,0) ns3::application

UDP 10Mb/s

NS-3 socket

NS-3 socket

DCE Linux kernel ns3::Netdevice

STA 1 10.1.1.2 (-15,15,0)

802.11g JakesPropagation 6Mb/s

46

DCE

STA 2 10.1.1.3 (-15,-15,0)

Linux kernel ns3::Netdevice

Example 6 • Result UDP 10Mb/s

STA 1: Client IP: 10.1.1.2

802.11g 6Mb/s

STA 2: Server IP: 10.1.1.3

Total Rx(0) = 2561536 bytes

47

Example 7 • How to use my binary – $ gcc -fPIC -c simple-socket.c (C code name: simple-socket) – $ gcc -o simple-socket -pie -rdynamic simple-socket.o – $ cp simple-socket WORKSPACE/dce/source/ns-3-dce/build/bin_dce/

48

Example 7 • Example – ex7-new-app-sol.cc – ./waf --run ex7-new-app-sol (Under /dce/source/ns-3-dce/)

• Result cat files-0/var/log/*/stdout cat files-1/var/log/*/stdout

49

50

Research Issues in Enterprise WiFi

Protocol stack. NetDevice. NetDevice. Channel. Channel. 6. Node. POSIX Socket or NS-3 Socket API. Linux Kernel or NS-3 TCP/IP Stack. NS-3 NetDevice & Channel ..... Skeleton code: ex4-dce-ns3-skel.cc. – Solution code: ex4-dce-ns3-sol.cc. POSIX socket. DCE ns3::Netdevice application ns3 TCP/IP stack. POSIX socket.

601KB Sizes 2 Downloads 217 Views

Recommend Documents

methodological issues in psychopathology research
Although each proposed solution would decrease the comorbid-. 376 SHER & ...... sonic vocalization in rat pups following isolation from their mother and/or.

pdf-14110\leadership-in-the-digital-enterprise-issues-and ...
... more apps... Try one of the apps below to open or edit this item. pdf-14110\leadership-in-the-digital-enterprise-issues-and-challenges-by-pak-yoong.pdf.

Ethical Issues in Field-Based Criminological Research in Canada
Considering that all social science research with Canadian university affiliation ... committed in the name of science during the Second World War by a group of German .... posters and websites could be used to allow potential participants to ...

Ethical Issues in Field-Based Criminological Research in Canada
2007 International Journal of Criminal Justice Sciences. All rights reserved. Under a ..... MA: Northeastern University Press. Berg, B. L. (2004). Qualitative ...

Using Annotations in Enterprise Search - Research at Google
With more and more companies having a significant part of their ..... 10. EA = Explicit Annotations, IA = Implicit Annotations. Adding explicit annotations to the ...

Foundational Issues in TouchSurface Stroke ... - Research at Google
The iPhone Gesture Interface. Graffiti and Unistrokes ... 4 The Usability of Stroke Gesture as an Interaction Medium: Early Research Issues. 5 The Motor Control ... takeaway conclusions, and forwardlooking calls to actions. First, stroke .... By way

pdf-2329\reflexivity-and-qualitative-research-current-issues-in ...
Try one of the apps below to open or edit this item. pdf-2329\reflexivity-and-qualitative-research-current-issues-in-qualitative-research-book-1-by-jane-gilgun.pdf.

RF-EMF Research to Ipads an WiFi devices.pdf
Page 1 of 2. RF Studies Reporting Biological Effects and Adverse Health Effects for. Exposures Similar to Wireless Devices (iPads and WI-FI). Cindy Sage, Sage ...

Dr David Carpenter - WiFi in Schools UK
Jan 28, 2011 - There is clear and strong evidence that intensive use of cell phones increases the risk of brain cancer, tumors of the auditory nerve and cancer ...

Dr David Carpenter - WiFi in Schools UK
Jan 28, 2011 - for the New York Powerline Project in the 1980s, a program of research ... There is clear and strong evidence that intensive use of cell phones ...

research evidence on race discrimination - Black Enterprise
production (often located within the creative department), and “overhead” departments such as accounting and human resources. Some full service agencies seek to serve a broad range of target audiences (such as multicultural, youth, or high income

The Mormon Gender Issues Survey: Research Summary.pdf ...
Page 1 of 33. The Mormon Gender Issues Survey: Research Summary. Prepared by The Mormon Gender Issues Survey Group. December 9, 2015. Researchers (listed alphabetically):. Brent D. Beal. Heather K. Olson Beal. Jennifer Beu. Eric Canen. Caitlin Carrol

research evidence on race discrimination - Black Enterprise
the prevalence of conscious racism and led to substantial increases in the number of. African Americans holding better-paid, more prestigious, more powerful positions in many industries. Reflecting these developments, public opinion polls today repor

Ad Exchanges: Research Issues
research problems in auction theory, optimization and game theory. The goal is ..... http calls to ai's servers, and awaiting (bi,di) to be determined by the network. ... budget of B. Design an online algorithm for E that for each incoming call. (wj,

The Mormon Gender Issues Survey: Research Summary.pdf ...
Lindsay Nielson. Michael Nielsen. Nancy Ross ..... Our shared interest in gender dynamics in the LDS Church led us to field two surveys in the. Fall of 2014.

Cheap WIFI Antenna HF-SLB100390065 for WIFI Module F18909.pdf
Cheap WIFI Antenna HF-SLB100390065 for WIFI Module F18909.pdf. Cheap WIFI Antenna HF-SLB100390065 for WIFI Module F18909.pdf. Open. Extract.

PRIVATE WiFi Online Help
It is virtually impossible to break into a guarded data center with biometric scanners and .... Customer Support by phone, call (860) 615-9896. •. Email support is ...