--- a/examples/simple-global-routing.cc Tue Sep 11 15:09:00 2007 +0100
+++ b/examples/simple-global-routing.cc Tue Sep 11 22:40:04 2007 -0700
@@ -157,8 +157,7 @@
Ptr<PacketSink> sink = Create<PacketSink> (
n3,
InetSocketAddress (Ipv4Address::GetAny (), 80),
- "Udp",
- true);
+ "Udp");
// Start the sink
sink->Start (Seconds (1.0));
sink->Stop (Seconds (10.0));
@@ -178,8 +177,7 @@
sink = Create<PacketSink> (
n1,
InetSocketAddress (Ipv4Address::GetAny (), 80),
- "Udp",
- true);
+ "Udp");
// Start the sink
sink->Start (Seconds (1.1));
sink->Stop (Seconds (10.0));
--- a/examples/simple-point-to-point.cc Tue Sep 11 15:09:00 2007 +0100
+++ b/examples/simple-point-to-point.cc Tue Sep 11 22:40:04 2007 -0700
@@ -182,7 +182,6 @@
// Start the sink
sink->Start (Seconds (1.1));
sink->Stop (Seconds (10.0));
- sink->SetQuiet (); // disable output from the Receive callback
// Here, finish off packet routing configuration
// This will likely set by some global StaticRouting object in the future
--- a/src/applications/packet-sink.cc Tue Sep 11 15:09:00 2007 +0100
+++ b/src/applications/packet-sink.cc Tue Sep 11 22:40:04 2007 -0700
@@ -1,20 +1,22 @@
-/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
-//
-// Copyright (c) 2006 Georgia Tech Research Corporation
-//
-// This program is free software; you can redistribute it and/or modify
-// it under the terms of the GNU General Public License version 2 as
-// published by the Free Software Foundation;
-//
-// This program is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with this program; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-//
+/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
+/*
+ * Copyright 2007 University of Washington
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation;
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ * Author: Tom Henderson (tomhend@u.washington.edu)
+ */
#include "ns3/address.h"
#include "ns3/debug.h"
#include "ns3/inet-socket-address.h"
@@ -35,35 +37,26 @@
PacketSink::PacketSink (Ptr<Node> n,
const Address &local,
- std::string iid,
- bool quiet)
+ std::string iid)
: Application(n)
{
- Construct (n, local, iid, quiet);
+ Construct (n, local, iid);
}
void
PacketSink::Construct (Ptr<Node> n,
const Address &local,
- std::string iid,
- bool quiet)
+ std::string iid)
{
m_socket = 0;
m_local = local;
m_iid = iid;
- m_quiet = quiet;
}
PacketSink::~PacketSink()
{}
void
-PacketSink::SetQuiet()
-{
- m_quiet = true;
-}
-
-void
PacketSink::DoDispose (void)
{
m_socket = 0;
@@ -99,19 +92,17 @@
}
}
-// This callback body suggested by Joe Kopena's wiki
+// This LOG output inspired by the application on Joseph Kopena's wiki
void PacketSink::Receive(Ptr<Socket> socket, const Packet &packet,
const Address &from)
{
- if (!m_quiet)
+ if (InetSocketAddress::IsMatchingType (from))
{
- if (InetSocketAddress::IsMatchingType (from))
- {
- InetSocketAddress address = InetSocketAddress::ConvertFrom (from);
- NS_DEBUG ( __PRETTY_FUNCTION__ << ": Received " <<
- packet.GetSize() << " bytes from " << address.GetIpv4() << " ["
- << address << "]---'" << packet.PeekData() << "'");
- }
+ InetSocketAddress address = InetSocketAddress::ConvertFrom (from);
+ NS_DEBUG ( __PRETTY_FUNCTION__ << ": Received " <<
+ packet.GetSize() << " bytes from " << address.GetIpv4() << " ["
+ << address << "]---'" << packet.PeekData() << "'");
+ // TODO: Add a tracing source here
}
}
--- a/src/applications/packet-sink.h Tue Sep 11 15:09:00 2007 +0100
+++ b/src/applications/packet-sink.h Tue Sep 11 22:40:04 2007 -0700
@@ -1,21 +1,22 @@
-/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
-//
-// Copyright (c) 2006 Georgia Tech Research Corporation
-//
-// This program is free software; you can redistribute it and/or modify
-// it under the terms of the GNU General Public License version 2 as
-// published by the Free Software Foundation;
-//
-// This program is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with this program; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-//
-//
+/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
+/*
+ * Copyright 2007 University of Washington
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation;
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ * Author: Tom Henderson (tomhend@u.washington.edu)
+ */
#ifndef __packet_sink_h__
#define __packet_sink_h__
@@ -33,34 +34,34 @@
/**
* \brief Receive and consume traffic generated to an IP address and port
*
- * This Application can be used as a receiver for packets generated by
- * traffic sourcing applications such as OnOffApplication. The constructor
- * specifies the Address (IP address and port) and the transport protocol
- * to use. A virtual Receive () method is installed as a callback on
- * the receiving socket. By default, it prints out the size of packets
- * and their address.
+ * This application was written to complement OnOffApplication, but it
+ * is more general so a PacketSink name was selected. Functionally it is
+ * important to use in multicast situations, so that reception of the layer-2
+ * multicast frames of interest are enabled, but it is also useful for
+ * unicast as an example of how you can write something simple to receive
+ * packets at the application layer. Also, if an IP stack generates
+ * ICMP Port Unreachable errors, receiving applications will be needed.
+ *
+ * The constructor specifies the Address (IP address and port) and the
+ * transport protocol to use. A virtual Receive () method is installed
+ * as a callback on the receiving socket. By default, when logging is
+ * enabled, it prints out the size of packets and their address, but
+ * we intend to also add a tracing source to Receive() at a later date.
*/
class PacketSink : public Application
{
public:
/**
* \param n node associated to this application
- * \param local local ip address
- * \param iid
- * \param ontime on time random variable
- * \param offtime off time random variable
+ * \param local local address to bind to
+ * \param iid string to identify transport protocol of interest
*/
PacketSink (Ptr<Node> n,
const Address &local,
- std::string iid, bool quiet=false);
+ std::string iid);
virtual ~PacketSink ();
- /**
- * \brief Turn off the logging output for the receive callback
- */
- void SetQuiet (void);
-
protected:
virtual void DoDispose (void);
private:
@@ -70,15 +71,13 @@
void Construct (Ptr<Node> n,
const Address &local,
- std::string iid,
- bool quiet);
+ std::string iid);
virtual void Receive (Ptr<Socket> socket, const Packet& packet, const Address& from);
Ptr<Socket> m_socket; // Associated socket
Address m_local; // Local address to bind to
std::string m_iid; // Protocol name (e.g., "Udp")
- bool m_quiet; // Governs whether receive callback is quiet
};