--- a/tutorial/bus-network.cc Tue Oct 09 21:54:03 2007 -0700
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,65 +0,0 @@
-/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
-/*
- * Copyright (c) 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
- */
-
-#include "ns3/mac48-address.h"
-#include "ns3/csma-net-device.h"
-#include "ns3/csma-topology.h"
-#include "ns3/csma-ipv4-topology.h"
-
-#include "bus-network.h"
-#include "ipv4-address-generator.h"
-
-namespace ns3 {
-
-BusNetwork::BusNetwork (
- Ipv4Mask mask,
- Ipv4Address network,
- Ipv4Address startAddress,
- DataRate bps,
- Time delay,
- uint32_t n)
-{
- Ipv4AddressGenerator::SeedNetwork (mask, network);
- Ipv4AddressGenerator::SeedAddress (mask, startAddress);
-
- m_channel = CsmaTopology::CreateCsmaChannel (bps, delay);
-
- for (uint32_t i = 0; i < n; ++i)
- {
- Ptr<Node> node = Create<InternetNode> ();
- uint32_t nd = CsmaIpv4Topology::AddIpv4CsmaNetDevice (node, m_channel,
- Mac48Address::Allocate ());
- Ipv4Address address = Ipv4AddressGenerator::AllocateAddress (mask,
- network);
- CsmaIpv4Topology::AddIpv4Address (node, nd, address, mask);
- m_nodes.push_back (node);
- }
-}
-
-BusNetwork::~BusNetwork ()
-{
- m_nodes.erase (m_nodes.begin (), m_nodes.end ());
-}
-
- Ptr<Node>
-BusNetwork::GetNode (uint32_t n)
-{
- return m_nodes[n];
-}
-
-}; // namespace ns3
--- a/tutorial/bus-network.h Tue Oct 09 21:54:03 2007 -0700
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,53 +0,0 @@
-/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
-/*
- * Copyright (c) 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
- */
-
-#ifndef BUS_NETWORK_H
-#define BUS_NETWORK_H
-
-#include <list>
-#include "ns3/ptr.h"
-#include "ns3/node.h"
-#include "ns3/ipv4-address.h"
-#include "ns3/data-rate.h"
-#include "ns3/csma-channel.h"
-
-namespace ns3 {
-
-class BusNetwork
-{
-public:
- BusNetwork (
- Ipv4Mask mask,
- Ipv4Address network,
- Ipv4Address startAddress,
- DataRate bps,
- Time delay,
- uint32_t n);
-
- virtual ~BusNetwork ();
-
- Ptr<Node> GetNode (uint32_t n);
-
-private:
- std::vector<Ptr<Node> > m_nodes;
- Ptr<CsmaChannel> m_channel;
-};
-
-}; // namespace ns3
-
-#endif /* BUS_NETWORK_H */
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/tutorial/ipv4-bus-network.cc Wed Oct 10 11:55:07 2007 -0700
@@ -0,0 +1,79 @@
+/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
+/*
+ * Copyright (c) 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
+ */
+
+#include "ns3/mac48-address.h"
+#include "ns3/csma-net-device.h"
+#include "ns3/csma-topology.h"
+#include "ns3/csma-ipv4-topology.h"
+
+#include "ipv4-bus-network.h"
+#include "ipv4-address-generator.h"
+
+namespace ns3 {
+
+Ipv4Network::Ipv4Network (
+ Ipv4Address network,
+ Ipv4Mask mask,
+ Ipv4Address address)
+:
+ m_network (network), m_mask (mask), m_baseAddress (address)
+{
+}
+
+Ipv4Network::~Ipv4Network ()
+{
+}
+
+Ipv4BusNetwork::Ipv4BusNetwork (
+ Ipv4Address network,
+ Ipv4Mask mask,
+ Ipv4Address baseAddress,
+ DataRate bps,
+ Time delay,
+ uint32_t n)
+:
+ Ipv4Network (network, mask, baseAddress)
+{
+ Ipv4AddressGenerator::SeedNetwork (mask, network);
+ Ipv4AddressGenerator::SeedAddress (mask, baseAddress);
+
+ m_channel = CsmaTopology::CreateCsmaChannel (bps, delay);
+
+ for (uint32_t i = 0; i < n; ++i)
+ {
+ Ptr<Node> node = Create<InternetNode> ();
+ uint32_t nd = CsmaIpv4Topology::AddIpv4CsmaNetDevice (node, m_channel,
+ Mac48Address::Allocate ());
+ Ipv4Address address = Ipv4AddressGenerator::AllocateAddress (mask,
+ network);
+ CsmaIpv4Topology::AddIpv4Address (node, nd, address, mask);
+ m_nodes.push_back (node);
+ }
+}
+
+Ipv4BusNetwork::~Ipv4BusNetwork ()
+{
+}
+
+ Ptr<Node>
+Ipv4BusNetwork::GetNode (uint32_t n)
+{
+ return m_nodes[n];
+}
+
+}; // namespace ns3
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/tutorial/ipv4-bus-network.h Wed Oct 10 11:55:07 2007 -0700
@@ -0,0 +1,64 @@
+/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
+/*
+ * Copyright (c) 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
+ */
+
+#ifndef IPV4_BUS_NETWORK_H
+#define IPV4_BUS_NETWORK_H
+
+#include <list>
+#include "ns3/ptr.h"
+#include "ns3/node.h"
+#include "ns3/ipv4-address.h"
+#include "ns3/data-rate.h"
+#include "ns3/csma-channel.h"
+
+namespace ns3 {
+
+class Ipv4Network
+{
+public:
+ Ipv4Network (Ipv4Address network, Ipv4Mask mask, Ipv4Address address);
+ virtual ~Ipv4Network ();
+
+ Ipv4Address m_network;
+ Ipv4Mask m_mask;
+ Ipv4Address m_baseAddress;
+};
+
+class Ipv4BusNetwork : public Ipv4Network
+{
+public:
+ Ipv4BusNetwork (
+ Ipv4Address network,
+ Ipv4Mask mask,
+ Ipv4Address baseAddress,
+ DataRate bps,
+ Time delay,
+ uint32_t n);
+
+ virtual ~Ipv4BusNetwork ();
+
+ Ptr<Node> GetNode (uint32_t n);
+
+private:
+ std::vector<Ptr<Node> > m_nodes;
+ Ptr<CsmaChannel> m_channel;
+};
+
+}; // namespace ns3
+
+#endif /* IPV4_BUS_NETWORK_H */
--- a/tutorial/tutorial-bus-network.cc Tue Oct 09 21:54:03 2007 -0700
+++ b/tutorial/tutorial-bus-network.cc Wed Oct 10 11:55:07 2007 -0700
@@ -22,7 +22,7 @@
#include "ns3/nstime.h"
#include "ns3/ascii-trace.h"
-#include "bus-network.h"
+#include "ipv4-bus-network.h"
NS_LOG_COMPONENT_DEFINE ("BusNetworkSimulation");
@@ -32,20 +32,19 @@
main (int argc, char *argv[])
{
LogComponentEnable ("BusNetworkSimulation", LOG_LEVEL_ALL);
- LogComponentEnable ("BusNetwork", LOG_LEVEL_ALL);
NS_LOG_INFO ("Bus Network Simulation");
- BusNetwork busNetwork (Ipv4Mask ("255.255.0.0"), Ipv4Address ("10.1.0.0"),
- Ipv4Address ("0.0.0.0"), DataRate(10000000), MilliSeconds(20), 10);
+ Ipv4BusNetwork bus ("10.1.0.0", "255.255.0.0", "0.0.0.0",
+ DataRate(10000000), MilliSeconds(20), 10);
uint32_t port = 7;
- Ptr<Node> n0 = busNetwork.GetNode (0);
+ Ptr<Node> n0 = bus.GetNode (0);
Ptr<UdpEchoClient> client = Create<UdpEchoClient> (n0, "10.1.0.1", port,
1, Seconds(1.), 1024);
- Ptr<Node> n1 = busNetwork.GetNode (1);
+ Ptr<Node> n1 = bus.GetNode (1);
Ptr<UdpEchoServer> server = Create<UdpEchoServer> (n1, port);
server->Start(Seconds(1.));
--- a/tutorial/wscript Tue Oct 09 21:54:03 2007 -0700
+++ b/tutorial/wscript Wed Oct 10 11:55:07 2007 -0700
@@ -40,5 +40,5 @@
obj = bld.create_ns3_program('tutorial-bus-network',
['core'])
obj.source = ['tutorial-bus-network.cc',
- 'bus-network.cc',
+ 'ipv4-bus-network.cc',
'ipv4-address-generator.cc']