'Network/Ns2_Lecture'에 해당되는 글 60건
- 2009.01.18 [펌] NS-2 관련 site 모음
- 2009.01.18 ns베이직 원본
- 2009.01.18 ns2 802.11b의 파라미터에 대한 설명
- 2009.01.18 802.11b
- 2009.01.18 R:[ns] Route to base_stn not known: dropping pkt
- 2009.01.18 Making NS-2 simulate an 802.11b link
- 2009.01.18 NS2 - 무선환경 시뮬레이션
- 2009.01.18 NS2 - OTcl linkage
- 2009.01.18 NS2 trace
- 2009.01.18 awk
http://csl.changwon.ac.kr/ref_doc/ns2/index.html
http://sung2ne.tistory.com/entry/Ref-Doc-NS-2
http://www.joon.pe.kr/blog/12
http://wm.hanyang.ac.kr/lecture/ns-2/ns_by_example.html
http://4ellene.net/tt/category/Network/Ns-2
http://www.gongdory.co.kr/category/연구실~/NS-2
http://blog.naver.com/etenallove?redire ··· 22229739
http://tagus.inesc-id.pt/~pestrela/ns2/
일반사항
manual
http://www.isi.edu/nsnam/ns/ns-documentation.html
NS-2 blog
http://ns-2.blogspot.com/
NS-2 by example
http://www.samsiki.net/175
NS-2 강의 mp3 녹음파일
http://nslab.ee.ntu.edu.tw/courses/net- ··· dio.html
802.11 MAC in NS-2
http://www.ece.rice.edu/~jpr/ns/docs/802_11.html
forum
http://www.nabble.com/network-simulator ··· 582.html
trace file for wireless LAN
http://ns-2.blogspot.com/2007/06/how-to ··· for.html
NAM editor
http://ns-2.blogspot.com/2007/04/extend ··· nam.html
Tips : How to scale your simulation to more nodes eg. > 500 nodes and increase the simulation speed
http://ns-2.blogspot.com/2007/02/tips-h ··· -to.html
NS WorkBench : Graphical User Interface For Network Simulator
http://ns-2.blogspot.com/2007/11/ns-wor ··· ace.html
awk 이용한 trace file 분석
http://ns-2.blogspot.com/2006/05/awk-to ··· ile.html
exercise - simulate ad hoc network
http://ns-2.blogspot.com/2006/03/exerci ··· ork.html
how to add a new module in NS-2
http://ns-2.blogspot.com/2006/03/how-do ··· s-2.html
GT-ITM topology generator
http://ns-2.blogspot.com/2006/05/gt-itm ··· tor.html
fast NS-2
http://lst.inf.ethz.ch/fast-ns2/
random trip mobility model for NS-2
http://www.cs.rice.edu/~santa/research/mobility/
modules
GPSR
http://ns-2.blogspot.com/2007/07/greedy ··· psr.html
DSR - FAQ
http://www.geocities.com/b_j_hogan/
infrastructure mode patch
http://www.ee.washington.edu/research/f ··· ions.htm
others
online papers library
http://www.citeulike.org/
network simulators
http://cnonyk.tistory.com/?page=91
기타 유용한 정보
http://www.elmurod.net/
http://www.megite.com/discover/:find_isi_edu/
http://www-static.cc.gatech.edu/classes ··· ummer%2F
http://tmtam.wordpress.com/
'Network > Ns2_Lecture' 카테고리의 다른 글
[ns] ns-2.29 allinone package error (1/2) (0) | 2009.01.18 |
---|---|
[펌] NS-2 유용한 site 모음 (0) | 2009.01.18 |
ns베이직 원본 (0) | 2009.01.18 |
ns2 802.11b의 파라미터에 대한 설명 (0) | 2009.01.18 |
802.11b (0) | 2009.01.18 |
OTcl: The User Language
As mentioned in the overview section, NS is basically an OTcl interpreter with network simulation object libraries. It is very useful to know how to program in OTcl to use NS. This section shows an example Tcl and OTcl script, from which one can get the basic idea of programming in OTcl. These examples are from the 5th VINT/NS Simulation Tutorial/Workshop. This section and the sections after assumes that the reader installed NS, and is familiar with C and C++.
Example 1 is a general Tcl script that shows how to create a procedure and call it, how to assign values to variables, and how to make a loop. Knowing that OTcl is Object-orieneted extension of Tcl, it is obvious that all Tcl commands work on OTcl - the relationship between Tcl and Otcl is just same as C and C++. To run this script you should download ex-tcl.tcl, and type "ns ex-tcl.tcl" at your shell prompt - the command "ns" starts the NS (an OTcl interpreter). You will also get the same results if you type "tcl ex-tcl.tcl", if tcl8.0 is installed in your machine.
Example 1. A Sample Tcl Script
In Tcl, the keyword proc is used to define a procedure, followed by an procedure name and arguments in curly brackets. The keyword set is used to assign a value to a variable. [expr ...] is to make the interpreter calculate the value of expression within the bracket after the keyword. One thing to note is that to get the value assigned to a variable, $ is used with the variable name. The keyword puts prints out the following string within double quotation marks. The following shows the result of Example 1.
The next example is an object-oriented programming example in OTcl. This example is very simple, but shows the way which an object is created and used in OTcl. As an ordinary NS user, the chances that you will write your own object might be rare. However, since all of the NS objects that you will use in a NS simulation programming, whether or not they are written in C++ and made available to OTcl via the linkage or written only in OTcl, are essentially OTcl objects, understanding OTcl object is helpful.
Example 2. A Sample OTcl Script
Example 2 is an OTcl script that defines two object classes, "mom" and "kid", where "kid" is the child class of "mom", and a member function called "greet" for each class. After the class definitions, each object instance is declared, the "age" variable of each instance is set to 45 (for mom) and 15 (for kid), and the "greet" member function of each object instance is called. The keyword Class is to create an object class and instproc is to define a member function to an object class. Class inheritance is specified using the keyword -superclass. In defining member functions, $self acts same as the "this" pointer in C++, and instvar checks if the following variable name is already declared in its class or in its superclass. If the variable name given is already declared, the variable is referenced, if not a new one is declared. Finally, to create an object instance, the keyword new is used as shown in the example. Downloading ex-otcl.tcl and executing "ns ex-otcl.tcl" will give you the following result:
'Network > Ns2_Lecture' 카테고리의 다른 글
[펌] NS-2 유용한 site 모음 (0) | 2009.01.18 |
---|---|
[펌] NS-2 관련 site 모음 (0) | 2009.01.18 |
ns2 802.11b의 파라미터에 대한 설명 (0) | 2009.01.18 |
802.11b (0) | 2009.01.18 |
R:[ns] Route to base_stn not known: dropping pkt (0) | 2009.01.18 |
'Network > Ns2_Lecture' 카테고리의 다른 글
[펌] NS-2 관련 site 모음 (0) | 2009.01.18 |
---|---|
ns베이직 원본 (0) | 2009.01.18 |
802.11b (0) | 2009.01.18 |
R:[ns] Route to base_stn not known: dropping pkt (0) | 2009.01.18 |
Making NS-2 simulate an 802.11b link (0) | 2009.01.18 |
The received power Pr at a distance d from the transmitter for the two-ray ground reflection model [2] can be expressed as:
where Gt is the transmitter antenna gain, Gr is the receiver antenna gain, d is the distance between the antennas in meters, ht is the height of the transmitter and hr is the height of the receiver.
The power level at which the packet was received at MAC layer is compared with the receiving threshold (RTX) and the carrier-sense threshold (CTX). If the power level falls below the carrier sense threshold, the packet is discarded as noise. If the received power level is above the carrier sense threshold but below the receive threshold, the packet is marked as a packet in error before being passed to the MAC layer. Otherwise, the packet is simply handed up to the MAC layer.
In NS-2, the default transmitting power Pt is 0.28, and thus the transmission range (TX_range) and physical carrier sensing range (PCS_range) are calculated as 250 meters and 550 meters. However, as discussion in [1; pp.97, 94, 73], the default values of TX_range and PCS_range used in the NS-2 is two to three times higher than the values measured in practice. To accurately model the attenuation of communication radius between antennas close to the ground, in our simulation model, the TX_range is set 40 meters, and the PCS_range, with respect to the transmitting station, is set to 90 meters. Thus the RTX and the CTX can calculated as 1.74293×10-08 and 3.44283×10-09, respectively. The height of antennas is
Table 1. Value of the IEEE 802.11b parameters
SLOT |
SIFS |
DIFS |
PHYhdr |
CWmin |
CWmax |
RTS |
CTS |
ACK |
20 μsec |
10μsec |
50 μsec |
192 bits |
32 |
1024 |
20 |
14 |
14 |
Table 2. Value of the IEEE
SLOT |
SIFS |
DIFS |
PHYhdr |
CWmin |
CWmax |
RTS |
CTS |
ACK |
9 μsec |
10μsec |
28 μsec |
192 bits |
16 |
1024 |
20 |
14 |
14 |
'Network > Ns2_Lecture' 카테고리의 다른 글
ns베이직 원본 (0) | 2009.01.18 |
---|---|
ns2 802.11b의 파라미터에 대한 설명 (0) | 2009.01.18 |
R:[ns] Route to base_stn not known: dropping pkt (0) | 2009.01.18 |
Making NS-2 simulate an 802.11b link (0) | 2009.01.18 |
NS2 - 무선환경 시뮬레이션 (0) | 2009.01.18 |
- To: ns-users@mash.CS.Berkeley.EDU, "'scao@lerc.nasa.gov'" <scao@lerc.nasa.gov>
- Subject: R:[ns] Route to base_stn not known: dropping pkt
- From: Bordes Marta <Marta.Bordes@CSELT.IT>
- Date: Thu, 01 Jun 2000 18:33:46 +0200
- Sender: owner-ns-users@mash.CS.Berkeley.EDU
Hello, The message "warning:Route to base_stn not known: dropping pkt" is generated by the mobile node's DSDV agent (see ns/dsdv/dsdv.cc). DSDV agent always tries to send packets to the base station referred in the variable base_stn_ of the class MobileNode (see ns/mobilenode.cc). In wireless3.tcl, with the instruction set HAaddress [AddrParams set-hieraddr [$HA node-addr]] [$MH set regagent_] set home_agent_ $HAaddress we set base_stn_ with the address of the home agent. When the mobile node performs a handoff, after receiving a new agent advertisement (from the foreign agent), it modifies the value of base_stn_ with the address of the foreign agent (see mip-reg.cc). The warning message is caused because the mobile node is trying to send a packet (probably an acknowledgement to a received TCP packet) to the old base station, but it is not under its coverage area and it has not updated the value of base_stn_ yet. I hope it helps,
'Network > Ns2_Lecture' 카테고리의 다른 글
ns2 802.11b의 파라미터에 대한 설명 (0) | 2009.01.18 |
---|---|
802.11b (0) | 2009.01.18 |
Making NS-2 simulate an 802.11b link (0) | 2009.01.18 |
NS2 - 무선환경 시뮬레이션 (0) | 2009.01.18 |
NS2 - OTcl linkage (0) | 2009.01.18 |
Making NS-2 simulate an 802.11b link
Last update: 4-29-05
Joshua Robinson
jpr -at- rice.edu
For a research project I worked on in 2004 (resulting paper here), I used two Netgear MA311 cards to create a simple ad hoc connection. These cards are 802.11b PCI cards, stuck in the back of brand new dell workstations. I did some simple throughput tests using netperf, and found that my results differed significantly from what NS told me.
So I set about to figure out why things were different and what needed to be done to sync the results. I'll quickly explain my findings as it wasn't a complex process. Skip to here if you want to see my actual results.
First, I'm assuming version 2.27 or newer here. If you're using older versions, some things will be different and I'll try to point them out if I can. If you're using a newer version, then things will likely also be different, but I've unfortunately stopped work on Ns-2 since 2005.
Data Rate
NS, by default, has the data rate for the MAC set at 2 Mbps. But cards are faster now. My cards are 802.11b, which means they're 11 Mbps, and so we need to change this. Add the following to the beginning of your simulation script:
Mac/802_11 set dataRate_ 11Mb
The card can send at 1, 2, 5.5, or 11 Mbps. Most cards support some kind of ARF (Auto-Rate Fallback) for automatic rate selection between these choices. ARF basically seems to be a slow-timescale feedback mechanism. If there are a lot of packet errors, ARF will step down the rate, and conversely, if there are no errors then the rate will be increased. I'm not explaining this in detail because NS doesn't support any multi-rate functionality by default. That means mobile nodes will always send their packets at dataRate_. So if you really want to be realistic, you need to support this somehow. I didn't.
RTS Threshold
Almost all commercial 802.11b cards have the RTS/CTS exchange turned off by default. This is not a bad decision since I think most people's home wlan networks are simple enough so that the RTS/CTS really is just unnecessary overhead. NS by default has this feature turned on, so we probably want to tell NS not to use this feature. Add this line to the beginning of your script:
Mac/802_11 set RTSThreshold_ 3000
This means that an RTS will only be sent for packets that are bigger than 3000 bytes, which should be never. Note: if you want RTS/CTS on, then set this value to zero.
Preamble
I think this is probably the least obvious modification so I'll try to be a little more detailed. Every packet is sent with a preamble, which is just a known pattern of bits at the beginning of the packet so that the receiver can sync up and be ready for the real data. This preamble must be sent at the basic rate (1 Mbps), according to the official standard. But there are two different kinds of preambles, short and long - referring to the length of the sync field. The long preamble has a field size of 128 bits, while the short preamble is only 56 bits. I would guess this short preamble option came about as hardware progressed and transceivers got better at locking on to a signal. NS is set by default to use the long preamble. My cards use the short preamble by default, and unfortunately, I don't know a good way to determine if your card is using long or short preambles. Email me if you have any ideas.
To support short preambles in NS, add the following line at the beginning of your script:
Mac/802_11 set PreambleLength_ 72
Note: there are 16 other bits in the preamble that aren't affected by the short/long distinction. To go back to long, change this value to 144.
The ChannelAbove is everything you need to simulate an 802.11b card accurately (at least more accurately than the default NS does), but there's still a big assumption in NS - that's the wireless channel model. Currently the received power of a packet only depends on the distance between sender and receiver. But in real life, there are a lot of other factors influencing received power. And if you want a realistic simulation, you need to simulate this. I would suggest going here to find out more information about a more realistic channel fading model.
Packet SizeThere is a slightly annoying default setting in many versions of ns that makes your packet size not what you think it is. The default setting is this:
Agent/UDP set packetSize_ 1000
Which means that if you try to set your UDP packet size to greater than this, it will actually split up each packet into two smaller ones. You really want this line:
Agent/UDP set packetSize_ 1500
If you are not sure if this is a problem, I would recommend checking the packet sizes in your trace file. If you see the wrong packet sizes, this is most likely the problem.
ResultsThe table below shows achieved UDP throughput in Mbps.
Packet Size (Bytes) |
Simulation |
Experimental |
Simulation |
Experimental |
---|---|---|---|---|
128 |
1.28 |
1.2 |
0.75 |
0.76 |
256 |
2.03 |
2.08 |
1.4 |
1.42 |
512 |
3.67 |
3.58 |
2.48 |
2.5 |
1024 |
5.49 |
5.38 |
4.03 |
4.05 |
1440 |
6.41 |
6.35 |
4.93 |
4.96 |
As you can see, the simulation results are very close to the real results I obtained. In fact, I believe that they are close enough so that the difference can be entirely accounted for by the randomness of the CSMA MAC.
Note that I have not actually worked on this project or Ns-2 for several years, so I'm sure things have changed and I can't guarantee that this will still work.
'Network > Ns2_Lecture' 카테고리의 다른 글
802.11b (0) | 2009.01.18 |
---|---|
R:[ns] Route to base_stn not known: dropping pkt (0) | 2009.01.18 |
NS2 - 무선환경 시뮬레이션 (0) | 2009.01.18 |
NS2 - OTcl linkage (0) | 2009.01.18 |
NS2 trace (0) | 2009.01.18 |
유선과 무선 환경의 차이
- 노드 사이의 명시적인 링크가 존재하지 않음
- 라디오의 전송 범위 내에 노드들이 위치하면 통신 가능
- 무선상에서는 MAC 기술이 아주 중요
- NS2 유선 시뮬레이션 환경은 MAX이 존재하지 않음
- 무선상에서 노드는 이동성이 존재
- 라우팅
- 유선상에서는 특별히 라우팅을 설정하지 않아도 링크 설정관계를 통해서 최단 경로가 선택
- 무선에는 반드시 라우팅이 존재해야 함
- 주소
- 유선에서는 flat address
- 무선만 존재하면 flat address
- 유무선 연동인 경우는 hierarchical address
NS2에서의 유선과 무선의 차이
- C++ 상에서의
- 유선 : class Node
- 무선 : class MobileNode
- 노드 생성은 유무선 모두 $ns node로 하지만 무선에서는 node-config라는 추가 작업이 필요
- Trace
- $ns/common 에서
- 유선 : trace.{h, cc}
- 무선 : cmu-trace.{h, cc}
- $ns/common 에서
- 이동성
- 무선에서는 이동성을 지원
- 위치 정보가 중요
- 유선에서는 연결 구조가 중요, 노드의 배치는 중요하지 않음
- 무선에서는 위치에 따라서 전송 범위 내에 있는지 여부가 결정
- 그 외에는 유무선 모두 같은 네트워크 컴포넌트를 사용
node-config
* $ns가 앞으로 만들어질 노드에 대한 설정 정보들을 저장, 이후 만들어지는 노드들은 그 설정 정보들로부터 생성됨
* -adhocRouting 설정 정보로부터 유선 노드와 무선 노드 구별
* node-config를 이용해서 노드 설정을 바뀌었다면 바뀐 설정은 새로 만들어지는 노드부터 적용
Topography
* 지형도
* 영역을 만듦 ->무선 환경에서는 위치가 중요 정보
* set topo [new Topography]
* $topo load_flatgrid <x축 크기> <y축 크기>
God 객체
* Simulater와 마찬가지로 단 하나의 인스턴스만 존재, 없다면 에러
* 노드간 연결(라우팅 가능한지) 정보 제공
* 예) set god_ [create-god <모바일 노드 개수>]
* God 인스턴스 이름은 god_로 해야함 (일부 $god_로 사용)
- -adhocRouting : 라우팅 프로토콜 설정
- DSDV, AODV, TORA,, FLOODING,...
- -llType : 링크 레이어 설정
- LL
- -macType : 맥프로토콜 설정
- Mac/802_11, Mac/SMAC
- -propType : 경로손실타입
- Propagation/twoRayGround, Propagation/FreeSpace, Propagation/Shadowing,...
- -ifqType : 큐타입
- Queue/DropTail/PriQueue,...
- 애드혹라우팅 프로토콜이>
- -ifqLen : 큐길이
- 패킷 개수
- -phyType : 피지컬레이어타입
- Phy/WirelessPhy,...
- -antType : 안테나 타입
- Antenna/OmniAntenna
- -channel : 현재는 없어짐
- Channel/WirelssChannel
- -topoInstance : 전체 영역
- $topo
- -agentTrace : 트레이스 설정
- ON or OFF
- -routerTrace : 트레이스 설정
- ON or OFF
- -macTrace : 트레이스 설정
- ON or OFF
- -movementTrace : 트레이스 설정
- ON or OFF
NS2 무선환경 시뮬레이션 스크립터
set ns [new Simulator]set trfd [open prac10.tr w]
$ns trace-all $trfdset namfd [open prac10.nam w]
$ns namtrace-all-wireless $namfd 1000 1000set topo [new Topography]
$topo load_flatgrid 1000 1000set god_ [create-god 25]$ns node-config -adhocRouting AODV \
-llType LL \
-macType Mac/802_11 \
-propType Propagation/TwoRayGround \
-ifqType Queue/DropTail/PriQueue \
-ifqLen 50 \
-phyType Phy/WirelessPhy \
-antType Antenna/OmniAntenna \
-channel [new Channel/WirelessChannel] \
-topoInstance $topo \
-agentTrace ON \
-routerTrace ON \
-macTrace ON \
-movementTrace ONfor {set i 0} {$i < 25} {incr i} {
set node_($i) [$ns node]$node_($i) set X_ [expr $i % 5 * 200]
$node_($i) set Y_ [expr $i / 5 * 200]
$node_($i) set Z_ 0$ns initial_node_pos $node_($i) 150
}set udp [new Agent/UDP]
$ns attach-agent $node_(0) $udpset cbr [new Application/Traffic/CBR]
$cbr set packetSize_ 500
$cbr set interval_ 0.1
$cbr attach-agent $udpset null [new Agent/Null]
$ns attach-agent $node_(24) $null$ns connect $udp $nullset tcp [new Agent/TCP]
$ns attach-agent $node_(20) $tcpset ftp [new Application/FTP]
$ftp attach-agent $tcpset tcpSink [new Agent/TCPSink]
$ns attach-agent $node_(4) $tcpSink$ns connect $tcp $tcpSink$ns at 0.5 "$cbr start"
$ns at 5.0 "$cbr stop"$ns at 2.0 "$ftp start"
$ns at 4.0 "$ftp stop"#$ns at 1.0 "$node_(24) setdest 500 800 20"$ns at 6.0 "$ns halt"
$ns run
Max/802_11 Bandwidth
- basic rate, data rate 두가지 존재
- basic reate : RTS, CTS, ACK 을 전송하는 속도
- data rate : 실제 데이터를 전송하는 속도
- 설정하는 방법
- Mac/802_11 set basicRate_ 1Mb
- Mac/802_11 set dataRate_ 1Mb
- 기본값은 둘다 1Mbps
범위 설정
- 전송 범위 : 데이터가 성공적으로 수신되는 범위
- 캐리어 감지 범위 : 데이터를 성공적으로 수신하지는 못하지만 신호만 감지하는 범위 -> CSMA/CA 프로토콜의 CA
- 전송 범위와 캐리어 감지 범위는 수신 노드에서 받는 전파세기와 쓰레쉬홀드에 의해서 결정
- $ns/tcl/lib/ns-default.tcl
Phy/WirelessPhy set CPThresh_ 10.0
Phy/WirelessPhy set CSThresh_ 1.559e-11 # 수신한 전파의 세기가 이 값 이상이면 감지
Phy/WirelessPhy set RXThresh_ 3.652e-10 # 수신한 전파의 세기가 이 값 이상이면 성공적인 수신
Phy/WirelessPhy set bandwidth_ 2e6
Phy/WirelessPhy set Pt_ 0.28183815
Phy/WirelessPhy set freq_ 914e+6
Phy/WirelessPhy set L_ 1.0
- 다른 설정은 변경하지 않고 위 두개의 threshold만 변화시켜 범위 조절 가능
- $ns/indep-utils/propagation/threshold.cc
- 컴파일 후 threshold -m <경로손실모델> <범위> ->threshold 값 리턴
'Network > Ns2_Lecture' 카테고리의 다른 글
R:[ns] Route to base_stn not known: dropping pkt (0) | 2009.01.18 |
---|---|
Making NS-2 simulate an 802.11b link (0) | 2009.01.18 |
NS2 - OTcl linkage (0) | 2009.01.18 |
NS2 trace (0) | 2009.01.18 |
awk (0) | 2009.01.18 |
$NS/tclcl-1.17/tclcl.h, Tcl.cc
$NS/tclcl-1.17/tcl-object.tcl
class TclObject
- split object의 base class
- 제공하는 기능
- 멤버 변수 바인딩
- OTcl상에서 C++ 접근
- OTcl에서 선언된 split object의 C++상의 인스턴스 접근
- 바인딩
- split object의 OTcl상의 멤버변수와 C++상의 멤버변수를 묶어줌
- 어느 한곳의 값이 변하면 다른 곳에 바로 적용됨
- C++ 상에서 bind_XXX()함수 이용
- 보통 생성자에서 해줌
- bind("<OTcl상에서 멤버변수 이름>", &<C++상에서 멤버변수 이름>);
- ASRMAgent::ASRMAgent(){
- bind("pdistance_",&pdistance_);
- bind_time("lastSent_", &lastSessSent");
- bind_bw("ctrlLinit_",&ctrlBWLimit_);
- bind_bool("running_",&running_)
- }
- Bandwidth,Time은 고려해서 기본단위로 C++상의 멤버변수에 저장이 됨
- Boolean은 true면 1, false면 0이 C++상의 멤버변수에 저장
- 바인된 변수 초기화
- $ns/tcl/lib/ns-default.tcl에 추가
- 추가하지 않으면 경고가 뜸
- 5가지 변수
- real (double형)
- $object set realvar 1.2e3
- bandwidth (double형)
- $object set bwvar 1.5m
- $object set bwvar 1500k
- 접미사 지원
- kilo - k,K
- mega - m, M
- B - byte
- b - bit(default)
- time (double형)
- $object set timevar 1500m
- $object set timevar 1.5e9n
- $object set timevar 1.5e9p
- 접미사 지원
- mili second - m
- nano second - n
- pico second - p
- second - s(default)
- integer (int형)
- $object set intVar 12
- boolean (int형)
- true : 1 또는 t나 T로 시작하는 문자열
- $object set boolvar t
- $object set boolvar true
- $object set boolbar 1
- false : 0 또는 t나 T로 시작하지 않는 문자열
- $object set boolvar false
- $object set boolvar junk
- $object set boolvar 0
- true : 1 또는 t나 T로 시작하는 문자열
- OTcl상에서의 C++ 접근
- OTcl상에서 클래스의 멤버함수가 아닌 커맨드도 존재
- 커맨드가 클래스 멤버함수 중 존재하지 않으면
- $object cmd 커맨드 인자들
- cmd는 split object의 C++상의 클래스의 command()를 호출
- int ASRMAgent::command(int argc, const char*const*argv) {
- Tcl &tcl = tcl::instance();
- if(strcmp(argv[1], "distance?") == 0) {
- int sender = atoi(argv[2]);
- SRMinfo *sp = get_state(sender);
- tcl.resultf("%f",sp->distance_);
- return TCL_OK; //cf> TCL_ERROR
- }
- }
- return (SRMAgent::command(argc,argv));
- }
- argv[0] <- cmd
- argv[1] <- 명령어
- argv[2] <- arg1
- argv[3] <- arg2
- command()내에서 성공시 return TCL_OK; 실패시 return TCL_ERROR;를 해줘야 함
- Split object 접근
- class TclObject{
- ...
- inline static lookup(const char *name) {
- return (Tcl::instance().lookup(name));
- }
- }
- TclObject::lookup("oNNN")
- OTcl 상에서 reference가 _oNNN인 split object의 C++상의 인스턴스(포인터)를 리턴
- Typecasting을 해줘야 함
class Tcl
- OTcl interpreter에 접근하고 통신하는 방법을 제공
- OTcl 커맨드 실행
- interpreter에서 실행된 결과의 리턴 값을 얻어 옴
- interpreter로 결과값을 리턴
- Tcl &tcl = Tcl::instance();
- 이 instance로 OTcl interpreter 접근
- OTcl 명령어 실행(OTcl 상에서 실행
- tcl.eval(char *)
- tcl.evalc(const char *) : 문자열 상수인 경우 ""
- tcl.eval():tcl.buffer()있는 문자열로 실행
- tcl.evalf(const char *) : formated string
- OTcl로 / OTcl로부터 리턴
- 결과(리턴값-문자열)을 OTcl상으로 넘기거나, OTcl상에서부터 받아온다.
- 결과값 넘기기
- tcl.result(const char *s)
- tcl.resultf(const char* fmt, ...)
- 결과값 가져오기
- tcl.result()
class TclClass
- C++상의 클래스 계층에 대응하는 OTcl 상의 클래스 계층을 만든다.
- C++상의 클래스의 인스턴스를 만드는 멤버함수를 제공한다.
- static class RenoTcpclass:public TclClass{
- public:
- RenoTcpClass():TclClass("Agnet/TCP/Reno") {}
- TclObject* create(int argc, const char*const*argv){
- return (new RenoTcpAgent());
- }class_reno;
- 클래스 정의 후 인스턴스까지 만듬
- 생성자에서 하는 일은 없음
- 부모 생성자 TclClass가 전 슬라이드에 언급한 일을 수행
- argv[4] 부터 추가 변수
- new Agent/TCP/Reno 시 내부적으로 RenoTcpClass::create() 실행
- "Agent/TCP/Reno"는 OTcl상에 클래스 이름
- static 클래스 정의와 정시에 선언 => C++상의 클래스에 대응하는 OTcl상의 클래스의 계층을 만듦.
- SplitObject proc register className
- OTcl 상에서 SplitObject(TclObject)를 최상위로 해서 클래스 계층을 만들어 준다.
- create-shadow
- TclClass::create_shadow()를 호출, create()를 호출한다.
- 최종적으로 SplitObject의 생성자가 호출됨
- SplitObject는 $self create-shadow 호출
- create-shadow는 TclClass::create_shadow() 호출
- TclClass::create_shadow()는 create()호출
- TclClass를 상속한 class의 create()에서 C++상의 클래스의 인스턴스를 생성해야 함
'Network > Ns2_Lecture' 카테고리의 다른 글
Making NS-2 simulate an 802.11b link (0) | 2009.01.18 |
---|---|
NS2 - 무선환경 시뮬레이션 (0) | 2009.01.18 |
NS2 trace (0) | 2009.01.18 |
awk (0) | 2009.01.18 |
NS2 스크립트 - 유선환경 시뮬레이션 (0) | 2009.01.18 |
- 종류
- tr : 패킷 전송 관련 트레이스 (큐 입출력, 패킷 도착, ...)
- nam : NAM을 위한 트레이스
- 커맨드
- trace-all <파일 핸들>
- namtrace-all <파일 핸들>
- topology 만들기 전에 설정해야 함
- NS2 유선 트레이스 Format
예)
+ 1 0 1 cbr 210 ------- 0 0.0 1.0 0 0
- 1 0 1 cbr 210 ------- 0 0.0 1.0 0 0
r 1.002168 0 1 cbr 210 ------ 0 0.0 1.0 0
* Event
+ : enqueue (큐삽입)
- : dequeue (큐삭제)
r : 수신
- ns 실행 후 *.tr, *.nam 파일 생성
- nam *.nam ->xwindow를 이용한 그래픽적 표현
- 무선 trace 특징
- 유선 trace에 비하여 더 복잡 -> 무선은 MAC, Routing이 포함
- 구조 : $ns/trace/cmu-trace.cc
예)
Event time NodeID TraceLayer Flags Pktld PktType PktSize NAV RA TA ETHER_TYPE srcAddr:srcPort dstAddr:dstPort TTL PktSeqNo numForwards optNumForwards
* Event
- s : send, r : receive, f : forward, D : drop
* TraceLayer
- AGT : transport layer (end-to-end)
- RTR : routing layer (hop-by-hop)
- MAC : mac layer ( mac control packet also)
* NAV : network allocate vector
* RV : receiving address
* TA : transmitting address
* ETHER_TYPE
- IP : 800
- ARP : 806
- MAC을 거쳐가지 않은 패킷은 모두 초기값 0
* Routing layer를 거치지 않으면 nextHop은 0으로 초기화
* PktSeqNo : packet sequence number
* numForwards : number of forwards - 지금까지 거쳐온 홉 수
* optNumforwards : 소스 - 목적지간 최단경로 홉수 => God에서 제공하는 기능 (기본은 최단경로 홉을 계산하지 않음 => 0)
* [tcpSeqNo tcpAckNo] numforwards optNumForwards
- xgraph
- 파싱한 데이터만으로는 전체적인 양상을 한눈에 파악하기는 힘듦 -> 시각화 필요
- xgraph는 그래프로 그려주는 툴
- 실행
- xgraph <옵션들> <입력파일1> <입력파일2> ...
- 입력파일은 각 라인이 공백으로 구분되는 두 값을 가진다. : 첫번째 값은 x좌표, 두번째 값은 y좌표
- 주요 옵션
- -nl : no line, 선을 그리지 않음
- -m : mark, 마킹을 함 (구별되게 점을 찍음)
'Network > Ns2_Lecture' 카테고리의 다른 글
NS2 - 무선환경 시뮬레이션 (0) | 2009.01.18 |
---|---|
NS2 - OTcl linkage (0) | 2009.01.18 |
awk (0) | 2009.01.18 |
NS2 스크립트 - 유선환경 시뮬레이션 (0) | 2009.01.18 |
Description of the ns-2 modifications (0) | 2009.01.18 |
- NS2 Smulation 후 분석
- 정량적인 데이터 분석
- tr 파일을 이용 원하는 정보만 추출하는 과정 필요 -> Parsing
- awk : parsing 전용 language
- 실행 : awk -f <awk 스크립트> <입력파일>
- c와 유사한 문법/ 함수
- 구성
- BEGIN{}
- 입력파일(파싱할 파일)을 읽 전에 한번 실행
- 변수 초기화
- {}
- 입력파일의 매 라인마다 실행
- 실제 파싱
- END{}
- 입력파일의 끝에 도달했을 때 한번 실행
- 변수 최종값 출력
- BEGIN{}
- 변수
- "..." : 문자열 상수
- name = "Bestya"; #name에 문자열 상수 bestya 할당
- age2 = "28" #age2에 문자열 28 할당
- 숫자 : 숫자 상수
- age = 28; # age에 숫자 28 할당
- 숫자와 문자 조합 : 변수 이름
- 변수 선언은 필요치 않다.
- 미리 입력된 변수 (입력 파일의 실행 시점 기준)
- NF : number of fields, 이라인의 단어 수
- NR : number of record, 라인 넘버
- FILENAME: 이 파일 이름
- FS : field deparator, 단어 구분자, 기본은 " "
- RS : record separator, 라인 구분자, 기본은 "\n"
- $0 : 이 라인
- $1 : 이 라인의 첫번째 단어
- 출력문
- printf : c와 동일
- print(변수 또는 상수, 변수 또는 상수, 변수 또는 상수,...) : 공백간격으로 출력됨, 줄바꿈
- 제어문
- 조건에는 <, >, <=, >=, ==, != 가 올 수 있음, 문자열간의 비교도 가능
- if (조건1) {몸체1} else if(조건2) {몸체2} else {몸체3}
- for (초기화; 조건; 증가) {몸체}
- while (조건) {몸체}
- awk 매뉴얼
예
#필요한 결과를 얻기 위한 규칙
#tr 포맷과 필요한 결과의 상황으로 부터 작성
if($4 == 3 && $1 == "r" && $9 =="0.0") {
print $11, $2
'Network > Ns2_Lecture' 카테고리의 다른 글
NS2 - OTcl linkage (0) | 2009.01.18 |
---|---|
NS2 trace (0) | 2009.01.18 |
NS2 스크립트 - 유선환경 시뮬레이션 (0) | 2009.01.18 |
Description of the ns-2 modifications (0) | 2009.01.18 |
5.3 Node Configuration Interface (0) | 2009.01.18 |