Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void
- AodvExample::InstallApplications ()
- {
- //-------------------------------------tcp-------------------------------------------------
- Config::SetDefault ("ns3::OnOffApplication::PacketSize", UintegerValue (512));
- Config::SetDefault ("ns3::OnOffApplication::DataRate", StringValue ("2kb/s"));
- // Create a packet sink on the star "hub" to receive these packets
- NodeContainer serverNodeContainer(nodes.Get(2));
- uint16_t port = 9;
- Address sinkLocalAddress (InetSocketAddress (Ipv4Address::GetAny (), port));
- PacketSinkHelper sinkHelper ("ns3::TcpSocketFactory", sinkLocalAddress);
- ApplicationContainer sinkApp = sinkHelper.Install (serverNodeContainer);
- sinkApp.Start (Seconds (1.0));
- sinkApp.Stop (Seconds (100.0));
- // Create the OnOff applications to send TCP to the server
- OnOffHelper clientHelper ("ns3::TcpSocketFactory", Address ());
- clientHelper.SetAttribute ("OnTime", StringValue ("ns3::ConstantRandomVariable[Constant=1]"));
- clientHelper.SetAttribute ("OffTime", StringValue ("ns3::ConstantRandomVariable[Constant=0]"));
- ApplicationContainer clientApps;
- AddressValue remoteAddress
- (InetSocketAddress (interfaces.GetAddress(2,0), port));
- clientHelper.SetAttribute ("Remote", remoteAddress);
- clientApps.Add (clientHelper.Install (nodes.Get (0)));
- clientApps.Start (Seconds (2.0));
- clientApps.Stop (Seconds (100.0));
- //TypeId tid = TypeId::LookupByName ("ns3::TcpSocketFactory");
- // Ptr<Socket> recvSink = Socket::CreateSocket (nodes.Get (0), tid);
- //InetSocketAddress local = InetSocketAddress (Ipv4Address::GetAny (), port);
- // recvSink->Bind (local);
- //recvSink->TraceConnectWithoutContext ("CongestionWindow", MakeCallback (&CwndChange));
- //-----------------------------------------------------------------------------------------
- Ptr<Node> node = nodes.Get (1);
- Ptr<MobilityModel> mob = node->GetObject<MobilityModel> ();
- // Trace Received Packets
- Config::ConnectWithoutContext("/NodeList/*/ApplicationList/*/$ns3::PacketSink/Rx", MakeCallback (&ReceivePacket));
- // Trace changes to the congestion window
- // Config::ConnectWithoutContext ("/NodeList/0/$ns3::TcpL4Protocol/SocketList/0/CongestionWindow", MakeCallback (&CwndTracer));
- Simulator::Schedule (Seconds (0), &MobilityModel::SetPosition, mob, Vector (1000, 0, 0));
- Simulator::Schedule (Seconds (20), &MobilityModel::SetPosition, mob, Vector (100, 0, 0));
- Simulator::Schedule (Seconds (35), &MobilityModel::SetPosition, mob, Vector (2000, 0, 0));
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement