[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [ns] Minor Bug in TCP code
On Sat, 1 Dec 2001, Sugat Jain wrote:
> There seems to be a minor bug in the TCP code in NS.
>
> The Problem: It apparently drops the very first packet sent out on the
> connection. This happens because the TCP has to do a handshake to set up
> the connection and therefore sends a SYN packet.
I'm confused.
In ns, only FullTcp attempts to simulate SYN/ACK exchanges (well,
that's what the documentation says - can't see a mention of the syn_
boolean there), although the tcp.cc code is shared by both.
What TCP agent are you trying to fix the problem for?
(last I looked, FullTcp receivers still relied on packet size as a way
of detecting SYN etc. - breaking FullTcp is a useful way to
demonstrate that you're not adding/removing tunnelling overhead
correctly or symmetrically.)
L.
> The way it is implemented
> is that when it is detected that the very first packet is being sent out,
> that packet is converted to a SYN packet by changing the size to 40 bytes.
> Thus if, say 500bytes, were to be sent out in the first packet, instead
> only a SYN packet of 40 bytes is sent out.
>
> If you want to look at where this happens, it's in tcp.cc, in function
> TcpAgent::output around line 536:
> if (seqno == 0) {
> if (syn_) {
> hdr_cmn::access(p)->size() = tcpip_base_hdr_size_;
> }
> ...
> }
>
>
> To correct this problem:
> In file tcp.cc in function TcpAgent::sendmsg
> Around lines, 585 replace
> if (nbytes == -1 && curseq_ <= TCP_MAXSEQ)
> curseq_ = TCP_MAXSEQ;
> else
> curseq_ += (nbytes/size_ + (nbytes%size_ ? 1 : 0));
>
> with the following code:
> if (nbytes == -1 && curseq_ <= TCP_MAXSEQ)
> curseq_ = TCP_MAXSEQ;
> else
> {
> if (syn_ && 0 == curseq_)
> curseq_++; //For syn packet
> curseq_ += (nbytes/size_ + (nbytes%size_ ? 1 : 0));
> }
>
> This will ensure that when the first packet is being sent out a separate
> packet for SYN is sent out before the first packet.
<[email protected]>PGP<http://www.ee.surrey.ac.uk/Personal/L.Wood/>