blob: d2533c20b2449d11d203de3b31a6ec6d8dfa35d7 [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 Afanasyev3a6ea5c2011-08-11 18:15:49 -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
Ilya Moiseenkoc166cd32011-08-12 12:50:30 -070017#include "ccn/ccn.h"
Alexander Afanasyev3a6ea5c2011-08-11 18:15:49 -070018#include <ns3/udp-socket-factory.h>
Ilya Moiseenko42b49242011-08-05 20:23:30 -070019
20namespace ns3
21{
22
23
24//namespace NDNabstraction
25//{
26 class Socket; //dynamic linking works in a somehow strange way
27
28 class StupidInterestGenerator: public Application
29 {
30 public:
31 static TypeId GetTypeId (void);
32
33 StupidInterestGenerator ();
34
35 virtual ~StupidInterestGenerator();
36
37
38 protected:
39 virtual void DoDispose (void);
40 private:
41 // inherited from Application base class.
42 virtual void StartApplication (void); // Called at time specified by Start
43 virtual void StopApplication (void); // Called at time specified by Stop
44
45 //Time m_onTime;
46 Time m_offTime;
47
48 Address m_peer; // Peer address
49 Ptr<Socket> m_socket;
50 EventId m_startStopEvent; // Event id for next start or stop event
51 EventId m_sendEvent; // Eventid of pending "send packet" event
52 TypeId m_tid;
53
54 //helpers
55 void CancelEvents ();
56
57 void Construct (Ptr<Node> n,
58 const Address &remote,
59 std::string tid,
60 const RandomVariable& ontime,
61 const RandomVariable& offtime,
62 uint32_t size);
63
64 // Event handlers
65 void StartSending ();
66 void StopSending ();
67 void SendPacket ();
68
69 private:
70 void ScheduleNextTx ();
71 void ScheduleStartEvent ();
72 void ScheduleStopEvent ();
73 void ConnectionSucceeded (Ptr<Socket>);
74 void ConnectionFailed (Ptr<Socket>);
75 void Ignore (Ptr<Socket>);
76
77 };
78//}
Alexander Afanasyev43e70252011-08-08 18:48:18 -070079}