Moving apps back to apps/ folder.  Finally worked out the problem with headers

WAF building system copies all headers to one directory. As a result,
all #include directives in all NS3 modules should be either in form
"ns3/header-file.h" or just "header-file.h", disregarding the actual
directory structure.
diff --git a/apps/stupid-interest-generator.cc b/apps/stupid-interest-generator.cc
new file mode 100644
index 0000000..0dfcf51
--- /dev/null
+++ b/apps/stupid-interest-generator.cc
@@ -0,0 +1,180 @@
+//
+//  ndn_stupidinterestgenerator.cpp
+//  Abstraction
+//
+//  Created by Ilya Moiseenko on 05.08.11.
+//  Copyright 2011 UCLA. All rights reserved.
+//
+
+#include "stupid-interest-generator.h"
+
+#include "ns3/socket-factory.h"
+#include "ns3/simulator.h"
+
+#include "ns3/interest-header.h"
+#include "ns3/content-object-header.h"
+
+NS_LOG_COMPONENT_DEFINE ("StupidInterestGenerator");
+
+namespace ns3
+{
+//namespace NDNabstraction
+//{
+    using namespace NDNabstraction;
+    
+    NS_OBJECT_ENSURE_REGISTERED (StupidInterestGenerator);
+    
+    TypeId
+    StupidInterestGenerator::GetTypeId (void)
+    {
+        static TypeId tid = TypeId ("ns3::StupidInterestGenerator")
+        .SetParent<Application> ()
+        .AddConstructor<StupidInterestGenerator> ()
+        .AddAttribute ("Remote", "The address of the destination",
+                       AddressValue (),
+                       MakeAddressAccessor (&StupidInterestGenerator::m_peer),
+                       MakeAddressChecker ())
+        .AddAttribute ("OffTime", "Time interval between packets",
+                       TimeValue (Seconds (0.1)),
+                       MakeTimeAccessor (&StupidInterestGenerator::m_offTime),
+                       MakeTimeChecker ())
+        .AddAttribute ("Protocol", "The type of protocol to use.",
+                       TypeIdValue (UdpSocketFactory::GetTypeId ()),
+                       MakeTypeIdAccessor (&StupidInterestGenerator::m_tid),
+                       MakeTypeIdChecker ())
+        ;
+        return tid;
+    }
+
+    StupidInterestGenerator::StupidInterestGenerator ()
+    {
+        NS_LOG_FUNCTION_NOARGS ();
+        m_socket = 0;
+        //m_connected = false;
+        //m_residualBits = 0;
+        //m_lastStartTime = Seconds (0);
+        //m_totBytes = 0;
+    }
+    
+    StupidInterestGenerator::~StupidInterestGenerator()
+    {
+        NS_LOG_FUNCTION_NOARGS ();
+    }
+    
+    void
+    StupidInterestGenerator::DoDispose (void)
+    {
+        NS_LOG_FUNCTION_NOARGS ();
+        
+        m_socket = 0;
+        // chain up
+        Application::DoDispose ();
+    }
+    
+    // Application Methods
+    void StupidInterestGenerator::StartApplication () // Called at time specified by Start
+    {
+        NS_LOG_FUNCTION_NOARGS ();
+        
+        // Create the socket if not already
+        if (!m_socket)
+        {
+            m_socket = Socket::CreateSocket (GetNode (), m_tid);
+            m_socket->Bind ();
+            m_socket->Connect (m_peer);
+            m_socket->SetAllowBroadcast (true);
+            m_socket->ShutdownRecv ();
+        }
+        // Insure no pending event
+        CancelEvents ();
+        // If we are not yet connected, there is nothing to do here
+        // The ConnectionComplete upcall will start timers at that time
+        //if (!m_connected) return;
+        ScheduleStartEvent ();
+    }
+    
+    void StupidInterestGenerator::StopApplication () // Called at time specified by Stop
+    {
+        NS_LOG_FUNCTION_NOARGS ();
+        
+        CancelEvents ();
+        if(m_socket != 0)
+        {
+            m_socket->Close ();
+        }
+        else
+        {
+            NS_LOG_WARN ("OnOffApplication found null socket to close in StopApplication");
+        }
+    }
+    
+    void StupidInterestGenerator::CancelEvents ()
+    {
+        NS_LOG_FUNCTION_NOARGS ();
+        
+        Simulator::Cancel (m_sendEvent);
+        Simulator::Cancel (m_startStopEvent);
+    }
+
+    void StupidInterestGenerator::ScheduleStartEvent ()
+    {  // Schedules the event to start sending data (switch to the "On" state)
+        NS_LOG_FUNCTION_NOARGS ();
+        
+        Time offInterval = Seconds (m_offTime);
+        NS_LOG_LOGIC ("start at " << offInterval);
+        m_startStopEvent = Simulator::Schedule (offInterval, &StupidInterestGenerator::StartSending, this);
+    }
+    
+    // Event handlers
+    void StupidInterestGenerator::StartSending ()
+    {
+        NS_LOG_FUNCTION_NOARGS ();
+        //m_lastStartTime = Simulator::Now ();
+        ScheduleNextTx ();  // Schedule the send packet event
+        //ScheduleStopEvent ();
+    }
+    
+    void StupidInterestGenerator::StopSending ()
+    {
+        NS_LOG_FUNCTION_NOARGS ();
+        CancelEvents ();
+        
+        ScheduleStartEvent ();
+    }
+    
+    // Private helpers
+    void StupidInterestGenerator::ScheduleNextTx ()
+    {
+        NS_LOG_FUNCTION_NOARGS ();
+        
+
+        Time nextTime = Seconds(0.); //send now
+        m_sendEvent = Simulator::Schedule (nextTime,
+                                               &StupidInterestGenerator::SendPacket, this);
+    }
+
+        
+    void StupidInterestGenerator::SendPacket ()
+    {
+        // NS_LOG_FUNCTION_NOARGS ();
+        // NS_LOG_LOGIC ("sending packet at " << Simulator::Now ());
+        // NS_ASSERT (m_sendEvent.IsExpired ());
+        
+        // NameBuilder name;
+		// name("prefix1")("prefix2")("filename");
+		InterestHeader ();
+
+		ContentObjectHeader ();
+		
+        // const ccn_charbuf *output = name.GetName();
+        // Ptr<InterestPacket> packet = Create<InterestPacket>(name,(uint32_t)output->length);
+        // packet->AddTimeout(4000);
+        // UniformVariable var;
+        // packet->AddNonce(var.GetInteger(1,10000));
+        // m_socket->Send(packet);
+        
+        // ScheduleStartEvent();
+    }
+
+//}
+}
diff --git a/apps/stupid-interest-generator.h b/apps/stupid-interest-generator.h
new file mode 100644
index 0000000..395bc3f
--- /dev/null
+++ b/apps/stupid-interest-generator.h
@@ -0,0 +1,78 @@
+//
+//  ndn_stupidinterestgenerator.h
+//  Abstraction
+//
+//  Created by Ilya Moiseenko on 05.08.11.
+//  Copyright 2011 UCLA. All rights reserved.
+//
+
+#include "ns3/application.h"
+#include "ns3/log.h"
+#include "ns3/address.h"
+#include "ns3/random-variable.h"
+#include "ns3/nstime.h"
+#include "ns3/event-id.h"
+#include "ns3/ptr.h"
+#include "ns3/udp-socket-factory.h"
+#include "ns3/socket.h"
+
+namespace ns3 
+{
+
+    
+//namespace NDNabstraction
+//{
+    class Socket; //dynamic linking works in a somehow strange way
+    
+    class StupidInterestGenerator: public Application
+    {
+    public: 
+        static TypeId GetTypeId (void);
+        
+        StupidInterestGenerator ();
+        
+        virtual ~StupidInterestGenerator();
+        
+                
+    protected:
+        virtual void DoDispose (void);
+    private:
+        // inherited from Application base class.
+        virtual void StartApplication (void);    // Called at time specified by Start
+        virtual void StopApplication (void);     // Called at time specified by Stop
+        
+        //Time m_onTime;
+        Time m_offTime;
+        
+        Address         m_peer;         // Peer address
+        Ptr<Socket>     m_socket;
+        EventId         m_startStopEvent;     // Event id for next start or stop event
+        EventId         m_sendEvent;    // Eventid of pending "send packet" event
+        TypeId          m_tid;
+        
+        //helpers
+        void CancelEvents ();
+        
+        void Construct (Ptr<Node> n,
+                        const Address &remote,
+                        std::string tid,
+                        const RandomVariable& ontime,
+                        const RandomVariable& offtime,
+                        uint32_t size);
+        
+        // Event handlers
+        void StartSending ();
+        void StopSending ();
+        void SendPacket ();
+        
+    private:
+        void ScheduleNextTx ();
+        void ScheduleStartEvent ();
+        void ScheduleStopEvent ();
+        void ConnectionSucceeded (Ptr<Socket>);
+        void ConnectionFailed (Ptr<Socket>);
+        void Ignore (Ptr<Socket>);
+
+    };
+//}
+}
diff --git a/apps/stupid-interest-sink.cc b/apps/stupid-interest-sink.cc
new file mode 100644
index 0000000..febd621
--- /dev/null
+++ b/apps/stupid-interest-sink.cc
@@ -0,0 +1,188 @@
+//
+//  stupid-interest-sink.cpp
+//  Abstraction
+//
+//  Created by Ilya Moiseenko on 10.08.11.
+//  Copyright 2011 UCLA. All rights reserved.
+//
+
+#include "stupid-interest-sink.h"
+
+#include "ns3/address.h"
+#include "ns3/address-utils.h"
+#include "ns3/log.h"
+#include "ns3/inet-socket-address.h"
+#include "ns3/node.h"
+#include "ns3/socket.h"
+#include "ns3/udp-socket.h"
+#include "ns3/simulator.h"
+#include "ns3/socket-factory.h"
+#include "ns3/packet.h"
+#include "ns3/trace-source-accessor.h"
+#include "ns3/udp-socket-factory.h"
+
+using namespace std;
+
+namespace ns3 {
+    
+    NS_LOG_COMPONENT_DEFINE ("StupidInterestSink");
+    NS_OBJECT_ENSURE_REGISTERED (StupidInterestSink);
+    
+    TypeId 
+    StupidInterestSink::GetTypeId (void)
+    {
+        static TypeId tid = TypeId ("ns3::StupidInterestSink")
+        .SetParent<Application> ()
+        .AddConstructor<StupidInterestSink> ()
+        .AddAttribute ("Local", "The Address on which to Bind the rx socket.",
+                       AddressValue (),
+                       MakeAddressAccessor (&StupidInterestSink::m_local),
+                       MakeAddressChecker ())
+        .AddAttribute ("Protocol", "The type id of the protocol to use for the rx socket.",
+                       TypeIdValue (UdpSocketFactory::GetTypeId ()),
+                       MakeTypeIdAccessor (&StupidInterestSink::m_tid),
+                       MakeTypeIdChecker ())
+        .AddTraceSource ("Rx", "A packet has been received",
+                         MakeTraceSourceAccessor (&StupidInterestSink::m_rxTrace))
+        ;
+        return tid;
+    }
+    
+    StupidInterestSink::StupidInterestSink ()
+    {
+        NS_LOG_FUNCTION (this);
+        m_socket = 0;
+        m_totalRx = 0;
+    }
+    
+    StupidInterestSink::~StupidInterestSink()
+    {
+        NS_LOG_FUNCTION (this);
+    }
+    
+    uint32_t StupidInterestSink::GetTotalRx () const
+    {
+        return m_totalRx;
+    }
+    
+    Ptr<Socket>
+    StupidInterestSink::GetListeningSocket (void) const
+    {
+        NS_LOG_FUNCTION (this);
+        return m_socket;
+    }
+    
+    std::list<Ptr<Socket> >
+    StupidInterestSink::GetAcceptedSockets (void) const
+    {
+        NS_LOG_FUNCTION (this);
+        return m_socketList;
+    }
+    
+    void StupidInterestSink::DoDispose (void)
+    {
+        NS_LOG_FUNCTION (this);
+        m_socket = 0;
+        m_socketList.clear ();
+        
+        // chain up
+        Application::DoDispose ();
+    }
+    
+    
+    // Application Methods
+    void StupidInterestSink::StartApplication ()    // Called at time specified by Start
+    {
+        NS_LOG_FUNCTION (this);
+        // Create the socket if not already
+        if (!m_socket)
+        {
+            m_socket = Socket::CreateSocket (GetNode (), m_tid);
+            m_socket->Bind (m_local);
+            m_socket->Listen ();
+            m_socket->ShutdownSend ();
+            if (addressUtils::IsMulticast (m_local))
+            {
+                Ptr<UdpSocket> udpSocket = DynamicCast<UdpSocket> (m_socket);
+                if (udpSocket)
+                {
+                    // equivalent to setsockopt (MCAST_JOIN_GROUP)
+                    udpSocket->MulticastJoinGroup (0, m_local);
+                }
+                else
+                {
+                    NS_FATAL_ERROR ("Error: joining multicast on a non-UDP socket");
+                }
+            }
+        }
+        
+        m_socket->SetRecvCallback (MakeCallback (&StupidInterestSink::HandleRead, this));
+        m_socket->SetAcceptCallback (
+                                     MakeNullCallback<bool, Ptr<Socket>, const Address &> (),
+                                     MakeCallback (&StupidInterestSink::HandleAccept, this));
+        m_socket->SetCloseCallbacks (
+                                     MakeCallback (&StupidInterestSink::HandlePeerClose, this),
+                                     MakeCallback (&StupidInterestSink::HandlePeerError, this));
+    }
+    
+    void StupidInterestSink::StopApplication ()     // Called at time specified by Stop
+    {
+        NS_LOG_FUNCTION (this);
+        while(!m_socketList.empty ()) //these are accepted sockets, close them
+        {
+            Ptr<Socket> acceptedSocket = m_socketList.front ();
+            m_socketList.pop_front ();
+            acceptedSocket->Close ();
+        }
+        if (m_socket) 
+        {
+            m_socket->Close ();
+            m_socket->SetRecvCallback (MakeNullCallback<void, Ptr<Socket> > ());
+        }
+    }
+    
+    void StupidInterestSink::HandleRead (Ptr<Socket> socket)
+    {
+        NS_LOG_FUNCTION (this << socket);
+        Ptr<Packet> packet;
+        Address from;
+        while (packet = socket->RecvFrom (from))
+        {
+            if (packet->GetSize () == 0)
+            { //EOF
+                break;
+            }
+            if (InetSocketAddress::IsMatchingType (from))
+            {
+                m_totalRx += packet->GetSize ();
+                InetSocketAddress address = InetSocketAddress::ConvertFrom (from);
+                NS_LOG_INFO ("Received " << packet->GetSize () << " bytes from " <<
+                             address.GetIpv4 () << " [" << address << "]"
+                             << " total Rx " << m_totalRx);
+                //cast address to void , to suppress 'address' set but not used 
+                //compiler warning in optimized builds
+                (void) address;
+            }
+            m_rxTrace (packet, from);
+        }
+    }
+    
+    void StupidInterestSink::HandlePeerClose (Ptr<Socket> socket)
+    {
+        NS_LOG_INFO ("PktSink, peerClose");
+    }
+    
+    void StupidInterestSink::HandlePeerError (Ptr<Socket> socket)
+    {
+        NS_LOG_INFO ("PktSink, peerError");
+    }
+    
+    
+    void StupidInterestSink::HandleAccept (Ptr<Socket> s, const Address& from)
+    {
+        NS_LOG_FUNCTION (this << s << from);
+        s->SetRecvCallback (MakeCallback (&StupidInterestSink::HandleRead, this));
+        m_socketList.push_back (s);
+    }
+    
+} // Namespace ns3
diff --git a/apps/stupid-interest-sink.h b/apps/stupid-interest-sink.h
new file mode 100644
index 0000000..66cedd9
--- /dev/null
+++ b/apps/stupid-interest-sink.h
@@ -0,0 +1,67 @@
+//
+//  stupid-interest-sink.h
+//  Abstraction
+//
+//  Created by Ilya Moiseenko on 10.08.11.
+//  Copyright 2011 UCLA. All rights reserved.
+//
+
+#include "ns3/application.h"
+#include "ns3/event-id.h"
+#include "ns3/ptr.h"
+#include "ns3/traced-callback.h"
+#include "ns3/address.h"
+
+namespace ns3 
+{
+    
+    class Address;
+    class Socket;
+    class Packet;
+
+    class StupidInterestSink : public Application
+    {
+    public:
+        static TypeId GetTypeId (void);
+        StupidInterestSink ();
+        
+        virtual ~StupidInterestSink ();
+        
+        /**
+         * \return the total bytes received in this sink app
+         */
+        uint32_t GetTotalRx () const;
+        
+        /**
+         * \return pointer to listening socket
+         */
+        Ptr<Socket> GetListeningSocket (void) const;
+        
+        /**
+         * \return list of pointers to accepted sockets
+         */
+        std::list<Ptr<Socket> > GetAcceptedSockets (void) const;
+        
+    protected:
+        virtual void DoDispose (void);
+    private:
+        // inherited from Application base class.
+        virtual void StartApplication (void);    // Called at time specified by Start
+        virtual void StopApplication (void);     // Called at time specified by Stop
+        
+        void HandleRead (Ptr<Socket>);
+        void HandleAccept (Ptr<Socket>, const Address& from);
+        void HandlePeerClose (Ptr<Socket>);
+        void HandlePeerError (Ptr<Socket>);
+        
+        // In the case of TCP, each socket accept returns a new socket, so the 
+        // listening socket is stored seperately from the accepted sockets
+        Ptr<Socket>     m_socket;       // Listening socket
+        std::list<Ptr<Socket> > m_socketList; //the accepted sockets
+        
+        Address         m_local;        // Local address to bind to
+        uint32_t        m_totalRx;      // Total bytes received
+        TypeId          m_tid;          // Protocol TypeId
+        TracedCallback<Ptr<const Packet>, const Address &> m_rxTrace;
+    };
+}
\ No newline at end of file