signetlabdei / DESERT_Underwater

DESERT Underwater: an NS-Miracle extension to DEsign, Simulate, Emulate and Realize Test-beds for Underwater network protocols
http://desert-underwater.dei.unipd.it/
BSD 3-Clause "New" or "Revised" License
27 stars 21 forks source link

Aloha with ACK mode #22

Open alshayokh opened 2 weeks ago

alshayokh commented 2 weeks ago

Hi. I set the TCL file for ACK mode for Aloha. But it shows the following Screenshot from 2024-09-23 15-05-13

Is there any solution to this?

alshayokh commented 2 weeks ago

i tried to debug. Here is the screenshot

Screenshot from 2024-09-23 15-40-49

I am not being able to understand why the segmentation fault is happening? Is it because of Pure Aloha is being used with ACK? Without ACK it works fine.

fedefava86 commented 3 days ago

From the issue itself is not clear whether you are using a sample tcl file or a custom tcl file built by you. In the latter case, would you mind paste it here?

alshayokh commented 2 days ago

Stack of the nodes

+-------------------------+

| 7. UW/CBR |

+-------------------------+

| 6. UW/UDP |

+-------------------------+

| 5. UW/STATICROUTING |

+-------------------------+

| 4. UW/IP |

+-------------------------+

| 3. UW/MLL |

+-------------------------+

| 2. UW/ALOHA |

+-------------------------+

| 1. MPHY/BPSK/Underwater|

+-------------------------+

| |

+-------------------------+

| UnderwaterChannel |

+-------------------------+

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

Flags to enable or disable options

###################################### set opt(verbose) 1 set opt(trace_files) 0 set opt(bash_parameters) 0

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

Library Loading

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

load libMiracle.so load libMiracleBasicMovement.so load libmphy.so load libmmac.so load libUwmStd.so load libuwip.so load libuwstaticrouting.so load libuwmll.so load libuwudp.so load libuwcbr.so load libuwaloha.so load libuwinterference.so load libuwphy_clmsgs.so load libuwstats_utilities.so load libuwphysical.so

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

NS-Miracle initialization

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

You always need the following two lines to use the NS-Miracle simulator

set ns [new Simulator] $ns use-Miracle

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

Tcl variables

################## set opt(nn) 2.0 ;# Number of Nodes set opt(pktsize) 125 ;# Pkt size in byte set opt(starttime) 1
set opt(stoptime) 10000 set opt(txduration) [expr $opt(stoptime) - $opt(starttime)] ;# Duration of the simulation set opt(txpower) 180.0 ;#Power transmitted in dB re uPa set opt(maxinterval_) 20.0 ; set opt(freq) 25000.0 ;#Frequency used in Hz set opt(bw) 8000.0 ;#Bandwidth used in Hz set opt(bitrate) $opt(bw) ;#bitrate in bps set opt(ack_mode) "setAckMode" set opt(rngstream) 1; set opt(rx_snr_penalty_db) -10.0; set opt(per_tgt) 0.1; set opt(tx_margin_db) 10.0; set opt(prop_speed) 1500; #m/s set opt(cbr_period) 60 set opt(scale) 500

global defaultRNG for {set k 0} {$k < $opt(rngstream)} {incr k} { $defaultRNG next-substream

}

if {$opt(trace_files)} { set opt(tracefilename) "./test_uwdacap.tr" set opt(tracefile) [open $opt(tracefilename) w]

set opt(cltracefilename) "./test_uwdacap.cltr"
set opt(cltracefile) [open $opt(tracefilename) w]

} else { set opt(tracefilename) "/dev/null" set opt(tracefile) [open $opt(tracefilename) w]

set opt(cltracefilename) "/dev/null"
set opt(cltracefile) [open $opt(cltracefilename) w]

}

MPropagation/Underwater set practicalSpreading 1.5 MPropagation/Underwater set debug 0 MPropagation/Underwater set windspeed 10 MPropagation/Underwater set shipping 1

set channel [new Module/UnderwaterChannel] set propagation [new MPropagation/Underwater] set data_mask [new MSpectralMask/Rect] $data_mask setFreq $opt(freq)proc $data_mask setBandwidth $opt(bw)

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

Module Configuration

######################### Module/UW/CBR set packetSize $opt(pktsize) Module/UW/CBR set period $opt(cbrperiod) Module/UW/CBR set PoissonTraffic 1 Module/UW/CBR set debug_ 0 Module/UW/ALOHA set uwalohadebug 1 Module/UW/PHYSICAL set MaxTxSPLdB $opt(txpower) Module/MPhy/BPSK set TxPower_ $opt(txpower) Module/UW/PHYSICAL set MaxTxSPLdB $opt(txpower) Module/UW/PHYSICAL set debug_ 0 Module/UW/PHYSICAL set MinTxSPLdB 10 Module/UW/PHYSICAL set AcquisitionThresholddB 4.0 Module/UW/PHYSICAL set CentralFreqOptimization 0 Module/UW/PHYSICAL set SPLOptimization 1 Module/UW/PHYSICAL set TxPower $opt(txpower) Module/UW/PHYSICAL set BitRate $opt(bitrate) Module/UW/PHYSICAL set RxSnrPenaltydB $opt(rx_snr_penaltydb) Module/UW/PHYSICAL set BandwidthOptimization 0 Module/UW/PHYSICAL set PERtarget $opt(per_tgt) Module/UW/PHYSICAL set TxSPLMargindB $opt(tx_margindb) Module/UW/PHYSICAL set MaxTxRange 50000 Module/UW/PHYSICAL set NoiseSPD_ 0

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

Procedure(s) to create nodes

################################ proc createNode { id } {

global channel propagation data_mask ns cbr position node udp portnum ipr ipif channel_estimator
global phy posdb opt rvposx rvposy rvposz mhrouting mll mac woss_utilities woss_creator db_manager
global node_coordinates

set node($id) [$ns create-M_Node $opt(tracefile) $opt(cltracefile)] 
for {set cnt 0} {$cnt < $opt(nn)} {incr cnt} {
    set cbr($id,$cnt)  [new Module/UW/CBR] 

}
set udp($id)  [new Module/UW/UDP]
set ipr($id)  [new Module/UW/StaticRouting]
set ipif($id) [new Module/UW/IP]
set mll($id)  [new Module/UW/MLL] 
set mac($id)  [new Module/UW/ALOHA]
set phy($id)  [new Module/UW/PHYSICAL]

for {set cnt 0} {$cnt < $opt(nn)} {incr cnt} {
    $node($id) addModule 7 $cbr($id,$cnt)   1  "CBR"
}
$node($id) addModule 6 $udp($id)   1  "UDP"
$node($id) addModule 5 $ipr($id)   1  "IPR"
$node($id) addModule 4 $ipif($id)  1  "IPF"   
$node($id) addModule 3 $mll($id)   1  "MLL"
$node($id) addModule 2 $mac($id)   1  "MAC"
$node($id) addModule 1 $phy($id)   1  "PHY"

for {set cnt 0} {$cnt < $opt(nn)} {incr cnt} {
    $node($id) setConnection $cbr($id,$cnt)   $udp($id)   0
    set portnum($id,$cnt) [$udp($id) assignPort $cbr($id,$cnt) ]
}
$node($id) setConnection $udp($id)   $ipr($id)   1
$node($id) setConnection $ipr($id)   $ipif($id)  1
$node($id) setConnection $ipif($id)  $mll($id)   1
$node($id) setConnection $mll($id)   $mac($id)   1
$node($id) setConnection $mac($id)   $phy($id)   1
$node($id) addToChannel  $channel    $phy($id)   1

if {$id > 254} {
    puts "hostnum > 254!!! exiting"
    exit
}

$ipif($id) addr [expr $id + 1]

set position($id) [new "Position/BM"]
$node($id) addPosition $position($id)
set posdb($id) [new "PlugIn/PositionDB"]
$node($id) addPlugin $posdb($id) 20 "PDB"
$posdb($id) addpos [$ipif($id) addr] $position($id)

#Setup positions
$position($id) setX_ [expr $id*0]
$position($id) setY_ [expr $id*$opt(scale)]
$position($id) setZ_ -100

set interf_data($id) [new "Module/UW/INTERFERENCE"]
$interf_data($id) set maxinterval_ $opt(maxinterval_)
$interf_data($id) set debug_       0

$phy($id) setPropagation $propagation

$phy($id) setSpectralMask $data_mask
$phy($id) setInterference $interf_data($id)
$mac($id) $opt(ack_mode)

}

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

Node Creation

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

Create here all the nodes you want to network together

for {set id 0} {$id < $opt(nn)} {incr id} { createNode $id }

for {set i 0} {$i < $opt(nn)} {incr i} {
    puts "node $i position: x:[$position($i) getX_], y:[$position($i) getY_], z:[$position($i) getZ_]"
}
puts "\n"

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

Inter-node module connection

################################ proc connectNodes {id1 des1} { global ipif ipr portnum cbr cbr_sink ipif_sink portnum_sink ipr_sink opt

$cbr($id1,$des1) set destAddr_ [$ipif($des1) addr]
$cbr($id1,$des1) set destPort_ $portnum($des1,$id1)

$cbr($des1,$id1) set destAddr_ [$ipif($id1) addr]
$cbr($des1,$id1) set destPort_ $portnum($id1,$des1) 

}

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

Setup Flows

################# for {set id1 0} {$id1 < $opt(nn)} {incr id1} { for {set id2 0} {$id2 < $opt(nn)} {incr id2} { connectNodes $id1 $id2 } }

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

Fill ARP tables

################### for {set id1 0} {$id1 < $opt(nn)} {incr id1} { for {set id2 0} {$id2 < $opt(nn)} {incr id2} { $mll($id1) addentry [$ipif($id2) addr] [$mac($id2) addr] } }

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

Routing tables

################## for {set id1 0} {$id1 < $opt(nn)} {incr id1} { for {set id2 0} {$id2 < $opt(nn)} {incr id2} {

if {$id2 != $id1} {

        $ipr($id2) addRoute [$ipif($id1) addr] [$ipif($id1) addr]
    #}
}

}

if {$opt(verbose)} {

for {set id1 0} {$id1 < $opt(nn)} {incr id1} {

$ipr($id1) printroutes

}

}

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

Start/Stop Timers

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

Set here the timers to start and/or stop modules (optional)

e.g.,

for {set id1 0} {$id1 < $opt(nn)} {incr id1} { if {$id1 != 0} { $ns at $opt(starttime) "$cbr($id1,0) start" $ns at $opt(stoptime) "$cbr($id1,0) stop" } } ###################

Final Procedure

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

Define here the procedure to call at the end of the simulation

proc finish {} { global ns opt outfile global mac propagation cbr_sink mac_sink phy_data phy_data_sink channel db_manager propagation global node_coordinates global ipr_sink ipr ipif udp cbr phy phy_data_sink global node_stats tmp_node_stats sink_stats tmp_sink_stats if ($opt(verbose)) { puts "---------------------------------------------------------------------" puts "Simulation summary" puts "number of nodes : $opt(nn)" puts "packet size : $opt(pktsize) byte" puts "cbr period : $opt(cbr_period) s"

    puts "simulation length: $opt(txduration) s"
    puts "tx power         : $opt(txpower) dB"
    puts "tx frequency     : $opt(freq) Hz"
    puts "tx bandwidth     : $opt(bw) Hz"
    puts "bitrate          : $opt(bitrate) bps"
    puts "---------------------------------------------------------------------"
}
set sum_cbr_throughput     0
set sum_per                0
set sum_cbr_sent_pkts      0.0
set sum_cbr_rcv_pkts       0.0    

for {set i 0} {$i < $opt(nn)} {incr i}  {
    for {set j 0} {$j < $opt(nn)} {incr j} {
        set cbr_throughput           [$cbr($i,$j) getthr]
        set sum_cbr_throughput [expr $sum_cbr_throughput + $cbr_throughput]
        if {$i != $j} {
            set cbr_sent_pkts        [$cbr($i,$j) getsentpkts]
            puts "sent                                     :$cbr_sent_pkts"
            set sum_cbr_sent_pkts [expr $sum_cbr_sent_pkts + $cbr_sent_pkts]
            set cbr_rcv_pkts           [$cbr($i,$j) getrecvpkts]
            puts "received                                 :$cbr_rcv_pkts"
            set sum_cbr_rcv_pkts  [expr $sum_cbr_rcv_pkts + $cbr_rcv_pkts]
        }
        if ($opt(verbose)) {
            puts "cbr($i,$j) throughput                      :$cbr_throughput"
        }
        puts "\n" 
    }

}

set ipheadersize        [$ipif(1) getipheadersize]
set udpheadersize       [$udp(1) getudpheadersize]
set cbrheadersize       [$cbr(1,0) getcbrheadersize]

if ($opt(verbose)) {
    puts "Mean Throughput          : [expr ($sum_cbr_throughput/(($opt(nn))*($opt(nn)-1)))]"
    puts "Sent Packets             : $sum_cbr_sent_pkts"
    puts "Received Packets         : $sum_cbr_rcv_pkts"
    puts "Packet Delivery Ratio    : [expr $sum_cbr_rcv_pkts / $sum_cbr_sent_pkts * 100]"
    puts "IP Pkt Header Size       : $ipheadersize"
    puts "UDP Header Size          : $udpheadersize"
    puts "CBR Header Size          : $cbrheadersize"
    puts "done!"
}

$ns flush-trace
close $opt(tracefile)

}

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

start simulation

################### if ($opt(verbose)) { puts "\nStarting Simulation\n" puts "----------------------------------------------" }

$ns at [expr $opt(stoptime) + 250.0] "finish; $ns halt"

$ns run

fedefava86 commented 2 days ago

Thanks, confirmed segfault also on our side, we are going to look into it and let you know, thx for spotting. BTW, the segfault seems to be present only on ACK case because it actually segfault on handling data packets with ACK

fedefava86 commented 1 day ago

Thanks, confirmed bug we found and solved internally, will be part of the next release which will happen soon