nodes' interfaces on the same channel are not communicating

54 views
Skip to first unread message

hesra

unread,
Jan 20, 2016, 4:00:42 PM1/20/16
to ns-3-users
Hi,

I have 6 nodes, 2 interfaces on each node, and each interface is linked to a different channel, but I don't know the reason that each 2 interfaces on the same channel are not communicating.
Do you have any suggestions, please ?

Thanks in advance,

  WifiHelper wifi;

  YansWifiPhyHelper wifiPhy1 =  YansWifiPhyHelper::Default ();
  wifiPhy1.SetPcapDataLinkType (YansWifiPhyHelper::DLT_IEEE802_11);

  YansWifiPhyHelper wifiPhy2 =  YansWifiPhyHelper::Default ();
  wifiPhy2.SetPcapDataLinkType (YansWifiPhyHelper::DLT_IEEE802_11);

  YansWifiChannelHelper wifiChannel1 ;
  YansWifiChannelHelper wifiChannel2 ;

  wifiChannel1.SetPropagationDelay ("ns3::ConstantSpeedPropagationDelayModel");
  wifiChannel2.SetPropagationDelay ("ns3::ConstantSpeedPropagationDelayModel");

  wifiChannel1.AddPropagationLoss ("ns3::TwoRayGroundPropagationLossModel","SystemLoss", DoubleValue(1), "HeightAboveZ", DoubleValue(1.5));
  wifiChannel2.AddPropagationLoss ("ns3::TwoRayGroundPropagationLossModel","SystemLoss", DoubleValue(1), "HeightAboveZ", DoubleValue(1.5));

  wifi.SetStandard (WIFI_PHY_STANDARD_80211b);
  wifi.SetRemoteStationManager ("ns3::ConstantRateWifiManager", "DataMode",StringValue(phyMode), "ControlMode",StringValue(phyMode));

  Ssid ssid = Ssid ("ns-3-ssid");

  NqosWifiMacHelper wifiMac1 = NqosWifiMacHelper::Default ();
  NqosWifiMacHelper wifiMac2 = NqosWifiMacHelper::Default ();

  wifiMac1.SetType ("ns3::AdhocWifiMac");  
  wifiMac2.SetType ("ns3::AdhocWifiMac");                     

  wifiPhy1.Set("ChannelNumber",UintegerValue(1));
  wifiPhy1.SetChannel (wifiChannel1.Create ());
  NetDeviceContainer devices1 = wifi.Install (wifiPhy1, wifiMac1, m_nodes);
 
  wifiPhy2.Set("ChannelNumber",UintegerValue(6));
  wifiPhy2.SetChannel (wifiChannel2.Create ());
  NetDeviceContainer devices2 = wifi.Install (wifiPhy2, wifiMac2, m_nodes);
                              
  InternetStackHelper internet;
  internet.Install (m_nodes);

  Ipv4AddressHelper ip;
  Ipv4AddressHelper ip1;
  ip.SetBase ("10.1.1.0", "255.255.255.0");
  ip1.SetBase ("10.1.2.0", "255.255.255.0");
  Ipv4InterfaceContainer IF1=ip.Assign(devices1);
  Ipv4InterfaceContainer IF2=ip1.Assign(devices2);

  TypeId tid = TypeId::LookupByName ("ns3::UdpSocketFactory");
  Ptr<Socket> recvSink = Socket::CreateSocket (m_nodes.Get (0), tid);
  InetSocketAddress local = InetSocketAddress (Ipv4Address ("10.1.1.1"), 80);
  recvSink->Bind (local);
  recvSink->SetRecvCallback (MakeCallback (&ReceivePacket));
  Ptr<Socket> source = Socket::CreateSocket (m_nodes.Get (1), tid);
  InetSocketAddress remote = InetSocketAddress (Ipv4Address ("10.1.1.2"), 80);
  source->SetAllowBroadcast (true);
  source->Connect (remote);

   

Tommaso Pecorella

unread,
Jan 20, 2016, 7:27:19 PM1/20/16
to ns-3-users
Hi,

beside the fact that the snippet is cryptic and the question is confusing, the nodes are communicating. The problem is that you did tell node 1 to send packets to itself.

T.

hesra

unread,
Jan 21, 2016, 2:13:48 PM1/21/16
to ns-3-users
Yes, you are right, thanks for your help and sorry for confusing.
Reply all
Reply to author
Forward
0 new messages