연구/시뮬레이션

ns-2 간단한 예제3

노드의 구성은 아래와 같다.


시나리오 파일은 아래와 같다.
주의사항: 줄번호가 들어간 것은 설명의 편의상 넣은 것이므로 파일로 다운받기 바랍니다.




     1 #Create a simulator object
     2 set ns [new Simulator]      
     3 #Tell the simulator to use dynamic routing
     4 $ns rtproto DV      
     5 #Open the nam trace file
     6 set nf [open out.nam w]
     7 $ns namtrace-all $nf     
     8 #Define a 'finish' procedure
     9 proc finish {} {
    10         global ns nf
    11         $ns flush-trace
    12  #Close the trace file
    13         close $nf
    14  #Execute nam on the trace file
    15         exec nam out.nam &
    16         exit 0
    17 }      
    18 #Create seven nodes
    19 for {set i 0} {$i < 7} {incr i} {
    20         set n($i) [$ns node]
    21 }      
    22 #Create links between the nodes
    23 for {set i 0} {$i < 7} {incr i} {
    24         $ns duplex-link $n($i) $n([expr ($i+1)%7]) 1Mb 10ms DropTail
    25 }      
    26 #Create a UDP agent and attach it to node n(0)
    27 set udp0 [new Agent/UDP]
    28 $ns attach-agent $n(0) $udp0      
    29 # Create a CBR traffic source and attach it to udp0
    30 set cbr0 [new Application/Traffic/CBR]
    31 $cbr0 set packetSize_ 500
    32 $cbr0 set interval_ 0.005
    33 $cbr0 attach-agent $udp0      
    34 #Create a Null agent (a traffic sink) and attach it to node n(3)
    35 set null0 [new Agent/Null]
    36 $ns attach-agent $n(3) $null0      
    37 #Connect the traffic source with the traffic sink
    38 $ns connect $udp0 $null0        
    39 #Schedule events for the CBR agent and the network dynamics
    40 $ns at 0.5 "$cbr0 start"
    41 $ns rtmodel-at 1.0 down $n(1) $n(2)
    42 $ns rtmodel-at 2.0 up $n(1) $n(2)
    43 $ns at 4.5 "$cbr0 stop"
    44 #Call the finish procedure after 5 seconds of simulation time
    45 $ns at 5.0 "finish"      
    46 #Run the simulation
    47 $ns run
이번 시나리오에서는 0.5초에 노드0에서 노드3으로 CBR트래픽을 생성하여 보내다가 1초에 노드1과 노드2의 링크를 끊는다. 동적라우팅 프로토콜인 DV에 의해서 끊겨진 링크를 우회하여 패킷을 전달한다.
이올린에 북마크하기(0) 이올린에 추천하기(0)
top


http://www.joon.pe.kr/blog/trackback/4

Tracked from Denis.Usj.es at 2023/02/04 04:22  Delete
병준이저장소 :: ns-2 간단한 예제3
Commented by sdvsvd at 2022/10/21 01:27  Reply|Edit|Delete
세계카지노순위 슬롯머신잭팟 해외카지노후기 바카라전략 카지노룰 무료바카라게임 에볼루션바카라 블랙잭게임다운 블랙잭플래시게임 강원랜드게임종류 카지노룰 블랙잭주소 강원랜드게임종류 <a href="http://dd.vmm789.com" target="_blank">온라인카지노</a> 로얄카지노사이트 카지노다이사이 <a href="http://cc.vmm789.com" target="_blank">바카라사이트</a> 온라인바카라주소 무료룰렛게임 <a href="http://tt.vmm789.com" target="_blank">룰렛사이트</a> 강원랜드카지노주소 안전한바카라사이트 <a href="http://zxc.vmm789.com" target="_blank">슬롯머신사이트</a> 해외카지노순위 룰렛사이트주소 <a href="http://vmm789.com" target="_blank">카지노사이트</a> 마카오카지노후기 카지노식보 강원랜드카지노주소 온라인카지노주소 강원랜드룰렛 더킹카지노주소 카지노이기는법 슬롯머신게임사이트 바카라필승법


<< Prev   1   ... 329   330   331   332   333   334   335   336   Next >>