00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #include "packet-sink-helper.h"
00022 #include "ns3/string.h"
00023 #include "ns3/inet-socket-address.h"
00024
00025 namespace ns3 {
00026
00027 PacketSinkHelper::PacketSinkHelper (std::string protocol, Address address)
00028 {
00029 m_factory.SetTypeId ("ns3::PacketSink");
00030 m_factory.Set ("Protocol", StringValue (protocol));
00031 m_factory.Set ("Local", AddressValue (address));
00032 }
00033
00034 void
00035 PacketSinkHelper::SetAttribute (std::string name, const AttributeValue &value)
00036 {
00037 m_factory.Set (name, value);
00038 }
00039
00040
00041 #if 0
00042 void
00043 PacketSinkHelper::SetUdpLocal (Ipv4Address ip, uint16_t port)
00044 {
00045 m_factory.Set ("Protocol", String ("ns3::UdpSocketFactory"));
00046 m_factory.Set ("Local", Address (InetSocketAddress (ip, port)));
00047 }
00048 void
00049 PacketSinkHelper::SetTcpLocal (Ipv4Address ip, uint16_t port)
00050 {
00051 m_factory.Set ("Protocol", String ("ns3::TcpSocketFactory"));
00052 m_factory.Set ("Local", Address (InetSocketAddress (ip, port)));
00053 }
00054 #endif
00055
00056 ApplicationContainer
00057 PacketSinkHelper::Install (Ptr<Node> node) const
00058 {
00059 return ApplicationContainer (InstallPriv (node));
00060 }
00061
00062 ApplicationContainer
00063 PacketSinkHelper::Install (NodeContainer c) const
00064 {
00065 ApplicationContainer apps;
00066 for (NodeContainer::Iterator i = c.Begin (); i != c.End (); ++i)
00067 {
00068 apps.Add (InstallPriv (*i));
00069 }
00070
00071 return apps;
00072 }
00073
00074 Ptr<Application>
00075 PacketSinkHelper::InstallPriv (Ptr<Node> node) const
00076 {
00077 Ptr<Application> app = m_factory.Create<Application> ();
00078 node->AddApplication (app);
00079
00080 return app;
00081 }
00082
00083 }