Presentation is loading. Please wait.

Presentation is loading. Please wait.

Network Simulator 2 성균관대학교 모바일컴퓨팅 연구실

Similar presentations


Presentation on theme: "Network Simulator 2 성균관대학교 모바일컴퓨팅 연구실"— Presentation transcript:

1 Network Simulator 2 성균관대학교 모바일컴퓨팅 연구실 http://csn.skku.ac.kr
안 혜환

2 목차 NS-2 역사 NS-2 설치 방법 NS-2 사용 목적 NS – 2 동작 원리 더욱 간단한 NS-2 동작원리
왜 2 가지 언어를 사용하는가? NS, Otcl, C++ 와의 관계 간단한 OTcl 과 복잡한 C++ NS, Otcl, C++ 의 디렉토리 위치 소스 코드 상속 구조 새로운 요소 추가시 컴파일 방법 이벤트 스케쥴러 간단한 예제 간단한 시뮬레이션 코드 구성방식 시뮬레이션 영상툴 NAM 성능평가를 위한 파일 추출 및 파일 내부 성능평가를 위한 파일로 부터 그래프 그리기 1/2 성능평가를 위한 파일로 부터 그래프 그리기 2/2 참고 자료

3 NS-2 역사 1989 년 REAL network simulator 의 세부연구로 시작.
여러 기관이 참여하는 (LBL, Xerox, PARC, UCB, USC/ISI) VINT (Virtual InterNetwork Testbed ) 프로젝트 를 통해 DARPA 의 지원으로 1995 NS 개발 시작 현재 NS 개발은 CONSER (Collaborative Simulation for Education and Research) 과 함께 NSF 를 통해 SAMAN (Simulation Agumented by Measurement and Analysis for Networks) 과 함게 DARPA 를 통해 지원하고 있다.

4 NS-2 설치 방법 [데모 시청] Windows, Linux, FreeBSD 등등 여러 플렛폼을 지원하나 리눅스를 권장.
다운받을화일 “ns-allinone-2.xx.tar.gz” 를 적당한 위치에 압출을 푼다. 압축을 푼 곳에 가서 “./install” 이라고 입력함으로 인해서 설치를 완료. GCC 버전 문제로 컴파일 에러가 날수 있으니 리눅스 에 설치시 wowlinux 7.3 이나 레드헷 7.3 버전에는 설치하는 것을 권장함 .

5 NS-2 사용 목적 왜 NS-2 를 사용하는가 ? - 공식적인 기관이나 단체가 연합하여 제작 - 매우 신뢰성 있는 성능평가
큰 사이즈의 네트워크 성능평가 - 실제로 성능평가 할 경우 매우 많은 경비와 시간이 소모 되나 시뮬레이션 툴을 사용함으로 인해서 경비절감 새로운 프로토콜 성능평가 - 새로운 프로토콜의 검증 - 자신의 새로운 아이디어 성능평가

6 NS – 2 동작 원리 1/2 Scheduling Otcl (내부동작) Event Otcl (외부동작) C++ (내부동작)
#Create a simulator object set ns [new Simulator] #Create four nodes set n0 [$ns node] set n1 [$ns node] set n2 [$ns node] set n3 [$ns node] #Create links between the nodes $ns duplex-link $n0 $n2 2Mb 10ms DropTail $ns duplex-link $n1 $n2 2Mb 10ms DropTail $ns duplex-link $n2 $n3 1.7Mb 20ms DropTail #Set Queue Size of link (n2-n3) to 10 $ns queue-limit $n2 $n3 10 #Setup a TCP connection set tcp [new Agent/TCP] $tcp set class_ 2 $ns attach-agent $n0 $tcp set sink [new Agent/TCPSink] $ns attach-agent $n3 $sink $ns connect $tcp $sink $tcp set fid_ 1 #Schedule events for the CBR and FTP agents $ns at 0.1 "$cbr start" $ns at 1.0 "$ftp start" $ns at 4.0 "$ftp stop" $ns at 4.5 "$cbr stop" #Call the finish procedure after 5 seconds of simulation time $ns at 5.0 "finish" #Run the simulation $ns run Otcl (내부동작) Event Otcl (외부동작) C++ (내부동작)

7 NS – 2 동작 원리 2/2 코드 작성시 반드시 알고 있어야 할 동작 원리 ns 내부에서 Thread 등의 사용 금지
Windows 코드 동작원리 NS 와 OS 간 코드 동작원리

8 더욱 간단한 NS-2 동작원리 확률 분포에 따른 주기적 패킷 생성 트래픽 생성기 코드 위치
Ns-allinonexxx/ ns-2.xx/tcl/lib/ ns-source.tcl

9 왜 2 가지 언어를 사용하는가? C++ 사용 이유 [ 패킷 처리] - 패킷 처리 프로세서 구현 - 자세한 프로토콜 구현 [ OSI 7 구현 ] - Otcl 에 비해서 매우 빠른 처리 속도 Otcl 사용 이유 [ 실시간 이벤트 처리 ] - 이미 구현된 C++ 객체를 사용 하는것 (ex: ns-mobilenode.tcl 부록 1) - 다양한 파라미터 설정 (패킷 사이즈 등등) - 다양한 설정화일 가짐 (노드 콘피그 등등) - 네트워크 요소를 사용한 모델을 다양하게 변화 - C++ 에 비해서 매우 느린 처리속도 어려움 쉬움

10 NS, Otcl, C++ 와의 관계

11 간단한 OTcl 과 복잡한 C++ [전지 분석 자료 참고]
NODE.cc #include <stdio.h> #include <stdarg.h> #include "address.h" #include "config.h" #ifdef HAVE_STL #include "nix/nixnode.h" #endif //HAVE_STL #include "node.h" static class LinkHeadClass : public TclClass { public: LinkHeadClass() : TclClass("Connector/LinkHead") {} TclObject* create(int, const char*const*) { return (new LinkHead); } } class_link_head; LinkHead::LinkHead() : net_if_(0), node_(0), type_(0) { } int32_t LinkHead::label() { if (net_if_) return net_if_->intf_label(); printf("Configuration error: Network Interface missing\n"); exit(1); // Make msvc happy return 0; ………………….. #Create a simulator object set ns [new Simulator] #Create four nodes set n0 [$ns node] 아이디어 삽입 네트웍구성 Otcl (쉬움) X O C++ (어려움)

12 NS, Otcl, C++ 의 디렉토리 위치 ☞ 2 가지 기능을 가지는 TCL 의 위치 1. 시뮬레이션 구성

13 소스 코드 상속 구조 TclObject Scheduler NsObject Node Process Connector
Classifier Application FTP Queue Delay Agent Trace DropTail RED TCP Enq Deq Drop AddrClassifier PortClassifier Reno SACK Vegas

14 새로운 요소 추가시 컴파일 방법 xxx.cc C++ 코드 추가시 - “ns-allinone2.xx/ns-2.xx/Makefile” 내부에 “OBJ_CC = xxx.o” 추가 xxx.h header 코드 추가시 - 추가 한후 새로운 패킷 타입이 다루는 자료구조 선언 xxx.tcl OTcl 라이브 러리 추가시 - “ns-allinone2.xx/ns-2.xx/Makefile” 내부에 “NS_TCL_LIB=xxx.tcl” 추가 새로운 Application 추가시 - “ns-allinone2.xx/ns-2.xx/packet.h” 내부에 “PT_NEW” 패킷 타입 추가

15 이벤트 스케쥴러 Create event scheduler Schedule events (OTcl)
set ns [new Simulator] Schedule events (OTcl) OTcl: $ns at <time> <TCL_command> C++: Scheduler::schedule(h,e, delay) 가지 용도로 사용됨 독립된 노드 실행 Thread 대치 용도 Obtain simulation time OTcl: $ns now C++: Scheduler::clock() Start scheduler $ns run

16 간단한 예제 (데모 시청] 스케줄러 생성 에이젼트 생성 노드생성 트레이스 에플리 케이션 생성 링크생성 시뮬레이션 종료 에이젼트
간단한 예제 (데모 시청] 스케줄러 생성 set null0 [new Agent/Null] $ns attach-agent $n3 $null0 set null1 [new Agent/Null] $ns attach-agent $n1 $null1 $ns connect $udp0 $null0 $ns connect $udp1 $null1 $ns at 1.0 "$cbr0 start" $ns at 1.1 "$cbr1 start" set tcp [new Agent/TCP] $tcp set class_ 2 set sink [new Agent/TCPSink] $ns attach-agent $n0 $tcp $ns attach-agent $n3 $sink $ns connect $tcp $sink set ftp [new Application/FTP] $ftp attach-agent $tcp $ns at 1.2 "$ftp start" $ns at 1.35 "$ns detach-agent $n0 $tcp ; $ns detach-agent $n3 $sink" puts [$cbr0 set packetSize_] puts [$cbr0 set interval_] $ns at 3.0 "finish" proc finish {} { global ns f nf $ns flush-trace close $f close $nf puts "running nam..." exec nam out.nam & exit 0 } $ns run set ns [new Simulator] $ns color 0 blue $ns color 1 red $ns color 2 white set n0 [$ns node] set n1 [$ns node] set n2 [$ns node] set n3 [$ns node] set f [open out.tr w] $ns trace-all $f set nf [open out.nam w] $ns namtrace-all $nf $ns duplex-link $n0 $n2 5Mb 2ms DropTail $ns duplex-link $n1 $n2 5Mb 2ms DropTail $ns duplex-link $n2 $n3 1.5Mb 10ms DropTail $ns duplex-link-op $n0 $n2 orient right-up $ns duplex-link-op $n1 $n2 orient right-down $ns duplex-link-op $n2 $n3 orient right $ns duplex-link-op $n2 $n3 queuePos 0.5 set udp0 [new Agent/UDP] $ns attach-agent $n0 $udp0 set cbr0 [new Application/Traffic/CBR] $cbr0 attach-agent $udp0 set udp1 [new Agent/UDP] $ns attach-agent $n3 $udp1 $udp1 set class_ 1 set cbr1 [new Application/Traffic/CBR] $cbr1 attach-agent $udp1 에이젼트 생성 노드생성 트레이스 에플리 케이션 생성 링크생성 시뮬레이션 종료 에이젼트 생성 시뮬레이션 시작

17 간단한 시뮬레이션 코드 구성방식 스케쥴러 생성 노드 생성 트레이스 파일 생성 링크 생성 에이전트 생성 에플리케이션 생성
시뮬레이션 이벤트 생성 시뮬레이션 시작 시뮬레이션 종료 함수 생성

18 시뮬레이션 영상툴 NAM [데모 시청] NAM 파일 생성 …….. set f [open out.tr w] $ns trace-all $f set nf [open out.nam w] $ns namtrace-all $nf …….. NAM 파일을 통한 시뮬레이션 영상 재생 nam out.nam

19 성능평가를 위한 파일 추출 및 파일 내부 $ns trace-all [open out.tr w]

20 성능평가를 위한 파일로 부터 그래프 그리기 1/2 기존 방법 스크립트를 이용하여 tr 파일로 부터 그래프 파라미터 추출
스크립트후 나온 결과를 xgraph 사용하여 표현 예제 cat out.tr | grep " 2 3 cbr " | grep ^r | column 1 10 | awk '{dif = $2 - old2; if(dif==0) dif = ; if(dif > 0) {printf("%d\t%f\n", $2, ($1 - old1) / dif); old1 = $1; old2 = $2}}' > jitter.txt

21 성능평가를 위한 파일로 부터 그래프 그리기 2/2 [데모 시청]
성능평가를 위한 파일로 부터 그래프 그리기 2/2 [데모 시청] 새로운 방법 Matlab 6.0 이상 에서 운영되는 새로나온 tracegraph202 라는 툴 사용 (단점 : 1000 라인 이상 트레이스 파일 처리 못함) 자료 위치

22 참고 자료 Ns Manual - http://www.isi.edu/nsnam/ns/ns-documentation.html
Tcl - uist course: OTcl NS-2 - - Trace Tool -

23 감사 합니다. Q & A

24 부록 1. ns-mobilenode.tcl


Download ppt "Network Simulator 2 성균관대학교 모바일컴퓨팅 연구실"

Similar presentations


Ads by Google