blob: f4fb2878a7f6401b3117fac5f021c2fd56a1db07 [file] [log] [blame]
Alexander Afanasyev45b92d42011-08-14 23:11:38 -07001/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
Ilya Moiseenko42b49242011-08-05 20:23:30 -07002//
3// ndn_stupidinterestgenerator.h
4// Abstraction
5//
6// Created by Ilya Moiseenko on 05.08.11.
7// Copyright 2011 UCLA. All rights reserved.
8//
9
Alexander Afanasyev2536e202011-08-12 14:13:10 -070010#include "ns3/application.h"
11#include "ns3/log.h"
12#include "ns3/address.h"
13#include "ns3/random-variable.h"
14#include "ns3/nstime.h"
15#include "ns3/event-id.h"
16#include "ns3/ptr.h"
17#include "ns3/udp-socket-factory.h"
18#include "ns3/socket.h"
Ilya Moiseenko42b49242011-08-05 20:23:30 -070019
20namespace ns3
21{
22
Ilya Moiseenko42b49242011-08-05 20:23:30 -070023//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}