LEFT | RIGHT |
(no file at all) | |
| 1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
| 2 /* |
| 3 * Copyright (c) 2014 Universita' di Firenze |
| 4 * |
| 5 * This program is free software; you can redistribute it and/or modify |
| 6 * it under the terms of the GNU General Public License version 2 as |
| 7 * published by the Free Software Foundation; |
| 8 * |
| 9 * This program is distributed in the hope that it will be useful, |
| 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 12 * GNU General Public License for more details. |
| 13 * |
| 14 * You should have received a copy of the GNU General Public License |
| 15 * along with this program; if not, write to the Free Software |
| 16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
| 17 * |
| 18 * Author: Tommaso Pecorella <tommaso.pecorella@unifi.it> |
| 19 */ |
| 20 |
| 21 #ifndef PACKET_SOCKET_CLIENT_H |
| 22 #define PACKET_SOCKET_CLIENT_H |
| 23 |
| 24 #include "ns3/application.h" |
| 25 #include "ns3/event-id.h" |
| 26 #include "ns3/ptr.h" |
| 27 #include "ns3/packet-socket-address.h" |
| 28 |
| 29 namespace ns3 { |
| 30 |
| 31 class Socket; |
| 32 class Packet; |
| 33 |
| 34 /** |
| 35 * \ingroup socket |
| 36 * |
| 37 * \brief A simple client. |
| 38 * |
| 39 * Sends packets using PacketSocket. It does not require (or use) IP. |
| 40 * |
| 41 * Packets are sent as soon as PacketSocketClient::Start is called. |
| 42 * The application has the same requirements as the PacketSocket for |
| 43 * what concerns the underlying NetDevice and the Address scheme. |
| 44 * It is meant to be used in ns-3 tests. |
| 45 * |
| 46 * The application will send `MaxPackets' packets, one every `Interval' |
| 47 * time. Packet size (`PacketSize') can be configured. |
| 48 * Provides a "Tx" Traced Callback (transmitted packets, source address). |
| 49 * |
| 50 * Note: packets larger than the NetDevice MTU will not be sent. |
| 51 */ |
| 52 class PacketSocketClient : public Application |
| 53 { |
| 54 public: |
| 55 /** |
| 56 * \brief Get the type ID. |
| 57 * \return the object TypeId |
| 58 */ |
| 59 static TypeId GetTypeId (void); |
| 60 |
| 61 PacketSocketClient (); |
| 62 |
| 63 virtual ~PacketSocketClient (); |
| 64 |
| 65 /** |
| 66 * \brief set the remote address and protocol to be used |
| 67 * \param addr remote address |
| 68 */ |
| 69 void SetRemote (PacketSocketAddress addr); |
| 70 |
| 71 protected: |
| 72 virtual void DoDispose (void); |
| 73 |
| 74 private: |
| 75 |
| 76 virtual void StartApplication (void); |
| 77 virtual void StopApplication (void); |
| 78 |
| 79 /** |
| 80 * \brief Send a packet |
| 81 */ |
| 82 void Send (void); |
| 83 |
| 84 uint32_t m_maxPackets; //!< Maximum number of packets the application will sen
d |
| 85 Time m_interval; //!< Packet inter-send time |
| 86 uint32_t m_size; //!< Size of the sent packet |
| 87 |
| 88 uint32_t m_sent; //!< Counter for sent packets |
| 89 Ptr<Socket> m_socket; //!< Socket |
| 90 PacketSocketAddress m_peerAddress; //!< Remote peer address |
| 91 bool m_peerAddressSet; //!< Sanity check |
| 92 EventId m_sendEvent; //!< Event to send the next packet |
| 93 |
| 94 /// Traced Callback: sent packets, source address. |
| 95 TracedCallback<Ptr<const Packet>, const Address &> m_txTrace; |
| 96 }; |
| 97 |
| 98 } // namespace ns3 |
| 99 |
| 100 #endif /* PACKET_SOCKET_CLIENT_H */ |
LEFT | RIGHT |