Re: [dtn-users] A problem with dtntunnel

David Zoller <zollerd@gmail.com> Fri, 14 December 2012 17:32 UTC

Return-Path: <zollerd@gmail.com>
X-Original-To: dtn-users@ietfa.amsl.com
Delivered-To: dtn-users@ietfa.amsl.com
Received: from localhost (localhost [127.0.0.1]) by ietfa.amsl.com (Postfix) with ESMTP id 09AE821F8A90 for <dtn-users@ietfa.amsl.com>; Fri, 14 Dec 2012 09:32:03 -0800 (PST)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -2.998
X-Spam-Level:
X-Spam-Status: No, score=-2.998 tagged_above=-999 required=5 tests=[BAYES_00=-2.599, HTML_MESSAGE=0.001, J_CHICKENPOX_92=0.6, RCVD_IN_DNSWL_LOW=-1]
Received: from mail.ietf.org ([64.170.98.30]) by localhost (ietfa.amsl.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 5TnjgYSR8Udx for <dtn-users@ietfa.amsl.com>; Fri, 14 Dec 2012 09:32:02 -0800 (PST)
Received: from mail-da0-f54.google.com (mail-da0-f54.google.com [209.85.210.54]) by ietfa.amsl.com (Postfix) with ESMTP id 5E22B21F8A47 for <dtn-users@irtf.org>; Fri, 14 Dec 2012 09:32:02 -0800 (PST)
Received: by mail-da0-f54.google.com with SMTP id n2so1448252dad.13 for <dtn-users@irtf.org>; Fri, 14 Dec 2012 09:32:02 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:date:message-id:subject:from:to:content-type; bh=YtWoq4mcAmFF1nsBAZjQoT4U9NIBAOD6XWRXRwoCNbI=; b=xex4S7bQldBEHnEgc+73JkLOjvsuFjax17gxcp4Hc9VliS4ASoUcstppFKUjzvUzy6 rpd49UgLKtDGlW+epGYuYWUn/Db80jGIPs9AuPAIwmdAYgixTzryi8h7Ugm3VpZocPoS jp29BK5axim3xCl/NIR5xaWCwqQc+pxAGW6nwB3fNH6WkxqKpoXkuESwmJI+AKz9SjjO RWY4L6/CdhY4y+Kz1V1nWfXnqdHW2Poae5ackdnawJUkhqW8TIY+Ph4YhW9m8SmSFOiT fX62wNZkFyufJA3RsJZ4J3vYc223r//uSZazlwPFhXEly3zRHeI67MlcJtUQGVAo885S VDmQ==
MIME-Version: 1.0
Received: by 10.68.252.228 with SMTP id zv4mr17617835pbc.134.1355506322052; Fri, 14 Dec 2012 09:32:02 -0800 (PST)
Received: by 10.68.234.137 with HTTP; Fri, 14 Dec 2012 09:32:01 -0800 (PST)
Date: Fri, 14 Dec 2012 11:32:01 -0600
Message-ID: <CA+X1Codj6FoKWPDj+giFK-6oa-pbCZ8LF2x9cZyW1OzBJNTAYw@mail.gmail.com>
From: David Zoller <zollerd@gmail.com>
To: ssireskin@gmail.com, dtn-users@irtf.org
Content-Type: multipart/alternative; boundary="047d7b2e0e25d116ad04d0d3685b"
X-Mailman-Approved-At: Thu, 27 Dec 2012 08:05:59 -0800
Subject: Re: [dtn-users] A problem with dtntunnel
X-BeenThere: dtn-users@irtf.org
X-Mailman-Version: 2.1.12
Precedence: list
List-Id: "The Delay-Tolerant Networking Research Group \(DTNRG\) - Users." <dtn-users.irtf.org>
List-Unsubscribe: <https://www.irtf.org/mailman/options/dtn-users>, <mailto:dtn-users-request@irtf.org?subject=unsubscribe>
List-Archive: <http://www.irtf.org/mail-archive/web/dtn-users>
List-Post: <mailto:dtn-users@irtf.org>
List-Help: <mailto:dtn-users-request@irtf.org?subject=help>
List-Subscribe: <https://www.irtf.org/mailman/listinfo/dtn-users>, <mailto:dtn-users-request@irtf.org?subject=subscribe>
X-List-Received-Date: Fri, 14 Dec 2012 22:59:48 -0000

Hi Sergey,
I can't stay away from a problem that is nagging at me so I made some time
this morning. Going back to the original TCPTunnel.cc code, when a bundle
is received that has the EOF indication, an empty bundle with the same EOF
flag set needs to be returned to close the loop (the second FIN). There may
still be some loose ends or clean up needed but try the code below at the
end of the while loop.

I did not do a packet capture but I saw that if the receiving nc is not
running when you start the sender nc then the receiving dtntunnel logs an
error on the failed connect and returns an EOF bundle which closes the
sender nc. The EOF bundle could possibly be enhanced to include an error
message.

I agree that some applications could benefit from a "pretend to be a
receiver" option with the default working as a bidirectional end-to-end TCP
connection.

Thanks for dragging me along kicking and screaming on this lesson in DTN
and TCP tunneling. I've only been using dtntunnel as a one way UDP
transmitter. I see a good fit for the TCP tunnel in an upcoming project and
I'll try to make the pitch to use it. This is a pretty cool little app.
Best regards,
DZ





484             delete b_recv;
485
486             if (recv_hdr->eof_) {
487                 log_info("bundle had eof bit set... closing
connection");
488
489                 if ( !sock_eof ) {
490                     sock_eof = true;
491                     // send an empty bundle back since we did not
initiate the close
492                     dtn::APIBundle* b = new dtn::APIBundle();
493                     hdr.eof_ = 1;
494                     hdr.seqno_ = ntohl(send_seqno++);
495                     memcpy(b->payload_.buf(sizeof(hdr)), &hdr,
sizeof(hdr));
496                     b->payload_.set_len(sizeof(hdr));
497                     int err;
498                     if ((err = tunnel->send_bundle(b, &dest_eid_)) !=
DTN_SUCCESS) {
499                         log_err("error sending final socket closed
packet bundle: %s",
500                                 dtn_strerror(err));
501                         tcptun_->kill_connection(this);
502                         exit(1);
503                     }
504                     delete b;
505                 }
506                 sock_.close();
507                 goto done;
508             }
509         }
510     }
511
512  done: