remove dead code
authorMathieu Lacage <mathieu.lacage@sophia.inria.fr>
Mon, 14 May 2007 10:15:03 +0200
changeset 609 9baaee630644
parent 608 bcb8064049de
child 610 5d1d85ad02c6
remove dead code
src/applications/onoff-application.cc
src/applications/onoff-application.h
--- a/src/applications/onoff-application.cc	Mon May 14 10:08:01 2007 +0200
+++ b/src/applications/onoff-application.cc	Mon May 14 10:15:03 2007 +0200
@@ -67,28 +67,15 @@
 {
 }
 
-OnOffApplication::OnOffApplication(Ptr<INode> n, const OnOffApplication& c)
-  : Application(n), 
-    m_socket(0),
-    m_peerIP(c.m_peerIP),
-    m_peerPort(c.m_peerPort),
-    m_connected(c.m_connected),
-    m_onTime(c.m_onTime->Copy()),
-    m_offTime(c.m_offTime->Copy()),
-    m_cbrRate(c.m_cbrRate),
-    m_pktSize(c.m_pktSize),
-    m_residualBits(c.m_residualBits),
-    m_lastStartTime(c.m_lastStartTime),
-    m_maxBytes(c.m_maxBytes),
-    m_totBytes(c.m_totBytes),
-    m_startStopScheduled(false),
-    m_sendScheduled(false)
-{
-}
-
 OnOffApplication::~OnOffApplication()
 {}
 
+void 
+OnOffApplication::SetMaxBytes(uint32_t maxBytes)
+{
+  m_maxBytes = maxBytes;
+}
+
 void
 OnOffApplication::DoDispose (void)
 {
@@ -103,74 +90,20 @@
   Application::DoDispose ();
 }
 
-#ifdef REMOVE_THIS
-// Handler Methods
-void OnOffApplication::Handle(Event* e, Time_t t)
-{
-  AppOOEvent* ev = (AppOOEvent*)e;
-  switch (ev->event) {
-    case AppOOEvent::SEND_PKT :
-      {
-        SendPkt(false);         // Send the packet
-        return;
-      }
-    case AppOOEvent::START_GEN :
-      {
-        DEBUG0((cout << "StartGen at " << Simulator::Now() << endl));
-        lastStartTime = Simulator::Now();
-        ScheduleNextTx();
-        Time_t onInterval = onTime->Value();
-        pendingOO->event = AppOOEvent::STOP_GEN;
-         // Schedule the stop event
-        Simulator::Schedule(pendingOO, onInterval, this);
-        return;
-      }
-    case AppOOEvent::STOP_GEN :
-      {
-        DEBUG0((cout << "StopGen at " << Simulator::Now() << endl));
-        if (totBytes < maxBytes)
-          { // Only schedule if not execeeded maxBytes
-            Time_t offInterval = offTime->Value();
-            pendingOO->event = AppOOEvent::START_GEN;
-            // Schedule the start event
-            Simulator::Schedule(pendingOO, offInterval, this);
-          }
-        if (pendingEvent)
-          {
-            // Calculate residual bits since last packet sent
-            residualBits += (uint32_t)(cbrRate*(Simulator::Now()-lastStartTime));
-            Simulator::Cancel(pendingEvent);
-            delete pendingEvent;
-            pendingEvent = 0;
-          }
-        return;
-      }
-  }
-  Application::Handle(e, t);  // May be application event
-}
-#endif
 
 // Application Methods
 void OnOffApplication::StartApplication()    // Called at time specified by Start
 {
   // Create the socket if not already
   if (!m_socket)
-    { // Create the socket using the specified layer 4 protocol
-#ifdef NOTYET
-      m_socket = PeekINode()->GetKernel()->CreateGenericSocket(*m_l4Proto);
-      m_socket->Bind();  // Choose any available port local port
-      m_socket->Connect(*m_peerIP, m_peerPort,
-                        MakeCallback(&OnOffApplication::ConnectionSucceeded,
-                                     this),
-                        MakeCallback(&OnOffApplication::ConnectionFailed,
-                                     this));
-#endif
-      
+    {
       Ptr<IUdp> udp = GetINode ()->QueryInterface<IUdp> (IUdp::iid);
       m_socket = udp->CreateSocket ();
+      m_socket->Bind ();
       m_socket->Connect (m_peerIP, m_peerPort);
     }
-  StopApplication();                         // Insure no pending event
+  // Insure no pending event
+  StopApplication();
   // If we are not yet connected, there is nothing to do here
   // The ConnectionComplete upcall will start timers at that time
   //if (!m_connected) return;
@@ -244,9 +177,6 @@
   NS_ASSERT (m_sendScheduled);
   m_sendScheduled = false;
   m_socket->Send(0, m_pktSize);
-#ifdef NOTYET
-  m_socket->Send(0, m_pktSize); // Send the packet
-#endif
   m_totBytes += m_pktSize;
   m_lastStartTime = Simulator::Now();
   m_residualBits = 0;
--- a/src/applications/onoff-application.h	Mon May 14 10:08:01 2007 +0200
+++ b/src/applications/onoff-application.h	Mon May 14 10:15:03 2007 +0200
@@ -49,27 +49,26 @@
                    DataRate  = g_defaultRate,  // Data rate when on
                    uint32_t = g_defaultSize);  // Size of packets
 
-  OnOffApplication(Ptr<INode> n, const OnOffApplication&); // Copy constructor
   virtual ~OnOffApplication();               // Destructor
-  virtual void StartApplication();    // Called at time specified by Start
-  virtual void StopApplication();     // Called at time specified by Stop
+
+  void SetMaxBytes(uint32_t maxBytes);
+
+  static void DefaultRate(uint64_t r) { g_defaultRate = r;}
+
+  static void DefaultSize(uint32_t s) { g_defaultSize = s;}
+
+protected:
+  virtual void DoDispose (void);
+private:
+  // inherited from Application base class.
+  virtual void StartApplication (void);    // Called at time specified by Start
+  virtual void StopApplication (void);     // Called at time specified by Stop
 
   // Event handlers
   void StartSending();
   void StopSending();
   void SendPacket();
 
-  virtual void MaxBytes(uint32_t m) { m_maxBytes = m;}
-
-protected:
-  virtual void DoDispose (void);
-
-public: // Static methods
-  static void DefaultRate(uint64_t r) { g_defaultRate = r;}
-
-  static void DefaultSize(uint32_t s) { g_defaultSize = s;}
-
-public:
   Ptr<Socket>     m_socket;       // Associated socket
   Ipv4Address     m_peerIP;       // Peer IP address
   uint16_t        m_peerPort;     // Peer port