00001 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ 00002 /* 00003 * Copyright 2007 University of Washington 00004 * 00005 * This program is free software; you can redistribute it and/or modify 00006 * it under the terms of the GNU General Public License version 2 as 00007 * published by the Free Software Foundation; 00008 * 00009 * This program is distributed in the hope that it will be useful, 00010 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00012 * GNU General Public License for more details. 00013 * 00014 * You should have received a copy of the GNU General Public License 00015 * along with this program; if not, write to the Free Software 00016 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00017 */ 00018 00019 #ifndef __UDP_ECHO_CLIENT_H__ 00020 #define __UDP_ECHO_CLIENT_H__ 00021 00022 #include "ns3/application.h" 00023 #include "ns3/event-id.h" 00024 #include "ns3/ptr.h" 00025 #include "ns3/ipv4-address.h" 00026 00027 namespace ns3 { 00028 00029 class Socket; 00030 class Packet; 00031 00032 /** 00033 * \ingroup udpecho 00034 * \brief A Udp Echo client 00035 * 00036 * Every packet sent should be returned by the server and received here. 00037 */ 00038 class UdpEchoClient : public Application 00039 { 00040 public: 00041 static TypeId GetTypeId (void); 00042 00043 UdpEchoClient (); 00044 00045 virtual ~UdpEchoClient (); 00046 00047 void SetRemote (Ipv4Address ip, uint16_t port); 00048 00049 protected: 00050 virtual void DoDispose (void); 00051 00052 private: 00053 00054 virtual void StartApplication (void); 00055 virtual void StopApplication (void); 00056 00057 void ScheduleTransmit (Time dt); 00058 void Send (void); 00059 00060 void HandleRead (Ptr<Socket> socket); 00061 00062 uint32_t m_count; 00063 Time m_interval; 00064 uint32_t m_size; 00065 00066 uint32_t m_sent; 00067 Ptr<Socket> m_socket; 00068 Ipv4Address m_peerAddress; 00069 uint16_t m_peerPort; 00070 EventId m_sendEvent; 00071 00072 }; 00073 00074 } // namespace ns3 00075 00076 #endif // __UDP_ECHO_CLIENT_H__ 00077