OLD | NEW |
(Empty) | |
| 1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
| 2 /* |
| 3 * Copyright (c) 2008 INRIA |
| 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: Mohamed Amine Ismail <amine.ismail@sophia.inria.fr> |
| 19 * Modified by: NIST |
| 20 */ |
| 21 #include "nist-udp-client-server-helper.h" |
| 22 #include "ns3/nist-udp-server.h" |
| 23 #include "ns3/udp-client.h" |
| 24 #include "ns3/udp-trace-client.h" |
| 25 #include "ns3/uinteger.h" |
| 26 #include "ns3/string.h" |
| 27 |
| 28 namespace ns3 { |
| 29 |
| 30 NistUdpServerHelper::NistUdpServerHelper () |
| 31 { |
| 32 } |
| 33 |
| 34 NistUdpServerHelper::NistUdpServerHelper (uint16_t port) |
| 35 { |
| 36 m_factory.SetTypeId (NistUdpServer::GetTypeId ()); |
| 37 SetAttribute ("Port", UintegerValue (port)); |
| 38 } |
| 39 |
| 40 void |
| 41 NistUdpServerHelper::SetAttribute (std::string name, const AttributeValue &value
) |
| 42 { |
| 43 m_factory.Set (name, value); |
| 44 } |
| 45 |
| 46 ApplicationContainer |
| 47 NistUdpServerHelper::Install (NodeContainer c) |
| 48 { |
| 49 ApplicationContainer apps; |
| 50 for (NodeContainer::Iterator i = c.Begin (); i != c.End (); ++i) |
| 51 { |
| 52 Ptr<Node> node = *i; |
| 53 |
| 54 m_server = m_factory.Create<NistUdpServer> (); |
| 55 node->AddApplication (m_server); |
| 56 apps.Add (m_server); |
| 57 |
| 58 } |
| 59 return apps; |
| 60 } |
| 61 |
| 62 Ptr<NistUdpServer> |
| 63 NistUdpServerHelper::GetServer (void) |
| 64 { |
| 65 return m_server; |
| 66 } |
| 67 |
| 68 NistUdpClientHelper::NistUdpClientHelper () |
| 69 { |
| 70 } |
| 71 |
| 72 NistUdpClientHelper::NistUdpClientHelper (Address address, uint16_t port) |
| 73 { |
| 74 m_factory.SetTypeId (UdpClient::GetTypeId ()); |
| 75 SetAttribute ("RemoteAddress", AddressValue (address)); |
| 76 SetAttribute ("RemotePort", UintegerValue (port)); |
| 77 } |
| 78 |
| 79 NistUdpClientHelper::NistUdpClientHelper (Ipv4Address address, uint16_t port) |
| 80 { |
| 81 m_factory.SetTypeId (UdpClient::GetTypeId ()); |
| 82 SetAttribute ("RemoteAddress", AddressValue (Address(address))); |
| 83 SetAttribute ("RemotePort", UintegerValue (port)); |
| 84 } |
| 85 |
| 86 NistUdpClientHelper::NistUdpClientHelper (Ipv6Address address, uint16_t port) |
| 87 { |
| 88 m_factory.SetTypeId (UdpClient::GetTypeId ()); |
| 89 SetAttribute ("RemoteAddress", AddressValue (Address(address))); |
| 90 SetAttribute ("RemotePort", UintegerValue (port)); |
| 91 } |
| 92 |
| 93 void |
| 94 NistUdpClientHelper::SetAttribute (std::string name, const AttributeValue &value
) |
| 95 { |
| 96 m_factory.Set (name, value); |
| 97 } |
| 98 |
| 99 ApplicationContainer |
| 100 NistUdpClientHelper::Install (NodeContainer c) |
| 101 { |
| 102 ApplicationContainer apps; |
| 103 for (NodeContainer::Iterator i = c.Begin (); i != c.End (); ++i) |
| 104 { |
| 105 Ptr<Node> node = *i; |
| 106 Ptr<UdpClient> client = m_factory.Create<UdpClient> (); |
| 107 node->AddApplication (client); |
| 108 apps.Add (client); |
| 109 } |
| 110 return apps; |
| 111 } |
| 112 |
| 113 NistUdpTraceClientHelper::NistUdpTraceClientHelper () |
| 114 { |
| 115 } |
| 116 |
| 117 NistUdpTraceClientHelper::NistUdpTraceClientHelper (Address address, uint16_t po
rt, std::string filename) |
| 118 { |
| 119 m_factory.SetTypeId (UdpTraceClient::GetTypeId ()); |
| 120 SetAttribute ("RemoteAddress", AddressValue (address)); |
| 121 SetAttribute ("RemotePort", UintegerValue (port)); |
| 122 SetAttribute ("TraceFilename", StringValue (filename)); |
| 123 } |
| 124 |
| 125 NistUdpTraceClientHelper::NistUdpTraceClientHelper (Ipv4Address address, uint16_
t port, std::string filename) |
| 126 { |
| 127 m_factory.SetTypeId (UdpTraceClient::GetTypeId ()); |
| 128 SetAttribute ("RemoteAddress", AddressValue (Address (address))); |
| 129 SetAttribute ("RemotePort", UintegerValue (port)); |
| 130 SetAttribute ("TraceFilename", StringValue (filename)); |
| 131 } |
| 132 |
| 133 NistUdpTraceClientHelper::NistUdpTraceClientHelper (Ipv6Address address, uint16_
t port, std::string filename) |
| 134 { |
| 135 m_factory.SetTypeId (UdpTraceClient::GetTypeId ()); |
| 136 SetAttribute ("RemoteAddress", AddressValue (Address (address))); |
| 137 SetAttribute ("RemotePort", UintegerValue (port)); |
| 138 SetAttribute ("TraceFilename", StringValue (filename)); |
| 139 } |
| 140 |
| 141 void |
| 142 NistUdpTraceClientHelper::SetAttribute (std::string name, const AttributeValue &
value) |
| 143 { |
| 144 m_factory.Set (name, value); |
| 145 } |
| 146 |
| 147 ApplicationContainer |
| 148 NistUdpTraceClientHelper::Install (NodeContainer c) |
| 149 { |
| 150 ApplicationContainer apps; |
| 151 for (NodeContainer::Iterator i = c.Begin (); i != c.End (); ++i) |
| 152 { |
| 153 Ptr<Node> node = *i; |
| 154 Ptr<UdpTraceClient> client = m_factory.Create<UdpTraceClient> (); |
| 155 node->AddApplication (client); |
| 156 apps.Add (client); |
| 157 } |
| 158 return apps; |
| 159 } |
| 160 |
| 161 } // namespace ns3 |
OLD | NEW |