blob: 66cedd906d6a8dab942c92fcd8796d83f36a042d [file] [log] [blame]
Ilya Moiseenko02fb7062011-08-11 17:18:00 -07001//
2// stupid-interest-sink.h
3// Abstraction
4//
5// Created by Ilya Moiseenko on 10.08.11.
6// Copyright 2011 UCLA. All rights reserved.
7//
8
9#include "ns3/application.h"
10#include "ns3/event-id.h"
11#include "ns3/ptr.h"
12#include "ns3/traced-callback.h"
13#include "ns3/address.h"
14
15namespace ns3
16{
17
18 class Address;
19 class Socket;
20 class Packet;
21
22 class StupidInterestSink : public Application
23 {
24 public:
25 static TypeId GetTypeId (void);
26 StupidInterestSink ();
27
28 virtual ~StupidInterestSink ();
29
30 /**
31 * \return the total bytes received in this sink app
32 */
33 uint32_t GetTotalRx () const;
34
35 /**
36 * \return pointer to listening socket
37 */
38 Ptr<Socket> GetListeningSocket (void) const;
39
40 /**
41 * \return list of pointers to accepted sockets
42 */
43 std::list<Ptr<Socket> > GetAcceptedSockets (void) const;
44
45 protected:
46 virtual void DoDispose (void);
47 private:
48 // inherited from Application base class.
49 virtual void StartApplication (void); // Called at time specified by Start
50 virtual void StopApplication (void); // Called at time specified by Stop
51
52 void HandleRead (Ptr<Socket>);
53 void HandleAccept (Ptr<Socket>, const Address& from);
54 void HandlePeerClose (Ptr<Socket>);
55 void HandlePeerError (Ptr<Socket>);
56
57 // In the case of TCP, each socket accept returns a new socket, so the
58 // listening socket is stored seperately from the accepted sockets
59 Ptr<Socket> m_socket; // Listening socket
60 std::list<Ptr<Socket> > m_socketList; //the accepted sockets
61
62 Address m_local; // Local address to bind to
63 uint32_t m_totalRx; // Total bytes received
64 TypeId m_tid; // Protocol TypeId
65 TracedCallback<Ptr<const Packet>, const Address &> m_rxTrace;
66 };
67}