Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Message from discussion On callbacks
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
C Facchini  
View profile  
 More options Sep 16 2009, 1:05 pm
From: C Facchini <c.facch...@gmail.com>
Date: Wed, 16 Sep 2009 10:05:41 -0700 (PDT)
Local: Wed, Sep 16 2009 1:05 pm
Subject: Re: On callbacks
> I'm waiting for a bunch of tests to finish so I have some time to go into
> this now, so you get a bunch of words for free :-)

The greatest gift ever :)

> Hope this is all starting to make sense.

Actually, yes. The mechanisms behind all this are clearer now.

> > What I would like to achieve is to have all the ascii traces dumped
> > into a unique file.
> > So, by looking at how EnableAscii is implemented, I thought what I
> > need was 'MakeBoundCallback'. However it is not clear to me how to
> > build the callback (in particular, different files show different
> > implementations, e.g. CsmaHelper::AsciiRxEvent in src/helper/csma-
> > helper.cc and TxCallback in stats/wifi-example-sim.cc).

> Can you see a way to get this done now?

If I got it correctly, I should do something like:

// 1) defining the specialized callback
static void
CwndChangeAscii (uint32_t oldval, uint32_t newval, std::ofstream &os)
{
  os << Simulator::Now() << ": old: " << oldval << " new: " << newval
<< std::endl;

}

int
main (int argc, char *argv[])
{
  // 2) making such a bound callback
  std::ofstream ascii;
  ascii.open ("adhoc-transfer.tr");
  Config::ConnectWithoutContext ("/NodeList/0/$ns3::TcpL4Protocol/
SocketList/0/CongestionWindow", MakeBoundCallback (&CwndChangeAscii,
ascii));

}

Still, it doesn't compile. There are some errors regarding the type
passed.
And there are also errors regarding the callback:
/usr/include/c++/4.3/bits/ios_base.h: In copy constructor
‘std::basic_ios<char, std::char_traits<char> >::basic_ios(const
std::basic_ios<char, std::char_traits<char> >&)’:
/usr/include/c++/4.3/bits/ios_base.h:782: error:
‘std::ios_base::ios_base(const std::ios_base&)’ is private
/usr/include/c++/4.3/iosfwd:52: error: within this context
/usr/include/c++/4.3/iosfwd: In copy constructor
‘std::basic_ofstream<char, std::char_traits<char> >::basic_ofstream
(const std::basic_ofstream<char, std::char_traits<char> >&)’:
/usr/include/c++/4.3/iosfwd:89: note: synthesized method
‘std::basic_ios<char, std::char_traits<char> >::basic_ios(const
std::basic_ios<char, std::char_traits<char> >&)’ first required here
/usr/include/c++/4.3/streambuf: In copy constructor
‘std::basic_filebuf<char, std::char_traits<char> >::basic_filebuf
(const std::basic_filebuf<char, std::char_traits<char> >&)’:
/usr/include/c++/4.3/streambuf:775: error:
‘std::basic_streambuf<_CharT, _Traits>::basic_streambuf(const
std::basic_streambuf<_CharT, _Traits>&) [with _CharT = char, _Traits =
std::char_traits<char>]’ is private
/usr/include/c++/4.3/iosfwd:83: error: within this context
/usr/include/c++/4.3/iosfwd: In copy constructor
‘std::basic_ofstream<char, std::char_traits<char> >::basic_ofstream
(const std::basic_ofstream<char, std::char_traits<char> >&)’:
/usr/include/c++/4.3/iosfwd:89: note: synthesized method
‘std::basic_filebuf<char, std::char_traits<char> >::basic_filebuf
(const std::basic_filebuf<char, std::char_traits<char> >&)’ first
required here
../scratch/adhoc_multihop_app.cc: In function ‘int main(int, char**)’:
../scratch/adhoc_multihop_app.cc:239: note: synthesized method
‘std::basic_ofstream<char, std::char_traits<char> >::basic_ofstream
(const std::basic_ofstream<char, std::char_traits<char> >&)’ first
required here
../scratch/adhoc_multihop_app.cc:239: error:   initializing argument 2
of ‘ns3::Callback<R, T1, T2, ns3::empty, ns3::empty, ns3::empty,
ns3::empty, ns3::empty, ns3::empty, ns3::empty> ns3::MakeBoundCallback
(R (*)(TX, T1, T2), ARG) [with R = void, TX = uint32_t, ARG =
std::basic_ofstream<char, std::char_traits<char> >, T1 = uint32_t, T2
= std::ofstream&]’
debug/ns3/callback.h: In constructor ‘ns3::BoundFunctorCallbackImpl<T,
R, TX, T1, T2, T3, T4, T5, T6, T7, T8>::BoundFunctorCallbackImpl
(FUNCTOR, ARG) [with FUNCTOR = void (*)(unsigned int, unsigned int,
std::ofstream&), ARG = std::basic_ofstream<char,
std::char_traits<char> >, T = void (*)(unsigned int, unsigned int,
std::ofstream&), R = void, TX = unsigned int, T1 = unsigned int, T2 =
std::ofstream&, T3 = ns3::empty, T4 = ns3::empty, T5 = ns3::empty, T6
= ns3::empty, T7 = ns3::empty, T8 = ns3::empty]’:
debug/ns3/ptr.h:243:   instantiated from ‘ns3::Ptr<T> ns3::Create(T1,
T2) [with T = ns3::BoundFunctorCallbackImpl<void (*)(unsigned int,
unsigned int, std::ofstream&), void, unsigned int, unsigned int,
std::ofstream&, ns3::empty, ns3::empty, ns3::empty, ns3::empty,
ns3::empty, ns3::empty>, T1 = void (*)(unsigned int, unsigned int,
std::ofstream&), T2 = std::basic_ofstream<char, std::char_traits<char>
>]’

debug/ns3/callback.h:925:   instantiated from ‘ns3::Callback<R, T1,
T2, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty,
ns3::empty, ns3::empty> ns3::MakeBoundCallback(R (*)(TX, T1, T2), ARG)
[with R = void, TX = uint32_t, ARG = std::basic_ofstream<char,
std::char_traits<char> >, T1 = uint32_t, T2 = std::ofstream&]’
../scratch/adhoc_multihop_app.cc:239:   instantiated from here
debug/ns3/callback.h:287: error: invalid conversion from ‘void*’ to
‘unsigned int’

The same happens if I pass, say, a class instance.
If I pass, say, a char or an int, the code compiles but it doesn't
trace cwnd changes (not even using wildcards in lieu of node numbers)
although packets are exchanged, according to the .pcap trace.

The complete source can be found here: http://pastebin.com/m2c6f2be6

--
Christian


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.