simulation of wireless network

143 views
Skip to first unread message

meriam meriam

unread,
May 30, 2011, 8:42:22 AM5/30/11
to ns-3-users
Hi,
for the same topology I want to change the speed of nodes( 30m/s,50m/s,
100m/s) to make the comparison between the output parameters of
simulation (delay, the number of captured packets, rate...)
I take a simple topology (a node send udp packets to another )

the simulation result of different output parameters for different
speed values ​​have the same value
is true or not???

I did the same test by changing the number of nodes (5,10,50,100
nodes)
I take a simple topology (a node send udp packets to another ) and the
other nodes are moving
the simulation result of different output parameters for different
number of nodes ​​have the same value
is true or not???

is logical or not???

i need a help

thanks

meriam meriam

unread,
May 30, 2011, 8:45:36 AM5/30/11
to ns-3-users

meriam meriam

unread,
May 30, 2011, 8:48:32 AM5/30/11
to ns-3-users
Hi,

1/ i change speed  (speed=30,50,100) for nwifi=2

2/I change number of node(nwifi=5,10,50,100) for the same speed(speed=30) 
and node0 send udp to node1


thanks
%%%%%%%%%%% my code is:

#include "ns3/core-module.h"
#include "ns3/common-module.h"
#include "ns3/node-module.h"
#include "ns3/helper-module.h"
#include "ns3/mobility-module.h"
#include "ns3/contrib-module.h"
#include "ns3/wifi-module.h"
#include "ns3/ipv4-global-routing-helper.h"



NS_LOG_COMPONENT_DEFINE ("test");

using namespace ns3;


void 
Tx (std::string context, Ptr<Packet const> packet) 

        NS_LOG_UNCOND (context << 
                        "\tSend " << 
                        "\tTime " << Simulator::Now().GetSeconds()); 


void 
Rx (std::string context, Ptr<Packet const> packet, Address const& add) 

        NS_LOG_UNCOND (context << 
                        "\tReceive " << 
                        "\tTime " << Simulator::Now().GetSeconds()); 
}



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

  std::string phyMode ("DsssRate2Mbps");
  double rss = -80;  // -dBm
  uint32_t packetSize = 2000; // bytes
  uint32_t numPackets = 1580;
  double interval = 1.0; // second
  bool verbose = false;
  uint32_t nwifi = 2;

  CommandLine cmd;

  cmd.AddValue ("phyMode", "Wifi Phy mode", phyMode);
  cmd.AddValue ("rss", "received signal strength", rss);
  cmd.AddValue ("packetSize", "size of application packet sent", packetSize);
  cmd.AddValue ("numPackets", "number of packets generated", numPackets);
  cmd.AddValue ("interval", "interval (seconds) between packets", interval);
  cmd.AddValue ("verbose", "turn on all WifiNetDevice log components", verbose);
  cmd.AddValue ("nwifi", "number of wifi node", nwifi);

  
  cmd.Parse (argc, argv);

  // Convert to time object
  Time interPacketInterval = Seconds (interval);

//
 // disable fragmentation for frames below 2200 bytes
  Config::SetDefault ("ns3::WifiRemoteStationManager::FragmentationThreshold", StringValue ("2200"));
  // turn off RTS/CTS for frames below 2200 bytes
  Config::SetDefault ("ns3::WifiRemoteStationManager::RtsCtsThreshold", StringValue ("2200"));
  // Fix non-unicast data rate to be the same as that of unicast
  Config::SetDefault ("ns3::WifiRemoteStationManager::NonUnicastMode", 
                      StringValue (phyMode));

 //create node

  NodeContainer c;
  c.Create (nwifi);

  // The below set of helpers will help us to put together the wifi NICs we want
  WifiHelper wifi;
  if (verbose)
    {
      wifi.EnableLogComponents ();  // Turn on all Wifi logging
    }
  wifi.SetStandard (WIFI_PHY_STANDARD_80211b);

  YansWifiPhyHelper wifiPhy =  YansWifiPhyHelper::Default ();

  // This is one parameter that matters when using FixedRssLossModel
  // set it to zero; otherwise, gain will be added
  wifiPhy.Set ("RxGain", DoubleValue (0) ); 

  // ns-3 supports RadioTap and Prism tracing extensions for 802.11b
  wifiPhy.SetPcapDataLinkType (YansWifiPhyHelper::DLT_IEEE802_11_RADIO); 

  YansWifiChannelHelper wifiChannel ;

  wifiChannel.SetPropagationDelay ("ns3::ConstantSpeedPropagationDelayModel");
  // The below FixedRssLossModel will cause the rss to be fixed regardless
  // of the distance between the two stations, and the transmit power

  wifiChannel.AddPropagationLoss ("ns3::FixedRssLossModel","Rss",DoubleValue(rss));
  wifiPhy.SetChannel (wifiChannel.Create ());

  // Add a non-QoS upper mac, and disable rate control
  NqosWifiMacHelper wifiMac = NqosWifiMacHelper::Default ();
  wifi.SetRemoteStationManager ("ns3::ConstantRateWifiManager",
                                "DataMode",StringValue(phyMode),
                                "ControlMode",StringValue(phyMode));

  // Set it to adhoc mode

  wifiMac.SetType ("ns3::AdhocWifiMac");
  NetDeviceContainer devices = wifi.Install (wifiPhy, wifiMac, c);

  // Note that with FixedRssLossModel, the positions below are not 
  // used for received signal strength. 
  MobilityHelper mobility;
  mobility.SetPositionAllocator ("ns3::RandomRectanglePositionAllocator");

  
  mobility.SetMobilityModel ("ns3::RandomDirection2dMobilityModel",
                             "Bounds", RectangleValue (Rectangle (0, 500, 0, 500)),
                             "Speed", RandomVariableValue (ConstantVariable (30)));

  mobility.Install (c);


//
  InternetStackHelper internet;
  internet.Install (c);
  //

  Ipv4AddressHelper ipv4;
  NS_LOG_INFO ("Assign IP Addresses.");
  ipv4.SetBase ("10.1.1.0", "255.255.255.0");
  Ipv4InterfaceContainer i = ipv4.Assign (devices);


// Create the OnOff application to send UDP datagrams

 uint16_t port = 21;

                OnOffHelper onoff ("ns3::UdpSocketFactory", Address
                (InetSocketAddress (Ipv4Address ("255.255.255.255"), port)));
                onoff.SetAttribute ("OnTime", RandomVariableValue (ConstantVariable
               (1)));
                onoff.SetAttribute ("OffTime", RandomVariableValue (ConstantVariable
                (0)));
                onoff.SetAttribute ("DataRate",StringValue ("2Mbps"));
                onoff.SetAttribute ("PacketSize",UintegerValue(2000));
                ApplicationContainer app = onoff.Install (c.Get (0));

// Start the application
                app.Start (Seconds (30.0));
                app.Stop (Seconds (150.0));

// Create an optional packet sink to receive  packets
       
        PacketSinkHelper sink ("ns3::UdpSocketFactory",Address
       (InetSocketAddress (Ipv4Address::GetAny (), port)));
        app = sink.Install (c.Get(1));
        app.Start (Seconds (30.0));
        app.Stop (Seconds (150.0)); 

//
        Ipv4GlobalRoutingHelper::PopulateRoutingTables ();
//

         std::ostringstream oss; 
         oss << "/NodeList/*/ApplicationList/*/$ns3::OnOffApplication/Tx"; 
         Config::Connect (oss.str(), MakeCallback(&Tx)); 
          oss.str(""); 
         oss << "/NodeList/*/ApplicationList/*/$ns3::PacketSink/Rx"; 
         Config::Connect (oss.str(), MakeCallback(&Rx)); 
         oss.str("");
  

 // Tracing
  NS_LOG_INFO ("Configure Tracing."); 

  wifiPhy.EnablePcap ("test", devices);


 // Output what we are doing

  NS_LOG_UNCOND ("Testing " << numPackets  << " packets sent with receiver rss " << rss );

  Simulator::Stop (Seconds (180.0));

  Simulator::Run ();
  
  Simulator::Destroy ();

2011/5/30 meriam meriam <meriam.m...@gmail.com>

Lalith Suresh

unread,
May 30, 2011, 9:44:02 AM5/30/11
to ns-3-...@googlegroups.com
Hello,

It's logical if both nodes are talking to one another directly, without any multi-hop routing going on. Considering your wifi settings, it looks like that's the case. Try making a bigger rectangle for the mobility bounds and ensuring that the nodes are far enough apart (you'll need to use a routing protocol like OLSR as well).

 
thanks

--
You received this message because you are subscribed to the Google Groups "ns-3-users" group.
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.




--
Lalith Suresh
Department of Computer Science and Engineering
Instituto Superior Técnico
www.lalith.in

meriam meriam

unread,
May 30, 2011, 10:17:06 AM5/30/11
to ns-3-...@googlegroups.com
Hi
another question please
how to specify distance between nodes?

thanks

2011/5/30 Lalith Suresh <suresh...@gmail.com>

Lalith Suresh

unread,
May 30, 2011, 10:20:46 AM5/30/11
to ns-3-...@googlegroups.com
On Mon, May 30, 2011 at 3:17 PM, meriam meriam
<meriam.m...@gmail.com> wrote:
> Hi
> another question please
> how to specify distance between nodes?

Look into examples/wireless/wifi-simple-adhoc-grid.cc and grep for "distance".

Reply all
Reply to author
Forward
0 new messages