/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ /* * 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 #include #include #include #include #include "ns3/core-module.h" #include "ns3/network-module.h" #include "ns3/csma-module.h" #include "ns3/internet-module.h" #include "ns3/point-to-point-module.h" #include "ns3/applications-module.h" #include "ns3/ipv4-global-routing-helper.h" #include "ns3/tap-bridge-helper.h" #include "ns3/ipv4-routing-table-entry.h" // Default Network Topology // // 10.0.0.0 // ca ============== cb // LAN // 100Mbps // 5ms // using namespace std; using namespace ns3; void socketRecv (Ptr); void SendStuff (Ptr, Ipv4Address, uint16_t); NS_LOG_COMPONENT_DEFINE ("foo"); int i = 0; int main (int argc, char *argv[]) { CommandLine cmd; cmd.Parse (argc, argv); GlobalValue::Bind ("SimulatorImplementationType", StringValue ("ns3::RealtimeSimulatorImpl")); GlobalValue::Bind ("ChecksumEnabled", BooleanValue (true)); LogComponentEnable ("UdpEchoClientApplication", LOG_LEVEL_INFO); LogComponentEnable ("UdpEchoServerApplication", LOG_LEVEL_INFO); Ptr ca = CreateObject (); Ptr cb = CreateObject (); NodeContainer csmaNodes1 = NodeContainer (ca, cb); CsmaHelper csma; csma.SetChannelAttribute ("DataRate", StringValue ("1Gbps")); csma.SetChannelAttribute ("Delay", StringValue ("0ms")); NetDeviceContainer csmaDevices1 = csma.Install (csmaNodes1); InternetStackHelper stack; stack.Install (csmaNodes1); Ipv4AddressHelper addresses; addresses.SetBase ("10.0.0.0", "255.255.255.0"); Ipv4InterfaceContainer csmaInterfaces1 = addresses.Assign (csmaDevices1); Ipv4GlobalRoutingHelper::PopulateRoutingTables (); TapBridgeHelper tapBridge; tapBridge.SetAttribute ("Mode", StringValue ("ConfigureLocal")); tapBridge.SetAttribute ("DeviceName", StringValue ("tapOut")); tapBridge.Install (cb, csmaDevices1.Get (1)); UdpEchoClientHelper clientHelper (Ipv4Address ("10.0.0.3"), 9); clientHelper.SetAttribute ("MaxPackets", UintegerValue (2)); clientHelper.SetAttribute ("Interval", TimeValue (Seconds (1))); ApplicationContainer clientApp = clientHelper.Install (ca); clientApp.Start (Seconds (1.)); csma.EnablePcapAll ("udp-echo"); Simulator::Stop (Seconds (10.)); Simulator::Run (); Simulator::Destroy (); return 0; }