application container on the AP node

388 views
Skip to first unread message

Raad Qandah

unread,
Nov 12, 2012, 1:59:59 PM11/12/12
to ns-3-...@googlegroups.com
Dear all,

the below code is a simplified version of the topology I am working on, I added it to the post so that my question will be very clear
my question is if I want to have a wifi network as below and I want each STAs to communicate with the AP node
in this case do I have to install an application container to the AP node??
thanks in advance


#include "ns3/core-module.h"
#include "ns3/network-module.h"
#include "ns3/applications-module.h"
#include "ns3/mobility-module.h"
#include "ns3/tools-module.h"
#include "ns3/wifi-module.h"

#include <iostream>

NS_LOG_COMPONENT_DEFINE ("Main");

using namespace ns3;


int main (int argc, char *argv[])
{

  WifiHelper wifi = WifiHelper::Default ();

  wifi.SetRemoteStationManager ("ns3::ArfWifiManager");
  wifi.SetStandard (WIFI_PHY_STANDARD_80211b);
  NqosWifiMacHelper mac = NqosWifiMacHelper::Default ();


  YansWifiPhyHelper phy1 = YansWifiPhyHelper::Default ();


  YansWifiChannelHelper wifiChannel = YansWifiChannelHelper::Default ();
  mac.SetType ("ns3::AdhocWifiMac");

  NodeContainer c;
  c.Create (3);

  PacketSocketHelper packetSocket;
  packetSocket.Install (c);


  phy1.SetChannel (wifiChannel.Create ());


  NetDeviceContainer apDevices1 = wifi.Install (phy1, mac, c.Get(0));

  NetDeviceContainer staDevices1 = wifi.Install (phy1, mac, c.Get(1));

  NetDeviceContainer staDevices2 = wifi.Install (phy1, mac, c.Get(2));



  MobilityHelper mobility;
  mobility.SetPositionAllocator ("ns3::GridPositionAllocator",
                                 "MinX", DoubleValue (0.0),
                                 "MinY", DoubleValue (0.0),
                                 "DeltaX", DoubleValue (5.0),
                                 "DeltaY", DoubleValue (10.0),
                                 "GridWidth", UintegerValue (3),
                                 "LayoutType", StringValue ("RowFirst"));

  mobility.Install (c);


  PacketSocketAddress socket1;
  socket1.SetSingleDevice (staDevices1.Get (0)->GetIfIndex ());
  socket1.SetSingleDevice (staDevices2.Get (0)->GetIfIndex ());
  socket1.SetPhysicalAddress (apDevices1.Get (0)->GetAddress ());
  socket1.SetProtocol (1);

  OnOffHelper onoff1 ("ns3::PacketSocketFactory", Address (socket1));
  onoff1.SetAttribute ("OnTime", RandomVariableValue (ConstantVariable (250)));
  onoff1.SetAttribute ("OffTime", RandomVariableValue (ConstantVariable (0)));
  onoff1.SetAttribute ("DataRate", DataRateValue (DataRate ("500Mbps")));
  onoff1.SetAttribute ("PacketSize", UintegerValue (2000));

  ApplicationContainer apps1 = onoff1.Install (c.Get (0));
  apps1.Start (Seconds (0.5));
  apps1.Stop (Seconds (180));

  ApplicationContainer apps2 = onoff1.Install (c.Get (1));
  apps2.Start (Seconds (0.5));
  apps2.Stop (Seconds (180));

  ApplicationContainer apps3 = onoff1.Install (c.Get (2));
  apps3.Start (Seconds (0.5));
  apps3.Stop (Seconds (180));
 


  phy1.SetPcapDataLinkType(YansWifiPhyHelper::DLT_IEEE802_11_RADIO);

  phy1.EnablePcap ("apDevices1_topology8.1", apDevices1.Get(0));


  Simulator::Stop(Seconds(180));
  Simulator::Run ();
  Simulator::Destroy ();
  return 0;
}

Raad Qandah

unread,
Nov 13, 2012, 1:15:32 PM11/13/12
to ns-3-...@googlegroups.com
could anyone help me with this post please
thanks

Konstantinos

unread,
Nov 13, 2012, 5:25:45 PM11/13/12
to ns-3-...@googlegroups.com
The application container is an abstraction that can gather several applications.
What you need to install at the AP is a sink application (can be integrated in a container but not necessarily) to be able to receive the packets.
At the moment packets go to the AP, but it does not know what to do them, so they drop. 

See in the examples folder for ways to do that.

Raad Qandah

unread,
Nov 14, 2012, 12:34:02 PM11/14/12
to ns-3-...@googlegroups.com
Much thanks for the reply Konstantinos I really appreciate it
but when I use " PacketSinkHelper (std::string protocol, Address address)" does the address has to be an IP address, can't I use a mac address?
note: I am not using any IP addresses in my topology therefore how can I add an app sink using a mac address??
Thanks :)

Konstantinos

unread,
Nov 14, 2012, 1:33:03 PM11/14/12
to ns-3-...@googlegroups.com
The sink application is installed on one node and you put the address node of that node.
It just creates the necessary callbacks so that a packet that is received at the AP will be pushed up the the application layer of that node.

RAAD QANDAH

unread,
Nov 14, 2012, 2:08:35 PM11/14/12
to ns-3-...@googlegroups.com

Yes, but what I want to do is to install the sink on a node without using an ip address is that possible??

--
You received this message because you are subscribed to the Google Groups "ns-3-users" group.
To view this discussion on the web visit https://groups.google.com/d/msg/ns-3-users/-/UpyhrxMIuO4J.
To post to this group, send email to ns-3-...@googlegroups.com.
To unsubscribe from this group, send email to ns-3-users+...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/ns-3-users?hl=en.

Konstantinos

unread,
Nov 14, 2012, 3:04:07 PM11/14/12
to ns-3-...@googlegroups.com
The packet socket helper works with IP stack.You could try to implement your own sink application on the AP with sockets without IP address

RAAD QANDAH

unread,
Nov 15, 2012, 5:24:30 AM11/15/12
to ns-3-...@googlegroups.com
so if I did the following:

PacketSocketAddress socket;
  socket.SetSingleDevice (staDevices.Get (0)->GetIfIndex ());
  socket.SetPhysicalAddress (apDevices.Get (0)->GetAddress ());
  socket.SetProtocol (1);

  OnOffHelper onoff ("ns3::PacketSocketFactory", Address (socket));
  onoff.SetAttribute ("OnTime", RandomVariableValue (ConstantVariable (250)));
  onoff.SetAttribute ("OffTime", RandomVariableValue (ConstantVariable (0)));
  onoff.SetAttribute ("DataRate", DataRateValue (DataRate (999999999)));
  onoff.SetAttribute ("PacketSize", UintegerValue (2000));

  ApplicationContainer apps = onoff.Install (c.Get (0));
  apps.Start (Seconds (0.5));
  apps.Stop (Seconds (60));


would that be enough to send packets from first node in staDevices (staDevices.Get(0))  to the first node in apDevices??
I really appreciate you help.

To view this discussion on the web visit https://groups.google.com/d/msg/ns-3-users/-/0xUSyEEAWmYJ.

RAAD QANDAH

unread,
Nov 16, 2012, 9:06:40 AM11/16/12
to ns-3-...@googlegroups.com
Can any one help me of how can I set up a sink application on a node that does not have an IP address??
any link of info can be helpful
thanks in advance

RAAD QANDAH

unread,
Nov 17, 2012, 5:08:25 AM11/17/12
to ns-3-...@googlegroups.com
Dear all,


Can any one help me of how can I set up a sink application on a node that does not have an IP address??
any link of info can be helpful
thanks in advance

Hasib

unread,
Jun 12, 2013, 10:44:44 AM6/12/13
to ns-3-...@googlegroups.com
Hi!
Can you help me how I can communicate from a STA node from one wifi network to another wifi network thru APs? 

RAAD QANDAH

unread,
Jun 12, 2013, 11:20:45 AM6/12/13
to ns-3-...@googlegroups.com

I think u will need a wired connection between the APs

You received this message because you are subscribed to a topic in the Google Groups "ns-3-users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/ns-3-users/pb7dbIBnLeI/unsubscribe?hl=en.
To unsubscribe from this group and all its topics, send an email to ns-3-users+...@googlegroups.com.

To post to this group, send email to ns-3-...@googlegroups.com.

Hasib

unread,
Jun 12, 2013, 2:21:15 PM6/12/13
to ns-3-...@googlegroups.com
Thanks for your reply! Yes, APs are connected thru wired connection. But my question is how do packets go from one STA of AP1 to another STA of AP2? 
Thanks again

RAAD QANDAH

unread,
Jun 12, 2013, 2:27:45 PM6/12/13
to ns-3-...@googlegroups.com

Think u will have to give each STA an IP and send the packets to the appropriate one, I think there is a some how similar example in the NS3 tutorial

Message has been deleted

Hasib

unread,
Jun 12, 2013, 2:32:03 PM6/12/13
to ns-3-...@googlegroups.com
Thanks brother!
Yes, I have given IP address to each node, but i could not manage to send packets! i was following the wifi-simple-adhoc-grid example. but no real success! it executes well! but i dont see anything in tracing or pcap file. Strange!

RAAD QANDAH

unread,
Jun 12, 2013, 2:54:53 PM6/12/13
to ns-3-...@googlegroups.com

Well it has been a long while since i last used ns3, but u should post ur question on ns-3-users group, u will gt some help there

On Jun 12, 2013 9:31 PM, "Hasib" <hasibur....@gmail.com> wrote:
Thanks brother!
Yes, I have given IP address to each node, but i could manage to send packets! i was following the wifi-simple-adhoc-grid example. but no real success! it executes well! but i dont see anything in tracing or pcap file. Strange!
Reply all
Reply to author
Forward
0 new messages