1.1 --- a/examples/csma-broadcast.cc Wed Mar 26 21:28:27 2008 -0700
1.2 +++ b/examples/csma-broadcast.cc Mon Mar 31 13:54:41 2008 -0700
1.3 @@ -79,16 +79,21 @@
1.4 cmd.Parse (argc, argv);
1.5
1.6 NS_LOG_INFO ("Create nodes.");
1.7 - NodeContainer c0;
1.8 - c0.Create (2);
1.9 -
1.10 - NodeContainer c1;
1.11 - c1.Add (c0.Get (0));
1.12 - c1.Create (1);
1.13 -
1.14 + NodeContainer c;
1.15 + c.Create (3);
1.16 + NodeContainer c0 = NodeContainer (c.Get (0), c.Get (1));
1.17 + NodeContainer c1 = NodeContainer (c.Get (0), c.Get (2));
1.18
1.19 NS_LOG_INFO ("Build Topology.");
1.20 CsmaHelper csma;
1.21 + // Also configure some tcpdump traces; each interface will be traced
1.22 + // The output files will be named
1.23 + // csma-broadcast.pcap-<nodeId>-<interfaceId>
1.24 + // and can be read by the "tcpdump -tt -r" command
1.25 + csma.EnablePcap ("csma-broadcast.pcap");
1.26 + std::ofstream ascii;
1.27 + ascii.open ("csma-broadcast.tr");
1.28 + csma.EnableAscii (ascii);
1.29 csma.SetChannelParameter ("BitRate", DataRate(5000000));
1.30 csma.SetChannelParameter ("Delay", MilliSeconds(2));
1.31
1.32 @@ -133,20 +138,6 @@
1.33 sink.Build (c1.Get (1));
1.34
1.35
1.36 - NS_LOG_INFO ("Configure Tracing.");
1.37 - // Configure tracing of all enqueue, dequeue, and NetDevice receive events
1.38 - // Trace output will be sent to the csma-broadcast.tr file
1.39 - AsciiTrace asciitrace ("csma-broadcast.tr");
1.40 - asciitrace.TraceAllNetDeviceRx ();
1.41 - asciitrace.TraceAllQueues ();
1.42 -
1.43 - // Also configure some tcpdump traces; each interface will be traced
1.44 - // The output files will be named
1.45 - // simple-point-to-point.pcap-<nodeId>-<interfaceId>
1.46 - // and can be read by the "tcpdump -r" command (use "-tt" option to
1.47 - // display timestamps correctly)
1.48 - PcapTrace pcaptrace ("csma-broadcast.pcap");
1.49 - pcaptrace.TraceAllIp ();
1.50
1.51 NS_LOG_INFO ("Run Simulation.");
1.52 Simulator::Run ();
2.1 --- a/examples/simple-global-routing.cc Wed Mar 26 21:28:27 2008 -0700
2.2 +++ b/examples/simple-global-routing.cc Mon Mar 31 13:54:41 2008 -0700
2.3 @@ -42,31 +42,11 @@
2.4 #include <string>
2.5 #include <cassert>
2.6
2.7 -#include "ns3/log.h"
2.8 -
2.9 -#include "ns3/command-line.h"
2.10 -#include "ns3/ptr.h"
2.11 -#include "ns3/random-variable.h"
2.12 -#include "ns3/config.h"
2.13 -#include "ns3/uinteger.h"
2.14 -
2.15 -#include "ns3/simulator.h"
2.16 -#include "ns3/nstime.h"
2.17 -#include "ns3/data-rate.h"
2.18 -
2.19 +#include "ns3/core-module.h"
2.20 +#include "ns3/simulator-module.h"
2.21 +#include "ns3/helper-module.h"
2.22 #include "ns3/ascii-trace.h"
2.23 #include "ns3/pcap-trace.h"
2.24 -#include "ns3/internet-node.h"
2.25 -#include "ns3/point-to-point-channel.h"
2.26 -#include "ns3/point-to-point-net-device.h"
2.27 -#include "ns3/ipv4-address.h"
2.28 -#include "ns3/ipv4.h"
2.29 -#include "ns3/socket.h"
2.30 -#include "ns3/inet-socket-address.h"
2.31 -#include "ns3/ipv4-route.h"
2.32 -#include "ns3/point-to-point-topology.h"
2.33 -#include "ns3/onoff-application.h"
2.34 -#include "ns3/packet-sink.h"
2.35 #include "ns3/global-route-manager.h"
2.36
2.37 using namespace ns3;
2.38 @@ -118,38 +98,39 @@
2.39 // Here, we will explicitly create four nodes. In more sophisticated
2.40 // topologies, we could configure a node factory.
2.41 NS_LOG_INFO ("Create nodes.");
2.42 - Ptr<Node> n0 = CreateObject<InternetNode> ();
2.43 - Ptr<Node> n1 = CreateObject<InternetNode> ();
2.44 - Ptr<Node> n2 = CreateObject<InternetNode> ();
2.45 - Ptr<Node> n3 = CreateObject<InternetNode> ();
2.46 + NodeContainer c;
2.47 + c.Create (4);
2.48 + NodeContainer n0n2 = NodeContainer (c.Get(0), c.Get (2));
2.49 + NodeContainer n1n2 = NodeContainer (c.Get(1), c.Get (2));
2.50 + NodeContainer n3n2 = NodeContainer (c.Get(3), c.Get (2));
2.51 +
2.52 + InternetStackHelper internet;
2.53 + internet.Build (c);
2.54
2.55 // We create the channels first without any IP addressing information
2.56 NS_LOG_INFO ("Create channels.");
2.57 - Ptr<PointToPointChannel> channel0 =
2.58 - PointToPointTopology::AddPointToPointLink (
2.59 - n0, n2, DataRate (5000000), MilliSeconds (2));
2.60 + PointToPointHelper p2p;
2.61 + p2p.SetChannelParameter ("BitRate", DataRate (5000000));
2.62 + p2p.SetChannelParameter ("Delay", MilliSeconds (2));
2.63 + NetDeviceContainer d0d2 = p2p.Build (n0n2);
2.64
2.65 - Ptr<PointToPointChannel> channel1 =
2.66 - PointToPointTopology::AddPointToPointLink (
2.67 - n1, n2, DataRate (5000000), MilliSeconds (2));
2.68 + NetDeviceContainer d1d2 = p2p.Build (n1n2);
2.69
2.70 - Ptr<PointToPointChannel> channel2 =
2.71 - PointToPointTopology::AddPointToPointLink (
2.72 - n2, n3, DataRate (1500000), MilliSeconds (10));
2.73 + p2p.SetChannelParameter ("BitRate", DataRate (1500000));
2.74 + p2p.SetChannelParameter ("Delay", MilliSeconds (10));
2.75 + NetDeviceContainer d3d2 = p2p.Build (n3n2);
2.76
2.77 // Later, we add IP addresses.
2.78 NS_LOG_INFO ("Assign IP Addresses.");
2.79 - PointToPointTopology::AddIpv4Addresses (
2.80 - channel0, n0, Ipv4Address ("10.1.1.1"),
2.81 - n2, Ipv4Address ("10.1.1.2"));
2.82 + Ipv4AddressHelper ipv4;
2.83 + ipv4.SetBase ("10.1.1.0", "255.255.255.0");
2.84 + Ipv4InterfaceContainer i0i2 = ipv4.Allocate (d0d2);
2.85 +
2.86 + ipv4.SetBase ("10.1.2.0", "255.255.255.0");
2.87 + Ipv4InterfaceContainer i1i2 = ipv4.Allocate (d1d2);
2.88
2.89 - PointToPointTopology::AddIpv4Addresses (
2.90 - channel1, n1, Ipv4Address ("10.1.2.1"),
2.91 - n2, Ipv4Address ("10.1.2.2"));
2.92 -
2.93 - PointToPointTopology::AddIpv4Addresses (
2.94 - channel2, n2, Ipv4Address ("10.1.3.1"),
2.95 - n3, Ipv4Address ("10.1.3.2"));
2.96 + ipv4.SetBase ("10.1.3.0", "255.255.255.0");
2.97 + Ipv4InterfaceContainer i3i2 = ipv4.Allocate (d3d2);
2.98
2.99 // Create router nodes, initialize routing database and set up the routing
2.100 // tables in the nodes.
2.101 @@ -159,43 +140,32 @@
2.102 // 210 bytes at a rate of 448 Kb/s
2.103 NS_LOG_INFO ("Create Applications.");
2.104 uint16_t port = 9; // Discard port (RFC 863)
2.105 - Ptr<OnOffApplication> ooff =
2.106 - CreateObject<OnOffApplication> ("Remote", Address (InetSocketAddress ("10.1.3.2", port)),
2.107 - "Protocol", TypeId::LookupByName ("ns3::Udp"),
2.108 - "OnTime", ConstantVariable (1),
2.109 - "OffTime", ConstantVariable (0));
2.110 - n0->AddApplication (ooff);
2.111 - // Start the application
2.112 - ooff->Start (Seconds (1.0));
2.113 - ooff->Stop (Seconds (10.0));
2.114 + OnOffHelper onoff;
2.115 + onoff.SetAppAttribute ("OnTime", ConstantVariable (1));
2.116 + onoff.SetAppAttribute ("OffTime", ConstantVariable (0));
2.117 + onoff.SetUdpRemote (i3i2.GetAddress (0), port);
2.118 + ApplicationContainer apps = onoff.Build (c.Get (0));
2.119 + apps.Start (Seconds (1.0));
2.120 + apps.Stop (Seconds (10.0));
2.121
2.122 // Create a packet sink to receive these packets
2.123 // The last argument "true" disables output from the Receive callback
2.124 - Ptr<PacketSink> sink =
2.125 - CreateObject<PacketSink> ("Remote", Address (InetSocketAddress (Ipv4Address::GetAny (), port)),
2.126 - "Protocol", TypeId::LookupByName ("ns3::Udp"));
2.127 - n3->AddApplication (sink);
2.128 - // Start the sink
2.129 - sink->Start (Seconds (1.0));
2.130 - sink->Stop (Seconds (10.0));
2.131 + PacketSinkHelper sink;
2.132 + sink.SetupUdp (Ipv4Address::GetAny (), port);
2.133 + apps = sink.Build (c.Get (3));
2.134 + apps.Start (Seconds (1.0));
2.135 + apps.Stop (Seconds (10.0));
2.136
2.137 // Create a similar flow from n3 to n1, starting at time 1.1 seconds
2.138 - ooff = CreateObject<OnOffApplication> ("Remote", Address (InetSocketAddress ("10.1.2.1", port)),
2.139 - "Protocol", TypeId::LookupByName ("ns3::Udp"),
2.140 - "OnTime", ConstantVariable (1),
2.141 - "OffTime", ConstantVariable (0));
2.142 - n3->AddApplication (ooff);
2.143 - // Start the application
2.144 - ooff->Start (Seconds (1.1));
2.145 - ooff->Stop (Seconds (10.0));
2.146 + onoff.SetUdpRemote (i1i2.GetAddress (0), port);
2.147 + apps = onoff.Build (c.Get (3));
2.148 + apps.Start (Seconds (1.1));
2.149 + apps.Stop (Seconds (10.0));
2.150
2.151 // Create a packet sink to receive these packets
2.152 - sink = CreateObject<PacketSink> ("Remote", Address (InetSocketAddress (Ipv4Address::GetAny (), port)),
2.153 - "Protocol", TypeId::LookupByName ("ns3::Udp"));
2.154 - n1->AddApplication (sink);
2.155 - // Start the sink
2.156 - sink->Start (Seconds (1.1));
2.157 - sink->Stop (Seconds (10.0));
2.158 + apps = sink.Build (c.Get (1));
2.159 + apps.Start (Seconds (1.1));
2.160 + apps.Stop (Seconds (10.0));
2.161
2.162 // Configure tracing of all enqueue, dequeue, and NetDevice receive events
2.163 // Trace output will be sent to the simple-global-routing.tr file
3.1 --- a/examples/udp-echo.cc Wed Mar 26 21:28:27 2008 -0700
3.2 +++ b/examples/udp-echo.cc Mon Mar 31 13:54:41 2008 -0700
3.3 @@ -25,28 +25,11 @@
3.4 // - DropTail queues
3.5 // - Tracing of queues and packet receptions to file "udp-echo.tr"
3.6
3.7 -#include "ns3/command-line.h"
3.8 -#include "ns3/ptr.h"
3.9 -#include "ns3/log.h"
3.10 -#include "ns3/simulator.h"
3.11 -#include "ns3/nstime.h"
3.12 -#include "ns3/data-rate.h"
3.13 +#include "ns3/core-module.h"
3.14 +#include "ns3/simulator-module.h"
3.15 +#include "ns3/helper-module.h"
3.16 #include "ns3/ascii-trace.h"
3.17 #include "ns3/pcap-trace.h"
3.18 -#include "ns3/internet-node.h"
3.19 -#include "ns3/csma-channel.h"
3.20 -#include "ns3/csma-net-device.h"
3.21 -#include "ns3/csma-topology.h"
3.22 -#include "ns3/csma-ipv4-topology.h"
3.23 -#include "ns3/mac48-address.h"
3.24 -#include "ns3/ipv4-address.h"
3.25 -#include "ns3/inet-socket-address.h"
3.26 -#include "ns3/ipv4.h"
3.27 -#include "ns3/socket.h"
3.28 -#include "ns3/ipv4-route.h"
3.29 -#include "ns3/udp-echo-client.h"
3.30 -#include "ns3/udp-echo-server.h"
3.31 -#include "ns3/uinteger.h"
3.32
3.33 using namespace ns3;
3.34
3.35 @@ -94,75 +77,40 @@
3.36 // Explicitly create the nodes required by the topology (shown above).
3.37 //
3.38 NS_LOG_INFO ("Create nodes.");
3.39 - Ptr<Node> n0 = CreateObject<InternetNode> ();
3.40 - Ptr<Node> n1 = CreateObject<InternetNode> ();
3.41 - Ptr<Node> n2 = CreateObject<InternetNode> ();
3.42 - Ptr<Node> n3 = CreateObject<InternetNode> ();
3.43 + NodeContainer n;
3.44 + n.Create (4);
3.45 +
3.46 + InternetStackHelper internet;
3.47 + internet.Build (n);
3.48
3.49 NS_LOG_INFO ("Create channels.");
3.50 //
3.51 // Explicitly create the channels required by the topology (shown above).
3.52 //
3.53 - Ptr<CsmaChannel> lan = CsmaTopology::CreateCsmaChannel(
3.54 - DataRate(5000000), MilliSeconds(2));
3.55 + CsmaHelper csma;
3.56 + csma.SetChannelParameter ("BitRate", DataRate(5000000));
3.57 + csma.SetChannelParameter ("Delay", MilliSeconds (2));
3.58 + NetDeviceContainer d = csma.Build (n);
3.59
3.60 - NS_LOG_INFO ("Build Topology.");
3.61 -//
3.62 -// Now fill out the topology by creating the net devices required to connect
3.63 -// the nodes to the channels and hooking them up. AddIpv4CsmaNetDevice will
3.64 -// create a net device, add a MAC address (in memory of the pink flamingo) and
3.65 -// connect the net device to a nodes and also to a channel. the
3.66 -// AddIpv4CsmaNetDevice method returns a net device index for the net device
3.67 -// created on the node. Interpret nd0 as the net device we created for node
3.68 -// zero.
3.69 -//
3.70 - uint32_t nd0 = CsmaIpv4Topology::AddIpv4CsmaNetDevice (n0, lan,
3.71 - Mac48Address("08:00:2e:00:00:00"));
3.72 -
3.73 - uint32_t nd1 = CsmaIpv4Topology::AddIpv4CsmaNetDevice (n1, lan,
3.74 - Mac48Address("08:00:2e:00:00:01"));
3.75 -
3.76 - uint32_t nd2 = CsmaIpv4Topology::AddIpv4CsmaNetDevice (n2, lan,
3.77 - Mac48Address("08:00:2e:00:00:02"));
3.78 -
3.79 - uint32_t nd3 = CsmaIpv4Topology::AddIpv4CsmaNetDevice (n3, lan,
3.80 - Mac48Address("08:00:2e:00:00:03"));
3.81 + Ipv4AddressHelper ipv4;
3.82 //
3.83 // We've got the "hardware" in place. Now we need to add IP addresses.
3.84 //
3.85 NS_LOG_INFO ("Assign IP Addresses.");
3.86 -//
3.87 -// XXX BUGBUG
3.88 -// Need a better way to get the interface index. The point-to-point topology
3.89 -// as implemented can't return the index since it creates interfaces on both
3.90 -// sides (i.e., it does AddIpv4Addresses, not AddIpv4Address). We need a
3.91 -// method on Ipv4 to find the interface index corresponding to a given ipv4
3.92 -// address.
3.93 -//
3.94 -// Assign IP addresses to the net devices and associated interfaces
3.95 -// on the lan. The AddIpv4Address method returns an Ipv4 interface index
3.96 -// which we do not need here.
3.97 -//
3.98 - CsmaIpv4Topology::AddIpv4Address (n0, nd0, Ipv4Address("10.1.1.1"),
3.99 - Ipv4Mask("255.255.255.0"));
3.100 -
3.101 - CsmaIpv4Topology::AddIpv4Address (n1, nd1, Ipv4Address("10.1.1.2"),
3.102 - Ipv4Mask("255.255.255.0"));
3.103 -
3.104 - CsmaIpv4Topology::AddIpv4Address (n2, nd2, Ipv4Address("10.1.1.3"),
3.105 - Ipv4Mask("255.255.255.0"));
3.106 -
3.107 - CsmaIpv4Topology::AddIpv4Address (n3, nd3, Ipv4Address("10.1.1.4"),
3.108 - Ipv4Mask("255.255.255.0"));
3.109 + ipv4.SetBase ("10.1.1.0", "255.255.255.0");
3.110 + Ipv4InterfaceContainer i = ipv4.Allocate (d);
3.111
3.112 NS_LOG_INFO ("Create Applications.");
3.113 //
3.114 // Create a UdpEchoServer application on node one.
3.115 //
3.116 uint16_t port = 9; // well-known echo port number
3.117 + UdpEchoServerHelper server;
3.118 + server.SetPort (port);
3.119 + ApplicationContainer apps = server.Build (n.Get(1));
3.120 + apps.Start (Seconds (1.0));
3.121 + apps.Stop (Seconds (10.0));
3.122
3.123 - Ptr<UdpEchoServer> server = CreateObject<UdpEchoServer> ("Port", Uinteger (port));
3.124 - n1->AddApplication (server);
3.125 //
3.126 // Create a UdpEchoClient application to send UDP datagrams from node zero to
3.127 // node one.
3.128 @@ -170,22 +118,15 @@
3.129 uint32_t packetSize = 1024;
3.130 uint32_t maxPacketCount = 1;
3.131 Time interPacketInterval = Seconds (1.);
3.132 + UdpEchoClientHelper client;
3.133 + client.SetRemote (i.GetAddress (1), port);
3.134 + client.SetAppAttribute ("MaxPackets", Uinteger (maxPacketCount));
3.135 + client.SetAppAttribute ("Interval", interPacketInterval);
3.136 + client.SetAppAttribute ("PacketSize", Uinteger (packetSize));
3.137 + apps = client.Build (n.Get (0));
3.138 + apps.Start (Seconds (2.0));
3.139 + apps.Stop (Seconds (10.0));
3.140
3.141 - Ptr<UdpEchoClient> client =
3.142 - CreateObject<UdpEchoClient> ("RemoteIpv4", Ipv4Address ("10.1.1.2"),
3.143 - "RemotePort", Uinteger (port),
3.144 - "MaxPackets", Uinteger (maxPacketCount),
3.145 - "Interval", interPacketInterval,
3.146 - "PacketSize", Uinteger (packetSize));
3.147 - n0->AddApplication (client);
3.148 -//
3.149 -// Tell the applications when to start and stop.
3.150 -//
3.151 - server->Start(Seconds(1.));
3.152 - client->Start(Seconds(2.));
3.153 -
3.154 - server->Stop (Seconds(10.));
3.155 - client->Stop (Seconds(10.));
3.156 //
3.157 // Configure tracing of all enqueue, dequeue, and NetDevice receive events.
3.158 // Trace output will be sent to the file "udp-echo.tr"
4.1 --- a/examples/wifi-adhoc.cc Wed Mar 26 21:28:27 2008 -0700
4.2 +++ b/examples/wifi-adhoc.cc Mon Mar 31 13:54:41 2008 -0700
4.3 @@ -225,7 +225,6 @@
4.4 gnuplot.GenerateOutput (std::cout);
4.5
4.6
4.7 -
4.8 gnuplot = Gnuplot ("rate-control.png");
4.9 Config::SetDefault ("ns3::WifiPhy::Standard", String ("holland"));
4.10
5.1 --- a/src/applications/udp-echo/udp-echo-client.cc Wed Mar 26 21:28:27 2008 -0700
5.2 +++ b/src/applications/udp-echo/udp-echo-client.cc Mon Mar 31 13:54:41 2008 -0700
5.3 @@ -74,6 +74,13 @@
5.4 NS_LOG_FUNCTION;
5.5 }
5.6
5.7 +void
5.8 +UdpEchoClient::SetRemote (Ipv4Address ip, uint16_t port)
5.9 +{
5.10 + m_peerAddress = ip;
5.11 + m_peerPort = port;
5.12 +}
5.13 +
5.14 void
5.15 UdpEchoClient::DoDispose (void)
5.16 {
6.1 --- a/src/applications/udp-echo/udp-echo-client.h Wed Mar 26 21:28:27 2008 -0700
6.2 +++ b/src/applications/udp-echo/udp-echo-client.h Mon Mar 31 13:54:41 2008 -0700
6.3 @@ -22,10 +22,10 @@
6.4 #include "ns3/application.h"
6.5 #include "ns3/event-id.h"
6.6 #include "ns3/ptr.h"
6.7 +#include "ns3/ipv4-address.h"
6.8
6.9 namespace ns3 {
6.10
6.11 -class Address;
6.12 class Socket;
6.13 class Packet;
6.14
6.15 @@ -38,6 +38,8 @@
6.16
6.17 virtual ~UdpEchoClient ();
6.18
6.19 + void SetRemote (Ipv4Address ip, uint16_t port);
6.20 +
6.21 protected:
6.22 virtual void DoDispose (void);
6.23
7.1 --- a/src/applications/udp-echo/udp-echo-server.cc Wed Mar 26 21:28:27 2008 -0700
7.2 +++ b/src/applications/udp-echo/udp-echo-server.cc Mon Mar 31 13:54:41 2008 -0700
7.3 @@ -39,8 +39,8 @@
7.4 static TypeId tid = TypeId ("ns3::UdpEchoServer")
7.5 .SetParent<Application> ()
7.6 .AddConstructor<UdpEchoServer> ()
7.7 - .AddAttribute ("Port", "Client Port",
7.8 - Uinteger (0),
7.9 + .AddAttribute ("Port", "Port on which we listen for incoming packets.",
7.10 + Uinteger (9),
7.11 MakeUintegerAccessor (&UdpEchoServer::m_port),
7.12 MakeUintegerChecker<uint16_t> ())
7.13 ;
8.1 --- a/src/applications/udp-echo/udp-echo-server.h Wed Mar 26 21:28:27 2008 -0700
8.2 +++ b/src/applications/udp-echo/udp-echo-server.h Mon Mar 31 13:54:41 2008 -0700
8.3 @@ -22,10 +22,10 @@
8.4 #include "ns3/application.h"
8.5 #include "ns3/event-id.h"
8.6 #include "ns3/ptr.h"
8.7 +#include "ns3/address.h"
8.8
8.9 namespace ns3 {
8.10
8.11 -class Address;
8.12 class Socket;
8.13 class Packet;
8.14
9.1 --- a/src/common/pcap-writer.cc Wed Mar 26 21:28:27 2008 -0700
9.2 +++ b/src/common/pcap-writer.cc Mon Mar 31 13:54:41 2008 -0700
9.3 @@ -120,4 +120,4 @@
9.4 WriteData((uint8_t*)&data, 2);
9.5 }
9.6
9.7 -}; // namespace ns3
9.8 +} // namespace ns3
10.1 --- a/src/common/pcap-writer.h Wed Mar 26 21:28:27 2008 -0700
10.2 +++ b/src/common/pcap-writer.h Mon Mar 31 13:54:41 2008 -0700
10.3 @@ -22,8 +22,8 @@
10.4 #ifndef PCAP_WRITER_H
10.5 #define PCAP_WRITER_H
10.6
10.7 -#include "ns3/callback.h"
10.8 #include <stdint.h>
10.9 +#include "ns3/ref-count-base.h"
10.10
10.11 namespace ns3 {
10.12
10.13 @@ -35,7 +35,8 @@
10.14 * Log Packets to a file in pcap format which can be
10.15 * read by pcap readers.
10.16 */
10.17 -class PcapWriter {
10.18 +class PcapWriter : public RefCountBase
10.19 +{
10.20 public:
10.21 PcapWriter ();
10.22 ~PcapWriter ();
10.23 @@ -71,9 +72,8 @@
10.24 void Write16 (uint16_t data);
10.25 void WriteHeader (uint32_t network);
10.26 std::ofstream *m_writer;
10.27 - Callback<void,uint8_t *,uint32_t> m_writeCallback;
10.28 };
10.29
10.30 -}; // namespace ns3
10.31 +} // namespace ns3
10.32
10.33 #endif /* PCAP_WRITER_H */
11.1 --- a/src/core/random-variable.h Wed Mar 26 21:28:27 2008 -0700
11.2 +++ b/src/core/random-variable.h Mon Mar 31 13:54:41 2008 -0700
11.3 @@ -48,7 +48,7 @@
11.4 * the University of Montreal.
11.5 *
11.6 * NS-3 has a rich set of random number generators.
11.7 - * Class RandomVariableBase defines the base class functionalty
11.8 + * Class RandomVariable defines the base class functionalty
11.9 * required for all random number generators. By default, the underlying
11.10 * generator is seeded with the time of day, and then deterministically
11.11 * creates a sequence of seeds for each subsequent generator that is created.
11.12 @@ -93,7 +93,7 @@
11.13 * generator is seeded with data from /dev/random instead of
11.14 * being seeded based upon the time of day. For this to be effective,
11.15 * it must be called before the creation of the first instance of a
11.16 - * RandomVariableBase or subclass. Example:
11.17 + * RandomVariable or subclass. Example:
11.18 * \code
11.19 * RandomVariable::UseDevRandom();
11.20 * UniformVariable x(2,3); //these are seeded randomly
11.21 @@ -221,19 +221,19 @@
11.22 * \brief A random variable that returns a constant
11.23 * \ingroup randomvariable
11.24 *
11.25 - * Class ConstantVariableImpl defines a random number generator that
11.26 + * Class ConstantVariable defines a random number generator that
11.27 * returns the same value every sample.
11.28 */
11.29 class ConstantVariable : public RandomVariable {
11.30
11.31 public:
11.32 /**
11.33 - * Construct a ConstantVariableImpl RNG that returns zero every sample
11.34 + * Construct a ConstantVariable RNG that returns zero every sample
11.35 */
11.36 ConstantVariable();
11.37
11.38 /**
11.39 - * Construct a ConstantVariableImpl RNG that returns the specified value
11.40 + * Construct a ConstantVariable RNG that returns the specified value
11.41 * every sample.
11.42 * \param c Unchanging value for this RNG.
11.43 */
11.44 @@ -260,10 +260,10 @@
11.45 {
11.46 public:
11.47 /**
11.48 - * \brief Constructor for the SequentialVariableImpl RNG.
11.49 + * \brief Constructor for the SequentialVariable RNG.
11.50 *
11.51 * The four parameters define the sequence. For example
11.52 - * SequentialVariableImpl(0,5,1,2) creates a RNG that has the sequence
11.53 + * SequentialVariable(0,5,1,2) creates a RNG that has the sequence
11.54 * 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 0, 0 ...
11.55 * \param f First value of the sequence.
11.56 * \param l One more than the last value of the sequence.
11.57 @@ -273,13 +273,13 @@
11.58 SequentialVariable(double f, double l, double i = 1, uint32_t c = 1);
11.59
11.60 /**
11.61 - * \brief Constructor for the SequentialVariableImpl RNG.
11.62 + * \brief Constructor for the SequentialVariable RNG.
11.63 *
11.64 * Differs from the first only in that the increment parameter is a
11.65 * random variable
11.66 * \param f First value of the sequence.
11.67 * \param l One more than the last value of the sequence.
11.68 - * \param i Reference to a RandomVariableBase for the sequence increment
11.69 + * \param i Reference to a RandomVariable for the sequence increment
11.70 * \param c Number of times each member of the sequence is repeated
11.71 */
11.72 SequentialVariable(double f, double l, const RandomVariable& i, uint32_t c = 1);
11.73 @@ -303,10 +303,10 @@
11.74 * \f$ \left\{ \begin{array}{cl} \alpha e^{-\alpha x} & x < bound \\ bound & x > bound \end{array}\right. \f$
11.75 *
11.76 * \code
11.77 - * ExponentialVariableImpl x(3.14);
11.78 + * ExponentialVariable x(3.14);
11.79 * x.GetValue(); //will always return with mean 3.14
11.80 - * ExponentialVariableImpl::GetSingleValue(20.1); //returns with mean 20.1
11.81 - * ExponentialVariableImpl::GetSingleValue(108); //returns with mean 108
11.82 + * ExponentialVariable::GetSingleValue(20.1); //returns with mean 20.1
11.83 + * ExponentialVariable::GetSingleValue(108); //returns with mean 108
11.84 * \endcode
11.85 *
11.86 */
11.87 @@ -347,7 +347,7 @@
11.88 };
11.89
11.90 /**
11.91 - * \brief ParetoVariableImpl distributed random var
11.92 + * \brief ParetoVariable distributed random var
11.93 * \ingroup randomvariable
11.94 *
11.95 * This class supports the creation of objects that return random numbers
11.96 @@ -362,10 +362,10 @@
11.97 * with the equation \f$ x_m = mean \frac{k-1}{k}, k > 1\f$.
11.98 *
11.99 * \code
11.100 - * ParetoVariableImpl x(3.14);
11.101 + * ParetoVariable x(3.14);
11.102 * x.GetValue(); //will always return with mean 3.14
11.103 - * ParetoVariableImpl::GetSingleValue(20.1); //returns with mean 20.1
11.104 - * ParetoVariableImpl::GetSingleValue(108); //returns with mean 108
11.105 + * ParetoVariable::GetSingleValue(20.1); //returns with mean 20.1
11.106 + * ParetoVariable::GetSingleValue(108); //returns with mean 108
11.107 * \endcode
11.108 */
11.109 class ParetoVariable : public RandomVariable
11.110 @@ -419,7 +419,7 @@
11.111 };
11.112
11.113 /**
11.114 - * \brief WeibullVariableImpl distributed random var
11.115 + * \brief WeibullVariable distributed random var
11.116 * \ingroup randomvariable
11.117 *
11.118 * This class supports the creation of objects that return random numbers
11.119 @@ -459,7 +459,7 @@
11.120 /**
11.121 * \brief Constructs a weibull random variable with the specified mean
11.122 * \brief value, shape (alpha), and upper bound.
11.123 - * Since WeibullVariableImpl distributions can theoretically return unbounded values,
11.124 + * Since WeibullVariable distributions can theoretically return unbounded values,
11.125 * it is sometimes usefull to specify a fixed upper limit. Note however
11.126 * that when the upper limit is specified, the true mean of the distribution
11.127 * is slightly smaller than the mean value specified.
11.128 @@ -478,7 +478,7 @@
11.129 };
11.130
11.131 /**
11.132 - * \brief Class NormalVariableImpl defines a random variable with a
11.133 + * \brief Class NormalVariable defines a random variable with a
11.134 * normal (Gaussian) distribution.
11.135 * \ingroup randomvariable
11.136 *
11.137 @@ -505,20 +505,20 @@
11.138 * \brief Construct a normal random variable with specified mean and variance
11.139 * \param m Mean value
11.140 * \param v Variance
11.141 - * \param b Bound. The NormalVariableImpl is bounded within +-bound.
11.142 + * \param b Bound. The NormalVariable is bounded within +-bound.
11.143 */
11.144 NormalVariable(double m, double v, double b = INFINITE_VALUE);
11.145 /**
11.146 * \param m Mean value
11.147 * \param v Variance
11.148 - * \param b Bound. The NormalVariableImpl is bounded within +-bound.
11.149 + * \param b Bound. The NormalVariable is bounded within +-bound.
11.150 * \return A random number from a distribution specified by m,v, and b.
11.151 */
11.152 static double GetSingleValue(double m, double v, double b = INFINITE_VALUE);
11.153 };
11.154
11.155 /**
11.156 - * \brief EmpiricalVariableImpl distribution random var
11.157 + * \brief EmpiricalVariable distribution random var
11.158 * \ingroup randomvariable
11.159 *
11.160 * Defines a random variable that has a specified, empirical
11.161 @@ -528,12 +528,14 @@
11.162 * the specified value. When values are requested,
11.163 * a uniform random variable is used to select a probabililty,
11.164 * and the return value is interpreted linerarly between the
11.165 - * two appropriate points in the CDF
11.166 + * two appropriate points in the CDF. The method is known
11.167 + * as inverse transform sampling:
11.168 + * (http://en.wikipedia.org/wiki/Inverse_transform_sampling).
11.169 */
11.170 class EmpiricalVariable : public RandomVariable {
11.171 public:
11.172 /**
11.173 - * Constructor for the EmpiricalVariableImpl random variables.
11.174 + * Constructor for the EmpiricalVariable random variables.
11.175 */
11.176 explicit EmpiricalVariable();
11.177
11.178 @@ -552,8 +554,9 @@
11.179 * \ingroup randomvariable
11.180 *
11.181 * Defines an empirical distribution where all values are integers.
11.182 - * Indentical to EmpiricalVariableImpl, but with slightly different
11.183 - * interpolation between points.
11.184 + * Indentical to EmpiricalVariable, except that the inverse transform
11.185 + * sampling interpolation described in the EmpiricalVariable documentation
11.186 + * is modified to only return integers.
11.187 */
11.188 class IntEmpiricalVariable : public EmpiricalVariable
11.189 {
11.190 @@ -580,7 +583,7 @@
11.191 * on successive calls to ::Value(). Note that the d pointer is copied
11.192 * for use by the generator (shallow-copy), not its contents, so the
11.193 * contents of the array d points to have to remain unchanged for the use
11.194 - * of DeterministicVariableImpl to be meaningful.
11.195 + * of DeterministicVariable to be meaningful.
11.196 * \param d Pointer to array of random values to return in sequence
11.197 * \param c Number of values in the array
11.198 */
11.199 @@ -592,7 +595,7 @@
11.200 * \brief Log-normal Distributed random var
11.201 * \ingroup randomvariable
11.202 *
11.203 - * LogNormalVariableImpl defines a random variable with log-normal
11.204 + * LogNormalVariable defines a random variable with log-normal
11.205 * distribution. If one takes the natural logarithm of random
11.206 * variable following the log-normal distribution, the obtained values
11.207 * follow a normal distribution.
12.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
12.2 +++ b/src/core/ref-count-base.cc Mon Mar 31 13:54:41 2008 -0700
12.3 @@ -0,0 +1,37 @@
12.4 +/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
12.5 +/*
12.6 + * Copyright (c) 2007 Georgia Tech Research Corporation
12.7 + *
12.8 + * This program is free software; you can redistribute it and/or modify
12.9 + * it under the terms of the GNU General Public License version 2 as
12.10 + * published by the Free Software Foundation;
12.11 + *
12.12 + * This program is distributed in the hope that it will be useful,
12.13 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
12.14 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12.15 + * GNU General Public License for more details.
12.16 + *
12.17 + * You should have received a copy of the GNU General Public License
12.18 + * along with this program; if not, write to the Free Software
12.19 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
12.20 + *
12.21 + * Author: George Riley <riley@ece.gatech.edu>
12.22 + * Adapted from original code in object.h by:
12.23 + * Authors: Gustavo Carneiro <gjcarneiro@gmail.com>,
12.24 + * Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
12.25 + */
12.26 +
12.27 +#include "ref-count-base.h"
12.28 +
12.29 +namespace ns3 {
12.30 +
12.31 +RefCountBase::RefCountBase()
12.32 + : m_count (1)
12.33 +{
12.34 +}
12.35 +
12.36 +RefCountBase::~RefCountBase ()
12.37 +{
12.38 +}
12.39 +
12.40 +} // namespace ns3
13.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
13.2 +++ b/src/core/ref-count-base.h Mon Mar 31 13:54:41 2008 -0700
13.3 @@ -0,0 +1,87 @@
13.4 +/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
13.5 +/*
13.6 + * Copyright (c) 2007 Georgia Tech Research Corporation
13.7 + *
13.8 + * This program is free software; you can redistribute it and/or modify
13.9 + * it under the terms of the GNU General Public License version 2 as
13.10 + * published by the Free Software Foundation;
13.11 + *
13.12 + * This program is distributed in the hope that it will be useful,
13.13 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
13.14 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13.15 + * GNU General Public License for more details.
13.16 + *
13.17 + * You should have received a copy of the GNU General Public License
13.18 + * along with this program; if not, write to the Free Software
13.19 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
13.20 + *
13.21 + * Author: George Riley <riley@ece.gatech.edu>
13.22 + * Adapted from original code in object.h by:
13.23 + * Authors: Gustavo Carneiro <gjcarneiro@gmail.com>,
13.24 + * Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
13.25 + */
13.26 +#ifndef __REF_COUNT_BASE_H__
13.27 +#define __REF_COUNT_BASE_H__
13.28 +
13.29 +#include <stdint.h>
13.30 +
13.31 +namespace ns3 {
13.32 +
13.33 +/**
13.34 + * \brief a base class that provides implementations of reference counting
13.35 + * operations.
13.36 + *
13.37 + * A base class that provides implementations of reference counting
13.38 + * operations, for classes that wish to use the templatized smart
13.39 + * pointer for memory management but that do not wish to derive from
13.40 + * class ns3::Object.
13.41 + *
13.42 + */
13.43 +class RefCountBase
13.44 +{
13.45 +public:
13.46 + RefCountBase();
13.47 + virtual ~RefCountBase ();
13.48 + /**
13.49 + * Increment the reference count. This method should not be called
13.50 + * by user code. RefCountBase instances are expected to be used in
13.51 + * conjunction with the Ptr template which would make calling Ref
13.52 + * unecessary and dangerous.
13.53 + */
13.54 + inline void Ref () const;
13.55 + /**
13.56 + * Decrement the reference count. This method should not be called
13.57 + * by user code. RefCountBase instances are expected to be used in
13.58 + * conjunction with the Ptr template which would make calling Ref
13.59 + * unecessary and dangerous.
13.60 + */
13.61 + inline void Unref () const;
13.62 +private:
13.63 + // Note we make this mutable so that the const methods can still
13.64 + // change it.
13.65 + mutable uint32_t m_count; // Reference count
13.66 +};
13.67 +
13.68 +} // namespace ns3
13.69 +
13.70 +namespace ns3 {
13.71 +
13.72 +// Implementation of the in-line methods
13.73 +void
13.74 +RefCountBase::Ref () const
13.75 +{
13.76 + m_count++;
13.77 +}
13.78 +
13.79 +void
13.80 +RefCountBase::Unref () const
13.81 +{
13.82 + if (--m_count == 0)
13.83 + { // All references removed, ok to delete
13.84 + delete this;
13.85 + }
13.86 +}
13.87 +
13.88 +} // namespace ns3
13.89 +
13.90 +#endif /* __REF_COUNT_BASE_H__*/
14.1 --- a/src/core/traced-callback.h Wed Mar 26 21:28:27 2008 -0700
14.2 +++ b/src/core/traced-callback.h Mon Mar 31 13:54:41 2008 -0700
14.3 @@ -28,11 +28,14 @@
14.4 namespace ns3 {
14.5
14.6 /**
14.7 - * \brief log arbitrary number of parameters to a matching ns3::Callback
14.8 + * \brief forward calls to a chain of Callback
14.9 * \ingroup tracing
14.10 *
14.11 - * Whenever operator () is invoked on this class, the call and its arguments
14.12 - * are forwarded to the internal matching ns3::Callback.
14.13 + * An ns3::TracedCallback has almost exactly the same API as a normal ns3::Callback but
14.14 + * instead of forwarding calls to a single function (as an ns3::Callback normally does),
14.15 + * it forwards calls to a chain of ns3::Callback. TracedCallback::Connect adds a ns3::Callback
14.16 + * at the end of the chain of callbacks. TracedCallback::Disconnect removes a ns3::Callback from
14.17 + * the chain of callbacks.
14.18 */
14.19 template<typename T1 = empty, typename T2 = empty,
14.20 typename T3 = empty, typename T4 = empty>
14.21 @@ -40,9 +43,39 @@
14.22 {
14.23 public:
14.24 TracedCallback ();
14.25 + /**
14.26 + * \param callback callback to add to chain of callbacks
14.27 + *
14.28 + * Append the input callback to the end of the internal list
14.29 + * of ns3::Callback.
14.30 + */
14.31 void ConnectWithoutContext (const CallbackBase & callback);
14.32 + /**
14.33 + * \param callback callback to add to chain of callbacks
14.34 + * \param path the path to send back to the user callback.
14.35 + *
14.36 + * Append the input callback to the end of the internal list
14.37 + * of ns3::Callback. This method also will make sure that the
14.38 + * input path specified by the user will be give back to the
14.39 + * user's callback as its first argument.
14.40 + */
14.41 void Connect (const CallbackBase & callback, std::string path);
14.42 + /**
14.43 + * \param callback callback to remove from the chain of callbacks.
14.44 + *
14.45 + * Remove the input callback from the internal list
14.46 + * of ns3::Callback. This method is really the symmetric
14.47 + * of the TracedCallback::ConnectWithoutContext method.
14.48 + */
14.49 void DisconnectWithoutContext (const CallbackBase & callback);
14.50 + /**
14.51 + * \param callback callback to remove from the chain of callbacks.
14.52 + * \param path the path which is sent back to the user callback.
14.53 + *
14.54 + * Remove the input callback which has a matching path as first argument
14.55 + * from the internal list of ns3::Callback. This method is really the symmetric
14.56 + * of the TracedCallback::Connect method.
14.57 + */
14.58 void Disconnect (const CallbackBase & callback, std::string path);
14.59 void operator() (void) const;
14.60 void operator() (T1 a1) const;
15.1 --- a/src/core/wscript Wed Mar 26 21:28:27 2008 -0700
15.2 +++ b/src/core/wscript Mon Mar 31 13:54:41 2008 -0700
15.3 @@ -34,6 +34,7 @@
15.4 'type-id.cc',
15.5 'attribute-list.cc',
15.6 'object-base.cc',
15.7 + 'ref-count-base.cc',
15.8 'ptr.cc',
15.9 'object.cc',
15.10 'test.cc',
15.11 @@ -75,6 +76,7 @@
15.12 'empty.h',
15.13 'callback.h',
15.14 'object-base.h',
15.15 + 'ref-count-base.h',
15.16 'type-id.h',
15.17 'attribute-list.h',
15.18 'ptr.h',
16.1 --- a/src/devices/csma/csma-net-device.cc Wed Mar 26 21:28:27 2008 -0700
16.2 +++ b/src/devices/csma/csma-net-device.cc Mon Mar 31 13:54:41 2008 -0700
16.3 @@ -200,6 +200,7 @@
16.4 lengthType = protocolNumber;
16.5 break;
16.6 case LLC: {
16.7 + lengthType = p->GetSize() + header.GetSerializedSize() + trailer.GetSerializedSize();
16.8 LlcSnapHeader llc;
16.9 llc.SetType (protocolNumber);
16.10 p->AddHeader (llc);
16.11 @@ -441,6 +442,8 @@
16.12 return;
16.13 }
16.14
16.15 + m_rxTrace (packet);
16.16 +
16.17 if (m_encapMode == RAW)
16.18 {
16.19 m_rxCallback (this, packet, 0, GetBroadcast ());
16.20 @@ -490,7 +493,6 @@
16.21 }
16.22 else
16.23 {
16.24 - m_rxTrace (packet);
16.25 //
16.26 // protocol must be initialized to avoid a compiler warning in the RAW
16.27 // case that breaks the optimized build.
17.1 --- a/src/devices/wifi/amrr-wifi-manager.cc Wed Mar 26 21:28:27 2008 -0700
17.2 +++ b/src/devices/wifi/amrr-wifi-manager.cc Mon Mar 31 13:54:41 2008 -0700
17.3 @@ -89,31 +89,31 @@
17.4 {}
17.5
17.6 void
17.7 -AmrrWifiRemoteStation::ReportRxOk (double rxSnr, WifiMode txMode)
17.8 +AmrrWifiRemoteStation::DoReportRxOk (double rxSnr, WifiMode txMode)
17.9 {}
17.10 void
17.11 -AmrrWifiRemoteStation::ReportRtsFailed (void)
17.12 +AmrrWifiRemoteStation::DoReportRtsFailed (void)
17.13 {}
17.14 void
17.15 -AmrrWifiRemoteStation::ReportDataFailed (void)
17.16 +AmrrWifiRemoteStation::DoReportDataFailed (void)
17.17 {
17.18 m_retry++;
17.19 m_tx_retr++;
17.20 }
17.21 void
17.22 -AmrrWifiRemoteStation::ReportRtsOk (double ctsSnr, WifiMode ctsMode, double rtsSnr)
17.23 +AmrrWifiRemoteStation::DoReportRtsOk (double ctsSnr, WifiMode ctsMode, double rtsSnr)
17.24 {}
17.25 void
17.26 -AmrrWifiRemoteStation::ReportDataOk (double ackSnr, WifiMode ackMode, double dataSnr)
17.27 +AmrrWifiRemoteStation::DoReportDataOk (double ackSnr, WifiMode ackMode, double dataSnr)
17.28 {
17.29 m_retry = 0;
17.30 m_tx_ok++;
17.31 }
17.32 void
17.33 -AmrrWifiRemoteStation::ReportFinalRtsFailed (void)
17.34 +AmrrWifiRemoteStation::DoReportFinalRtsFailed (void)
17.35 {}
17.36 void
17.37 -AmrrWifiRemoteStation::ReportFinalDataFailed (void)
17.38 +AmrrWifiRemoteStation::DoReportFinalDataFailed (void)
17.39 {
17.40 m_retry = 0;
17.41 m_tx_err++;
18.1 --- a/src/devices/wifi/amrr-wifi-manager.h Wed Mar 26 21:28:27 2008 -0700
18.2 +++ b/src/devices/wifi/amrr-wifi-manager.h Mon Mar 31 13:54:41 2008 -0700
18.3 @@ -52,13 +52,14 @@
18.4
18.5 virtual ~AmrrWifiRemoteStation ();
18.6
18.7 - virtual void ReportRxOk (double rxSnr, WifiMode txMode);
18.8 - virtual void ReportRtsFailed (void);
18.9 - virtual void ReportDataFailed (void);
18.10 - virtual void ReportRtsOk (double ctsSnr, WifiMode ctsMode, double rtsSnr);
18.11 - virtual void ReportDataOk (double ackSnr, WifiMode ackMode, double dataSnr);
18.12 - virtual void ReportFinalRtsFailed (void);
18.13 - virtual void ReportFinalDataFailed (void);
18.14 +protected:
18.15 + virtual void DoReportRxOk (double rxSnr, WifiMode txMode);
18.16 + virtual void DoReportRtsFailed (void);
18.17 + virtual void DoReportDataFailed (void);
18.18 + virtual void DoReportRtsOk (double ctsSnr, WifiMode ctsMode, double rtsSnr);
18.19 + virtual void DoReportDataOk (double ackSnr, WifiMode ackMode, double dataSnr);
18.20 + virtual void DoReportFinalRtsFailed (void);
18.21 + virtual void DoReportFinalDataFailed (void);
18.22
18.23 private:
18.24 virtual Ptr<WifiRemoteStationManager> GetManager (void) const;
19.1 --- a/src/devices/wifi/arf-wifi-manager.cc Wed Mar 26 21:28:27 2008 -0700
19.2 +++ b/src/devices/wifi/arf-wifi-manager.cc Mon Mar 31 13:54:41 2008 -0700
19.3 @@ -88,7 +88,7 @@
19.4
19.5
19.6 void
19.7 -ArfWifiRemoteStation::ReportRtsFailed (void)
19.8 +ArfWifiRemoteStation::DoReportRtsFailed (void)
19.9 {}
19.10 /**
19.11 * It is important to realize that "recovery" mode starts after failure of
19.12 @@ -100,7 +100,7 @@
19.13 * transmission, be it an initial transmission or a retransmission.
19.14 */
19.15 void
19.16 -ArfWifiRemoteStation::ReportDataFailed (void)
19.17 +ArfWifiRemoteStation::DoReportDataFailed (void)
19.18 {
19.19 m_timer++;
19.20 m_failed++;
19.21 @@ -138,13 +138,13 @@
19.22 }
19.23 }
19.24 void
19.25 -ArfWifiRemoteStation::ReportRxOk (double rxSnr, WifiMode txMode)
19.26 +ArfWifiRemoteStation::DoReportRxOk (double rxSnr, WifiMode txMode)
19.27 {}
19.28 -void ArfWifiRemoteStation::ReportRtsOk (double ctsSnr, WifiMode ctsMode, double rtsSnr)
19.29 +void ArfWifiRemoteStation::DoReportRtsOk (double ctsSnr, WifiMode ctsMode, double rtsSnr)
19.30 {
19.31 NS_LOG_DEBUG ("self="<<this<<" rts ok");
19.32 }
19.33 -void ArfWifiRemoteStation::ReportDataOk (double ackSnr, WifiMode ackMode, double dataSnr)
19.34 +void ArfWifiRemoteStation::DoReportDataOk (double ackSnr, WifiMode ackMode, double dataSnr)
19.35 {
19.36 m_timer++;
19.37 m_success++;
19.38 @@ -164,10 +164,10 @@
19.39 }
19.40 }
19.41 void
19.42 -ArfWifiRemoteStation::ReportFinalRtsFailed (void)
19.43 +ArfWifiRemoteStation::DoReportFinalRtsFailed (void)
19.44 {}
19.45 void
19.46 -ArfWifiRemoteStation::ReportFinalDataFailed (void)
19.47 +ArfWifiRemoteStation::DoReportFinalDataFailed (void)
19.48 {}
19.49
19.50 WifiMode
20.1 --- a/src/devices/wifi/arf-wifi-manager.h Wed Mar 26 21:28:27 2008 -0700
20.2 +++ b/src/devices/wifi/arf-wifi-manager.h Mon Mar 31 13:54:41 2008 -0700
20.3 @@ -60,13 +60,14 @@
20.4 int minSuccessThreshold);
20.5 virtual ~ArfWifiRemoteStation ();
20.6
20.7 - virtual void ReportRxOk (double rxSnr, WifiMode txMode);
20.8 - virtual void ReportRtsFailed (void);
20.9 - virtual void ReportDataFailed (void);
20.10 - virtual void ReportRtsOk (double ctsSnr, WifiMode ctsMode, double rtsSnr);
20.11 - virtual void ReportDataOk (double ackSnr, WifiMode ackMode, double dataSnr);
20.12 - virtual void ReportFinalRtsFailed (void);
20.13 - virtual void ReportFinalDataFailed (void);
20.14 +protected:
20.15 + virtual void DoReportRxOk (double rxSnr, WifiMode txMode);
20.16 + virtual void DoReportRtsFailed (void);
20.17 + virtual void DoReportDataFailed (void);
20.18 + virtual void DoReportRtsOk (double ctsSnr, WifiMode ctsMode, double rtsSnr);
20.19 + virtual void DoReportDataOk (double ackSnr, WifiMode ackMode, double dataSnr);
20.20 + virtual void DoReportFinalRtsFailed (void);
20.21 + virtual void DoReportFinalDataFailed (void);
20.22
20.23 private:
20.24 virtual Ptr<WifiRemoteStationManager> GetManager (void) const;
21.1 --- a/src/devices/wifi/constant-rate-wifi-manager.cc Wed Mar 26 21:28:27 2008 -0700
21.2 +++ b/src/devices/wifi/constant-rate-wifi-manager.cc Mon Mar 31 13:54:41 2008 -0700
21.3 @@ -32,25 +32,25 @@
21.4 {}
21.5
21.6 void
21.7 -ConstantRateWifiRemoteStation::ReportRxOk (double rxSnr, WifiMode txMode)
21.8 +ConstantRateWifiRemoteStation::DoReportRxOk (double rxSnr, WifiMode txMode)
21.9 {}
21.10 void
21.11 -ConstantRateWifiRemoteStation::ReportRtsFailed (void)
21.12 +ConstantRateWifiRemoteStation::DoReportRtsFailed (void)
21.13 {}
21.14 void
21.15 -ConstantRateWifiRemoteStation::ReportDataFailed (void)
21.16 +ConstantRateWifiRemoteStation::DoReportDataFailed (void)
21.17 {}
21.18 void
21.19 -ConstantRateWifiRemoteStation::ReportRtsOk (double ctsSnr, WifiMode ctsMode, double rtsSnr)
21.20 +ConstantRateWifiRemoteStation::DoReportRtsOk (double ctsSnr, WifiMode ctsMode, double rtsSnr)
21.21 {}
21.22 void
21.23 -ConstantRateWifiRemoteStation::ReportDataOk (double ackSnr, WifiMode ackMode, double dataSnr)
21.24 +ConstantRateWifiRemoteStation::DoReportDataOk (double ackSnr, WifiMode ackMode, double dataSnr)
21.25 {}
21.26 void
21.27 -ConstantRateWifiRemoteStation::ReportFinalRtsFailed (void)
21.28 +ConstantRateWifiRemoteStation::DoReportFinalRtsFailed (void)
21.29 {}
21.30 void
21.31 -ConstantRateWifiRemoteStation::ReportFinalDataFailed (void)
21.32 +ConstantRateWifiRemoteStation::DoReportFinalDataFailed (void)
21.33 {}
21.34
21.35 WifiMode
22.1 --- a/src/devices/wifi/constant-rate-wifi-manager.h Wed Mar 26 21:28:27 2008 -0700
22.2 +++ b/src/devices/wifi/constant-rate-wifi-manager.h Mon Mar 31 13:54:41 2008 -0700
22.3 @@ -55,13 +55,14 @@
22.4 ConstantRateWifiRemoteStation (Ptr<ConstantRateWifiManager> stations);
22.5 virtual ~ConstantRateWifiRemoteStation ();
22.6
22.7 - virtual void ReportRxOk (double rxSnr, WifiMode txMode);
22.8 - virtual void ReportRtsFailed (void);
22.9 - virtual void ReportDataFailed (void);
22.10 - virtual void ReportRtsOk (double ctsSnr, WifiMode ctsMode, double rtsSnr);
22.11 - virtual void ReportDataOk (double ackSnr, WifiMode ackMode, double dataSnr);
22.12 - virtual void ReportFinalRtsFailed (void);
22.13 - virtual void ReportFinalDataFailed (void);
22.14 +protected:
22.15 + virtual void DoReportRxOk (double rxSnr, WifiMode txMode);
22.16 + virtual void DoReportRtsFailed (void);
22.17 + virtual void DoReportDataFailed (void);
22.18 + virtual void DoReportRtsOk (double ctsSnr, WifiMode ctsMode, double rtsSnr);
22.19 + virtual void DoReportDataOk (double ackSnr, WifiMode ackMode, double dataSnr);
22.20 + virtual void DoReportFinalRtsFailed (void);
22.21 + virtual void DoReportFinalDataFailed (void);
22.22
22.23 private:
22.24 virtual Ptr<WifiRemoteStationManager> GetManager (void) const;
23.1 --- a/src/devices/wifi/dca-txop.cc Wed Mar 26 21:28:27 2008 -0700
23.2 +++ b/src/devices/wifi/dca-txop.cc Mon Mar 31 13:54:41 2008 -0700
23.3 @@ -24,7 +24,6 @@
23.4 #include "ns3/simulator.h"
23.5 #include "ns3/node.h"
23.6 #include "ns3/uinteger.h"
23.7 -#include "ns3/trace-source-accessor.h"
23.8
23.9 #include "dca-txop.h"
23.10 #include "dcf-manager.h"
23.11 @@ -115,20 +114,13 @@
23.12 MakeUintegerAccessor (&DcaTxop::SetAifsn,
23.13 &DcaTxop::GetAifsn),
23.14 MakeUintegerChecker<uint32_t> ())
23.15 - .AddTraceSource ("Ssrc", "XXX",
23.16 - MakeTraceSourceAccessor (&DcaTxop::m_ssrc))
23.17 - .AddTraceSource ("Slrc", "XXX",
23.18 - MakeTraceSourceAccessor (&DcaTxop::m_slrc))
23.19 ;
23.20 return tid;
23.21 }
23.22
23.23 DcaTxop::DcaTxop ()
23.24 : m_manager (0),
23.25 - m_currentPacket (0),
23.26 - m_ssrc (0),
23.27 - m_slrc (0)
23.28 -
23.29 + m_currentPacket (0)
23.30 {
23.31 m_transmissionListener = new DcaTxop::TransmissionListener (this);
23.32 m_dcf = new DcaTxop::Dcf (this);
23.33 @@ -279,6 +271,19 @@
23.34 }
23.35
23.36 bool
23.37 +DcaTxop::NeedRtsRetransmission (void)
23.38 +{
23.39 + WifiRemoteStation *station = GetStation (m_currentHdr.GetAddr1 ());
23.40 + return station->NeedRtsRetransmission (m_currentPacket);
23.41 +}
23.42 +
23.43 +bool
23.44 +DcaTxop::NeedDataRetransmission (void)
23.45 +{
23.46 + WifiRemoteStation *station = GetStation (m_currentHdr.GetAddr1 ());
23.47 + return station->NeedDataRetransmission (m_currentPacket);
23.48 +}
23.49 +bool
23.50 DcaTxop::NeedFragmentation (void)
23.51 {
23.52 WifiRemoteStation *station = GetStation (m_currentHdr.GetAddr1 ());
23.53 @@ -337,19 +342,6 @@
23.54 return fragment;
23.55 }
23.56
23.57 -uint32_t
23.58 -DcaTxop::GetMaxSsrc (void) const
23.59 -{
23.60 - WifiRemoteStation *station = GetStation (m_currentHdr.GetAddr1 ());
23.61 - return station->GetMaxSsrc (m_currentPacket);
23.62 -}
23.63 -uint32_t
23.64 -DcaTxop::GetMaxSlrc (void) const
23.65 -{
23.66 - WifiRemoteStation *station = GetStation (m_currentHdr.GetAddr1 ());
23.67 - return station->GetMaxSlrc (m_currentPacket);
23.68 -}
23.69 -
23.70 bool
23.71 DcaTxop::NeedsAccess (void) const
23.72 {
23.73 @@ -372,8 +364,6 @@
23.74 m_currentHdr.SetFragmentNumber (0);
23.75 m_currentHdr.SetNoMoreFragments ();
23.76 m_currentHdr.SetNoRetry ();
23.77 - m_ssrc = 0;
23.78 - m_slrc = 0;
23.79 m_fragmentNumber = 0;
23.80 MY_DEBUG ("dequeued size="<<m_currentPacket->GetSize ()<<
23.81 ", to="<<m_currentHdr.GetAddr1 ()<<
23.82 @@ -453,15 +443,14 @@
23.83 DcaTxop::GotCts (double snr, WifiMode txMode)
23.84 {
23.85 MY_DEBUG ("got cts");
23.86 - m_ssrc = 0;
23.87 }
23.88 void
23.89 DcaTxop::MissedCts (void)
23.90 {
23.91 MY_DEBUG ("missed cts");
23.92 - m_ssrc++;
23.93 - if (m_ssrc > GetMaxSsrc ())
23.94 + if (!NeedRtsRetransmission ())
23.95 {
23.96 + MY_DEBUG ("Cts Fail");
23.97 WifiRemoteStation *station = GetStation (m_currentHdr.GetAddr1 ());
23.98 station->ReportFinalRtsFailed ();
23.99 // to reset the dcf.
23.100 @@ -478,7 +467,6 @@
23.101 void
23.102 DcaTxop::GotAck (double snr, WifiMode txMode)
23.103 {
23.104 - m_slrc = 0;
23.105 if (!NeedFragmentation () ||
23.106 IsLastFragment ())
23.107 {
23.108 @@ -505,9 +493,9 @@
23.109 DcaTxop::MissedAck (void)
23.110 {
23.111 MY_DEBUG ("missed ack");
23.112 - m_slrc++;
23.113 - if (m_slrc > GetMaxSlrc ())
23.114 + if (!NeedDataRetransmission ())
23.115 {
23.116 + MY_DEBUG ("Ack Fail");
23.117 WifiRemoteStation *station = GetStation (m_currentHdr.GetAddr1 ());
23.118 station->ReportFinalDataFailed ();
23.119 // to reset the dcf.
23.120 @@ -516,6 +504,7 @@
23.121 }
23.122 else
23.123 {
23.124 + MY_DEBUG ("Retransmit");
23.125 m_currentHdr.SetRetry ();
23.126 if (!m_txFailedCallback.IsNull ())
23.127 {
24.1 --- a/src/devices/wifi/dca-txop.h Wed Mar 26 21:28:27 2008 -0700
24.2 +++ b/src/devices/wifi/dca-txop.h Mon Mar 31 13:54:41 2008 -0700
24.3 @@ -26,7 +26,6 @@
24.4 #include "ns3/packet.h"
24.5 #include "ns3/nstime.h"
24.6 #include "ns3/object.h"
24.7 -#include "ns3/traced-value.h"
24.8 #include "wifi-mac-header.h"
24.9 #include "wifi-mode.h"
24.10 #include "wifi-remote-station-manager.h"
24.11 @@ -114,6 +113,7 @@
24.12 class Dcf;
24.13 friend class Dcf;
24.14 friend class TransmissionListener;
24.15 + friend class WifiRemoteStation;
24.16
24.17 // Inherited from ns3::Object
24.18 Ptr<MacLow> Low (void);
24.19 @@ -134,13 +134,13 @@
24.20 void RestartAccessIfNeeded (void);
24.21 void StartAccessIfNeeded (void);
24.22 bool NeedRts (void);
24.23 + bool NeedRtsRetransmission (void);
24.24 + bool NeedDataRetransmission (void);
24.25 bool NeedFragmentation (void);
24.26 uint32_t GetNFragments (void);
24.27 uint32_t GetNextFragmentSize (void);
24.28 uint32_t GetFragmentSize (void);
24.29 WifiRemoteStation *GetStation (Mac48Address to) const;
24.30 - uint32_t GetMaxSsrc (void) const;
24.31 - uint32_t GetMaxSlrc (void) const;
24.32 bool IsLastFragment (void);
24.33 void NextFragment (void);
24.34 Ptr<Packet> GetFragmentPacket (WifiMacHeader *hdr);
24.35 @@ -161,8 +161,6 @@
24.36 bool m_accessOngoing;
24.37 Ptr<const Packet> m_currentPacket;
24.38 WifiMacHeader m_currentHdr;
24.39 - TracedValue<uint32_t> m_ssrc;
24.40 - TracedValue<uint32_t> m_slrc;
24.41 uint8_t m_fragmentNumber;
24.42 };
24.43
25.1 --- a/src/devices/wifi/ideal-wifi-manager.cc Wed Mar 26 21:28:27 2008 -0700
25.2 +++ b/src/devices/wifi/ideal-wifi-manager.cc Mon Mar 31 13:54:41 2008 -0700
25.3 @@ -104,31 +104,31 @@
25.4 IdealWifiRemoteStation::~IdealWifiRemoteStation ()
25.5 {}
25.6 void
25.7 -IdealWifiRemoteStation::ReportRxOk (double rxSnr, WifiMode txMode)
25.8 +IdealWifiRemoteStation::DoReportRxOk (double rxSnr, WifiMode txMode)
25.9 {}
25.10 void
25.11 -IdealWifiRemoteStation::ReportRtsFailed (void)
25.12 +IdealWifiRemoteStation::DoReportRtsFailed (void)
25.13 {}
25.14 void
25.15 -IdealWifiRemoteStation::ReportDataFailed (void)
25.16 +IdealWifiRemoteStation::DoReportDataFailed (void)
25.17 {}
25.18 void
25.19 -IdealWifiRemoteStation::ReportRtsOk (double ctsSnr, WifiMode ctsMode, double rtsSnr)
25.20 +IdealWifiRemoteStation::DoReportRtsOk (double ctsSnr, WifiMode ctsMode, double rtsSnr)
25.21 {
25.22 TRACE ("got cts for rts snr="<<rtsSnr);
25.23 m_lastSnr = rtsSnr;
25.24 }
25.25 void
25.26 -IdealWifiRemoteStation::ReportDataOk (double ackSnr, WifiMode ackMode, double dataSnr)
25.27 +IdealWifiRemoteStation::DoReportDataOk (double ackSnr, WifiMode ackMode, double dataSnr)
25.28 {
25.29 TRACE ("got cts for rts snr="<<dataSnr);
25.30 m_lastSnr = dataSnr;
25.31 }
25.32 void
25.33 -IdealWifiRemoteStation::ReportFinalRtsFailed (void)
25.34 +IdealWifiRemoteStation::DoReportFinalRtsFailed (void)
25.35 {}
25.36 void
25.37 -IdealWifiRemoteStation::ReportFinalDataFailed (void)
25.38 +IdealWifiRemoteStation::DoReportFinalDataFailed (void)
25.39 {}
25.40
25.41 WifiMode
26.1 --- a/src/devices/wifi/ideal-wifi-manager.h Wed Mar 26 21:28:27 2008 -0700
26.2 +++ b/src/devices/wifi/ideal-wifi-manager.h Mon Mar 31 13:54:41 2008 -0700
26.3 @@ -73,13 +73,14 @@
26.4
26.5 virtual ~IdealWifiRemoteStation ();
26.6
26.7 - virtual void ReportRxOk (double rxSnr, WifiMode txMode);
26.8 - virtual void ReportRtsFailed (void);
26.9 - virtual void ReportDataFailed (void);
26.10 - virtual void ReportRtsOk (double ctsSnr, WifiMode ctsMode, double rtsSnr);
26.11 - virtual void ReportDataOk (double ackSnr, WifiMode ackMode, double dataSnr);
26.12 - virtual void ReportFinalRtsFailed (void);
26.13 - virtual void ReportFinalDataFailed (void);
26.14 +protected:
26.15 + virtual void DoReportRxOk (double rxSnr, WifiMode txMode);
26.16 + virtual void DoReportRtsFailed (void);
26.17 + virtual void DoReportDataFailed (void);
26.18 + virtual void DoReportRtsOk (double ctsSnr, WifiMode ctsMode, double rtsSnr);
26.19 + virtual void DoReportDataOk (double ackSnr, WifiMode ackMode, double dataSnr);
26.20 + virtual void DoReportFinalRtsFailed (void);
26.21 + virtual void DoReportFinalDataFailed (void);
26.22
26.23 private:
26.24 virtual Ptr<WifiRemoteStationManager> GetManager (void) const;
27.1 --- a/src/devices/wifi/onoe-wifi-manager.cc Wed Mar 26 21:28:27 2008 -0700
27.2 +++ b/src/devices/wifi/onoe-wifi-manager.cc Mon Mar 31 13:54:41 2008 -0700
27.3 @@ -75,35 +75,35 @@
27.4 {}
27.5
27.6 void
27.7 -OnoeWifiRemoteStation::ReportRxOk (double rxSnr, WifiMode txMode)
27.8 +OnoeWifiRemoteStation::DoReportRxOk (double rxSnr, WifiMode txMode)
27.9 {}
27.10 void
27.11 -OnoeWifiRemoteStation::ReportRtsFailed (void)
27.12 +OnoeWifiRemoteStation::DoReportRtsFailed (void)
27.13 {
27.14 m_shortRetry++;
27.15 }
27.16 void
27.17 -OnoeWifiRemoteStation::ReportDataFailed (void)
27.18 +OnoeWifiRemoteStation::DoReportDataFailed (void)
27.19 {
27.20 m_longRetry++;
27.21 }
27.22 void
27.23 -OnoeWifiRemoteStation::ReportRtsOk (double ctsSnr, WifiMode ctsMode, double rtsSnr)
27.24 +OnoeWifiRemoteStation::DoReportRtsOk (double ctsSnr, WifiMode ctsMode, double rtsSnr)
27.25 {}
27.26 void
27.27 -OnoeWifiRemoteStation::ReportDataOk (double ackSnr, WifiMode ackMode, double dataSnr)
27.28 +OnoeWifiRemoteStation::DoReportDataOk (double ackSnr, WifiMode ackMode, double dataSnr)
27.29 {
27.30 UpdateRetry ();
27.31 m_tx_ok++;
27.32 }
27.33 void
27.34 -OnoeWifiRemoteStation::ReportFinalRtsFailed (void)
27.35 +OnoeWifiRemoteStation::DoReportFinalRtsFailed (void)
27.36 {
27.37 UpdateRetry ();
27.38 m_tx_err++;
27.39 }
27.40 void
27.41 -OnoeWifiRemoteStation::ReportFinalDataFailed (void)
27.42 +OnoeWifiRemoteStation::DoReportFinalDataFailed (void)
27.43 {
27.44 UpdateRetry ();
27.45 m_tx_err++;
28.1 --- a/src/devices/wifi/onoe-wifi-manager.h Wed Mar 26 21:28:27 2008 -0700
28.2 +++ b/src/devices/wifi/onoe-wifi-manager.h Mon Mar 31 13:54:41 2008 -0700
28.3 @@ -57,13 +57,14 @@
28.4
28.5 virtual ~OnoeWifiRemoteStation ();
28.6
28.7 - virtual void ReportRxOk (double rxSnr, WifiMode txMode);
28.8 - virtual void ReportRtsFailed (void);
28.9 - virtual void ReportDataFailed (void);
28.10 - virtual void ReportRtsOk (double ctsSnr, WifiMode ctsMode, double rtsSnr);
28.11 - virtual void ReportDataOk (double ackSnr, WifiMode ackMode, double dataSnr);
28.12 - virtual void ReportFinalRtsFailed (void);
28.13 - virtual void ReportFinalDataFailed (void);
28.14 +protected:
28.15 + virtual void DoReportRxOk (double rxSnr, WifiMode txMode);
28.16 + virtual void DoReportRtsFailed (void);
28.17 + virtual void DoReportDataFailed (void);
28.18 + virtual void DoReportRtsOk (double ctsSnr, WifiMode ctsMode, double rtsSnr);
28.19 + virtual void DoReportDataOk (double ackSnr, WifiMode ackMode, double dataSnr);
28.20 + virtual void DoReportFinalRtsFailed (void);
28.21 + virtual void DoReportFinalDataFailed (void);
28.22
28.23 private:
28.24 virtual Ptr<WifiRemoteStationManager> GetManager (void) const;
29.1 --- a/src/devices/wifi/rraa-wifi-manager.cc Wed Mar 26 21:28:27 2008 -0700
29.2 +++ b/src/devices/wifi/rraa-wifi-manager.cc Mon Mar 31 13:54:41 2008 -0700
29.3 @@ -81,11 +81,11 @@
29.4
29.5
29.6 void
29.7 -RraaWifiRemoteStation::ReportRtsFailed (void)
29.8 +RraaWifiRemoteStation::DoReportRtsFailed (void)
29.9 {}
29.10
29.11 void
29.12 -RraaWifiRemoteStation::ReportDataFailed (void)
29.13 +RraaWifiRemoteStation::DoReportDataFailed (void)
29.14 {
29.15 m_lastFrameFail = true;
29.16 CheckTimeout ();
29.17 @@ -94,15 +94,15 @@
29.18 RunBasicAlgorithm ();
29.19 }
29.20 void
29.21 -RraaWifiRemoteStation::ReportRxOk (double rxSnr, WifiMode txMode)
29.22 +RraaWifiRemoteStation::DoReportRxOk (double rxSnr, WifiMode txMode)
29.23 {}
29.24 void
29.25 -RraaWifiRemoteStation::ReportRtsOk (double ctsSnr, WifiMode ctsMode, double rtsSnr)
29.26 +RraaWifiRemoteStation::DoReportRtsOk (double ctsSnr, WifiMode ctsMode, double rtsSnr)
29.27 {
29.28 NS_LOG_DEBUG ("self="<<this<<" rts ok");
29.29 }
29.30 void
29.31 -RraaWifiRemoteStation::ReportDataOk (double ackSnr, WifiMode ackMode, double dataSnr)
29.32 +RraaWifiRemoteStation::DoReportDataOk (double ackSnr, WifiMode ackMode, double dataSnr)
29.33 {
29.34 m_lastFrameFail = false;
29.35 CheckTimeout ();
29.36 @@ -110,10 +110,10 @@
29.37 RunBasicAlgorithm ();
29.38 }
29.39 void
29.40 -RraaWifiRemoteStation::ReportFinalRtsFailed (void)
29.41 +RraaWifiRemoteStation::DoReportFinalRtsFailed (void)
29.42 {}
29.43 void
29.44 -RraaWifiRemoteStation::ReportFinalDataFailed (void)
29.45 +RraaWifiRemoteStation::DoReportFinalDataFailed (void)
29.46 {}
29.47
29.48 WifiMode
30.1 --- a/src/devices/wifi/rraa-wifi-manager.h Wed Mar 26 21:28:27 2008 -0700
30.2 +++ b/src/devices/wifi/rraa-wifi-manager.h Mon Mar 31 13:54:41 2008 -0700
30.3 @@ -87,14 +87,15 @@
30.4 RraaWifiRemoteStation (Ptr<RraaWifiManager> stations);
30.5 virtual ~RraaWifiRemoteStation ();
30.6
30.7 - virtual void ReportRxOk (double rxSnr, WifiMode txMode);
30.8 - virtual void ReportRtsFailed (void);
30.9 - virtual void ReportDataFailed (void);
30.10 - virtual void ReportRtsOk (double ctsSnr, WifiMode ctsMode, double rtsSnr);
30.11 - virtual void ReportDataOk (double ackSnr, WifiMode ackMode, double dataSnr);
30.12 - virtual void ReportFinalRtsFailed (void);
30.13 - virtual void ReportFinalDataFailed (void);
30.14 virtual bool NeedRts (Ptr<const Packet> packet);
30.15 +protected:
30.16 + virtual void DoReportRxOk (double rxSnr, WifiMode txMode);
30.17 + virtual void DoReportRtsFailed (void);
30.18 + virtual void DoReportDataFailed (void);
30.19 + virtual void DoReportRtsOk (double ctsSnr, WifiMode ctsMode, double rtsSnr);
30.20 + virtual void DoReportDataOk (double ackSnr, WifiMode ackMode, double dataSnr);
30.21 + virtual void DoReportFinalRtsFailed (void);
30.22 + virtual void DoReportFinalDataFailed (void);
30.23
30.24 private:
30.25 virtual Ptr<WifiRemoteStationManager> GetManager (void) const;
31.1 --- a/src/devices/wifi/wifi-phy.cc Wed Mar 26 21:28:27 2008 -0700
31.2 +++ b/src/devices/wifi/wifi-phy.cc Mon Mar 31 13:54:41 2008 -0700
31.3 @@ -762,7 +762,7 @@
31.4 {
31.5 NS_ASSERT (m_txPowerBaseDbm <= m_txPowerEndDbm);
31.6 NS_ASSERT (m_nTxPower > 0);
31.7 - double dbm = m_txPowerBaseDbm + (m_txPowerEndDbm - m_txPowerBaseDbm) / m_nTxPower;
31.8 + double dbm = m_txPowerBaseDbm + power * (m_txPowerEndDbm - m_txPowerBaseDbm) / m_nTxPower;
31.9 return dbm;
31.10 }
31.11
32.1 --- a/src/devices/wifi/wifi-remote-station-manager.cc Wed Mar 26 21:28:27 2008 -0700
32.2 +++ b/src/devices/wifi/wifi-remote-station-manager.cc Mon Mar 31 13:54:41 2008 -0700
32.3 @@ -25,6 +25,7 @@
32.4 #include "ns3/boolean.h"
32.5 #include "ns3/uinteger.h"
32.6 #include "ns3/wifi-phy.h"
32.7 +#include "ns3/trace-source-accessor.h"
32.8
32.9 NS_LOG_COMPONENT_DEFINE ("WifiRemoteStationManager");
32.10
32.11 @@ -41,14 +42,14 @@
32.12 {
32.13 public:
32.14 NonUnicastWifiRemoteStation (Ptr<WifiRemoteStationManager> stations);
32.15 - virtual void ReportRxOk (double rxSnr, WifiMode txMode);
32.16 - virtual void ReportRtsFailed (void);
32.17 - virtual void ReportDataFailed (void);
32.18 - virtual void ReportRtsOk (double ctsSnr, WifiMode ctsMode, double rtsSnr);
32.19 - virtual void ReportDataOk (double ackSnr, WifiMode ackMode, double dataSnr);
32.20 - virtual void ReportFinalRtsFailed (void);
32.21 - virtual void ReportFinalDataFailed (void);
32.22 -
32.23 +protected:
32.24 + virtual void DoReportRxOk (double rxSnr, WifiMode txMode);
32.25 + virtual void DoReportRtsFailed (void);
32.26 + virtual void DoReportDataFailed (void);
32.27 + virtual void DoReportRtsOk (double ctsSnr, WifiMode ctsMode, double rtsSnr);
32.28 + virtual void DoReportDataOk (double ackSnr, WifiMode ackMode, double dataSnr);
32.29 + virtual void DoReportFinalRtsFailed (void);
32.30 + virtual void DoReportFinalDataFailed (void);
32.31 private:
32.32 virtual Ptr<WifiRemoteStationManager> GetManager (void) const;
32.33 virtual WifiMode DoGetDataMode (uint32_t size);
32.34 @@ -62,35 +63,35 @@
32.35 RecordDisassociated ();
32.36 }
32.37 void
32.38 -NonUnicastWifiRemoteStation::ReportRxOk (double rxSnr, WifiMode txMode)
32.39 +NonUnicastWifiRemoteStation::DoReportRxOk (double rxSnr, WifiMode txMode)
32.40 {
32.41 NS_ASSERT (false);
32.42 }
32.43 void
32.44 -NonUnicastWifiRemoteStation::ReportRtsFailed (void)
32.45 +NonUnicastWifiRemoteStation::DoReportRtsFailed (void)
32.46 {
32.47 NS_ASSERT (false);
32.48 }
32.49 void
32.50 -NonUnicastWifiRemoteStation::ReportDataFailed (void)
32.51 +NonUnicastWifiRemoteStation::DoReportDataFailed (void)
32.52 {
32.53 NS_ASSERT (false);
32.54 }
32.55 void
32.56 -NonUnicastWifiRemoteStation::ReportRtsOk (double ctsSnr, WifiMode ctsMode, double rtsSnr)
32.57 +NonUnicastWifiRemoteStation::DoReportRtsOk (double ctsSnr, WifiMode ctsMode, double rtsSnr)
32.58 {
32.59 NS_ASSERT (false);
32.60 }
32.61 void
32.62 -NonUnicastWifiRemoteStation::ReportDataOk (double ackSnr, WifiMode ackMode, double dataSnr)
32.63 +NonUnicastWifiRemoteStation::DoReportDataOk (double ackSnr, WifiMode ackMode, double dataSnr)
32.64 {
32.65 NS_ASSERT (false);
32.66 }
32.67 void
32.68 -NonUnicastWifiRemoteStation::ReportFinalRtsFailed (void)
32.69 +NonUnicastWifiRemoteStation::DoReportFinalRtsFailed (void)
32.70 {}
32.71 void
32.72 -NonUnicastWifiRemoteStation::ReportFinalDataFailed (void)
32.73 +NonUnicastWifiRemoteStation::DoReportFinalDataFailed (void)
32.74 {}
32.75
32.76 WifiMode
32.77 @@ -374,8 +375,23 @@
32.78
32.79 namespace ns3 {
32.80
32.81 +TypeId
32.82 +WifiRemoteStation::GetTypeId (void)
32.83 +{
32.84 + static TypeId tid = TypeId ("ns3::WifiRemoteStation")
32.85 + .SetParent<Object> ()
32.86 + .AddTraceSource ("Ssrc", "XXX",
32.87 + MakeTraceSourceAccessor (&WifiRemoteStation::m_ssrc))
32.88 + .AddTraceSource ("Slrc", "XXX",
32.89 + MakeTraceSourceAccessor (&WifiRemoteStation::m_slrc))
32.90 + ;
32.91 + return tid;
32.92 +}
32.93 +
32.94 WifiRemoteStation::WifiRemoteStation ()
32.95 - : m_state (BRAND_NEW)
32.96 + : m_state (BRAND_NEW),
32.97 + m_ssrc (0),
32.98 + m_slrc (0)
32.99 {}
32.100 WifiRemoteStation::~WifiRemoteStation ()
32.101 {}
32.102 @@ -560,16 +576,16 @@
32.103 return false;
32.104 }
32.105 }
32.106 -uint32_t
32.107 -WifiRemoteStation::GetMaxSsrc (Ptr<const Packet> packet)
32.108 +bool
32.109 +WifiRemoteStation::NeedRtsRetransmission (Ptr<const Packet> packet)
32.110 {
32.111 - return GetManager ()->GetMaxSsrc ();
32.112 + return (m_ssrc < GetManager ()->GetMaxSsrc ());
32.113 }
32.114
32.115 -uint32_t
32.116 -WifiRemoteStation::GetMaxSlrc (Ptr<const Packet> packet)
32.117 +bool
32.118 +WifiRemoteStation::NeedDataRetransmission (Ptr<const Packet> packet)
32.119 {
32.120 - return GetManager ()->GetMaxSlrc ();
32.121 + return (m_slrc < GetManager ()->GetMaxSlrc ());
32.122 }
32.123
32.124 bool
32.125 @@ -623,5 +639,52 @@
32.126 }
32.127 }
32.128
32.129 +void
32.130 +WifiRemoteStation::ReportRtsFailed (void)
32.131 +{
32.132 + m_ssrc++;
32.133 + DoReportRtsFailed ();
32.134 +}
32.135 +
32.136 +void
32.137 +WifiRemoteStation::ReportDataFailed (void)
32.138 +{
32.139 + m_slrc++;
32.140 + DoReportDataFailed ();
32.141 +}
32.142 +
32.143 +void
32.144 +WifiRemoteStation::ReportRtsOk (double ctsSnr, WifiMode ctsMode, double rtsSnr)
32.145 +{
32.146 + m_ssrc = 0;
32.147 + DoReportRtsOk (ctsSnr, ctsMode, rtsSnr);
32.148 +}
32.149 +
32.150 +void
32.151 +WifiRemoteStation::ReportDataOk (double ackSnr, WifiMode ackMode, double dataSnr)
32.152 +{
32.153 + m_slrc = 0;
32.154 + DoReportDataOk (ackSnr, ackMode, dataSnr);
32.155 +}
32.156 +
32.157 +void
32.158 +WifiRemoteStation::ReportFinalRtsFailed (void)
32.159 +{
32.160 + m_ssrc = 0;
32.161 + DoReportFinalRtsFailed ();
32.162 +}
32.163 +
32.164 +void
32.165 +WifiRemoteStation::ReportFinalDataFailed (void)
32.166 +{
32.167 + m_slrc = 0;
32.168 + DoReportFinalDataFailed ();
32.169 +}
32.170 +
32.171 +void
32.172 +WifiRemoteStation::ReportRxOk (double rxSnr, WifiMode txMode)
32.173 +{
32.174 + DoReportRxOk (rxSnr, txMode);
32.175 +}
32.176 } // namespace ns3
32.177
33.1 --- a/src/devices/wifi/wifi-remote-station-manager.h Wed Mar 26 21:28:27 2008 -0700
33.2 +++ b/src/devices/wifi/wifi-remote-station-manager.h Mon Mar 31 13:54:41 2008 -0700
33.3 @@ -25,6 +25,7 @@
33.4 #include "ns3/mac48-address.h"
33.5 #include "ns3/packet.h"
33.6 #include "ns3/object.h"
33.7 +#include "ns3/traced-value.h"
33.8 #include "wifi-mode.h"
33.9
33.10 namespace ns3 {
33.11 @@ -85,6 +86,7 @@
33.12 WifiRemoteStation *Lookup (Mac48Address address);
33.13 WifiRemoteStation *LookupNonUnicast (void);
33.14 protected:
33.15 + friend class WifiRemoteStation;
33.16 virtual void DoDispose (void);
33.17 private:
33.18 typedef std::vector <std::pair<Mac48Address, WifiRemoteStation *> > Stations;
33.19 @@ -106,6 +108,9 @@
33.20
33.21 class WifiRemoteStation {
33.22 public:
33.23 +
33.24 + static TypeId GetTypeId (void);
33.25 +
33.26 WifiRemoteStation ();
33.27 virtual ~WifiRemoteStation ();
33.28
33.29 @@ -130,20 +135,21 @@
33.30 void PrepareForQueue (Ptr<const Packet> packet, uint32_t fullPacketSize);
33.31 WifiMode GetDataMode (Ptr<const Packet> packet, uint32_t fullPacketSize);
33.32 WifiMode GetRtsMode (Ptr<const Packet> packet);
33.33 + // transmission-related methods
33.34 + void ReportRtsFailed (void);
33.35 + void ReportDataFailed (void);
33.36 + void ReportRtsOk (double ctsSnr, WifiMode ctsMode, double rtsSnr);
33.37 + void ReportDataOk (double ackSnr, WifiMode ackMode, double dataSnr);
33.38 + void ReportFinalRtsFailed (void);
33.39 + void ReportFinalDataFailed (void);
33.40
33.41 // reception-related method
33.42 - virtual void ReportRxOk (double rxSnr, WifiMode txMode) = 0;
33.43 + void ReportRxOk (double rxSnr, WifiMode txMode);
33.44
33.45 - // transmission-related methods
33.46 - virtual void ReportRtsFailed (void) = 0;
33.47 - virtual void ReportDataFailed (void) = 0;
33.48 - virtual void ReportRtsOk (double ctsSnr, WifiMode ctsMode, double rtsSnr) = 0;
33.49 - virtual void ReportDataOk (double ackSnr, WifiMode ackMode, double dataSnr) = 0;
33.50 - virtual void ReportFinalRtsFailed (void) = 0;
33.51 - virtual void ReportFinalDataFailed (void) = 0;
33.52 virtual bool NeedRts (Ptr<const Packet> packet);
33.53 - virtual uint32_t GetMaxSsrc (Ptr<const Packet> packet);
33.54 - virtual uint32_t GetMaxSlrc (Ptr<const Packet> packet);
33.55 + virtual bool NeedRtsRetransmission (Ptr<const Packet> packet);
33.56 + virtual bool NeedDataRetransmission (Ptr<const Packet> packet);
33.57 +
33.58 virtual bool NeedFragmentation (Ptr<const Packet> packet);
33.59 virtual uint32_t GetNFragments (Ptr<const Packet> packet);
33.60 virtual uint32_t GetFragmentSize (Ptr<const Packet> packet, uint32_t fragmentNumber);
33.61 @@ -158,6 +164,13 @@
33.62 virtual WifiMode DoGetDataMode (uint32_t size) = 0;
33.63 virtual WifiMode DoGetRtsMode (void) = 0;
33.64 protected:
33.65 + virtual void DoReportRtsFailed (void) = 0;
33.66 + virtual void DoReportDataFailed (void) = 0;
33.67 + virtual void DoReportRtsOk (double ctsSnr, WifiMode ctsMode, double rtsSnr) = 0;
33.68 + virtual void DoReportDataOk (double ackSnr, WifiMode ackMode, double dataSnr) = 0;
33.69 + virtual void DoReportFinalRtsFailed (void) = 0;
33.70 + virtual void DoReportFinalDataFailed (void) = 0;
33.71 + virtual void DoReportRxOk (double rxSnr, WifiMode txMode) = 0;
33.72 uint32_t GetNSupportedModes (void) const;
33.73 WifiMode GetSupportedMode (uint32_t i) const;
33.74 private:
33.75 @@ -170,6 +183,8 @@
33.76 GOT_ASSOC_TX_OK
33.77 } m_state;
33.78 SupportedModes m_modes;
33.79 + TracedValue<uint32_t> m_ssrc;
33.80 + TracedValue<uint32_t> m_slrc;
33.81 };
33.82
33.83 } // namespace ns3
34.1 --- a/src/helper/csma-helper.cc Wed Mar 26 21:28:27 2008 -0700
34.2 +++ b/src/helper/csma-helper.cc Mon Mar 31 13:54:41 2008 -0700
34.3 @@ -3,11 +3,16 @@
34.4 #include "ns3/queue.h"
34.5 #include "ns3/csma-net-device.h"
34.6 #include "ns3/csma-channel.h"
34.7 +#include "ns3/pcap-writer.h"
34.8 +#include "ns3/config.h"
34.9 +#include "ns3/packet.h"
34.10 #include <string>
34.11
34.12 namespace ns3 {
34.13
34.14 CsmaHelper::CsmaHelper ()
34.15 + : m_pcap (false),
34.16 + m_ascii (false)
34.17 {
34.18 m_queueFactory.SetTypeId ("ns3::DropTailQueue");
34.19 m_deviceFactory.SetTypeId ("ns3::CsmaNetDevice");
34.20 @@ -40,6 +45,31 @@
34.21 m_channelFactory.Set (n1, v1);
34.22 }
34.23
34.24 +void
34.25 +CsmaHelper::EnablePcap (std::string filename)
34.26 +{
34.27 + m_pcap = true;
34.28 + m_pcapFilename = filename;
34.29 +}
34.30 +void
34.31 +CsmaHelper::DisablePcap (void)
34.32 +{
34.33 + m_pcap = false;
34.34 +}
34.35 +
34.36 +void
34.37 +CsmaHelper::EnableAscii (std::ostream &os)
34.38 +{
34.39 + m_ascii = true;
34.40 + m_asciiOs = &os;
34.41 +}
34.42 +void
34.43 +CsmaHelper::DisableAscii (void)
34.44 +{
34.45 + m_ascii = false;
34.46 +}
34.47 +
34.48 +
34.49 NetDeviceContainer
34.50 CsmaHelper::Build (const NodeContainer &c)
34.51 {
34.52 @@ -60,10 +90,51 @@
34.53 Ptr<Queue> queue = m_queueFactory.Create<Queue> ();
34.54 device->AddQueue (queue);
34.55 device->Attach (channel);
34.56 + if (m_pcap)
34.57 + {
34.58 + std::ostringstream oss;
34.59 + oss << m_pcapFilename << "-" << node->GetId () << "-" << device->GetIfIndex ();
34.60 + std::string filename = oss.str ();
34.61 + Ptr<PcapWriter> pcap = Create<PcapWriter> ();
34.62 + pcap->Open (filename);
34.63 + pcap->WriteEthernetHeader ();
34.64 + device->TraceConnectWithoutContext ("Rx", MakeBoundCallback (&CsmaHelper::RxEvent, pcap));
34.65 + queue->TraceConnectWithoutContext ("Enqueue", MakeBoundCallback (&CsmaHelper::EnqueueEvent, pcap));
34.66 + }
34.67 + if (m_ascii)
34.68 + {
34.69 + Packet::EnableMetadata ();
34.70 + std::ostringstream oss;
34.71 + oss << "/NodeList/" << node->GetId () << "/DeviceList/" << device->GetIfIndex () << "/Rx";
34.72 + Config::Connect (oss.str (), MakeBoundCallback (&CsmaHelper::AsciiEvent, m_asciiOs));
34.73 + oss.str ("");
34.74 + oss << "/NodeList/" << node->GetId () << "/DeviceList/" << device->GetIfIndex () << "/TxQueue/Enqueue";
34.75 + Config::Connect (oss.str (), MakeBoundCallback (&CsmaHelper::AsciiEvent, m_asciiOs));
34.76 + oss.str ("");
34.77 + oss << "/NodeList/" << node->GetId () << "/DeviceList/" << device->GetIfIndex () << "/TxQueue/Dequeue";
34.78 + Config::Connect (oss.str (), MakeBoundCallback (&CsmaHelper::AsciiEvent, m_asciiOs));
34.79 +
34.80 + }
34.81 container.Add (device);
34.82 }
34.83 return container;
34.84 }
34.85
34.86 +void
34.87 +CsmaHelper::EnqueueEvent (Ptr<PcapWriter> writer, Ptr<const Packet> packet)
34.88 +{
34.89 + writer->WritePacket (packet);
34.90 +}
34.91 +void
34.92 +CsmaHelper::RxEvent (Ptr<PcapWriter> writer, Ptr<const Packet> packet)
34.93 +{
34.94 + writer->WritePacket (packet);
34.95 +}
34.96 +void
34.97 +CsmaHelper::AsciiEvent (std::ostream *os, std::string path, Ptr<const Packet> packet)
34.98 +{
34.99 + *os << path << " " << *packet << std::endl;
34.100 +}
34.101 +
34.102
34.103 } // namespace ns3
35.1 --- a/src/helper/csma-helper.h Wed Mar 26 21:28:27 2008 -0700
35.2 +++ b/src/helper/csma-helper.h Mon Mar 31 13:54:41 2008 -0700
35.3 @@ -2,6 +2,7 @@
35.4 #define CSMA_HELPER_H
35.5
35.6 #include <string>
35.7 +#include <ostream>
35.8 #include "ns3/attribute.h"
35.9 #include "ns3/object-factory.h"
35.10 #include "ns3/net-device-container.h"
35.11 @@ -10,6 +11,9 @@
35.12
35.13 namespace ns3 {
35.14
35.15 +class Packet;
35.16 +class PcapWriter;
35.17 +
35.18 /**
35.19 * \brief build a set of CsmaNetDevice objects
35.20 */
35.21 @@ -57,6 +61,24 @@
35.22 void SetChannelParameter (std::string n1, Attribute v1);
35.23
35.24 /**
35.25 + * \param filename file template to dump pcap traces in.
35.26 + *
35.27 + * Every ns3::CsmaNetDevice created through subsequent calls
35.28 + * to CsmaHelper::Build will be configured to dump
35.29 + * pcap output in a file named filename-nodeid-deviceid.
35.30 + */
35.31 + void EnablePcap (std::string filename);
35.32 + /**
35.33 + * Every ns3::CsmaNetDevice created through subsequent calls
35.34 + * to CsmaHelper::Build will be configured to not dump any pcap
35.35 + * output.
35.36 + */
35.37 + void DisablePcap (void);
35.38 +
35.39 + void EnableAscii (std::ostream &os);
35.40 + void DisableAscii (void);
35.41 +
35.42 + /**
35.43 * \param c a set of nodes
35.44 *
35.45 * This method creates a simple ns3::CsmaChannel with the
35.46 @@ -76,9 +98,16 @@
35.47 NetDeviceContainer Build (const NodeContainer &c, Ptr<CsmaChannel> channel);
35.48
35.49 private:
35.50 + static void RxEvent (Ptr<PcapWriter> writer, Ptr<const Packet> packet);
35.51 + static void EnqueueEvent (Ptr<PcapWriter> writer, Ptr<const Packet> packet);
35.52 + static void AsciiEvent (std::ostream *os, std::string path, Ptr<const Packet> packet);
35.53 ObjectFactory m_queueFactory;
35.54 ObjectFactory m_deviceFactory;
35.55 ObjectFactory m_channelFactory;
35.56 + bool m_pcap;
35.57 + std::string m_pcapFilename;
35.58 + bool m_ascii;
35.59 + std::ostream *m_asciiOs;
35.60 };
35.61
35.62
36.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
36.2 +++ b/src/helper/udp-echo-helper.cc Mon Mar 31 13:54:41 2008 -0700
36.3 @@ -0,0 +1,64 @@
36.4 +#include "udp-echo-helper.h"
36.5 +#include "ns3/udp-echo-server.h"
36.6 +#include "ns3/udp-echo-client.h"
36.7 +#include "ns3/uinteger.h"
36.8 +
36.9 +namespace ns3 {
36.10 +
36.11 +UdpEchoServerHelper::UdpEchoServerHelper ()
36.12 + : m_port (9)
36.13 +{}
36.14 +
36.15 +void
36.16 +UdpEchoServerHelper::SetPort (uint16_t port)
36.17 +{
36.18 + m_port = port;
36.19 +}
36.20 +ApplicationContainer
36.21 +UdpEchoServerHelper::Build (NodeContainer c)
36.22 +{
36.23 + ApplicationContainer apps;
36.24 + for (NodeContainer::Iterator i = c.Begin (); i != c.End (); ++i)
36.25 + {
36.26 + Ptr<Node> node = *i;
36.27 + Ptr<UdpEchoServer> server = CreateObject<UdpEchoServer> ("Port", Uinteger (m_port));
36.28 + node->AddApplication (server);
36.29 + apps.Add (server);
36.30 + }
36.31 + return apps;
36.32 +}
36.33 +
36.34 +UdpEchoClientHelper::UdpEchoClientHelper ()
36.35 +{
36.36 + m_factory.SetTypeId (UdpEchoClient::GetTypeId ());
36.37 +}
36.38 +void
36.39 +UdpEchoClientHelper::SetRemote (Ipv4Address ip, uint16_t port)
36.40 +{
36.41 + m_remoteIp = ip;
36.42 + m_remotePort = port;
36.43 +}
36.44 +void
36.45 +UdpEchoClientHelper::SetAppAttribute (std::string name, Attribute value)
36.46 +{
36.47 + m_factory.Set (name, value);
36.48 +}
36.49 +
36.50 +ApplicationContainer
36.51 +UdpEchoClientHelper::Build (NodeContainer c)
36.52 +{
36.53 + ApplicationContainer apps;
36.54 + for (NodeContainer::Iterator i = c.Begin (); i != c.End (); ++i)
36.55 + {
36.56 + Ptr<Node> node = *i;
36.57 + Ptr<UdpEchoClient> client = m_factory.Create<UdpEchoClient> ();
36.58 + client->SetRemote (m_remoteIp, m_remotePort);
36.59 + node->AddApplication (client);
36.60 + apps.Add (client);
36.61 + }
36.62 + return apps;
36.63 +}
36.64 +
36.65 +
36.66 +
36.67 +} // namespace ns3
37.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
37.2 +++ b/src/helper/udp-echo-helper.h Mon Mar 31 13:54:41 2008 -0700
37.3 @@ -0,0 +1,39 @@
37.4 +#ifndef UDP_ECHO_HELPER_H
37.5 +#define UDP_ECHO_HELPER_H
37.6 +
37.7 +#include <stdint.h>
37.8 +#include "application-container.h"
37.9 +#include "node-container.h"
37.10 +#include "ns3/object-factory.h"
37.11 +#include "ns3/ipv4-address.h"
37.12 +
37.13 +namespace ns3 {
37.14 +
37.15 +class UdpEchoServerHelper
37.16 +{
37.17 +public:
37.18 + UdpEchoServerHelper ();
37.19 + void SetPort (uint16_t port);
37.20 + ApplicationContainer Build (NodeContainer c);
37.21 +private:
37.22 + uint16_t m_port;
37.23 +};
37.24 +
37.25 +class UdpEchoClientHelper
37.26 +{
37.27 +public:
37.28 + UdpEchoClientHelper ();
37.29 +
37.30 + void SetRemote (Ipv4Address ip, uint16_t port);
37.31 + void SetAppAttribute (std::string name, Attribute value);
37.32 + ApplicationContainer Build (NodeContainer c);
37.33 + private:
37.34 + ObjectFactory m_factory;
37.35 + Ipv4Address m_remoteIp;
37.36 + uint16_t m_remotePort;
37.37 +};
37.38 +
37.39 +
37.40 +} // namespace ns3
37.41 +
37.42 +#endif /* UDP_ECHO_HELPER_H */
38.1 --- a/src/helper/wscript Wed Mar 26 21:28:27 2008 -0700
38.2 +++ b/src/helper/wscript Mon Mar 31 13:54:41 2008 -0700
38.3 @@ -18,6 +18,7 @@
38.4 'packet-sink-helper.cc',
38.5 'packet-socket-helper.cc',
38.6 'ipv4-interface-container.cc',
38.7 + 'udp-echo-helper.cc',
38.8 ]
38.9
38.10 headers = bld.create_obj('ns3header')
38.11 @@ -38,4 +39,5 @@
38.12 'packet-sink-helper.h',
38.13 'packet-socket-helper.h',
38.14 'ipv4-interface-container.h',
38.15 + 'udp-echo-helper.h',
38.16 ]
39.1 --- a/src/internet-node/tcp-header.cc Wed Mar 26 21:28:27 2008 -0700
39.2 +++ b/src/internet-node/tcp-header.cc Mon Mar 31 13:54:41 2008 -0700
39.3 @@ -150,11 +150,41 @@
39.4 }
39.5 void TcpHeader::Print (std::ostream &os) const
39.6 {
39.7 - //XXX
39.8 + os << m_sourcePort << " > " << m_destinationPort;
39.9 + if(m_flags!=0)
39.10 + {
39.11 + os<<" [";
39.12 + if((m_flags & FIN) != 0)
39.13 + {
39.14 + os<<" FIN ";
39.15 + }
39.16 + if((m_flags & SYN) != 0)
39.17 + {
39.18 + os<<" SYN ";
39.19 + }
39.20 + if((m_flags & RST) != 0)
39.21 + {
39.22 + os<<" RST ";
39.23 + }
39.24 + if((m_flags & PSH) != 0)
39.25 + {
39.26 + os<<" PSH ";
39.27 + }
39.28 + if((m_flags & ACK) != 0)
39.29 + {
39.30 + os<<" ACK ";
39.31 + }
39.32 + if((m_flags & URG) != 0)
39.33 + {
39.34 + os<<" URG ";
39.35 + }
39.36 + os<<"]";
39.37 + }
39.38 + os<<" Seq="<<m_sequenceNumber<<" Ack="<<m_ackNumber<<" Win="<<m_windowSize;
39.39 }
39.40 uint32_t TcpHeader::GetSerializedSize (void) const
39.41 {
39.42 - return 20; //tcp headers are 20 bytes
39.43 + return 4*m_length;
39.44 }
39.45 void TcpHeader::Serialize (Buffer::Iterator start) const
39.46 {
40.1 --- a/src/node/packet-socket.cc Wed Mar 26 21:28:27 2008 -0700
40.2 +++ b/src/node/packet-socket.cc Mon Mar 31 13:54:41 2008 -0700
40.3 @@ -116,7 +116,7 @@
40.4 }
40.5 else
40.6 {
40.7 - m_node->GetDevice (address.GetSingleDevice ());
40.8 + dev = m_node->GetDevice (address.GetSingleDevice ());
40.9 }
40.10 m_node->RegisterProtocolHandler (MakeCallback (&PacketSocket::ForwardUp, this),
40.11 address.GetProtocol (), dev);