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