Проблемы при отправке tcp-пакетов в циклической топологии - PullRequest
0 голосов
/ 12 января 2019

Я использую OnOFFApplication и PacketSinkHelper для отправки TCP-пакетов от источника к приемнику. Но пакеты не достигают в приемнике. Я думаю, что это из-за петли в топологии. Кто-нибудь может мне помочь с этим? Настоящий код прилагается.

  NodeContainer nodes;
  nodes.Create (5);

  InternetStackHelper stack;
  stack.Install (nodes);


  PointToPointHelper p2p;
  p2p.SetDeviceAttribute ("DataRate", StringValue ("10Mbps"));
  p2p.SetChannelAttribute ("Delay", StringValue ("5ms"));

  Ipv4AddressHelper address;
  address.SetBase ("10.1.1.0", "255.255.255.0"); 
  NetDeviceContainer devices;
  devices = p2p.Install (nodes.Get (0), nodes.Get (1));    //Point to point links
  Ipv4InterfaceContainer interfaces = address.Assign (devices);

  devices = p2p.Install (nodes.Get (1), nodes.Get (2));
  Ipv4InterfaceContainer interfaces1 = address.Assign (devices);

  devices = p2p.Install (nodes.Get (2), nodes.Get (3));
  Ipv4InterfaceContainer interfaces2 = address.Assign (devices);

  devices = p2p.Install (nodes.Get (3), nodes.Get (4));
  Ipv4InterfaceContainer interfaces3 = address.Assign (devices);

  devices = p2p.Install (nodes.Get (3), nodes.Get (1));
  Ipv4InterfaceContainer interfaces4 = address.Assign (devices);

  Ipv4GlobalRoutingHelper::PopulateRoutingTables ();



  OnOffHelper onOffHelper ("ns3::TcpSocketFactory", Address(InetSocketAddress (Ipv4Address (interfaces3.GetAddress(1)), 10)));//onoff app on node 0
  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(512));
  onOffHelper.SetAttribute ("MaxBytes",UintegerValue (1024));


  ApplicationContainer source = onOffHelper.Install (nodes.Get (0));
  source.Start (Seconds (1.0));
  source.Stop (Seconds (5.0));


  PacketSinkHelper sink ("ns3::TcpSocketFactory",Address(InetSocketAddress (Ipv4Address::GetAny (), 10)));//packet sink on node 4
  ApplicationContainer App_sink = sink.Install (nodes.Get (4));
  App_sink.Start (Seconds (1.0));
  App_sink.Stop (Seconds (10.0));
...