OLD | NEW |
(Empty) | |
| 1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
| 2 /* |
| 3 * Copyright (c) 2011 Yufei Cheng |
| 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: Yufei Cheng <yfcheng@ittc.ku.edu> |
| 19 * |
| 20 * James P.G. Sterbenz <jpgs@ittc.ku.edu>, director |
| 21 * ResiliNets Research Group http://wiki.ittc.ku.edu/resilinets |
| 22 * Information and Telecommunication Technology Center (ITTC) |
| 23 * and Department of Electrical Engineering and Computer Science |
| 24 * The University of Kansas Lawrence, KS USA. |
| 25 * |
| 26 * Work supported in part by NSF FIND (Future Internet Design) Program |
| 27 * under grant CNS-0626918 (Postmodern Internet Architecture), |
| 28 * NSF grant CNS-1050226 (Multilayer Network Resilience Analysis and Experimenta
tion on GENI), |
| 29 * US Department of Defense (DoD), and ITTC at The University of Kansas. |
| 30 */ |
| 31 |
| 32 #ifndef HTTP_HELPER_H |
| 33 #define HTTP_HELPER_H |
| 34 |
| 35 #include <stdint.h> |
| 36 #include <vector> |
| 37 #include <string> |
| 38 |
| 39 #include "ns3/application-container.h" |
| 40 #include "ns3/object-factory.h" |
| 41 #include "ns3/ipv4-address.h" |
| 42 #include "ns3/attribute.h" |
| 43 #include "ns3/object-factory.h" |
| 44 #include "ns3/node-container.h" |
| 45 #include "ns3/trace-helper.h" |
| 46 #include "ns3/http-client.h" |
| 47 #include "ns3/http-server.h" |
| 48 #include "ns3/http-controller.h" |
| 49 |
| 50 |
| 51 namespace ns3 { |
| 52 |
| 53 /** |
| 54 * \brief Create a server application which waits for input http packets |
| 55 * and uses the information carried into their payload to compute |
| 56 * delay and to determine if some packets are lost. |
| 57 */ |
| 58 class HttpHelper |
| 59 { |
| 60 public: |
| 61 /** |
| 62 * Create HttpServerHelper which will make life easier for people trying |
| 63 * to set up simulations with udp-client-server application. |
| 64 * |
| 65 */ |
| 66 HttpHelper (); |
| 67 /** |
| 68 * Record an attribute to be set in each Application after it is is created. |
| 69 * |
| 70 * \param name the name of the attribute to set |
| 71 * \param value the value of the attribute to set |
| 72 */ |
| 73 void SetAttribute (std::string name, const AttributeValue &value); |
| 74 Ptr<http::HttpController> GetController (void); |
| 75 private: |
| 76 ObjectFactory m_factory; |
| 77 Ptr<http::HttpController> m_controller; |
| 78 }; |
| 79 |
| 80 /** |
| 81 * \brief Create a server application which waits for input http packets |
| 82 * and uses the information carried into their payload to compute |
| 83 * delay and to determine if some packets are lost. |
| 84 */ |
| 85 class HttpServerHelper |
| 86 { |
| 87 public: |
| 88 /** |
| 89 * Create HttpServerHelper which will make life easier for people trying |
| 90 * to set up simulations with udp-client-server application. |
| 91 * |
| 92 */ |
| 93 HttpServerHelper (); |
| 94 /** |
| 95 * Record an attribute to be set in each Application after it is is created. |
| 96 * |
| 97 * \param name the name of the attribute to set |
| 98 * \param value the value of the attribute to set |
| 99 */ |
| 100 void SetAttribute (std::string name, const AttributeValue &value); |
| 101 /** |
| 102 * Create one http server application on each of the Nodes in the |
| 103 * NodeContainer. |
| 104 * |
| 105 * \param node The node on which to create the Applications. |
| 106 * \returns The applications created, one Application per Node in the |
| 107 * NodeContainer. |
| 108 */ |
| 109 ApplicationContainer Install (Ptr<Node> node); |
| 110 /** |
| 111 * Create one udp server application on each of the Nodes in the |
| 112 * NodeContainer. |
| 113 * |
| 114 * \param c The nodes on which to create the Applications. The nodes |
| 115 * are specified by a NodeContainer. |
| 116 * \returns The applications created, one Application per Node in the |
| 117 * NodeContainer. |
| 118 */ |
| 119 ApplicationContainer Install (NodeContainer c); |
| 120 private: |
| 121 ObjectFactory m_factory; |
| 122 HttpHelper httpHelper; |
| 123 }; |
| 124 |
| 125 /** |
| 126 * \brief Create a client application which sends udp packets carrying |
| 127 * a 32bit sequence number and a 64 bit time stamp. |
| 128 * |
| 129 */ |
| 130 class HttpClientHelper |
| 131 { |
| 132 |
| 133 public: |
| 134 /** |
| 135 * Create HttpClientHelper which will make life easier for people trying |
| 136 * to set up simulations with udp-client-server. |
| 137 * |
| 138 */ |
| 139 HttpClientHelper (); |
| 140 /** |
| 141 * Record an attribute to be set in each Application after it is is created. |
| 142 * |
| 143 * \param name the name of the attribute to set |
| 144 * \param value the value of the attribute to set |
| 145 */ |
| 146 void SetAttribute (std::string name, const AttributeValue &value); |
| 147 /** |
| 148 * Create one http client application on each of the Nodes in the |
| 149 * NodeContainer. |
| 150 * |
| 151 * \param node The node on which to create the Applications. |
| 152 * \returns The applications created, one Application per Node in the |
| 153 * NodeContainer. |
| 154 */ |
| 155 ApplicationContainer Install (Ptr<Node> node); |
| 156 /** |
| 157 * \param c the nodes |
| 158 * |
| 159 * Create one udp client application on each of the input nodes |
| 160 * |
| 161 * \returns the applications created, one application per input node. |
| 162 */ |
| 163 ApplicationContainer Install (NodeContainer c); |
| 164 Ptr<http::HttpClient> GetClient (void); |
| 165 |
| 166 private: |
| 167 ObjectFactory m_factory; |
| 168 Ptr<http::HttpClient> m_client; |
| 169 HttpHelper httpHelper; |
| 170 }; |
| 171 |
| 172 } // namespace ns3 |
| 173 |
| 174 #endif /* HTTP_HELPER_H */ |
OLD | NEW |