blob: 395bc3f899d764bf00efcda8889faa3772e86ff9 [file] [log] [blame]
Ilya Moiseenko42b49242011-08-05 20:23:30 -07001//
2// ndn_stupidinterestgenerator.h
3// Abstraction
4//
5// Created by Ilya Moiseenko on 05.08.11.
6// Copyright 2011 UCLA. All rights reserved.
7//
8
Alexander Afanasyev2536e202011-08-12 14:13:10 -07009#include "ns3/application.h"
10#include "ns3/log.h"
11#include "ns3/address.h"
12#include "ns3/random-variable.h"
13#include "ns3/nstime.h"
14#include "ns3/event-id.h"
15#include "ns3/ptr.h"
16#include "ns3/udp-socket-factory.h"
17#include "ns3/socket.h"
Ilya Moiseenko42b49242011-08-05 20:23:30 -070018
19namespace ns3
20{
21
22
23//namespace NDNabstraction
24//{
25 class Socket; //dynamic linking works in a somehow strange way
26
27 class StupidInterestGenerator: public Application
28 {
29 public:
30 static TypeId GetTypeId (void);
31
32 StupidInterestGenerator ();
33
34 virtual ~StupidInterestGenerator();
35
36
37 protected:
38 virtual void DoDispose (void);
39 private:
40 // inherited from Application base class.
41 virtual void StartApplication (void); // Called at time specified by Start
42 virtual void StopApplication (void); // Called at time specified by Stop
43
44 //Time m_onTime;
45 Time m_offTime;
46
47 Address m_peer; // Peer address
48 Ptr<Socket> m_socket;
49 EventId m_startStopEvent; // Event id for next start or stop event
50 EventId m_sendEvent; // Eventid of pending "send packet" event
51 TypeId m_tid;
52
53 //helpers
54 void CancelEvents ();
55
56 void Construct (Ptr<Node> n,
57 const Address &remote,
58 std::string tid,
59 const RandomVariable& ontime,
60 const RandomVariable& offtime,
61 uint32_t size);
62
63 // Event handlers
64 void StartSending ();
65 void StopSending ();
66 void SendPacket ();
67
68 private:
69 void ScheduleNextTx ();
70 void ScheduleStartEvent ();
71 void ScheduleStopEvent ();
72 void ConnectionSucceeded (Ptr<Socket>);
73 void ConnectionFailed (Ptr<Socket>);
74 void Ignore (Ptr<Socket>);
75
76 };
77//}
Alexander Afanasyev43e70252011-08-08 18:48:18 -070078}