sorry this is the first time I use this forum.
for ns2: I use ns-2.35
for dtn: I use DTN code for ns-2.35 in the following website:
https://www.netlab.tkk.fi/tutkimus/dtn/ns/
for the script is that the:
global ns
set ns [new Simulator -multicast on]
$ns multicast
Agent/Bundle set helloInterval_ 100 ; # [ms]
Agent/Bundle set retxTimeout_ 1000.0 ; # [s]
Agent/Bundle set deleteForwarded_ 0 ; # Do not delete forwarded bundles when epidemic routing is used
Agent/Bundle set cqsize_ 0
Agent/Bundle set retxqsize_ 0
Agent/Bundle set qsize_ 0
Agent/Bundle set ifqCongestionDuration_ 0
Agent/Bundle set sentBundles_ 0
Agent/Bundle set receivedBundles_ 0
Agent/Bundle set duplicateReceivedBundles_ 0
Agent/Bundle set duplicateBundles_ 0
Agent/Bundle set deletedBundles_ 0
Agent/Bundle set forwardedBundles_ 0
Agent/Bundle set sentReceipts_ 0
Agent/Bundle set receivedReceipts_ 0
Agent/Bundle set duplicateReceivedReceipts_ 0
Agent/Bundle set duplicateReceipts_ 0
Agent/Bundle set forwardedReceipts_ 0
Agent/Bundle set avBundleDelay_ 0
Agent/Bundle set avReceiptDelay_ 0
Agent/Bundle set avBundleHopCount_ 0
Agent/Bundle set avReceiptHopCount_ 0
Agent/Bundle set avLinkLifetime_ 0
Agent/Bundle set CVRR_ 1000.0
Agent/Bundle set limitRR_ 1.0
Agent/Bundle set avNumNeighbors_ 0
Agent/Bundle set antiPacket_ 1
Agent/Bundle set routingProtocol_ 1
Agent/Bundle set initialSpray_ 16
Agent/Bundle set dropStrategy_ 0 ; # Drop tail
Agent/Bundle set bundleStorageSize_ 100000000 ; # Bytes
Agent/Bundle set congestionControl_ 0
Agent/Bundle set bundleStorageThreshold_ 0.8
global opt
set opt(chan) Channel/Sat
set opt(bw_down) 1.5Mb; # Downlink bandwidth (satellite to ground)
set opt(bw_up) 1.5Mb; # Uplink bandwidth
set opt(bw_isl) 25Mb
set opt(phy) Phy/Sat
set opt(mac) Mac/Sat
set opt(ifq) Queue/DropTail
set opt(qlim) 50
set opt(ll) LL/Sat
set opt(wiredRouting) OFF
set outfile [open satgeo.tr w]
$ns trace-all $outfile
set namtracefd [open satgeo.nam w]
$ns namtrace-all-wireless $namtracefd 1000 1000
###########################################################################
# Set up satellite and terrestrial nodes #
###########################################################################
$ns node-config -satNodeType geo-repeater /bs
-phyType Phy/Repeater /bs
-channelType $opt(chan) /bs
-downlinkBW $opt(bw_down) /bs
-wiredRouting $opt(wiredRouting)
set n0 [$ns node]
$n0 set-position 100
##########################################################################
# Terminals: Let's put two within the US, two around the prime meridian #
##########################################################################
$ns node-config -satNodeType terminal /bs
set n1 [$ns node]; set n2 [$ns node]
$n1 set-position 50 100
$n2 set-position -50 100
###########################################################################
# Set up links #
###########################################################################
# GSLs to the geo satellite:
$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_]
proc print-queue-stats {} {
global ns_ bundle_ val qtrace node_
for {set i 0} {$i < 3 } {incr i} {
puts $qtrace "[format "%.1f" [$ns now]] [$bundle$i set cqsize_] [$bundle$i set retxqsize_] [$bundle$i set qsize_] [format "%.4f" [$bundle$i set ifqCongestionDuration_]] $i [format "%.4f" [$n$i energy]]."
}
$ns_ at [expr [$ns_ now] + 1.0] "print-queue-stats"
}
proc print-average-stats {} {
global ns_ bundle_ val
set delaysum 0
set sent 0
set received 0
set receipt_delaysum 0
set sent_receipts 0
set received_receipts 0
set bundlehopcountsum 0
set receipthopcountsum 0
for {set i 0} {$i < 3 } {incr i} {
set delaysum [expr $delaysum + [$bundle$i set avBundleDelay_]*[$bundle$i set receivedBundles_]]
set sent [expr $sent + [$bundle$i set sentBundles_]]
set received [expr $received + [$bundle$i set receivedBundles_]]
set receipt_delaysum [expr $receipt_delaysum + [$bundle$i set avReceiptDelay_]*[$bundle$i set receivedReceipts_]]
set sent_receipts [expr $sent_receipts + [$bundle$i set sentReceipts_]]
set received_receipts [expr $received_receipts + [$bundle$i set receivedReceipts_]]
set bundlehopcountsum [expr $bundlehopcountsum + [$bundle$i set avBundleHopCount_]*[$bundle$i set receivedBundles_]]
set receipthopcountsum [expr $receipthopcountsum + [$bundle$i set avReceiptHopCount_]*[$bundle$i set receivedReceipts_]]
}
puts "Bundle end-to-end delay at t = [format "%.6f" [$ns now]]: [format "%.6f" [expr $delaysum/$received.0]]."
puts "Bundle delivery ratio at t = [format "%.6f" [$ns now]]: [format "%.6f" [expr $received/$sent.0]] ($received/$sent)."
puts "Bundle hop count at t = [format "%.6f" [$ns now]]: [format "%.6f" [expr $bundlehopcountsum/$received.0]]."
puts "Receipt end-to-end delay at t = [format "%.6f" [$ns now]]: [format "%.6f" [expr $receipt_delaysum/$received_receipts.0]]."
puts "Receipt delivery ratio at t = [format "%.6f" [$ns now]]: [format "%.6f" [expr $received_receipts/$sent_receipts.0]] ($received_receipts/$sent_receipts)."
puts "Receipt hop count at t = [format "%.6f" [$ns now]]: [format "%.6f" [expr $receipthopcountsum/$received_receipts.0]]."
}
Agent/Bundle instproc print-stats {time} {
$self instvar n cqsize_ retxqsize_ qsize_ sentBundles_ receivedBundles_ duplicateReceivedBundles_ duplicateBundles_ deletedBundles_ forwardedBundles_\
sentReceipts_ receivedReceipts_ duplicateReceivedReceipts_ duplicateReceipts_ forwardedReceipts_ avBundleDelay_ avReceiptDelay_ avBundleHopCount_ avReceiptHopCount_
puts "Node [$n id] stats at t = $time: $cqsize_ $retxqsize_ $qsize_ $sentBundles_ $receivedBundles_ $duplicateReceivedBundles_ $duplicateBundles_ $deletedBundles_ $forwardedBundles_\
$sentReceipts_ $receivedReceipts_ $duplicateReceivedReceipts_ $duplicateReceipts_ $forwardedReceipts_ [format "%.6f" $avBundleDelay_] [format "%.6f" $avReceiptDelay_]\
[format "%.6f" $avBundleHopCount_] [format "%.6f" $avReceiptHopCount_]."
}
# Define a 'recv' function for the class 'Agent/Bundle'
Agent/Bundle instproc recv {source from delay hc time} {
$self instvar n
puts "Destination [$n id] received bundle, source: $source, from: $from, delay: $delay ms, hop count: $hc, at t = $time."
}
Agent/Bundle instproc retx_recv {nretx source from delay hc time} {
$self instvar n retxTimeout_
puts "Destination [$n id] received retxbundle, source: $source, from: $from, delay: $delay ms, hop count: $hc, at t = $time."
}
Agent/Bundle instproc mid_recv {source from delay hc time} {
$self instvar n
#puts "Node [$n id] received bundle, source: $source, from: $from, delay: $delay ms, hop count: $hc, at t = $time."
}
Agent/Bundle instproc duplicate_recv {source from delay hc time} {
$self instvar n
#puts "Destination [$n id] received duplicate bundle, source: $source, from: $from, delay: $delay ms, hop count: $hc, at t = $time. New bundle deleted."
}
Agent/Bundle instproc duplicate_mid_recv {source from delay hc time} {
$self instvar n
#puts "Node [$n id] received duplicate bundle, source: $source, from: $from, delay: $delay ms, hop count: $hc, at t = $time. New bundle deleted."
}
Agent/Bundle instproc ret_recv {source from delay hc time} {
$self instvar n
puts "Source [$n id] received receipt, destination: $source, from: $from, delay: $delay ms, hop count: $hc, at t = $time."
}
Agent/Bundle instproc ret_mid_recv {source from delay hc time} {
$self instvar n_
#puts "Node [$n id] received receipt, destination: $source, from: $from, delay: $delay ms, hop count: $hc, at t = $time."
}
Agent/Bundle instproc ret_duplicate_recv {source from delay hc time} {
$self instvar n
#puts "Source [$n id] received duplicate receipt, destination: $source, from: $from, delay: $delay ms, hop count: $hc, at t = $time. New receipt deleted."
}
Agent/Bundle instproc ret_duplicate_mid_recv {source from delay hc time} {
$self instvar n
#puts "Node [$n id] received duplicate receipt, destination: $source, from: $from, delay: $delay ms, hop count: $hc, at t = $time. New receipt deleted."
}
Agent/Bundle instproc hello_recv {from time} {
$self instvar n
#puts "Node [$n id] received hello from node $from at t = $time."
}
Agent/Bundle instproc ack_recv {from time} {
$self instvar n_
#puts "Node [$n id] received custody ack from node $from at t = $time."
}
###########################################################################
# Tracing #
###########################################################################
$ns trace-all-satlinks $outfile
###########################################################################
# Attach agents #
###########################################################################
set bundle0 [new Agent/Bundle]; #$ns node-config -satNodeType geo-repeater
$ns attach-agent $n0 $bundle0
set bundle1 [new Agent/Bundle]; #$ns node-config -satNodeType terminal
$ns attach-agent $n1 $bundle1
set bundle2 [new Agent/Bundle]; #$ns node-config -satNodeType terminal
$ns attach-agent $n2 $bundle2
$ns connect $bundle0 $bundle1
$ns connect $bundle1 $bundle2
###########################################################################
# Satellite routing #
###########################################################################
set satrouteobject_ [new SatRouteObject]
#$satrouteobject_ compute_routes
$satrouteobject_ set wiredRouting_ off
$ns at 1.0 "$bundle1 start"
$ns at 9000.0 "finish"
proc finish {} {
global ns outfile namtracefd
$ns flush-trace
close $outfile
close $namtracefd
exit 0
}
$ns run
I'm still a beginner on ns2