help, can somebody help me to trace that where is wrong with my tcl code ?

global ns

set ns [new Simulator]

 

# Note:  Even though "Static" is normally reserved for static

#        topologies, the satellite code will trigger a recalculation

#        of the routing tables whenever the topology changes.

#        Therefore, it is not so much "static" as "omniscient", in that

#        topology changes are known instantly throughout the topology.

#        See documentation for discussion of dynamic routing protocols.

$ns rtproto Static

 

###########################################################################

# Global configuration parameters (全域通用參數)                        #

###########################################################################

 

###########################################################################

#handoff的模擬是針對leo衛星網路模擬的部份。                               #

###########################################################################

 

HandoffManager/Term set elevation_mask_ 8.2;
#檢查當前衛星已經落到terminal的最小允許覆蓋角

HandoffManager/Term set term_handoff_int_ 10;                             #

HandoffManager set handoff_randomization_ false;    

 

global opt

set opt(chan)         Channel/Sat  ;  #衛星通道

set opt(bw_down)              10Mb;       ;  # Downlink bandwidth (satellite
to ground)(下行頻寬,衛星至地面)

set opt(bw_up)                   10Mb;       ;  # Uplink bandwidth(上行頻寬
)

set opt(phy)          Phy/Sat      ;  #物理層:衛星

set opt(mac)          Mac/Sat                            ;  #MAC層:衛星

set opt(ifq)          Queue/DropTail; #佇列型態:DropTail

set opt(qlim)                          512          ;  #Queue的最大值:256個
封包

set opt(ll)           LL/Sat       ;  #鏈結層:衛星

set opt(wiredRouting)   ON          ;   #三個事件:"+"進佇列;"-"離開佇列;
"r"接收到封包

 

 

 

# IMPORTANT This tracing enabling (trace-all) must precede link and node 

#           creation.  Then following all node, link, and error model

#           creation, invoke "$ns trace-all-satlinks $outfile" 

#重要:這個TRACE使(trace-all)必須在鏈接和結點建立之前。

#      然後跟隨的所有結點, 鏈接, 和錯誤模型的建立後,必須加入"$ns
trace-all-satlinks $outfile"

 

set outfile [open throughput_0.tr w]

$ns trace-all $outfile

 

###########################################################################

# Set up satellite and terrestrial nodes                                  #

###########################################################################

 

# Let's first create a single orbital plane of Iridium-like satellites

# 11 satellites in a plane

 

# Set up the node configuration

#建立geo衛星

 

$ns node-config -satNodeType geo \

                     -llType $opt(ll) \

                     -ifqType $opt(ifq) \

                     -ifqLen $opt(qlim) \

                     -macType $opt(mac) \

                     -phyType $opt(phy)         \

                     -channelType $opt(chan) \

                     -downlinkBW 10Mb \

                     -wiredRouting $opt(wiredRouting)  

 

 

 

# Create nodes n0 through n1

set n0 [$ns node]; 

 

###########################################################################

#n3<---->n1<---->n0<---->n2<---->n4                                       #

# 3<----->1<----->0<----->2<----->4                                       #

#          (satellite link)                                               #

###########################################################################

 

# GEO satellite:  above North America-- lets put it at 100 deg. W

#設定geo衛星的位置

#n0設東經:100度

 

$n0 set-position 100

 

###########################################################################

#Terminal                                                                 #

###########################################################################

# Terminals:  Let's put two within the US, two around the prime meridian

$ns node-config -satNodeType terminal 

set n1 [$ns node]

$n1 set-position 50 100;

set n2 [$ns node]

$n2 set-position -50 100;

###########################################################################

# Set up links                                                            #

###########################################################################

 

# Add any necessary ISLs or GSLs

# GSLs to the geo satellite:

#GEO---------->Terminal

#$n0 set downlink_ 10Mb

#$n0 set uplink_ 10Mb

$n1 add-gsl geo $opt(ll) $opt(ifq) $opt(qlim) $opt(mac) $opt(bw_up) \

  $opt(phy) [$n0 set downlink_ ] [$n0 set uplink_]

$n2 add-gsl geo $opt(ll) $opt(ifq) $opt(qlim) $opt(mac) $opt(bw_up) \

  $opt(phy) [$n0 set downlink_] [$n0 set uplink_]

  

puts "$n0 set_downlink"

 

###########################################################################

# wired link                                                              #

###########################################################################


$ns unset satNodeType_

set n3 [$ns node]  

set n4 [$ns node]

 

$ns duplex-link $n3 $n1 10Mb 1ms DropTail;

$ns duplex-link $n2 $n4 10Mb 1ms DropTail;

 

$ns queue-limit $n3 $n1 128

$ns queue-limit $n2 $n4 128

###########################################################################

# Error Model   1                                                         #

###########################################################################

           set err [new ErrorModel]

           $err unit pkt

           $err set rate_ 0

           $err ranvar [new RandomVariable/Uniform]

#        $n1 interface-errormodel $err

           $n0 interface-errormodel $err

#        $n2 interface-errormodel $err

 

###########################################################################

# Tracing                                                                 #

###########################################################################

$ns trace-all-satlinks $outfile

 

###########################################################################

# Attach agents                                                           #

###########################################################################

 

set tcp [new Agent/TCP/Reno]

$ns attach-agent $n3 $tcp

set ftp [new Application/FTP]

$ftp attach-agent $tcp

 

 

###########################################################################

# 每個封包的大小,包含標頭(40bytes)及payload
#

# 而這裡的packetSize_及為tcp的payload大小                                 #

###########################################################################

$tcp set packetSize_ [expr 1000-40]

 

###########################################################################

#                                                                         #

###########################################################################

$tcp set window_ 64

 

 

 

set sink [new Agent/TCPSink]

$ns attach-agent $n4 $sink

$ns connect $tcp $sink

 

 

###########################################################################

# Satellite routing                                                       #

###########################################################################

 

set satrouteobject_ [new SatRouteObject]

$satrouteobject_ compute_routes

#$satrouteobject_ set wiredRouting_ true

           

###########################################################################

#設定ftp傳送的封包大小                                                    #

###########################################################################


           set packetSize_ 100

           set packets_ftp 10

           set bytes_ftp [expr 10*1000*1000]

 

#1000bytes=1Kb

 

###########################################################################

#設定亂數                                                                 #

###########################################################################


set rng [new RNG]

$rng seed 0

 

set u [new RandomVariable/Uniform]

$u use-rng $rng

$u set min_ 0.0

$u set max_ 1.0

set random [expr [$u value]]

puts $random

 

###########################################################################

#                                                                 #

###########################################################################


           $ns at $random "$ftp send $bytes_ftp"

           puts "ftp  bytes_produced $bytes_ftp (using `FTP send nbytes')"

 

 

$ns at 0.0 "record1"

$ns at 0.0 "record3"

$ns at 100.0 "finish"

 

proc finish {} {

           global ns outfile tcp

           $ns flush-trace

           close $outfile

           

 

           exit 0

}

 

 

###########################################################################

# Trace Cwnd                                                              #

###########################################################################

           

set f1 [open cwnd.tr w]

proc record1 {} {

           global ns tcp f1 sink

           

           set now [$ns now]

           puts $f1 "$now [$tcp set cwnd_]"

           $ns at [expr $now+0.52] "record1"

           }

           

 

set f3 [open ack.tr w]

proc record3 {} {

           global ns tcp f3 sink

           set now [$ns now]

           puts $f3 "$now [$tcp set ack_]"

           $ns at [expr $now+0.52] "record3"

           }

           

 

$ns run

 

 

 

 

multi-link

 

 

 

#set parl [lindex $argv 0]

 

global ns

set ns [new Simulator]

 

# Note:  Even though "Static" is normally reserved for static

#        topologies, the satellite code will trigger a recalculation

#        of the routing tables whenever the topology changes.

#        Therefore, it is not so much "static" as "omniscient", in that

#        topology changes are known instantly throughout the topology.

#        See documentation for discussion of dynamic routing protocols.

$ns rtproto Static

 

###########################################################################

# Global configuration parameters (全域通用參數)                        #

###########################################################################

 

###########################################################################

#handoff的模擬是針對leo衛星網路模擬的部份。                               #

###########################################################################

 

HandoffManager/Term set elevation_mask_ 8.2;
#檢查當前衛星已經落到terminal的最小允許覆蓋角

HandoffManager/Term set term_handoff_int_ 10;                             #

HandoffManager set handoff_randomization_ false;    

 

global opt

set opt(chan)         Channel/Sat  ;  #衛星通道

set opt(bw_down)              10Mb;       ;  # Downlink bandwidth (satellite
to ground)(下行頻寬,衛星至地面)

set opt(bw_up)                   10Mb;       ;  # Uplink bandwidth(上行頻寬
)

set opt(phy)          Phy/Sat      ;  #物理層:衛星

set opt(mac)          Mac/Sat                            ;  #MAC層:衛星

set opt(ifq)          Queue/DropTail; #佇列型態:DropTail

set opt(qlim)                          256          ;  #Queue的最大值:256個
封包

set opt(ll)           LL/Sat       ;  #鏈結層:衛星

set opt(wiredRouting)   ON          ;   #三個事件:"+"進佇列;"-"離開佇列;
"r"接收到封包

 

 

 

# IMPORTANT This tracing enabling (trace-all) must precede link and node 

#           creation.  Then following all node, link, and error model

#           creation, invoke "$ns trace-all-satlinks $outfile" 

#重要:這個TRACE使(trace-all)必須在鏈接和結點建立之前。

#      然後跟隨的所有結點, 鏈接, 和錯誤模型的建立後,必須加入"$ns
trace-all-satlinks $outfile"

 

set outfile [open throughput_0.tr w]

$ns trace-all $outfile

 

###########################################################################

# Set up satellite and terrestrial nodes                                  #

###########################################################################

 

# Let's first create a single orbital plane of Iridium-like satellites

# 11 satellites in a plane

 

# Set up the node configuration

#建立geo衛星

 

$ns node-config -satNodeType geo \

                     -llType $opt(ll) \

                     -ifqType $opt(ifq) \

                     -ifqLen $opt(qlim) \

                     -macType $opt(mac) \

                     -phyType $opt(phy)         \

                     -channelType $opt(chan) \

                     -downlinkBW $opt(bw_down) \

                     -wiredRouting $opt(wiredRouting)  

 

 

 

# Create nodes n0 through n1

set n0 [$ns node]; 

 

 

# GEO satellite:  above North America-- lets put it at 100 deg. W

#設定geo衛星的位置

#n0設東經:100度

 

$n0 set-position 100

 

###########################################################################

#Terminal                                                                 #

###########################################################################

# Terminals:  Let's put two within the US, two around the prime meridian

$ns node-config -satNodeType terminal 

set n1 [$ns node]

$n1 set-position 50 100;

set n2 [$ns node]

$n2 set-position -50 100;

###########################################################################

# Set up links                                                            #

###########################################################################

 

# Add any necessary ISLs or GSLs

# GSLs to the geo satellite:

#GEO---------->Terminal

 

$n1 add-gsl geo $opt(ll) $opt(ifq) $opt(qlim) $opt(mac) $opt(bw_up) \

  $opt(phy) [$n0 set downlink_] [$n0 set uplink_]

$n2 add-gsl geo $opt(ll) $opt(ifq) $opt(qlim) $opt(mac) $opt(bw_up) \

  $opt(phy) [$n0 set downlink_] [$n0 set uplink_]

 

###########################################################################

# wired link                                                              #

###########################################################################


$ns unset satNodeType_

###########################################################################

# sender                                                                  #

########################################################################### 

 

set s1 [$ns node]

set s2 [$ns node]

set s3 [$ns node]

$ns duplex-link $s1 $n1 10Mb 1ms DropTail

$ns duplex-link $s2 $n1 10Mb 1ms DropTail

$ns duplex-link $s3 $n1 10Mb 1ms DropTail

 

 

set d1 [$ns node]

set d2 [$ns node]

set d3 [$ns node]

$ns duplex-link $n2 $d1 10Mb 1ms DropTail

$ns duplex-link $n2 $d2 10Mb 1ms DropTail

$ns duplex-link $n2 $d3 10Mb 1ms DropTail

 

 

 

 

 

 

set tcp1 [new Agent/TCP/Reno]

set tcpsink1 [new Agent/TCPSink]

$ns attach-agent $s1 $tcp1

$ns attach-agent $d1 $tcpsink1

$ns connect $tcp1 $tcpsink1

$tcp1 set fid_ 1

$tcpsink1 set fid_ 1

 

$tcp1 set packetSize_ [expr 1000-40]

$tcp1 set window_ 64

 

set ftp1 [new Application/FTP]

$ftp1 attach-agent $tcp1

 

 

set tcp2 [new Agent/TCP/Reno]

set tcpsink2 [new Agent/TCPSink]

$ns attach-agent $s2 $tcp2

$ns attach-agent $d2 $tcpsink2

$ns connect $tcp2 $tcpsink2

$tcp2 set fid_ 2

$tcpsink2 set fid_ 2

 

$tcp2 set packetSize_ [expr 1000-40]

$tcp2 set window_ 64

 

set ftp2 [new Application/FTP]

$ftp2 attach-agent $tcp2

 

 

set tcp3 [new Agent/TCP/Reno]

set tcpsink3 [new Agent/TCPSink]

$ns attach-agent $s3 $tcp3

$ns attach-agent $d3 $tcpsink3

$ns connect $tcp3 $tcpsink3

$tcp3 set fid_ 3

$tcpsink3 set fid_ 3

 

$tcp3 set packetSize_ [expr 1000-40]

$tcp3 set window_ 64

 

set ftp3 [new Application/FTP]

$ftp3 attach-agent $tcp3

 

 

###########################################################################

# Error Model   1                                                         #

###########################################################################

           set err [new ErrorModel]

           $err unit pkt

           $err set rate_ 0

           $err ranvar [new RandomVariable/Uniform]

#        $n1 interface-errormodel $err

           $n0 interface-errormodel $err

#        $n2 interface-errormodel $err

 

###########################################################################

# Tracing                                                                 #

###########################################################################

$ns trace-all-satlinks $outfile

 

 

 

###########################################################################

# 每個封包的大小,包含標頭(40bytes)及payload
#

# 而這裡的packetSize_及為tcp的payload大小                                 #

###########################################################################

 

###########################################################################

#                                                                         #

###########################################################################

 

 

###########################################################################

# Satellite routing                                                       #

###########################################################################

 

set satrouteobject_ [new SatRouteObject]

$satrouteobject_ compute_routes

#$satrouteobject_ set wiredRouting_ true

           

###########################################################################

#設定ftp傳送的封包大小                                                    #

###########################################################################


           set packetSize_ 100

           set packets_ftp 10

           set bytes_ftp [expr 100*1000*1000]

 

#1000bytes=1Kb

###########################################################################

#設定亂數                                                                 #

###########################################################################


set rng [new RNG]

$rng seed 0

 

set u [new RandomVariable/Uniform]

$u use-rng $rng

$u set min_ 0.0

$u set max_ 1.0

set random1 [expr [$u value]]

set random2 [expr [$u value]]

set random3 [expr [$u value]]

puts $random1

puts $random2

puts $random3

 

           $ns at $random1 "$ftp1 send $bytes_ftp"

           puts "ftp1 at $random1 bytes_produced $bytes_ftp (using `FTP send
nbytes')"

           

           $ns at $random2 "$ftp2 send $bytes_ftp"

           puts "ftp2 at $random2 bytes_produced $bytes_ftp (using `FTP send
nbytes')"

           

           $ns at $random3 "$ftp3 send $bytes_ftp"

           puts "ftp3 at $random3 bytes_produced $bytes_ftp (using `FTP send
nbytes')"

 

 

 

#$ns at 0.0 "record"

$ns at 0.0 "record1"

$ns at 0.0 "record3"

$ns at 20.0 "finish"

 

proc finish {} {

           global ns outfile tcp1 tcp2 tcp3

           $ns flush-trace

           close $outfile

           puts [format "Reno-throughput: %.1f Kbps" [expr [$tcp1 set
ack_]*([$tcp1 set packetSize_])*8/1000/60]]

                     puts [format "Reno-throughput: %.1f Kbps" [expr [$tcp2
set ack_]*([$tcp2 set packetSize_])*8/1000/60]]

           puts [format "Reno-throughput: %.1f Kbps" [expr [$tcp3 set
ack_]*([$tcp3 set packetSize_])*8/1000/60]]

           exit 0

}

 

 

###########################################################################

# Trace Cwnd                                                              #

###########################################################################

           

set f1 [open cwnd_tcp_wnd_128_bw_1m_mtu_500_pkt_10m_ber_004.tr w]

proc record1 {} {

           global ns tcp1 f1 sink

           

           set now [$ns now]

           puts $f1 "$now [$tcp1 set cwnd_]"

           $ns at [expr $now+0.52] "record1"

           }

           

 

set f3 [open ack_tcp_wnd_128_bw_1m_mtu_500_pkt_10m_ber_004.tr w]

proc record3 {} {

           global ns tcp1 f3 sink

           set now [$ns now]

           puts $f3 "$now [$tcp1 set ack_]"

           $ns at [expr $now+0.52] "record3"

           }

           

 

$ns run

 

 

 

question, when I finish ns, but the throughput which I calculate is about
1Mb, but my link capacity is 10Mb,

so, where is my wrong ?

 

thanks

Reply via email to