Hey Jaume,
I computed the collision probability exactly as the same as you did,
using (missed cts #) / (rts #).
From the result I got for 2 nodes (please refer to the figure I send
you), the average of collision probability when saturation is around
0.04. In Bianchi's model, it does not consider the retransmission
limit. I think for our test the default retransmission limit is 7(But
I don't think it will influence your result got from octave a lot).
From simulation results for 4 nodes and 8 nodes, the average of
collision probability when saturation is around 0.11 and 0.20,
respectively. You can use apply Bianchi's model to check again.
Please check out my updated ns3 code. I generate random start time,
and fix the rate for sending data and control packets. Also, I changed
the radius of the disc area to 50, which makes sure the maximum
distance of two nodes is 100(guarantee they can talk to each other). I
added two input parameters, which are "PacketArrivalRate" and
"StationNumber". For "StationNumber" you only can use even number, I
created the udp flows for pairs. You can run the command like:
./waf --run "scratch/kexu --PacketArrivalRate=1000 --StationNumber=4"
2> output.txt
Here is the code.
#include "ns3/core-module.h"
#include "ns3/point-to-point-module.h"
#include "ns3/network-module.h"
#include "ns3/applications-module.h"
#include "ns3/wifi-module.h"
#include "ns3/mobility-module.h"
#include "ns3/csma-module.h"
#include "ns3/internet-module.h"
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <string>
#include <sstream>
using namespace ns3;
void PopulateArpCache ();
int
main (int argc, char *argv[])
{
uint32_t n_sta = 2;// number of stations
uint32_t i;// iteration index
uint32_t pkt_arrv_rate = 50;// pkt/s
float pkt_interval; // sec
float randtime_1,randtime_2;// random start time
srand(time(NULL));
std::string controlRate ("DsssRate1Mbps");
std::string dataRate ("DsssRate11Mbps");
CommandLine cmd;
cmd.AddValue ("PacketArrivalRate", "packet arrival rate on each
station(/s)", pkt_arrv_rate);
cmd.AddValue ("StationNumber", "the number of stations", n_sta);
cmd.Parse (argc, argv);
// Calcuate packet arrival interval
pkt_interval = 1.00 / pkt_arrv_rate;
// Enable rts/cts all the time
Config::SetDefault("ns3::WifiRemoteStationManager::RtsCtsThreshold",
StringValue ("0"));
// Fix non-unicast data rate to be the same as that of unicast
Config::SetDefault ("ns3::WifiRemoteStationManager::NonUnicastMode",
StringValue (controlRate));
// Create wifi nodes
NodeContainer sta;
sta.Create (n_sta);
YansWifiChannelHelper channel = YansWifiChannelHelper::Default ();
YansWifiPhyHelper phy = YansWifiPhyHelper::Default ();
phy.SetPcapDataLinkType (YansWifiPhyHelper::DLT_IEEE802_11_RADIO);
phy.SetChannel (channel.Create ());
WifiHelper wifi = WifiHelper::Default ();
// wifi.SetRemoteStationManager ("ns3::AarfWifiManager"); //rate
control algorithm
// Set data rate as 12Mbps; control rate as 1Mbps
wifi.SetRemoteStationManager ("ns3::ConstantRateWifiManager",
"DataMode",StringValue(dataRate),
"ControlMode",StringValue(controlRate));
wifi.SetStandard(WIFI_PHY_STANDARD_80211b);// IEEE 802.11g
NqosWifiMacHelper mac = NqosWifiMacHelper::Default ();
// Set it to adhoc mode
mac.SetType ("ns3::AdhocWifiMac");
NetDeviceContainer devices = wifi.Install (phy, mac, sta);
//Specify wifi modes to be stationary but randomly allocated within
a disc
MobilityHelper mobility;
mobility.SetPositionAllocator ("ns3::RandomDiscPositionAllocator",
"Theta", RandomVariableValue
(UniformVariable (0.0, 6.2830)),
"Rho", RandomVariableValue
(UniformVariable (0.0, 50.0)),
"X", DoubleValue (0.0),
"Y", DoubleValue (0.0));
mobility.SetMobilityModel ("ns3::ConstantPositionMobilityModel");
mobility.Install (sta);
// Internet and Stack
InternetStackHelper stack;
stack.Install (sta);
Ipv4AddressHelper address;
address.SetBase ("10.1.1.0", "255.255.255.0");
Ipv4InterfaceContainer ipadd = address.Assign (devices);
//============================== Generate traffic
=======================================
// define UDP port
uint16_t port_1 = 4000;
uint16_t port_2 = 2000;
// define UDP maximum packet number and packet size
uint32_t maxPacketCount = 400000000;
uint32_t MaxPacketSize = 1024;
for (i=0; i<n_sta; i+=2) {
// Generate random time
randtime_1 = (rand()%1000+1)/1000.00;//random time 1: [0,1]sec
randtime_2 = (rand()%1000+1)/1000.00;//random time 2: [0,1]sec
// UDP: 10.1.1.(i) ===>>> 10.1.1.(i+1)
// Create one udpServer applications on 10.1.1.(i+1)
UdpServerHelper server_1 (port_1);
ApplicationContainer apps_1 = server_1.Install (sta.Get(i+1));
apps_1.Start (Seconds (0.0));
// Create one UdpClient application to send UDP datagrams from
10.1.1.(i) to 10.1.1.(i+1).
Time interPacketInterval = Seconds (pkt_interval);
UdpClientHelper client_1 (ipadd.GetAddress (i+1), port_1);
client_1.SetAttribute ("MaxPackets", UintegerValue
(maxPacketCount));
client_1.SetAttribute ("Interval", TimeValue
(interPacketInterval));
client_1.SetAttribute ("PacketSize", UintegerValue
(MaxPacketSize));
apps_1 = client_1.Install (sta.Get (i));
apps_1.Start (Seconds (randtime_1));
// UDP: 10.1.1.(i+1) ===>>> 10.1.1.(i)
// Create one udpServer applications on 10.1.1.(i)
UdpServerHelper server_2 (port_2);
ApplicationContainer apps_2 = server_2.Install (sta.Get(i));
apps_2.Start (Seconds (0.0));
// Create one UdpClient application to send UDP datagrams from
10.1.1.(i+1) to 10.1.1.(i).
UdpClientHelper client_2 (ipadd.GetAddress (i), port_2);
client_2.SetAttribute ("MaxPackets", UintegerValue
(maxPacketCount));
client_2.SetAttribute ("Interval", TimeValue
(interPacketInterval));
client_2.SetAttribute ("PacketSize", UintegerValue
(MaxPacketSize));
apps_2 = client_2.Install (sta.Get (i+1));
apps_2.Start (Seconds (randtime_2));
}
// Set routing
Ipv4GlobalRoutingHelper::PopulateRoutingTables ();
// Populate ARP cache
PopulateArpCache ();
// Set simulation stop time
Simulator::Stop (Seconds (30.0));
// Save pcap file for each station
for (i=0; i<n_sta; i++) {
phy.EnablePcap ("sta", devices.Get (i));
}
// Start the simulation
Simulator::Run ();
Simulator::Destroy ();
return 0;
}
//=========== Below are functions ====================
Thanks,
Ke