2009/5/29 Antti Mäkelä <zar...@gmail.com>> 2009/5/27 Antti Mäkelä <zar...@gmail.com>
> I am proposing for including TapNetDevice in ns-3-dev:Well, for tunneling anything over UDP looks like I need this anyway.
>
> http://code.nsnam.org/gjc/ns-3-tap-netdevice/
Looks relatively straightforward, but can you tell me what are the
parameters that will be passed in your
typedef Callback<bool, Ptr<Packet>, const Address&, const Address&,
uint16_t> SendFromCallback;
When I create the callback function, what happens depending on the
return type (the boolean) being true or false?
Ptr<Packet> is probably just a pointer to the packet itself - I guess
when I'm sending this I'll just push it out as UDP datagram.
Besides wondering what these are and why, wondering why does it
require so many parameters - after all, I just want to load the
octects from the inbound packet into a tunnel...
What's the uint16 ( bool PromiscReceive() suggests it's protocol
number) - what do I need this for?
Also, what are the addresses for? Aren't all the IP headers included
in Ptr<Packet>?
I take it that choosing what actually gets encapsulated is as simple
as setting up a static route with AddNetworkRouteTo and pointing the
network at the other end of a tunnel being reachable via the Tap-Net-
Device...
(Well, if you had that example program, that would probably answer all
of these questions :))
I will make an example program tomorrow.
Besides, your questions are very useful for me to know how to improve the documentation ;-)
But I don't have time today to work on the example or answer the question; sorry.
--
Gustavo J. A. M. Carneiro
INESC Porto, Telecommunications and Multimedia Unit
"The universe is always one step beyond logic." -- Frank Herbert
Ok - that wasn't obvious for me - I'll take a look.
> The documentation for SendFromCallback will just point to the documentation
> for NetDevice::SendFrom.
> The example program is written, see examples/tap-net-device.cc inhttp://code.nsnam.org/gjc/ns-3-tap-netdevice/
Right...ok, in this example your "Tunnel" class is specifically one
that creates point-to-multipoint tunnel (which is nice example since
it makes more clear how should I go on modifying it).
The tunnel class seems relatively straightforward - you basically
create and bind UDP socket in fixed port 667. I notice that you are
using IPv4Address::GetAny() instead of the specific (physical) point-
to-point interface so I guess it would consider *any* packet recevied
in port 667 as coming in via tunnel.
Anyway, the example makes it clear that SetRecvCallback is already
part of ns-3, your TapDevice adds the SendFromCallback functionality.
I haven''t yet completely grokked the sockets interface yet.
Instead of routing you just use RNG to determine the destination -
using full routing shouldn't be a problem here I guess, interface is
still an interface. Also, you are binding the OnOffapplication
directly to the tunnel so from routing perspective it's directly-
connected. Anyhow, if I want to tunnel stuff that is coming not from
the tunnel endpoint itself but another node, it's should still doable
with routing pointing to the tunnel interface.
All in all, thanks for the example - only stuff that I seem to be
unclear on right now is about the receiving callbacks. Is there any
easy way to make the RecvCallback functions generic? I mean, you have
void N3SocketRecv (Ptr<Socket> socket), void N0SocketRecv (Ptr<Socket>
socket) and void N1SocketRecv (Ptr<Socket> socket), each basically
consisting of m_nXTap->Receive (packet, 0x0800, Address ()).. So
basically, each and every node needs a separate callback function?
(My idea would be to try socket->GetSockName and then maybe have
some data structure that would associate TapDevices with physical i/f
addresses - then you could just do the Receive call through a pointer
to the correct device)
Also, in the m_nXTap->Receive call itself - what purposes do using
protocol 0x0800 (Yes, it's Ethertype for IPv4, but why) and basically
empty address (created by Address())? If I look at your Receive method
it further calls m_RxTrace(), but unfortunalely I cannot decipher
further since the documentation at http://www.nsnam.org/doxygen/functions_0x6d.html#index_m
doesn't include m_RxTrace method...
Anyway, big thanks!
Is there any way to simulate IPv6 tunneling techniques, like; 6to4, Teredo, and ISATAP ?
> I am proposing for including TapNetDevice in ns-3-dev:Hey, glad to see this got made into VirtualNetDevice and is now part
>
> http://code.nsnam.org/gjc/ns-3-tap-netdevice/
>
> The TapNetDevice allows one to register a callback for transmitting
> packets. There's some documentation in the header file, see:
of the main tree. I have noticed one weird issue - if I have enabled
pcap captures on nodes where there are tunnel devices present, the
capture files turn up zero-length (not the "empty" 24 bytes, but
zero). It's almost as if something is not getting flushed at
Simulator::Destroy(). I have pretty much adapted your tunnel class
example to my purposes.
Anyway, two things - your example as it stands now (virtual-net-
device.cc) does not work anymore, fails with
assert failed. file=../src/routing/list-routing/ipv4-list-routing.cc,
line=108, cond="m_ipv4->GetInterfaceForDevice (idev) >= 0"
thus I cannot check if this happens also with your example,
and second - just my guess - but should I write a deconstructor for
the Tunnel class which would clean up the netdevices? Or what could be
the cause?
Well, apparently the fix doesn't work - assert at ipv4-list-routing
On Jul 3, 1:15 pm, Gustavo Carneiro <gjcarne...@gmail.com> wrote:
> Hm.. you don't understand and neither do I because it doesn't make sense!
> :-P
>
> Pushed a fix now, thanks for spotting the problem.
still fails. (Just did hg pull&hg update). Anyway, problem is
apparently elsewhere (and this doesn't help me trace down my zero-
length-captures issue, either). If I turn on logging it appears that
most of the problems appear at the end of the simulation run. I tried
a few tests with logging on on your example, and to save some time I
set the apps to stop (Changed all lines with apps.Stop()) to 1.3
seconds - even so, sim stops at 3.37 to the aforementioned assert()
error.
Oh well, let's see if I can fix my issue by coming up with a proper
deconstructor, although I thought that Ptr<>'s being smart and all
should take care of that by itself.
On Jul 3, 2:48 pm, Gustavo Carneiro <gjcarne...@gmail.com> wrote:
> > Well, apparently the fix doesn't work - assert at ipv4-list-routing
> > still fails. (Just did hg pull&hg update). Anyway, problem is
> > apparently elsewhere (and this doesn't help me trace down my zero-
> > length-captures issue, either). If I turn on logging it appears that
> > most of the problems appear at the end of the simulation run. I tried
> > a few tests with logging on on your example, and to save some time I
> > set the apps to stop (Changed all lines with apps.Stop()) to 1.3
> > seconds - even so, sim stops at 3.37 to the aforementioned assert()
> > error.
>
> Grr! I had tested the fix, committed, but then I had to merge with more
> upstream changes and it stopped working again :-/
Well, I resolved my issue :) I had used Simulator::Stop(Seconds(30))
to terminate simulation at predetermined time, before calling
Simulator::Destroy(). Removing the Stop() made pcaps print out just
fine. Now I'm just wondering what would be the best way to specify the
maximum running time of a simulation if I don't want to individually
shut down all my apps at that maxtime.
Anyway, as my intention is to simulate creating and shutting down
VPNs (Tunnels), I'm wondering what is the best way to *delete*
tunnels. I mean, you can only AddDevice()s to nodes, and I really
don't want to have gazillion VirtualNetDevices exist at once - they
should be removed completely once shut down.
I can easily close the sockets at deconstructor, but removing the
devices is another matter. Or will smart pointers take care of it
autotically - if no one refers to a NetDevice (the instance of Tunnel
is removed, thus anyone who ever had knowledge (via
Ptr<VirtualNetDevice>s) of the VirtualNetDevice is gone) - it the
device automatically removed from the node when refcount ticks to
zero?
Of course I can handle this by routing as well and keep the devices
up all times, but my intention is to include a keepalive system into
the tunnel protocol, and an error model which forces the tunnels to be
re-established every now and then when the keepalive fails...thus,
simulating the actual tunnel failing by nuking packets and switching
routes sounds a bit cumbersome.
> Ok, I was finally able to test something - and looks like the bug
> with packet dumps is still there.
>
> Alter your virtual-net-device.cc by adding the line
>
> onoff.SetAttribute ("MaxBytes", UintegerValue(210));
>
> to around line 269. That is, this manifests itself only when you are
> sending very small amounts of data.
>
> You'll see zero-sized files.
>
> If you increase the value to something >20000, the files are no
> longer empty, but it's apparent not all packets made it. Also,
> wireshark complains "The capture file appears to have been cut short
> in the middle of a packet".
>
> Problem is that *all* interfaces of a node have these issues. It's
> like some flushing is not being done...
This is the classic symptom of a memory leak. What usually happens is that
a pointer reference is held that prevents the reference counts of the nodes
from being decremented to zero, which (after a sometimes long chain of
events) in turn causes the trace writer destructors not to be executed which
means the trace files are not flushed at close.
Try running your simulation under valgrind and I'll bet you'll see a leak.
-- Craig