[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[ns] A problem of using FullTcp in wireless simulation (a bug somewhere?)




Hi all,

I'd like to use FullTcp in some wireless simulations. However, it seems
that currently,  FullTcp upon a wireless link does not work well.
( I used ns-2.1b8a and run simulations on a Linux machine.)
Attached is a tcl script I used for a simple scenario. The topology is
like:

                   wireless link
n0 <-----------------> n1
FullTcp-agent                         FullTcp-agent

And I got the following error messages:
1.015565: FullTcpAgent::recv(_o46): bad ACK (29) for our SYN(1)
1.016846: FullTcpAgent::recv(_o47) got packet lacking ACK (seq 29)
7.000969: FullTcpAgent::recv(_o47) got packet lacking ACK (seq 29)
7.015133: FullTcpAgent::recv(_o46): bad ACK (29) for our SYN(1)
7.016474: FullTcpAgent::recv(_o47) got packet lacking ACK (seq 29)

I've diggen into tcp-full.cc a little bit, and find that something was
wrong when the first SYN packet was received by node n1. The
correct process should be:
n0 ---------------------> n1
       SYN, sequence #=0
n0 <--------------------- n1
        SYN + ACK (ack # =1)
.................

However, in the wireless simulation, the ack number from n1 was set
incorrectly. The process is like:
n0 ---------------------> n1
       SYN, sequence #=0
n0 <--------------------- n1
        SYN + ACK (ack # =29)
.................

And, the reason ack is set to 29 is: in the recv() function of tcp1
(attached to n1),  the packet size (th->size() , where th is a hdr_cmn
pointer) is modified to 68 (40 is the right value, which is equal to the

sum of the size of tcp header(40) and datelen(0)).

Does anybody have a clue to what could be wrong? I suspect it may be
the link layer or the MAC layer that accidently modifies the packet
size.
I also printed out some debugging messages, and hope that may help.

-Huaiyu(Kitty) Liu

#----------------- Debug message --------------------
Starting Simulation...
time 1:In FullTcpAgent _o46; connect() called
--------------------
time 1: FullTcpAgent(_o46), at state2; send a pkt, seqno(0);ackno(-1)
"datalen is" 0; "tcph->hlen" is 40
--------------------
1.01416 :FullTcpAgent(_o47) at state LISTEN, recv a pkt, with ackno(-1)
"th->size()" is:68; "tcph->hlen" is:40
"irs_" is:0; "datalen" is:28
"rcv_nxt_" is set to 29
--------------------
1.01416: FullTcpAgent(_o47), at state 3; send a pkt, seqno(0);ackno(29)
"datalen" is 0; "tcph->hlen" is 40
--------------------
--------------------
1.01557: FullTcpAgent(_o46), at state2; send a pkt, seqno(29);ackno(0)
"datalen" is 0; "tcph->hlen" is 40
--------------------
--------------------
7: FullTcpAgent(_o46), at state2; send a pkt, seqno(0);ackno(-1)
datalen is 0; tcph->hlen is 40
--------------------
--------------------
7.01416: FullTcpAgent(_o47), at state3; send a pkt, seqno(0);ackno(29)
datalen is 0; tcph->hlen is 40
--------------------
--------------------
7.01513: FullTcpAgent(_o46), at state2; send a pkt, seqno(29);ackno(0)
datalen is 0; tcph->hlen is 40
--------------------
NS EXITING...
#-------------------------------------------------------------


#----------------- Simulation Script ------------------------------

set val(chan)       Channel/WirelessChannel
set val(prop)       Propagation/TwoRayGround
set val(netif)      Phy/WirelessPhy
set val(mac)        Mac/802_11
set val(ifq)        Queue/DropTail/PriQueue
set val(ll)         LL
set val(ant)        Antenna/OmniAntenna
set val(x)              100   ;# X dimension of the topography
set val(y)              100   ;# Y dimension of the topography
set val(ifqlen)         50            ;# max packet in ifq
set val(seed)           0.0
set val(adhocRouting)   DSR
set val(nn)             2            ;# how many nodes are simulated
set val(stop)           10.0           ;# simulation time

set ns_  [new Simulator]
set topo [new Topography]

set tracefd [open wireless1-out.tr w]
$ns_ trace-all $tracefd

$topo load_flatgrid $val(x) $val(y)

set god_ [create-god $val(nn)]

set chan_ [new $val(chan)]
$ns_ node-config -adhocRouting $val(adhocRouting) \
                 -llType $val(ll) \
                 -macType $val(mac) \
                 -ifqType $val(ifq) \
                 -ifqLen $val(ifqlen) \
                 -antType $val(ant) \
                 -propType $val(prop) \
                 -phyType $val(netif) \
   -topoInstance $topo \
   -agentTrace ON \
                 -routerTrace OFF \
                 -macTrace OFF \
   -channel $chan_ \

set cubebase_ 2
set totalnode_ $val(nn)
set totalround_ [expr log($totalnode_)/log($cubebase_)]

for {set i 0} {$i< $totalnode_} {incr i} {
    set node_($i) [$ns_ node]
 $node_($i) random-motion 0
}

$node_(0) set X_ 10.0
$node_(0) set Y_ 10.0
$node_(0) set Z_ 0.0

$node_(1) set X_ 90.0
$node_(1) set Y_ 10.0
$node_(1) set Z_ 0.0


#--------- Test with a FullTCP flow _________________
set tcp0 [new Agent/TCP/FullTcp]
$tcp0 set window_ 100
$tcp0 set fid_ 0
$tcp0 set class_ 2
set tcp1 [new Agent/TCP/FullTcp]
$tcp1 set window_ 100
$tcp1 set fid_ 1
$ns_ attach-agent $node_(0) $tcp0
$ns_ attach-agent $node_(1) $tcp1
$ns_ connect $tcp0 $tcp1
$tcp1 listen

$ns_ at 1.0 "$tcp0 send 2048"


for {set i 0} {$i < $val(nn) } {incr i} {
    $ns_ at $val(stop).0 "$node_($i) reset";
}

puts $tracefd "M 0.0 nn $val(nn) x $val(x) y $val(y) rp
$val(adhocRouting)"
puts $tracefd "M 0.0 prop $val(prop) ant $val(ant)"

$ns_ at 10 "stop"
$ns_ at 10.01 "puts \"NS EXITING...\" ; $ns_ halt"
proc stop {} {
    global ns_ tracefd
    $ns_ flush-trace
    close $tracefd
}

puts "Starting Simulation..."
$ns_ run