DsssRate1Mbps
DsssRate2Mbps
DsssRate5_5Mbps
DsssRate11Mbps
ErpOfdmRate6Mbps
ErpOfdmRate9Mbps
ErpOfdmRate12Mbps
ErpOfdmRate18Mbps
ErpOfdmRate24Mbps
ErpOfdmRate36Mbps
ErpOfdmRate48Mbps
ErpOfdmRate54Mbps
OfdmRate6Mbps
OfdmRate9Mbps
OfdmRate12Mbps
OfdmRate18Mbps
OfdmRate24Mbps
OfdmRate36Mbps
OfdmRate48Mbps
OfdmRate54Mbps
OfdmRate3MbpsBW10MHz
OfdmRate4_5MbpsBW10MHz
OfdmRate6MbpsBW10MHz
OfdmRate9MbpsBW10MHz
OfdmRate12MbpsBW10MHz
OfdmRate18MbpsBW10MHz
OfdmRate24MbpsBW10MHz
OfdmRate27MbpsBW10MHz
OfdmRate1_5MbpsBW5MHz
OfdmRate2_25MbpsBW5MHz
OfdmRate3MbpsBW5MHz
OfdmRate4_5MbpsBW5MHz
OfdmRate6MbpsBW5MHz
OfdmRate9MbpsBW5MHz
OfdmRate12MbpsBW5MHz
OfdmRate13_5MbpsBW5MHz
OfdmRate6_5MbpsBW20MHz
OfdmRate13MbpsBW20MHz
OfdmRate19_5MbpsBW20MHz
OfdmRate26MbpsBW20MHz
OfdmRate39MbpsBW20MHz
OfdmRate52MbpsBW20MHz
OfdmRate58_5MbpsBW20MHz
OfdmRate65MbpsBW20MHz
OfdmRate13_5MbpsBW40MHz
OfdmRate27MbpsBW40MHz
OfdmRate40_5MbpsBW40MHz
OfdmRate54MbpsBW40MHz
OfdmRate81MbpsBW40MHz
OfdmRate108MbpsBW40MHz
OfdmRate121_5MbpsBW40MHz
OfdmRate135MbpsBW40MHz
OfdmRate7_2MbpsBW20MHz
OfdmRate14_4MbpsBW20MHz
OfdmRate21_7MbpsBW20MHz
OfdmRate28_9MbpsBW20MHz
OfdmRate43_3MbpsBW20MHz
OfdmRate57_8MbpsBW20MHz
OfdmRate65MbpsBW20MHzShGi
OfdmRate72_2MbpsBW20MHz
Network Simulator
NS3 , NS2 ,LTE-Sim Project
Finish Project
Open Source Download
NS2 With 802.11e
─ https://drive.google.com/file/d/0B3oQRnn9BPSGaTJZby04aTA3NTg/view?usp=sharing
NS2 with WiMAX
─ https://drive.google.com/file/d/0B3oQRnn9BPSGVDZfOEdMMVhRc0E/view?usp=sharing
LTE-Sim with ABS
─https://drive.google.com/file/d/0B3oQRnn9BPSGR29LZktYRXpOQUk/view?usp=sharing
Need to modify
JSVM 9.18(Windows)
─ https://drive.google.com/file/d/0B3oQRnn9BPSGZzhqRUl4cDYtLXc/view?usp=sharing
目前正在研發
NS3 Multi-RAT (WiFi +LTE)
最後更新: 20150210
2015年2月4日 星期三
APPLAYER-Lab2
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation;
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
/*
LAB Assignment #2
1. Create a simple dumbbell topology, two client Node1 and Node2 on
the left side of the dumbbell and server nodes Node3 and Node4 on the
right side of the dumbbell. Let Node5 and Node6 form the bridge of the
dumbbell. Use point to point links.
2. Install a TCP socket instance on Node1 that will connect to Node3.
3. Install a UDP socket instance on Node2 that will connect to Node4.
4. Start the TCP application at time 1s.
5. Start the UDP application at time 20s at rate Rate1 such that it clogs
half the dumbbell bridge's link capacity.
6. Increase the UDP application's rate at time 30s to rate Rate2
such that it clogs the whole of the dumbbell bridge's capacity.
7. Use the ns-3 tracing mechanism to record changes in congestion window
size of the TCP instance over time. Use gnuplot/matplotlib to visualise plots of cwnd vs time.
8. Mark points of fast recovery and slow start in the graphs.
9. Perform the above experiment for TCP variants Tahoe, Reno and New Reno,
all of which are available with ns-3.
Solution by: Konstantinos Katsaros (K.Katsaros@surrey.ac.uk)
based on fifth.cc
*/
// Network topology
//
// n0 ---+ +--- n2
// | |
// n4 -- n5
// | |
// n1 ---+ +--- n3
//
// - All links are P2P with 500kb/s and 2ms
// - TCP flow form n0 to n2
// - UDP flow from n1 to n3
#include <fstream>
#include <string>
#include "ns3/core-module.h"
#include "ns3/network-module.h"
#include "ns3/point-to-point-module.h"
#include "ns3/applications-module.h"
#include "ns3/internet-module.h"
#include "ns3/flow-monitor-module.h"
#include "ns3/ipv4-global-routing-helper.h"
using namespace ns3;
NS_LOG_COMPONENT_DEFINE ("Lab2");
class MyApp : public Application
{
public:
MyApp ();
virtual ~MyApp();
void Setup (Ptr<Socket> socket, Address address, uint32_t packetSize, uint32_t nPackets, DataRate dataRate);
void ChangeRate(DataRate newrate);
private:
virtual void StartApplication (void);
virtual void StopApplication (void);
void ScheduleTx (void);
void SendPacket (void);
Ptr<Socket> m_socket;
Address m_peer;
uint32_t m_packetSize;
uint32_t m_nPackets;
DataRate m_dataRate;
EventId m_sendEvent;
bool m_running;
uint32_t m_packetsSent;
};
MyApp::MyApp ()
: m_socket (0),
m_peer (),
m_packetSize (0),
m_nPackets (0),
m_dataRate (0),
m_sendEvent (),
m_running (false),
m_packetsSent (0)
{
}
MyApp::~MyApp()
{
m_socket = 0;
}
void
MyApp::Setup (Ptr<Socket> socket, Address address, uint32_t packetSize, uint32_t nPackets, DataRate dataRate)
{
m_socket = socket;
m_peer = address;
m_packetSize = packetSize;
m_nPackets = nPackets;
m_dataRate = dataRate;
}
void
MyApp::StartApplication (void)
{
m_running = true;
m_packetsSent = 0;
m_socket->Bind ();
m_socket->Connect (m_peer);
SendPacket ();
}
void
MyApp::StopApplication (void)
{
m_running = false;
if (m_sendEvent.IsRunning ())
{
Simulator::Cancel (m_sendEvent);
}
if (m_socket)
{
m_socket->Close ();
}
}
void
MyApp::SendPacket (void)
{
Ptr<Packet> packet = Create<Packet> (m_packetSize);
m_socket->Send (packet);
if (++m_packetsSent < m_nPackets)
{
ScheduleTx ();
}
}
void
MyApp::ScheduleTx (void)
{
if (m_running)
{
Time tNext (Seconds (m_packetSize * 8 / static_cast<double> (m_dataRate.GetBitRate ())));
m_sendEvent = Simulator::Schedule (tNext, &MyApp::SendPacket, this);
}
}
void
MyApp::ChangeRate(DataRate newrate)
{
m_dataRate = newrate;
return;
}
static void
CwndChange (uint32_t oldCwnd, uint32_t newCwnd)
{
std::cout << Simulator::Now ().GetSeconds () << "\t" << newCwnd <<"\n";
}
void
IncRate (Ptr<MyApp> app, DataRate rate)
{
app->ChangeRate(rate);
return;
}
int main (int argc, char *argv[])
{
std::string lat = "2ms";
std::string rate = "500kb/s"; // P2P link
bool enableFlowMonitor = false;
CommandLine cmd;
cmd.AddValue ("latency", "P2P link Latency in miliseconds", lat);
cmd.AddValue ("rate", "P2P data rate in bps", rate);
cmd.AddValue ("EnableMonitor", "Enable Flow Monitor", enableFlowMonitor);
cmd.Parse (argc, argv);
//
// Explicitly create the nodes required by the topology (shown above).
//
NS_LOG_INFO ("Create nodes.");
NodeContainer c; // ALL Nodes
c.Create(6);
NodeContainer n0n4 = NodeContainer (c.Get (0), c.Get (4));
NodeContainer n1n4 = NodeContainer (c.Get (1), c.Get (4));
NodeContainer n2n5 = NodeContainer (c.Get (2), c.Get (5));
NodeContainer n3n5 = NodeContainer (c.Get (3), c.Get (5));
NodeContainer n4n5 = NodeContainer (c.Get (4), c.Get (5));
//
// Install Internet Stack
//
InternetStackHelper internet;
internet.Install (c);
// We create the channels first without any IP addressing information
NS_LOG_INFO ("Create channels.");
PointToPointHelper p2p;
p2p.SetDeviceAttribute ("DataRate", StringValue (rate));
p2p.SetChannelAttribute ("Delay", StringValue (lat));
NetDeviceContainer d0d4 = p2p.Install (n0n4);
NetDeviceContainer d1d4 = p2p.Install (n1n4);
NetDeviceContainer d4d5 = p2p.Install (n4n5);
NetDeviceContainer d2d5 = p2p.Install (n2n5);
NetDeviceContainer d3d5 = p2p.Install (n3n5);
// Later, we add IP addresses.
NS_LOG_INFO ("Assign IP Addresses.");
Ipv4AddressHelper ipv4;
ipv4.SetBase ("10.1.1.0", "255.255.255.0");
Ipv4InterfaceContainer i0i4 = ipv4.Assign (d0d4);
ipv4.SetBase ("10.1.2.0", "255.255.255.0");
Ipv4InterfaceContainer i1i4 = ipv4.Assign (d1d4);
ipv4.SetBase ("10.1.3.0", "255.255.255.0");
Ipv4InterfaceContainer i4i5 = ipv4.Assign (d4d5);
ipv4.SetBase ("10.1.4.0", "255.255.255.0");
Ipv4InterfaceContainer i2i5 = ipv4.Assign (d2d5);
ipv4.SetBase ("10.1.5.0", "255.255.255.0");
Ipv4InterfaceContainer i3i5 = ipv4.Assign (d3d5);
NS_LOG_INFO ("Enable static global routing.");
//
// Turn on global static routing so we can actually be routed across the network.
//
Ipv4GlobalRoutingHelper::PopulateRoutingTables ();
NS_LOG_INFO ("Create Applications.");
// TCP connfection from N0 to N2
uint16_t sinkPort = 8080;
Address sinkAddress (InetSocketAddress (i2i5.GetAddress (0), sinkPort)); // interface of n2
PacketSinkHelper packetSinkHelper ("ns3::TcpSocketFactory", InetSocketAddress (Ipv4Address::GetAny (), sinkPort));
ApplicationContainer sinkApps = packetSinkHelper.Install (c.Get (2)); //n2 as sink
sinkApps.Start (Seconds (0.));
sinkApps.Stop (Seconds (100.));
Ptr<Socket> ns3TcpSocket = Socket::CreateSocket (c.Get (0), TcpSocketFactory::GetTypeId ()); //source at n0
// Trace Congestion window
ns3TcpSocket->TraceConnectWithoutContext ("CongestionWindow", MakeCallback (&CwndChange));
// Create TCP application at n0
Ptr<MyApp> app = CreateObject<MyApp> ();
app->Setup (ns3TcpSocket, sinkAddress, 1040, 100000, DataRate ("250Kbps"));
c.Get (0)->AddApplication (app);
app->SetStartTime (Seconds (1.));
app->SetStopTime (Seconds (100.));
// UDP connfection from N1 to N3
uint16_t sinkPort2 = 6;
Address sinkAddress2 (InetSocketAddress (i3i5.GetAddress (0), sinkPort2)); // interface of n3
PacketSinkHelper packetSinkHelper2 ("ns3::UdpSocketFactory", InetSocketAddress (Ipv4Address::GetAny (), sinkPort2));
ApplicationContainer sinkApps2 = packetSinkHelper2.Install (c.Get (3)); //n3 as sink
sinkApps2.Start (Seconds (0.));
sinkApps2.Stop (Seconds (100.));
Ptr<Socket> ns3UdpSocket = Socket::CreateSocket (c.Get (1), UdpSocketFactory::GetTypeId ()); //source at n1
// Create UDP application at n1
Ptr<MyApp> app2 = CreateObject<MyApp> ();
app2->Setup (ns3UdpSocket, sinkAddress2, 1040, 100000, DataRate ("250Kbps"));
c.Get (1)->AddApplication (app2);
app2->SetStartTime (Seconds (20.));
app2->SetStopTime (Seconds (100.));
// Increase UDP Rate
Simulator::Schedule (Seconds(30.0), &IncRate, app2, DataRate("500kbps"));
// Flow Monitor
Ptr<FlowMonitor> flowmon;
if (enableFlowMonitor)
{
FlowMonitorHelper flowmonHelper;
flowmon = flowmonHelper.InstallAll ();
}
//
// Now, do the actual simulation.
//
NS_LOG_INFO ("Run Simulation.");
Simulator::Stop (Seconds(100.0));
Simulator::Run ();
if (enableFlowMonitor)
{
flowmon->CheckForLostPackets ();
flowmon->SerializeToXmlFile("lab-2.flowmon", true, true);
}
Simulator::Destroy ();
NS_LOG_INFO ("Done.");
}
2015年1月19日 星期一
Finish Project
Open Source Download
NS2 With 802.11e
─ https://drive.google.com/file/d/0B3oQRnn9BPSGaTJZby04aTA3NTg/view?usp=sharing
NS2 with WiMAX
─ https://drive.google.com/file/d/0B3oQRnn9BPSGVDZfOEdMMVhRc0E/view?usp=sharing
LTE-Sim with ABS
─https://drive.google.com/file/d/0B3oQRnn9BPSGR29LZktYRXpOQUk/view?usp=sharing
Need to modify
JSVM 9.18(Windows)
─ https://drive.google.com/file/d/0B3oQRnn9BPSGZzhqRUl4cDYtLXc/view?usp=sharing
目前正在研發
NS3 Multi-RAT (WiFi +LTE) over SVC
最後更新: 20150210
NS2 With 802.11e
─ https://drive.google.com/file/d/0B3oQRnn9BPSGaTJZby04aTA3NTg/view?usp=sharing
NS2 with WiMAX
─ https://drive.google.com/file/d/0B3oQRnn9BPSGVDZfOEdMMVhRc0E/view?usp=sharing
LTE-Sim with ABS
─https://drive.google.com/file/d/0B3oQRnn9BPSGR29LZktYRXpOQUk/view?usp=sharing
Need to modify
JSVM 9.18(Windows)
─ https://drive.google.com/file/d/0B3oQRnn9BPSGZzhqRUl4cDYtLXc/view?usp=sharing
目前正在研發
NS3 Multi-RAT (WiFi +LTE) over SVC
最後更新: 20150210
2014年2月20日 星期四
YUV CIF reference videos (lossless H.264 encoded)
http://www2.tkn.tu-berlin.de/research/evalvid/cif.html
2014年2月19日 星期三
WIFI ON NS3
WIFI on NS-3
written by Junseok KIM, last updated 20 Jan 2010
Ns-3 is a discrete-event network simulator which is developed as a replacement for the ns-2. Of course, it's a free software and you can edit existing codes and implement your algorithms on ns-3. Ns-3 provides more realistic 802.11 module than ns-2. The 802.11 module of ns-3 support the medium access control (MAC) and physical (PHY) layers of IEEE 802.11a/b/e/n/p. (IEEE 802.11e/n/p are not available in basic ns-2) The 802.11 module of ns-3 also supports several rate-adaptation algorithms such as the auto rate fallback (ARF), and the adaptive ARF (AARF). However, this means that it becomes difficult to analyze and edit the 802.11 module, and implement new algorithms on ns-3. I was analyzing and editing the 802.11 module of ns-2 when I was a junior undergraduate student. There are only two C++ files related to 802.11. It was not very difficult to analyze the code of ns-2., but the 802.11 module of ns-3 consists of 50 C++ files. At least 6 C files have to be reviewed thoroughly to understand the basic transmission procedure of the ns-3's 802.11 module. It's a huge amount especially for beginners and I have difficulties to teach young students with this new 802.11 module. In this web-page, I summarize the basic procedure of the 802.11 module of ns-3 in terms of the transmission and reception. I hope this web-page can help you and your research works. If there is any question or problem about this web-page, please email me. Note that I'm not the person who made this 802.11 module and you can read more information about ns-3 and 802.11 module from the ns-3 official site.
Image a messenger program like a MSN. When you send a message to your friend by typing an enter key though the MSN chat window, the application makes the data packet and forwards it to lower layer (i.e., session layer or transmission control protocol (TCP) layer). Eventually, the data packet will be forwarded to MAC layer. However, MAC protocol cannot send the data packet immediately because a lot of data packets, from many applications, are already waiting to transmit. The data packet has to be inserted into the queue (i.e., temporary storage for packets) and wait its turn. In ns-3, the IEEE 802.11 MAC protocol is implemented with several C++ classes. These five classes are most important to understand the basic procedure of the transmission and reception: DcaTxop, DcfManager, MacLow, YansWifiPhy, and YansWifiChannel. DCA and DCF mean the dynamic channel assignment and the discrete contention function respectively. When a data packet is inserted into the queue, DCA and DCF check whether another packet transmission or reception is processing. If there is no other packet, or when the packet transmission is finished, one data packet is extracted from the queue and it is forwarded to MacLow class. MacLow checks whether the data packet is multicast packet, or it requires the ready to send (RTS) or the fragmentation. After estimating the duration of the transmission, MacLow forwards the data packet to YansWifiPhy and YansWifiPhy forwards it to YansWifiChannel, the most lowest protocol layer in the 802.11 module of ns-3. I have seen that many students, including some experts, misunderstand the backoff procedure. The backoff procedure -- selecing a random number and waiting for a short period -- is required only if there is another packet transmission or reception (i.e., channel is busy) when a new data packet is tossed from the upper layer (e.g., routing protocol). This means that if there is no transmission or reception (i.e., channel is idle) for a specific time (i.e., during DIFS), MAC protocol send a data packet immediately when the data packet is tossed from the upper layer.
Here is a simple sample code for a simulation that one of three WiFi nodes is transmitting UDP packets, one WiFi node is recipient, and one WiFi node is overhearing.
The basic procedure of transmission is as follows:
Uppder Layer → WifiNetDevice::Send() # Convert IP address to MAC address; Add LLC header.
→ AdhocWifiMac::Enqueue() # Set Wifi MAC header; Estimate PHY modes (i.e., data rate) supported by destination node.
→ DcaTxop::Queue() # Insert new packet into queue through WifiMacQueue::Enqueue().
→ DcaTxop::StartAccessIfNeeded() # Request Access to DCF manager if there is no packet pending (i.e., if m_accessRequested == true).
→ DcfManager::RequestAccess() # If there is another packet pending, signal a collision through DcaTxop::NotifyCollision() which will select a random back-off number and try to access again.
→ DcfManager::DoGrantAccess() # Check the internal collision among four different queues (for EDCA of IEEE 802.11e).
→ DcfState::NotifyAccessGranted() # Set m_accessRequested as false; Notify that channel access is granted.
→ DcaTxop::NotifyAccessGranted() # Extract one packet from queue; Set new sequence; Check whether this packet is multicast message, or requiring fragment or RTS.
→ MacLow::StartTransmission() # If RTS is required, call SendRtsForPacket(). If not, call SendDataPacket().
→ MacLow::SendDataPacket() # Estimate the duration of sum of transmission, ACK reception, and/or next transmission (for Block ACK or fragmentation).
→ MacLow::ForwardDown() # Toss the packet to PHY layer.
→ YansWifiPhy::SendPacket() # Change current PHY state to TX (this command will eventually inform DCF that a transmission is starting); Toss the packet to CHANNEL layer.
→ YansWifiChannel::Send() # Estimate receive power; Set the propagation delay to trigger YansWifiChannel::Receive() of neighbors after a short period.
The basic procedure of reception is as follows:
YansWifiChannel::Receive() # Triggered after the propagation delay (set by sender through YansWifiChannel::Receive()).
→ YansWifiPhy::StartReceivePacket() # Calculate the current interference level; Drop the received packet if the state of PHY is not idle or the receive power is below than a threshold; Set the delay to trigger YansWifiPhy::EndSync() after the packet transmission.
→ YansWifiPhy::EndSync() # Estimate the packet error rate (PER) from the signal to noise ratio (SNR) (i.e., signal power / (noise + interference power)); If a random value is smaller than the PER value, the packet is dropped.
→ MacLow::ReceiveOk() # If the packet is the RTS packet, schedule MacLow::SendCtsAfterRts(); If it is CTS, schedule MacLow::SendDataAfterCts(); If it is DATA, forward it to the upper; If the destination is me, schedule MacLow::SendAckAfterData().
→ MacRxMiddle::Receive() # Check whether the received packet is a duplicated one with a sequence number.
→ AdhocWifiMac::ForwardUp() # Just forward the received packet to the upper.
→ WifiNetDevice::ForwardUp() → Upper Layer # Unless the destination is other node, forward the received packet to the upper layer.
Since the 802.11 module of ns-3 consists of several C++ classes, some functions are triggered by callback functions. In addition, some class links itself to other classes through Pointers. It is difficult to analyze the 802.11 module of ns-3 especially for who are not familiar to the C++ language. The main reason for use of callback function and class pointers is that the 802.11 module of ns-3 is designed to support different functions and services by replacing a few C++ classes. For example, the 802.11 module of ns-3 provides several rate adaptation algorithms such as the ARF, the AARF, the robust rate adaptation algorithm (RRAA), and etc. You can set a rate adaptation algorithm of a WiFi device by editing a simulation scenario file. You can also set the type of 802.11 devices such as 802.11a/b/g/e/p/n/s. For example, you can make a Wifi access point (AP) which can support the enhanced DCA (which is for QoS aware services) by replacing AdhocWifiMac with QapWifiMac.
Following figure explains briefly the transmission and reception processes:

http://usn.konkuk.ac.kr/~jskim/ns3_wifi.htm
written by Junseok KIM, last updated 20 Jan 2010
Ns-3 is a discrete-event network simulator which is developed as a replacement for the ns-2. Of course, it's a free software and you can edit existing codes and implement your algorithms on ns-3. Ns-3 provides more realistic 802.11 module than ns-2. The 802.11 module of ns-3 support the medium access control (MAC) and physical (PHY) layers of IEEE 802.11a/b/e/n/p. (IEEE 802.11e/n/p are not available in basic ns-2) The 802.11 module of ns-3 also supports several rate-adaptation algorithms such as the auto rate fallback (ARF), and the adaptive ARF (AARF). However, this means that it becomes difficult to analyze and edit the 802.11 module, and implement new algorithms on ns-3. I was analyzing and editing the 802.11 module of ns-2 when I was a junior undergraduate student. There are only two C++ files related to 802.11. It was not very difficult to analyze the code of ns-2., but the 802.11 module of ns-3 consists of 50 C++ files. At least 6 C files have to be reviewed thoroughly to understand the basic transmission procedure of the ns-3's 802.11 module. It's a huge amount especially for beginners and I have difficulties to teach young students with this new 802.11 module. In this web-page, I summarize the basic procedure of the 802.11 module of ns-3 in terms of the transmission and reception. I hope this web-page can help you and your research works. If there is any question or problem about this web-page, please email me. Note that I'm not the person who made this 802.11 module and you can read more information about ns-3 and 802.11 module from the ns-3 official site.
Image a messenger program like a MSN. When you send a message to your friend by typing an enter key though the MSN chat window, the application makes the data packet and forwards it to lower layer (i.e., session layer or transmission control protocol (TCP) layer). Eventually, the data packet will be forwarded to MAC layer. However, MAC protocol cannot send the data packet immediately because a lot of data packets, from many applications, are already waiting to transmit. The data packet has to be inserted into the queue (i.e., temporary storage for packets) and wait its turn. In ns-3, the IEEE 802.11 MAC protocol is implemented with several C++ classes. These five classes are most important to understand the basic procedure of the transmission and reception: DcaTxop, DcfManager, MacLow, YansWifiPhy, and YansWifiChannel. DCA and DCF mean the dynamic channel assignment and the discrete contention function respectively. When a data packet is inserted into the queue, DCA and DCF check whether another packet transmission or reception is processing. If there is no other packet, or when the packet transmission is finished, one data packet is extracted from the queue and it is forwarded to MacLow class. MacLow checks whether the data packet is multicast packet, or it requires the ready to send (RTS) or the fragmentation. After estimating the duration of the transmission, MacLow forwards the data packet to YansWifiPhy and YansWifiPhy forwards it to YansWifiChannel, the most lowest protocol layer in the 802.11 module of ns-3. I have seen that many students, including some experts, misunderstand the backoff procedure. The backoff procedure -- selecing a random number and waiting for a short period -- is required only if there is another packet transmission or reception (i.e., channel is busy) when a new data packet is tossed from the upper layer (e.g., routing protocol). This means that if there is no transmission or reception (i.e., channel is idle) for a specific time (i.e., during DIFS), MAC protocol send a data packet immediately when the data packet is tossed from the upper layer.
Here is a simple sample code for a simulation that one of three WiFi nodes is transmitting UDP packets, one WiFi node is recipient, and one WiFi node is overhearing.
| #include "ns3/core-module.h" #include "ns3/simulator-module.h" #include "ns3/node-module.h" #include "ns3/helper-module.h" #include "ns3/wifi-module.h" #include "ns3/mobility-module.h" using namespace ns3; int main (int argc, char *argv[]) { NodeContainer wifiNodes; wifiNodes.Create (3); YansWifiPhyHelper wifiPhy = YansWifiPhyHelper::Default (); YansWifiChannelHelper wifiChannel = YansWifiChannelHelper::Default (); wifiPhy.SetChannel (wifiChannel.Create ()); WifiHelper wifi = WifiHelper::Default (); NqosWifiMacHelper wifiMac = NqosWifiMacHelper::Default (); wifi.SetRemoteStationManager ("ns3::ConstantRateWifiManager"); wifiMac.SetType("ns3::AdhocWifiMac"); NetDeviceContainer wifiDevices = wifi.Install( wifiPhy, wifiMac, wifiNodes ); 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.SetMobilityModel ("ns3::ConstantPositionMobilityModel"); mobility.Install (wifiNodes); InternetStackHelper internet; internet.Install (wifiNodes); | Ipv4AddressHelper address; address.SetBase ("10.1.1.0", "255.255.255.0"); Ipv4InterfaceContainer wifiInterfaces; wifiInterfaces = address.Assign( wifiDevices ); UdpEchoServerHelper echoServer (9); ApplicationContainer serverApps = echoServer.Install (wifiNodes.Get( 0 )); serverApps.Start (Seconds (1.0)); serverApps.Stop (Seconds (10.0)); UdpEchoClientHelper echoClient (wifiInterfaces.GetAddress (0), 9); echoClient.SetAttribute ("MaxPackets", UintegerValue (2)); echoClient.SetAttribute ("Interval", TimeValue (Seconds (1.))); echoClient.SetAttribute ("PacketSize", UintegerValue (1024)); ApplicationContainer clientApps = echoClient.Install ( wifiNodes.Get( 2 ) ); clientApps.Start( Seconds (2.0) ); clientApps.Stop( Seconds (10.0) ); Ipv4GlobalRoutingHelper::PopulateRoutingTables (); Simulator::Stop (Seconds (5.05)); Simulator::Run (); Simulator::Destroy (); return 0; } |
Uppder Layer → WifiNetDevice::Send() # Convert IP address to MAC address; Add LLC header.
→ AdhocWifiMac::Enqueue() # Set Wifi MAC header; Estimate PHY modes (i.e., data rate) supported by destination node.
→ DcaTxop::Queue() # Insert new packet into queue through WifiMacQueue::Enqueue().
→ DcaTxop::StartAccessIfNeeded() # Request Access to DCF manager if there is no packet pending (i.e., if m_accessRequested == true).
→ DcfManager::RequestAccess() # If there is another packet pending, signal a collision through DcaTxop::NotifyCollision() which will select a random back-off number and try to access again.
→ DcfManager::DoGrantAccess() # Check the internal collision among four different queues (for EDCA of IEEE 802.11e).
→ DcfState::NotifyAccessGranted() # Set m_accessRequested as false; Notify that channel access is granted.
→ DcaTxop::NotifyAccessGranted() # Extract one packet from queue; Set new sequence; Check whether this packet is multicast message, or requiring fragment or RTS.
→ MacLow::StartTransmission() # If RTS is required, call SendRtsForPacket(). If not, call SendDataPacket().
→ MacLow::SendDataPacket() # Estimate the duration of sum of transmission, ACK reception, and/or next transmission (for Block ACK or fragmentation).
→ MacLow::ForwardDown() # Toss the packet to PHY layer.
→ YansWifiPhy::SendPacket() # Change current PHY state to TX (this command will eventually inform DCF that a transmission is starting); Toss the packet to CHANNEL layer.
→ YansWifiChannel::Send() # Estimate receive power; Set the propagation delay to trigger YansWifiChannel::Receive() of neighbors after a short period.
The basic procedure of reception is as follows:
YansWifiChannel::Receive() # Triggered after the propagation delay (set by sender through YansWifiChannel::Receive()).
→ YansWifiPhy::StartReceivePacket() # Calculate the current interference level; Drop the received packet if the state of PHY is not idle or the receive power is below than a threshold; Set the delay to trigger YansWifiPhy::EndSync() after the packet transmission.
→ YansWifiPhy::EndSync() # Estimate the packet error rate (PER) from the signal to noise ratio (SNR) (i.e., signal power / (noise + interference power)); If a random value is smaller than the PER value, the packet is dropped.
→ MacLow::ReceiveOk() # If the packet is the RTS packet, schedule MacLow::SendCtsAfterRts(); If it is CTS, schedule MacLow::SendDataAfterCts(); If it is DATA, forward it to the upper; If the destination is me, schedule MacLow::SendAckAfterData().
→ MacRxMiddle::Receive() # Check whether the received packet is a duplicated one with a sequence number.
→ AdhocWifiMac::ForwardUp() # Just forward the received packet to the upper.
→ WifiNetDevice::ForwardUp() → Upper Layer # Unless the destination is other node, forward the received packet to the upper layer.
Since the 802.11 module of ns-3 consists of several C++ classes, some functions are triggered by callback functions. In addition, some class links itself to other classes through Pointers. It is difficult to analyze the 802.11 module of ns-3 especially for who are not familiar to the C++ language. The main reason for use of callback function and class pointers is that the 802.11 module of ns-3 is designed to support different functions and services by replacing a few C++ classes. For example, the 802.11 module of ns-3 provides several rate adaptation algorithms such as the ARF, the AARF, the robust rate adaptation algorithm (RRAA), and etc. You can set a rate adaptation algorithm of a WiFi device by editing a simulation scenario file. You can also set the type of 802.11 devices such as 802.11a/b/g/e/p/n/s. For example, you can make a Wifi access point (AP) which can support the enhanced DCA (which is for QoS aware services) by replacing AdhocWifiMac with QapWifiMac.
Following figure explains briefly the transmission and reception processes:

http://usn.konkuk.ac.kr/~jskim/ns3_wifi.htm
訂閱:
意見 (Atom)