출처(ref.): http://www.ifn.et.tu-dresden.de/~marandin/ZigBee/ZigBeeSimulation.html
이번 패키지의 좋은 점은 문서화가 잘 되어있다는 점과 서비스로 시나리오 제너레이터, traffic 제너레이터를 제공했다는 거다!
물론 이건 시간 들여 누구나 구현하면 할 수는 있지만, 기존 코드에 착 달라붙게 만들었을 것이기 때문에 사용자 측면에서 매우매우매우 기쁜 일 ! (귀찮은 일을 안해도 되니까 :) )
그 외에도 awk, 샘플 코드도 수정해서 올려두었다 : )
하나씩 그럼 따라해 볼까?
일단, 이 패키지는 목적에 따라 다른 코드 구성을 만들었다는 것이다.
소스를 다운 받고 압축을 풀어보면, 폴더가 네 개다. (click) (doc: click)
1. 868
It contains the zigbee software modules (wpan), personalized to 868Mhz frequency band simulation. All implemented changes can be viewed in this document. The following changes are implemented in the code presented in this folder:
Energy Detection Threshold
TxOptions
Radio Frequency Selection
Number of Scanned Channels
Channels Supported
Passive Scan Support
Acknowledgement Wait Duration
2. 868abe
It contains the zigbee software modules (wpan), personalized to 868Mhz simulation (implemeting the changes as indicated in section-1), implementing the algorithm, Adaptive Backoff Exponent. For more details into the changes made to the source code, search the files for the keyword, adaptive?
3. modified_aodv_for_star_topology
Contains the modified version of aodv suited only for STAR network topology. It is reminded that in a star topology formation routing of data is not possible, hence the routing mechanism has been disabled. Only the file aodv.cc has been modified. For more details into the changes made to the source code, search the files for the keyword, ??rakash?
4. modified_mac_for_star_topology
Contains the modified version of MAC disabling the address resolution mechanism. It is reminded that in a STAR network formation address resolution is not needed the mechanism can be safely disabled. For more details into the changes made to the source code, search the files for the keyword, ??rakash?
(압축 파일 내 README.txt 파일에 있는 내용)
그래서 나는 1,3,4를 적용할 예정이다!
먼저 백업 하고 나서, xshell와 xftp를 통해서 파일을 덮어 씌웠다 (간편하니까^^)
이제 1번 먼저 컴파일 시도!
(ns-2.28/wpan 에 1번 폴더에 있는 파일을 몽땅 붙여넣기)
cd ../ns-2.28
make clean
./configure
make
컴파일 잘된다 :) 샘플 코드 돌리기!
샘플 코드는 여기에서 제공하는 것만 써도 대박 ~ 근데 tcl 파일 실행 하기 전에 해줘야 할 것들이 있다. 그것은 traffic 만드는 것과 시나리오 생성! 차례대로 해볼까?!
cbrgen_star.tcl
# ns cbrgen star.tcl [-type cbrtcp] [-nn nodes] [-seed input-seed] [-mc max connections] [-rate datarate(kb)] [-starttime st][-timegap tg]
# ns cbrgen_star.tcl -type cbr -nn 10 -seed 1 -mc 10 -rate 10.0 -starttime 10 -timegap 0.2 > traffic
제가 예제로 생성한 파라미터 입니다.
마지막에 traffic 파일을 생성해서 값을 넣어주는 이유는 샘플코드에서 이 파일명을 사용하기 때문이지 별 다른 이유는 없습니다~변경해서 쓰세요`!!
이제 실행?
couldn't execute "/root/ns-2/ns-allinone-2.28/ns-2.28/examples/backoff_test/scen_gen": permission denied
while executing
"exec /root/ns-2/ns-allinone-2.28/ns-2.28/examples/backoff_test/scen_gen $temp1 25 25 9"
(file "wpan868.tcl" line 57)
경로를 변경해 주지 않았네요 : ) 그리고 scen_gen.cc를 컴파일 해서 실행 파일을 만들어 두어야 한답니다! 그 부분을 이제 다루지요.
cd ns-2.28
mkdir examples
cd examples
mkdir backoff_test
backoff_test 폴더에 scen_gen.cc를 복사해 두고
g++ -o scen_gen scen_gen.cc
이렇게만 실행하면 실행 파일이 생성되는 것을 확인 할 수 있습니다.
그리고!!
wpan.scn이라는 파일도 wpan.tcl에서 사용하고 있는데, 이것도 생성해 줘야 실행 될 겁니다. 안그러면 에러나요. 당연하죠 시나리오 토폴로지니까요~!!
backoff_test 폴더에서 아래를 실행합니다.
#scen_gen [number-of-nodes] [X-Pos-of-coord] [Y-Pos-of-coord] [Personal-Operating-Space]
저는 아래와 같이 실행했습니다.
$ ./scen_gen 10 100 200 10
이렇게 하면, wpan.scn이 생성됩니다.
그리고 중요한 것,! current_seed.txt 라는 파일이 있어야 실행이 되는데, 이것은 그냥 빈 파일로 생성해 두세요.
모든 파일들은 여기서 다운 받을 수 있습니다.
analyze라는 것도 제공하는데요.
이것은 같은 폴더에 analyze_program.zip압축 푼 파일 4개를 넣어 실행하면 됩니다. 실행 파일 권한 풀어주는건 기본!
자, 이제 다 실행 되시나요~?