--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/helper/udp-echo-helper.cc Thu Mar 27 12:20:14 2008 -0700
@@ -0,0 +1,64 @@
+#include "udp-echo-helper.h"
+#include "ns3/udp-echo-server.h"
+#include "ns3/udp-echo-client.h"
+#include "ns3/uinteger.h"
+
+namespace ns3 {
+
+UdpEchoServerHelper::UdpEchoServerHelper ()
+ : m_port (9)
+{}
+
+void
+UdpEchoServerHelper::SetPort (uint16_t port)
+{
+ m_port = port;
+}
+ApplicationContainer
+UdpEchoServerHelper::Build (NodeContainer c)
+{
+ ApplicationContainer apps;
+ for (NodeContainer::Iterator i = c.Begin (); i != c.End (); ++i)
+ {
+ Ptr<Node> node = *i;
+ Ptr<UdpEchoServer> server = CreateObject<UdpEchoServer> ("Port", Uinteger (m_port));
+ node->AddApplication (server);
+ apps.Add (server);
+ }
+ return apps;
+}
+
+UdpEchoClientHelper::UdpEchoClientHelper ()
+{
+ m_factory.SetTypeId (UdpEchoClient::GetTypeId ());
+}
+void
+UdpEchoClientHelper::SetRemote (Ipv4Address ip, uint16_t port)
+{
+ m_remoteIp = ip;
+ m_remotePort = port;
+}
+void
+UdpEchoClientHelper::SetAppAttribute (std::string name, Attribute value)
+{
+ m_factory.Set (name, value);
+}
+
+ApplicationContainer
+UdpEchoClientHelper::Build (NodeContainer c)
+{
+ ApplicationContainer apps;
+ for (NodeContainer::Iterator i = c.Begin (); i != c.End (); ++i)
+ {
+ Ptr<Node> node = *i;
+ Ptr<UdpEchoClient> client = m_factory.Create<UdpEchoClient> ();
+ client->SetRemote (m_remoteIp, m_remotePort);
+ node->AddApplication (client);
+ apps.Add (client);
+ }
+ return apps;
+}
+
+
+
+} // namespace ns3
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/helper/udp-echo-helper.h Thu Mar 27 12:20:14 2008 -0700
@@ -0,0 +1,39 @@
+#ifndef UDP_ECHO_HELPER_H
+#define UDP_ECHO_HELPER_H
+
+#include <stdint.h>
+#include "application-container.h"
+#include "node-container.h"
+#include "ns3/object-factory.h"
+#include "ns3/ipv4-address.h"
+
+namespace ns3 {
+
+class UdpEchoServerHelper
+{
+public:
+ UdpEchoServerHelper ();
+ void SetPort (uint16_t port);
+ ApplicationContainer Build (NodeContainer c);
+private:
+ uint16_t m_port;
+};
+
+class UdpEchoClientHelper
+{
+public:
+ UdpEchoClientHelper ();
+
+ void SetRemote (Ipv4Address ip, uint16_t port);
+ void SetAppAttribute (std::string name, Attribute value);
+ ApplicationContainer Build (NodeContainer c);
+ private:
+ ObjectFactory m_factory;
+ Ipv4Address m_remoteIp;
+ uint16_t m_remotePort;
+};
+
+
+} // namespace ns3
+
+#endif /* UDP_ECHO_HELPER_H */