こんにちは、私は NS3 を初めて使用します。UDP ではなく TCP を実行するように first.cc を変更しようとしています。エラーは発生しませんでしたが、データ交換も発生しませんでした。誰でもこれについて私を助けることができますか?~~多くの感謝~~コードは次のとおりです:メインで:
NS_LOG_INFO ("Creating Topology");
Config::SetDefault ("ns3::OnOffApplication::PacketSize", UintegerValue (137));
Config::SetDefault ("ns3::OnOffApplication::DataRate", StringValue ("14kb/s"));
NodeContainer nodes;
nodes.Create (2);
//
PointToPointHelper pointToPoint;
pointToPoint.SetDeviceAttribute ("DataRate", StringValue ("100Mbps"));
pointToPoint.SetChannelAttribute ("Delay", StringValue ("20ms"));
//
NetDeviceContainer devices;
devices = pointToPoint.Install (nodes);
InternetStackHelper stack;
stack.Install (nodes);
Ipv4AddressHelper address;
address.SetBase ("109.11.12.0", "255.255.255.0");//address setting
Ipv4InterfaceContainer interfaces = address.Assign (devices);
OnOffHelper onOffHelper ("ns3::TcpSocketFactory", Address
(InetSocketAddress (Ipv4Address ("255.255.255.0"), 10)));
onOffHelper.SetAttribute ("OnTime", StringValue ("ns3::ConstantRandomVariable[Constant=1]"));
onOffHelper.SetAttribute ("OffTime", StringValue ("ns3::ConstantRandomVariable[Constant=0]"));
onOffHelper.SetAttribute ("DataRate",StringValue ("2Mbps"));
onOffHelper.SetAttribute ("PacketSize",UintegerValue(2000));
ApplicationContainer app = onOffHelper.Install (nodes.Get (0));
// Start the application
app.Start (Seconds (10.0));
app.Stop (Seconds (100.0));
// Create an optional packet sink to receive packets
PacketSinkHelper sink ("ns3::TcpSocketFactory",Address
(InetSocketAddress (Ipv4Address::GetAny (), 10)));
app = sink.Install (nodes.Get(1));
app.Start (Seconds (1.0));
app.Stop (Seconds (100.0));
pointToPoint.EnablePcapAll ("testtcp");