OLD | NEW |
(Empty) | |
| 1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
| 2 /* |
| 3 * Copyright (c) 2007,2008,2009 INRIA, UDCAST |
| 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: Amine Ismail <amine.ismail@sophia.inria.fr> |
| 19 * <amine.ismail@udcast.com> |
| 20 * |
| 21 * Modified by: NIST |
| 22 */ |
| 23 |
| 24 #ifndef NIST_UDP_SERVER_H |
| 25 #define NIST_UDP_SERVER_H |
| 26 |
| 27 #include "ns3/application.h" |
| 28 #include "ns3/event-id.h" |
| 29 #include "ns3/ptr.h" |
| 30 #include "ns3/address.h" |
| 31 #include "ns3/packet-loss-counter.h" |
| 32 #include "ns3/traced-callback.h" |
| 33 |
| 34 namespace ns3 { |
| 35 /** |
| 36 * \ingroup applications |
| 37 * \defgroup nistudpclientserver NistUdpClientServer |
| 38 */ |
| 39 |
| 40 /** |
| 41 * \ingroup nistudpclientserver |
| 42 * \class NistUdpServer |
| 43 * \brief A UDP server, receives UDP packets from a remote host. |
| 44 * |
| 45 * UDP packets carry a 32bits sequence number followed by a 64bits time |
| 46 * stamp in their payloads. The application uses the sequence number |
| 47 * to determine if a packet is lost, and the time stamp to compute the delay. |
| 48 */ |
| 49 class NistUdpServer : public Application |
| 50 { |
| 51 public: |
| 52 /** |
| 53 * \brief Get the type ID. |
| 54 * \return the object TypeId |
| 55 */ |
| 56 static TypeId GetTypeId (void); |
| 57 NistUdpServer (); |
| 58 virtual ~NistUdpServer (); |
| 59 /** |
| 60 * \brief Returns the number of lost packets |
| 61 * \return the number of lost packets |
| 62 */ |
| 63 uint32_t GetLost (void) const; |
| 64 |
| 65 /** |
| 66 * \brief Returns the number of received packets |
| 67 * \return the number of received packets |
| 68 */ |
| 69 uint32_t GetReceived (void) const; |
| 70 |
| 71 /** |
| 72 * \brief Returns the size of the window used for checking loss. |
| 73 * \return the size of the window used for checking loss. |
| 74 */ |
| 75 uint16_t GetPacketWindowSize () const; |
| 76 |
| 77 /** |
| 78 * \brief Set the size of the window used for checking loss. This value should |
| 79 * be a multiple of 8 |
| 80 * \param size the size of the window used for checking loss. This value shoul
d |
| 81 * be a multiple of 8 |
| 82 */ |
| 83 void SetPacketWindowSize (uint16_t size); |
| 84 ·· |
| 85 /** |
| 86 * TracedCallback signature for packet and source/destination addresses. |
| 87 * |
| 88 * \param [in] packet The packet. |
| 89 * \param [in] src_address The source address. |
| 90 * \param [in] dest_address The destination address. |
| 91 */ |
| 92 typedef void (* PacketAddressTracedCallback) |
| 93 (const Ptr<const Packet> packet, const Address &src_address, const Address &
dest_address); |
| 94 ········ |
| 95 protected: |
| 96 virtual void DoDispose (void); |
| 97 |
| 98 private: |
| 99 |
| 100 virtual void StartApplication (void); |
| 101 virtual void StopApplication (void); |
| 102 |
| 103 /** |
| 104 * \brief Handle a packet reception. |
| 105 * |
| 106 * This function is called by lower layers. |
| 107 * |
| 108 * \param socket the socket the packet was received to. |
| 109 */ |
| 110 void HandleRead (Ptr<Socket> socket); |
| 111 |
| 112 uint16_t m_port; //!< Port on which we listen for incoming packets. |
| 113 Ptr<Socket> m_socket; //!< IPv4 Socket |
| 114 Ptr<Socket> m_socket6; //!< IPv6 Socket |
| 115 uint32_t m_received; //!< Number of received packets |
| 116 PacketLossCounter m_lossCounter; //!< Lost packet counter |
| 117 /// Callbacks for tracing the packet Rx events |
| 118 TracedCallback<Ptr<const Packet>, const Address &> m_rxTrace; |
| 119 ·· |
| 120 /// Callbacks for tracing the packet Rx events, includes source and destinatio
n addresses |
| 121 TracedCallback<Ptr<const Packet>, const Address &, const Address &> m_rxTraceW
ithAddresses; |
| 122 }; |
| 123 |
| 124 } // namespace ns3 |
| 125 |
| 126 #endif /* UDP_SERVER_H */ |
OLD | NEW |