TCP traffic in aodv script

This commit is contained in:
Borovkova Elena
2009-08-19 13:49:41 +04:00
parent 0f7972dbae
commit d4e5ff2659
2 changed files with 38 additions and 1 deletions

View File

@@ -250,6 +250,42 @@ AodvExample::InstallApplications ()
apps.Stop (Seconds (totalTime));
break;
}
case TCP:
{
// V4PingHelper ping (interfaces.GetAddress(size - 1));
// ping.SetAttribute ("Verbose", BooleanValue (true));
//
// ApplicationContainer p = ping.Install (nodes.Get (0));
// p.Start (Seconds (0));
// p.Stop (Seconds (totalTime/2));
Config::SetDefault ("ns3::OnOffApplication::PacketSize", UintegerValue (4096));
Config::SetDefault ("ns3::OnOffApplication::DataRate", StringValue ("6Mbps"));
uint16_t port = 8080;
PacketSinkHelper sinkHelper ("ns3::TcpSocketFactory", InetSocketAddress (Ipv4Address::GetAny (), port));
ApplicationContainer sinkApp = sinkHelper.Install (nodes.Get (size-1));
sinkApp.Start (Seconds (totalTime/2));
sinkApp.Stop (Seconds (totalTime));
// Create the OnOff applications to send TCP
OnOffHelper clientHelper ("ns3::TcpSocketFactory", Address ());
clientHelper.SetAttribute
("OnTime", RandomVariableValue (ConstantVariable (1)));
clientHelper.SetAttribute
("OffTime", RandomVariableValue (ConstantVariable (0)));
ApplicationContainer clientApp;
AddressValue remoteAddress
(InetSocketAddress (interfaces.GetAddress (size-1), port));
clientHelper.SetAttribute ("Remote", remoteAddress);
clientApp = clientHelper.Install (nodes.Get (0));
clientApp.Start (Seconds (totalTime/2));
clientApp.Stop (Seconds (totalTime));
}
};
}

View File

@@ -45,7 +45,7 @@
#include "ns3/adhoc-wifi-mac.h"
#include <algorithm>
#include "ns3/icmpv4.h"
#include "ns3/udp-socket.h"
NS_LOG_COMPONENT_DEFINE ("AodvRoutingProtocol");
@@ -426,6 +426,7 @@ RoutingProtocol::NotifyInterfaceUp (uint32_t i )
socket->SetRecvCallback (MakeCallback (&RoutingProtocol::RecvAodv, this));
socket->Bind(InetSocketAddress (iface.GetLocal(), AODV_PORT));
socket->Connect (InetSocketAddress (iface.GetBroadcast(), AODV_PORT));
socket->SetAttribute("IpTtl", UintegerValue(1));
m_socketAddresses.insert (std::make_pair (socket, iface));
// Add local broadcast record to the routing table