Difference between revisions of "Ns-3-Network-Simulator/C3/Infrastructure-based-Wireless-Network/English"

From Script | Spoken-Tutorial
Jump to: navigation, search
(Created page with "{| border="1" |- || '''Visual Cue''' || '''Narration''' |- || Show Slide: '''Title Slide''' || Welcome to Spoken tutorial on '''Infrastructure''' '''based''' '''wireless netwo...")
 
Line 6: Line 6:
 
|| Show Slide: '''Title Slide'''
 
|| Show Slide: '''Title Slide'''
 
|| Welcome to Spoken tutorial on '''Infrastructure''' '''based''' '''wireless network'''.
 
|| Welcome to Spoken tutorial on '''Infrastructure''' '''based''' '''wireless network'''.
|- style="border:1pt solid #000000;padding-top:0cm;padding-bottom:0cm;padding-left:0.206cm;padding-right:0.191cm;"
+
|-  
 
|| Show Slide:
 
|| Show Slide:
  
 
'''Learning Objectives'''
 
'''Learning Objectives'''
 
|| In this tutorial, we will learn to
 
|| In this tutorial, we will learn to
* <div style="margin-left:1.27cm;margin-right:0cm;">Create an '''infrastructure''' based '''wireless network'''.</div>
+
* Create an '''infrastructure''' based '''wireless network'''.
* <div style="margin-left:1.27cm;margin-right:0cm;">Create three '''UDP flows''' in the channels.</div>
+
* Create three '''UDP flows''' in the channels.
* <div style="margin-left:1.27cm;margin-right:0cm;">Analyze the flow using a '''flow monitor'''.</div>
+
* Analyze the flow using a '''flow monitor'''.
* <div style="margin-left:1.27cm;margin-right:0cm;">Visualize the network using '''NetAnim'''.</div>
+
* Visualize the network using '''NetAnim'''.
  
 
|-
 
|-
|- style="border:1pt solid #000000;padding-top:0cm;padding-bottom:0cm;padding-left:0.206cm;padding-right:0.191cm;"
+
|-  
 
|| Show Slide:  
 
|| Show Slide:  
  
 
'''System Requirements'''
 
'''System Requirements'''
 
|| To record this tutorial, I am using
 
|| To record this tutorial, I am using
* <div style="margin-left:1.27cm;margin-right:0cm;">'''Ubuntu Linux OS version 22.04.'''</div>
+
* '''Ubuntu Linux OS version 22.04.'''
* <div style="margin-left:1.27cm;margin-right:0cm;">'''ns-3 version '''3.38.</div>
+
* '''ns-3 version '''3.38.
* <div style="margin-left:1.27cm;margin-right:0cm;">'''NetAnim''' visualizer tool.</div>
+
* '''NetAnim''' visualizer tool.
  
|- style="border:1pt solid #000000;padding-top:0cm;padding-bottom:0cm;padding-left:0.206cm;padding-right:0.191cm;"
+
|-  
 
|| Show slide:
 
|| Show slide:
  
 
'''Pre-requisites'''
 
'''Pre-requisites'''
 
|| To follow this tutorial:
 
|| To follow this tutorial:
* <div style="margin-left:1.27cm;margin-right:0cm;">The learner must have basic knowledge of ns-3 software</div>
+
* The learner must have basic knowledge of ns-3 software
* <div style="margin-left:1.27cm;margin-right:0cm;">For pre-requisite ns-3 tutorials, please visit this website [https://spoken-tutorial.org/ https://spoken-tutorial.org]</div>
+
* For pre-requisite ns-3 tutorials, please visit this website [https://spoken-tutorial.org/ https://spoken-tutorial.org]
  
|- style="border:0.6pt solid #808080;padding:0.176cm;"
+
|-  
|| <div style="color:#252525;">Show Slide:</div>
+
|| Show Slide:
  
<div style="color:#252525;">'''Code Files'''</div>
+
'''Code Files'''
 
||  
 
||  
* <div style="margin-left:1.87cm;margin-right:0cm;"><span style="color:#252525;">The files used in this tutorial are provided in the </span><span style="color:#252525;">'''Code files'''</span><span style="color:#252525;"> link.</span></div>
+
* The files used in this tutorial are provided in the'''Code files''' link.
* <div style="margin-left:1.87cm;margin-right:0cm;"><span style="color:#252525;">Please download and extract the </span><span style="color:#000000;">files</span><span style="color:#252525;">.</span></div>
+
* Please download and extract the files.
* <div style="color:#252525;margin-left:1.87cm;margin-right:0cm;">Make a copy and then use them while practicing.</div>
+
* Make a copy and then use them while practicing.
  
|- style="border:1pt solid #000000;padding-top:0cm;padding-bottom:0cm;padding-left:0.206cm;padding-right:0.191cm;"
+
|-  
 
|| Show Slide:  
 
|| Show Slide:  
  
Line 52: Line 52:
  
 
'''Node 1''' is the '''access point '''of the '''infrastructure'''.
 
'''Node 1''' is the '''access point '''of the '''infrastructure'''.
|- style="border:1pt solid #000000;padding-top:0cm;padding-bottom:0cm;padding-left:0.206cm;padding-right:0.191cm;"
+
|-  
 
||  
 
||  
 
|| Now, let us learn about '''DSSS'''.
 
|| Now, let us learn about '''DSSS'''.
|- style="border:1pt solid #000000;padding-top:0cm;padding-bottom:0cm;padding-left:0.206cm;padding-right:0.191cm;"
+
|-  
 
|| Show Slide:
 
|| Show Slide:
  
Line 65: Line 65:
 
In a '''DSSS system''', data is spread over a '''wider bandwidth''' using a '''spreading code'''.  
 
In a '''DSSS system''', data is spread over a '''wider bandwidth''' using a '''spreading code'''.  
  
|- style="border:1pt solid #000000;padding-top:0cm;padding-bottom:0cm;padding-left:0.206cm;padding-right:0.191cm;"
+
|-  
 
|| Show Slide:
 
|| Show Slide:
  
Line 73: Line 73:
  
 
'''DSSS''' can transfer up to''' 11 Mbps''' of '''data.'''
 
'''DSSS''' can transfer up to''' 11 Mbps''' of '''data.'''
|- style="border:1pt solid #000000;padding-top:0cm;padding-bottom:0cm;padding-left:0.206cm;padding-right:0.191cm;"
+
|-  
 
|| Open code editor
 
|| Open code editor
 
|| I have created the source file '''wifi-simple-infra.cc''' for this program.
 
|| I have created the source file '''wifi-simple-infra.cc''' for this program.
Line 80: Line 80:
  
 
Now we will go through the source code in the text editor.
 
Now we will go through the source code in the text editor.
|- style="border:1pt solid #000000;padding-top:0cm;padding-bottom:0cm;padding-left:0.206cm;padding-right:0.191cm;"
+
|-  
 
|| Highlight '''std::string phyMode("DsssRate1Mbps");'''
 
|| Highlight '''std::string phyMode("DsssRate1Mbps");'''
 
|| We set the '''dsss rate''' of the '''physical layer''' to '''1 Mbps'''.
 
|| We set the '''dsss rate''' of the '''physical layer''' to '''1 Mbps'''.
|- style="border:1pt solid #000000;padding-top:0cm;padding-bottom:0cm;padding-left:0.206cm;padding-right:0.191cm;"
+
|-  
 
|| Highlight '''double rss = -80'''
 
|| Highlight '''double rss = -80'''
 
|| Next, we’ll set the''' Received Signal Strength '''or''' RSS''' to '''-80 dBm.'''
 
|| Next, we’ll set the''' Received Signal Strength '''or''' RSS''' to '''-80 dBm.'''
|- style="border:1pt solid #000000;padding-top:0cm;padding-bottom:0cm;padding-left:0.206cm;padding-right:0.191cm;"
+
|-  
 
|| Highlight '''uint32_t packetSize = 1000;'''
 
|| Highlight '''uint32_t packetSize = 1000;'''
  
Line 93: Line 93:
  
 
Then we’ll set the '''number of packets''' to be transmitted as '''100'''.
 
Then we’ll set the '''number of packets''' to be transmitted as '''100'''.
|- style="border:1pt solid #000000;padding-top:0cm;padding-bottom:0cm;padding-left:0.206cm;padding-right:0.191cm;"
+
|-  
 
|| Highlight '''Time interval = Seconds(0.003);'''
 
|| Highlight '''Time interval = Seconds(0.003);'''
 
|| Further, we set the '''time interval''' between the '''packet transfer''' as '''0.003 seconds'''.
 
|| Further, we set the '''time interval''' between the '''packet transfer''' as '''0.003 seconds'''.
|- style="border:1pt solid #000000;padding-top:0cm;padding-bottom:0cm;padding-left:0.206cm;padding-right:0.191cm;"
+
|-  
 
|| Highlight '''uint32_t sinkNode = 1;'''
 
|| Highlight '''uint32_t sinkNode = 1;'''
  
Line 102: Line 102:
  
 
|| Let us set up the '''source''' and''' sink nodes''' for the '''flow''' that we are yet to create.
 
|| Let us set up the '''source''' and''' sink nodes''' for the '''flow''' that we are yet to create.
|- style="border:1pt solid #000000;padding-top:0cm;padding-bottom:0cm;padding-left:0.206cm;padding-right:0.191cm;"
+
|-  
 
|| Highlight '''Config::SetDefault("ns3::WifiRemoteStationManager::NonUnicastMode", StringValue(phyMode));'''
 
|| Highlight '''Config::SetDefault("ns3::WifiRemoteStationManager::NonUnicastMode", StringValue(phyMode));'''
  
Line 109: Line 109:
 
'''Non-unicast mode''' means that the data may be sent from one node to many nodes.
 
'''Non-unicast mode''' means that the data may be sent from one node to many nodes.
  
|- style="border:1pt solid #000000;padding-top:0cm;padding-bottom:0cm;padding-left:0.206cm;padding-right:0.191cm;"
+
|-  
 
|| Highlight '''NodeContainer c;'''
 
|| Highlight '''NodeContainer c;'''
  
Line 115: Line 115:
  
 
|| Now, let us create a '''node container''' with '''four nodes'''.
 
|| Now, let us create a '''node container''' with '''four nodes'''.
|- style="border:1pt solid #000000;padding-top:0cm;padding-bottom:0cm;padding-left:0.206cm;padding-right:0.191cm;"
+
|-  
 
|| Highlight '''WifiHelper wifi;'''
 
|| Highlight '''WifiHelper wifi;'''
  
Line 127: Line 127:
  
 
Here, the '''standard''' set is '''IEEE 802.11b.'''
 
Here, the '''standard''' set is '''IEEE 802.11b.'''
|- style="border:1pt solid #000000;padding-top:0cm;padding-bottom:0cm;padding-left:0.206cm;padding-right:0.191cm;"
+
|-  
 
|| Highlight '''YansWifiPhyHelper wifiPhy;'''
 
|| Highlight '''YansWifiPhyHelper wifiPhy;'''
  
Line 135: Line 135:
  
 
'''RxGain''' is used to adjust the sensitivity of the receiving signal.
 
'''RxGain''' is used to adjust the sensitivity of the receiving signal.
|- style="border:1pt solid #000000;padding-top:0cm;padding-bottom:0cm;padding-left:0.206cm;padding-right:0.191cm;"
+
|-  
 
|| Highlight '''YansWifiChannelHelper wifiChannel;'''
 
|| Highlight '''YansWifiChannelHelper wifiChannel;'''
  
Line 144: Line 144:
  
 
Let us set the '''Propagation delay''' and '''add '''the '''propagation loss''' to our model.
 
Let us set the '''Propagation delay''' and '''add '''the '''propagation loss''' to our model.
|- style="border:1pt solid #000000;padding-top:0cm;padding-bottom:0cm;padding-left:0.206cm;padding-right:0.191cm;"
+
|-  
 
|| Highlight '''wifiPhy.SetChannel(wifiChannel.Create());'''
 
|| Highlight '''wifiPhy.SetChannel(wifiChannel.Create());'''
 
|| Next, we connect the''' wifi physical layer '''to the '''wifi-channel'''.
 
|| Next, we connect the''' wifi physical layer '''to the '''wifi-channel'''.
|- style="border:1pt solid #000000;padding-top:0cm;padding-bottom:0cm;padding-left:0.206cm;padding-right:0.191cm;"
+
|-  
 
|| Highlight '''WifiMacHelper wifiMac;'''
 
|| Highlight '''WifiMacHelper wifiMac;'''
  
Line 155: Line 155:
  
 
Then we set a '''constant rate''' for '''data''' and '''control modes '''of '''wifi stations.'''
 
Then we set a '''constant rate''' for '''data''' and '''control modes '''of '''wifi stations.'''
|- style="border:1pt solid #000000;padding-top:0cm;padding-bottom:0cm;padding-left:0.206cm;padding-right:0.191cm;"
+
|-  
 
|| Highlight '''Ssid ssid = Ssid("wifi-default");'''
 
|| Highlight '''Ssid ssid = Ssid("wifi-default");'''
 
|| Then, we assign '''SSID '''to the network.
 
|| Then, we assign '''SSID '''to the network.
  
 
'''SSID''' or '''Service Set Identifier''' is a sequence of characters uniquely identifying a network.  
 
'''SSID''' or '''Service Set Identifier''' is a sequence of characters uniquely identifying a network.  
|- style="border:1pt solid #000000;padding-top:0cm;padding-bottom:0cm;padding-left:0.206cm;padding-right:0.191cm;"
+
|-  
 
|| Highlight '''wifiMac.SetType("ns3::StaWifiMac", "Ssid", SsidValue(ssid));'''
 
|| Highlight '''wifiMac.SetType("ns3::StaWifiMac", "Ssid", SsidValue(ssid));'''
  
Line 171: Line 171:
  
 
As a next step, we shall take a copy of '''staDevice container '''in '''devices container.'''
 
As a next step, we shall take a copy of '''staDevice container '''in '''devices container.'''
|- style="border:1pt solid #000000;padding-top:0cm;padding-bottom:0cm;padding-left:0.206cm;padding-right:0.191cm;"
+
|-  
 
|| Highlight  
 
|| Highlight  
  
Line 187: Line 187:
  
 
Then '''ssid''' is assigned to the '''AP node''' of the network.
 
Then '''ssid''' is assigned to the '''AP node''' of the network.
|- style="border:1pt solid #000000;padding-top:0cm;padding-bottom:0cm;padding-left:0.206cm;padding-right:0.191cm;"
+
|-  
 
|| Highlight '''MobilityHelper mobility;'''
 
|| Highlight '''MobilityHelper mobility;'''
  
Line 196: Line 196:
 
'''mobility.SetPositionAllocator(positionAlloc);'''
 
'''mobility.SetPositionAllocator(positionAlloc);'''
 
|| Now set up '''mobility '''for the nodes by allocating '''positions '''for the '''nodes''' created.
 
|| Now set up '''mobility '''for the nodes by allocating '''positions '''for the '''nodes''' created.
|- style="border:1pt solid #000000;padding-top:0cm;padding-bottom:0cm;padding-left:0.206cm;padding-right:0.191cm;"
+
|-  
 
|| Highlight '''mobility.SetMobilityModel("ns3::ConstantPositionMobilityModel");'''
 
|| Highlight '''mobility.SetMobilityModel("ns3::ConstantPositionMobilityModel");'''
  
Line 206: Line 206:
  
 
Also, '''install '''the''' model '''that we '''set,''' to all the '''nodes''' that we created.
 
Also, '''install '''the''' model '''that we '''set,''' to all the '''nodes''' that we created.
|- style="border:1pt solid #000000;padding-top:0cm;padding-bottom:0cm;padding-left:0.206cm;padding-right:0.191cm;"
+
|-  
 
|| Highlight '''InternetStackHelper internet;'''
 
|| Highlight '''InternetStackHelper internet;'''
  
Line 212: Line 212:
  
 
|| Then let us install the''' internet stack''' on all the nodes.
 
|| Then let us install the''' internet stack''' on all the nodes.
|- style="border:1pt solid #000000;padding-top:0cm;padding-bottom:0cm;padding-left:0.206cm;padding-right:0.191cm;"
+
|-  
 
|| Highlight '''Ipv4AddressHelper ipv4;'''
 
|| Highlight '''Ipv4AddressHelper ipv4;'''
  
Line 220: Line 220:
  
 
|| Now, we shall '''assign IP addresses''' to the '''nodes''' that we created
 
|| Now, we shall '''assign IP addresses''' to the '''nodes''' that we created
|- style="border:1pt solid #000000;padding-top:0cm;padding-bottom:0cm;padding-left:0.206cm;padding-right:0.191cm;"
+
|-  
 
|| Highlight '''TypeId tid = TypeId::LookupByName("ns3::UdpSocketFactory");'''
 
|| Highlight '''TypeId tid = TypeId::LookupByName("ns3::UdpSocketFactory");'''
  
 
|| The highlighted command is used to get the '''TypeId''' of '''UdpSocketFactory.'''
 
|| The highlighted command is used to get the '''TypeId''' of '''UdpSocketFactory.'''
  
|- style="border:1pt solid #000000;padding-top:0cm;padding-bottom:0cm;padding-left:0.206cm;padding-right:0.191cm;"
+
|-  
 
|| Highlight '''Ptr<Socket> recvSink = Socket::CreateSocket(c.Get(sinkNode), tid);'''
 
|| Highlight '''Ptr<Socket> recvSink = Socket::CreateSocket(c.Get(sinkNode), tid);'''
 
|| We shall create a receiving '''socket''' for the '''UDP Flow'''.  
 
|| We shall create a receiving '''socket''' for the '''UDP Flow'''.  
|- style="border:1pt solid #000000;padding-top:0cm;padding-bottom:0cm;padding-left:0.206cm;padding-right:0.191cm;"
+
|-  
 
|| Highlight '''InetSocketAddress local = InetSocketAddress(Ipv4Address::GetAny(), 80);'''
 
|| Highlight '''InetSocketAddress local = InetSocketAddress(Ipv4Address::GetAny(), 80);'''
 
|| Let us create an '''internet socket''' '''address''' using any '''IPv4 address''' and '''port 80.'''
 
|| Let us create an '''internet socket''' '''address''' using any '''IPv4 address''' and '''port 80.'''
|- style="border:1pt solid #000000;padding-top:0cm;padding-bottom:0cm;padding-left:0.206cm;padding-right:0.191cm;"
+
|-  
 
|| Highlight '''recvSink->Bind(local);'''
 
|| Highlight '''recvSink->Bind(local);'''
 
|| Then '''bind '''the '''receiving socket''' to the '''local addres'''s and to the '''port 80'''.
 
|| Then '''bind '''the '''receiving socket''' to the '''local addres'''s and to the '''port 80'''.
|- style="border:1pt solid #000000;padding-top:0cm;padding-bottom:0cm;padding-left:0.206cm;padding-right:0.191cm;"
+
|-  
|| Highlight <span style="background-color:#ffffff;">'''recvSink->SetRecvCallback(MakeCallback(&ReceivePacket));'''</span>
+
|| Highlight <span style="background-color:#ffffff;">'''recvSink->SetRecvCallback(MakeCallback(&ReceivePacket));'''
 
|| Now set the '''receive''' '''callback function''' for the '''receiving socket'''.
 
|| Now set the '''receive''' '''callback function''' for the '''receiving socket'''.
  
 
When the '''packet '''is received in the '''sinknode''', we call '''RecievePacket function'''.
 
When the '''packet '''is received in the '''sinknode''', we call '''RecievePacket function'''.
|- style="border:1pt solid #000000;padding-top:0cm;padding-bottom:0cm;padding-left:0.206cm;padding-right:0.191cm;"
+
|-  
 
|| Highlight '''Ptr<Socket> source = Socket::CreateSocket(c.Get(sourceNode), tid);'''
 
|| Highlight '''Ptr<Socket> source = Socket::CreateSocket(c.Get(sourceNode), tid);'''
 
|| Let us then '''create''' a'''n UDP socket '''on '''node 0, '''which is our '''sourceNode'''.
 
|| Let us then '''create''' a'''n UDP socket '''on '''node 0, '''which is our '''sourceNode'''.
|- style="border:1pt solid #000000;padding-top:0cm;padding-bottom:0cm;padding-left:0.206cm;padding-right:0.191cm;"
+
|-  
 
|| Highlight '''InetSocketAddress remote = InetSocketAddress(i.GetAddress(sinkNode, 0), 80);'''
 
|| Highlight '''InetSocketAddress remote = InetSocketAddress(i.GetAddress(sinkNode, 0), 80);'''
 
|| We shall create an''' internet socket '''using '''Ipv4 address''' of '''sinknode''' and '''port 80'''.
 
|| We shall create an''' internet socket '''using '''Ipv4 address''' of '''sinknode''' and '''port 80'''.
|- style="border:1pt solid #000000;padding-top:0cm;padding-bottom:0cm;padding-left:0.206cm;padding-right:0.191cm;"
+
|-  
 
|| Highlight '''source->Connect(remote);'''
 
|| Highlight '''source->Connect(remote);'''
 
|| Let us connect the '''source socket '''to the '''remote address''' and '''port 80.'''  
 
|| Let us connect the '''source socket '''to the '''remote address''' and '''port 80.'''  
|- style="border:1pt solid #000000;padding-top:0cm;padding-bottom:0cm;padding-left:0.206cm;padding-right:0.191cm;"
+
|-  
 
|| Highlight '''void'''
 
|| Highlight '''void'''
  
Line 262: Line 262:
  
 
Here, we are invoking the '''receive functionality''' of the '''socket'''.  
 
Here, we are invoking the '''receive functionality''' of the '''socket'''.  
|- style="border:1pt solid #000000;padding-top:0cm;padding-bottom:0cm;padding-left:0.206cm;padding-right:0.191cm;"
+
|-  
 
|| Highlight '''static void'''
 
|| Highlight '''static void'''
  
Line 268: Line 268:
  
 
|| Then we define a '''function '''called '''generate packet traffic'''.  
 
|| Then we define a '''function '''called '''generate packet traffic'''.  
|- style="border:1pt solid #000000;padding-top:0cm;padding-bottom:0cm;padding-left:0.206cm;padding-right:0.191cm;"
+
|-  
 
|| Highlight '''if (pktCount > 0)'''
 
|| Highlight '''if (pktCount > 0)'''
  
Line 303: Line 303:
  
 
Then, we '''stop invoking send function'''.
 
Then, we '''stop invoking send function'''.
|- style="border:1pt solid #000000;padding-top:0cm;padding-bottom:0cm;padding-left:0.206cm;padding-right:0.191cm;"
+
|-  
 
|| Only Narration
 
|| Only Narration
 
|| We have created''' two''' other '''UDP flows as well'''.
 
|| We have created''' two''' other '''UDP flows as well'''.
  
|- style="border:1pt solid #000000;padding-top:0cm;padding-bottom:0cm;padding-left:0.206cm;padding-right:0.191cm;"
+
|-  
 
|| Highlight '''Simulator::Schedule(Seconds('''
 
|| Highlight '''Simulator::Schedule(Seconds('''
  
Line 314: Line 314:
  
 
This procedure happens after '''ten seconds '''from the start''' of execution'''.
 
This procedure happens after '''ten seconds '''from the start''' of execution'''.
|- style="border:1pt solid #000000;padding-top:0cm;padding-bottom:0cm;padding-left:0.206cm;padding-right:0.191cm;"
+
|-  
 
|| Highlight '''Ptr<FlowMonitor> flowMonitor;'''
 
|| Highlight '''Ptr<FlowMonitor> flowMonitor;'''
 
|| Then, '''Initialize''' '''flow monitor''' for '''tracing.'''
 
|| Then, '''Initialize''' '''flow monitor''' for '''tracing.'''
|- style="border:1pt solid #000000;padding-top:0cm;padding-bottom:0cm;padding-left:0.206cm;padding-right:0.191cm;"
+
|-  
 
|| HIghlight '''FlowMonitorHelper flowHelper;'''
 
|| HIghlight '''FlowMonitorHelper flowHelper;'''
  
Line 323: Line 323:
  
 
|| We shall then install a '''flow monitor''' on all the '''nodes'''.
 
|| We shall then install a '''flow monitor''' on all the '''nodes'''.
|- style="border:1pt solid #000000;padding-top:0cm;padding-bottom:0cm;padding-left:0.206cm;padding-right:0.191cm;"
+
|-  
 
|| Highlight '''AnimationInterface anim ("animationwifi-infra-2.xml"); '''
 
|| Highlight '''AnimationInterface anim ("animationwifi-infra-2.xml"); '''
 
|| Let us create the''' XML output''' of the program.
 
|| Let us create the''' XML output''' of the program.
|- style="border:1pt solid #000000;padding-top:0cm;padding-bottom:0cm;padding-left:0.206cm;padding-right:0.191cm;"
+
|-  
 
|| HIghlight '''Ptr<Ipv4FlowClassifier> classifier=DynamicCast<Ipv4FlowClassifier> (flowHelper.GetClassifier());'''
 
|| HIghlight '''Ptr<Ipv4FlowClassifier> classifier=DynamicCast<Ipv4FlowClassifier> (flowHelper.GetClassifier());'''
 
|| Let us further create an object of the '''Ipv4FlowClassifier class.'''
 
|| Let us further create an object of the '''Ipv4FlowClassifier class.'''
Line 332: Line 332:
 
The created '''object '''returns a''' pointer''' to the '''flow classifier.'''
 
The created '''object '''returns a''' pointer''' to the '''flow classifier.'''
  
|- style="border:1pt solid #000000;padding-top:0cm;padding-bottom:0cm;padding-left:0.206cm;padding-right:0.191cm;"
+
|-  
 
|| Highlight '''std::map<FlowId,FlowMonitor::FlowStats> stats=flowMonitor->GetFlowStats();'''
 
|| Highlight '''std::map<FlowId,FlowMonitor::FlowStats> stats=flowMonitor->GetFlowStats();'''
 
|| To store the information about the '''network flow, '''let us use this command.
 
|| To store the information about the '''network flow, '''let us use this command.
|- style="border:1pt solid #000000;padding-top:0cm;padding-bottom:0cm;padding-left:0.206cm;padding-right:0.191cm;"
+
|-  
 
|| Highlight the '''entire for loop.'''
 
|| Highlight the '''entire for loop.'''
 
|| Let’s retrieve the details of the flow using a '''for loop.'''
 
|| Let’s retrieve the details of the flow using a '''for loop.'''
Line 345: Line 345:
 
We will analyze the '''type of flow''' and '''print''' the''' delay''' and '''throughput'''.
 
We will analyze the '''type of flow''' and '''print''' the''' delay''' and '''throughput'''.
  
|- style="border:1pt solid #000000;padding-top:0cm;padding-bottom:0cm;padding-left:0.206cm;padding-right:0.191cm;"
+
|-  
 
|| Highlight '''Simulator::Destroy()'''
 
|| Highlight '''Simulator::Destroy()'''
 
|| The '''Destroy() '''function ends the simulation.
 
|| The '''Destroy() '''function ends the simulation.
  
|- style="border:1pt solid #000000;padding-top:0cm;padding-bottom:0cm;padding-left:0.206cm;padding-right:0.191cm;"
+
|-  
 
|| Press '''Ctrl, Alt '''and '''T keys''' simultaneously
 
|| Press '''Ctrl, Alt '''and '''T keys''' simultaneously
  
Line 364: Line 364:
  
 
Move your '''source file''' to the '''scratch '''directory within the '''ns-3.38''' '''directory'''.
 
Move your '''source file''' to the '''scratch '''directory within the '''ns-3.38''' '''directory'''.
|- style="border:1pt solid #000000;padding-top:0cm;padding-bottom:0cm;padding-left:0.206cm;padding-right:0.191cm;"
+
|-  
 
|| Type ./'''ns3 run scratch/wifi-simple-infra.cc'''
 
|| Type ./'''ns3 run scratch/wifi-simple-infra.cc'''
 
|| Run the command ./'''ns3 run scratch/wifi-simple-infra.cc '''
 
|| Run the command ./'''ns3 run scratch/wifi-simple-infra.cc '''
  
 
'''wifi-simple-infra.cc '''is the name of the source file.  
 
'''wifi-simple-infra.cc '''is the name of the source file.  
|- style="border:1pt solid #000000;padding-top:0cm;padding-bottom:0cm;padding-left:0.206cm;padding-right:0.191cm;"
+
|-  
 
|| Keep the terminal open and show the output of the command  
 
|| Keep the terminal open and show the output of the command  
 
|| After compilation, we get the details of each '''packet transfer'''.
 
|| After compilation, we get the details of each '''packet transfer'''.
Line 377: Line 377:
 
We also see the '''average end to end delay''' and '''throughput''' of the '''wireless network'''.
 
We also see the '''average end to end delay''' and '''throughput''' of the '''wireless network'''.
  
|- style="border:1pt solid #000000;padding-top:0cm;padding-bottom:0cm;padding-left:0.206cm;padding-right:0.191cm;"
+
|-  
 
|| Navigate to '''netanim '''directory under '''ns-allinone-3.38'''
 
|| Navigate to '''netanim '''directory under '''ns-allinone-3.38'''
  
Line 390: Line 390:
  
 
Then type '''cd netanim'''
 
Then type '''cd netanim'''
|- style="border:1pt solid #000000;padding-top:0cm;padding-bottom:0cm;padding-left:0.206cm;padding-right:0.191cm;"
+
|-  
 
|| Type ./'''NetAnim'''
 
|| Type ./'''NetAnim'''
 
|| Now type '''./NetAnim. '''
 
|| Now type '''./NetAnim. '''
  
 
The '''NetAnim''' window should open.
 
The '''NetAnim''' window should open.
|- style="border:1pt solid #000000;padding-top:0cm;padding-bottom:0cm;padding-left:0.206cm;padding-right:0.191cm;"
+
|-  
 
|| Click on the Open''' XML trace file '''icon on the top left corner of the window.
 
|| Click on the Open''' XML trace file '''icon on the top left corner of the window.
 
|| Click on the Open''' XML trace file '''icon on the top left corner of the window.
 
|| Click on the Open''' XML trace file '''icon on the top left corner of the window.
|- style="border:1pt solid #000000;padding-top:0cm;padding-bottom:0cm;padding-left:0.206cm;padding-right:0.191cm;"
+
|-  
 
|| In the file picker, navigate to the '''ns-allinone-3.38/ns3.38 '''directory and select the '''animationwifi-infra-2.xml '''file.
 
|| In the file picker, navigate to the '''ns-allinone-3.38/ns3.38 '''directory and select the '''animationwifi-infra-2.xml '''file.
 
|| In the file picker, '''navigate''' to the '''ns-allinone-3.38, '''then to''' ns3.38 '''directory.
 
|| In the file picker, '''navigate''' to the '''ns-allinone-3.38, '''then to''' ns3.38 '''directory.
  
 
Then select the''' animationwifi-infra-2.xml '''file.
 
Then select the''' animationwifi-infra-2.xml '''file.
|- style="border:1pt solid #000000;padding-top:0cm;padding-bottom:0cm;padding-left:0.206cm;padding-right:0.191cm;"
+
|-  
 
|| On the toolbar, click on the '''play button'''
 
|| On the toolbar, click on the '''play button'''
  
Line 412: Line 412:
  
 
Now, we can close the '''NetAnim''' window.
 
Now, we can close the '''NetAnim''' window.
|- style="border:1pt solid #000000;padding-top:0cm;padding-bottom:0cm;padding-left:0.206cm;padding-right:0.191cm;"
+
|-  
 
|| Show Slide: '''Summary'''
 
|| Show Slide: '''Summary'''
|| <div style="color:#252525;">This brings us to the end of this tutorial. Let us summarize. </div>
+
|| This brings us to the end of this tutorial. Let us summarize.  
  
<div style="color:#252525;">In this tutorial, we have</div>
+
In this tutorial, we have
  
* <div style="margin-left:1.27cm;margin-right:0cm;">Created an '''infrastructure''' based '''wireless network'''.</div>
+
* Created an '''infrastructure''' based '''wireless network'''.
* <div style="margin-left:1.27cm;margin-right:0cm;">Created three '''UDP flows''' in the channels.</div>
+
* Created three '''UDP flows''' in the channels.
* <div style="margin-left:1.27cm;margin-right:0cm;">Analyzed the flow using a '''flow monitor'''.</div>
+
* Analyzed the flow using a '''flow monitor'''.
* <div style="margin-left:1.27cm;margin-right:0cm;">Visualized the network using NetAnim.</div>
+
* Visualized the network using NetAnim.
  
|- style="border:1pt solid #000000;padding-top:0cm;padding-bottom:0cm;padding-left:0.206cm;padding-right:0.191cm;"
+
|-  
 
|| Show Slide : '''Assignment'''
 
|| Show Slide : '''Assignment'''
 
|| As an assignment, please do the following
 
|| As an assignment, please do the following
  
* <div style="margin-left:2.54cm;margin-right:0cm;">Create a '''simulation''' for a''' wireless network''' with three '''nodes'''.</div>
+
* Create a '''simulation''' for a''' wireless network''' with three '''nodes'''.
* <div style="margin-left:2.54cm;margin-right:0cm;">Create one''' access point (AP)''' and two '''stations'''.</div>
+
* Create one''' access point (AP)''' and two '''stations'''.
* <div style="margin-left:2.54cm;margin-right:0cm;">The '''AP '''and '''stations''' should use an '''802.11g physical layer'''.</div>
+
* The '''AP '''and '''stations''' should use an '''802.11g physical layer'''.
* <div style="margin-left:2.54cm;margin-right:0cm;">Implement''' UDP traffic''' between the''' stations''' and the '''AP.'''</div>
+
* Implement''' UDP traffic''' between the''' stations''' and the '''AP.'''
* <div style="margin-left:2.54cm;margin-right:0cm;">Set '''packet size''' as '''1500 bytes''' and send '''200 packets''' from each '''station''' to the''' AP.'''</div>
+
* Set '''packet size''' as '''1500 bytes''' and send '''200 packets''' from each '''station''' to the''' AP.'''
* <div style="margin-left:2.54cm;margin-right:0cm;">Set the''' RSS''' at the '''AP''' to''' -70 dBm'''.</div>
+
* Set the''' RSS''' at the '''AP''' to''' -70 dBm'''.
* <div style="margin-left:2.54cm;margin-right:0cm;">Set the''' interval''' between '''packets''' to '''0.005 seconds.'''</div>
+
* Set the''' interval''' between '''packets''' to '''0.005 seconds.'''
* <div style="margin-left:2.54cm;margin-right:0cm;">Analyze the '''flow''' using '''flow monitor'''.</div>
+
* Analyze the '''flow''' using '''flow monitor'''.
* <div style="margin-left:2.54cm;margin-right:0cm;">'''Visualize''' the '''network''' using '''NetAnim'''.</div>
+
* '''Visualize''' the '''network''' using '''NetAnim'''.
  
|- style="border:1pt solid #000000;padding-top:0cm;padding-bottom:0cm;padding-left:0.206cm;padding-right:0.191cm;"
+
|-  
 
|| Show Slide:
 
|| Show Slide:
  
Line 443: Line 443:
 
|| In the terminal window, you will get the following output.
 
|| In the terminal window, you will get the following output.
  
|- style="border:1pt solid #000000;padding-top:0cm;padding-bottom:0cm;padding-left:0.206cm;padding-right:0.191cm;"
+
|-  
 
|| Show Slide:
 
|| Show Slide:
  
Line 450: Line 450:
  
 
Observe the packet transfer.
 
Observe the packet transfer.
|- style="border:0.75pt solid #808080;padding:0.176cm;"
+
|-  
|| <div style="color:#252525;">Show Slide:</div>
+
|| Show Slide:
  
<div style="color:#252525;">'''About Spoken Tutorial Project'''</div>
+
'''About Spoken Tutorial Project'''
|| <span style="color:#252525;">The video at the following link summarizes the </span><span style="color:#252525;">'''Spoken Tutorial project'''</span><span style="color:#252525;">.</span>
+
|| The video at the following link summarizes the'''Spoken Tutorial project'''.
  
<div style="color:#252525;">Please download and watch it.</div>
+
Please download and watch it.
|- style="border:0.75pt solid #808080;padding:0.176cm;"
+
|-  
|| <div style="color:#252525;">Show Slide:</div>
+
|| Show Slide:
  
<div style="color:#252525;">'''Spoken Tutorial Workshops'''</div>
+
'''Spoken Tutorial Workshops'''
|| <span style="color:#252525;">The </span><span style="color:#252525;">'''Spoken Tutorial Project'''</span><span style="color:#252525;"> team conducts workshops and gives certificates.</span>
+
|| The'''Spoken Tutorial Project''' team conducts workshops and gives certificates.
  
<div style="color:#252525;">For more details, please write to us.</div>
+
For more details, please write to us.
|- style="border:0.75pt solid #808080;padding:0.176cm;"
+
|-  
|| <div style="color:#252525;">Show Slide:</div>
+
|| Show Slide:
  
<div style="color:#252525;">'''Answers for THIS Spoken Tutorial'''</div>
+
'''Answers for THIS Spoken Tutorial'''
 
| style="color:#252525;" | Please post your timed queries in this forum.
 
| style="color:#252525;" | Please post your timed queries in this forum.
|- style="border:0.75pt solid #808080;padding:0.176cm;"
+
|-  
|| <div style="color:#252525;">Show Slide:</div>
+
|| Show Slide:
  
<div style="color:#252525;">'''FOSSEE Forum'''</div>
+
'''FOSSEE Forum'''
|| <span style="color:#252525;">For any general or technical questions on </span><span style="color:#252525;">'''ns-3'''</span><span style="color:#252525;">, visit the</span><span style="color:#252525;">''' FOSSEE forum'''</span><span style="color:#252525;"> and post your question.</span>
+
|| For any general or technical questions on'''ns-3''', visit the''' FOSSEE forum''' and post your question.
|- style="border:0.75pt solid #808080;padding:0.176cm;"
+
|-  
|| <span style="color:#252525;">Show Slide: </span><span style="color:#252525;">'''Acknowledgement'''</span>
+
|| Show Slide:'''Acknowledgement'''
|| <span style="color:#252525;">'''Spoken Tutorial'''</span><span style="color:#252525;"> Project was established by the </span><span style="color:#252525;">'''Ministry of Education, Government of India'''</span><span style="color:#252525;">.</span>
+
|| '''Spoken Tutorial''' Project was established by the'''Ministry of Education, Government of India'''.
|- style="border:0.75pt solid #808080;padding:0.176cm;"
+
|-  
 
|| Show Slide: '''Acknowledgement'''
 
|| Show Slide: '''Acknowledgement'''
|| <span style="color:#252525;">We thank </span><span style="color:#252525;">'''Dr.Moyukh Laha'''</span><span style="color:#252525;"> from </span><span style="color:#252525;">'''IIT Kharagpur'''</span><span style="color:#252525;"> for his domain support.</span>
+
|| We thank'''Dr.Moyukh Laha''' from'''IIT Kharagpur''' for his domain support.
 +
 
 +
We would also like to thank'''Dr. R. Radha, Dr. X. Anita, and Dr.T.Subbulakshmi '''from''' VIT, Chennai '''for their support.
 +
|-
 +
|| Show Slide: Thank you
  
<span style="color:#252525;">We would also like to thank </span><span style="color:#252525;">'''Dr. R. Radha, Dr. X. Anita, and Dr.T.Subbulakshmi '''</span><span style="color:#252525;">from</span><span style="color:#252525;">''' VIT, Chennai '''</span><span style="color:#252525;">for their support.</span>
 
|- style="border:0.75pt solid #808080;padding:0.176cm;"
 
|| <div style="color:#252525;">Show Slide: Thank you</div>
 
  
<div style="color:#252525;"></div>
+
|| This is'''Arun Santhosh''',a FOSSEE Summer Fellow 2023, IIT Bombay signing off.
|| <span style="color:#252525;">This is </span><span style="color:#252525;">'''Arun Santhosh'''</span><span style="color:#252525;">,a FOSSEE Summer Fellow 2023, IIT Bombay signing off.</span>
+
Thank you for joining.
<div style="color:#252525;">Thank you for joining.</div>
+
 
|-
 
|-
 
|}
 
|}

Revision as of 17:49, 8 April 2024

Visual Cue Narration
Show Slide: Title Slide Welcome to Spoken tutorial on Infrastructure based wireless network.
Show Slide:

Learning Objectives

In this tutorial, we will learn to
  • Create an infrastructure based wireless network.
  • Create three UDP flows in the channels.
  • Analyze the flow using a flow monitor.
  • Visualize the network using NetAnim.
Show Slide:

System Requirements

To record this tutorial, I am using
  • Ubuntu Linux OS version 22.04.
  • ns-3 version 3.38.
  • NetAnim visualizer tool.
Show slide:

Pre-requisites

To follow this tutorial:
  • The learner must have basic knowledge of ns-3 software
  • For pre-requisite ns-3 tutorials, please visit this website https://spoken-tutorial.org
Show Slide:

Code Files

  • The files used in this tutorial are provided in theCode files link.
  • Please download and extract the files.
  • Make a copy and then use them while practicing.
Show Slide:

Infrastructure based Wifi network

For this tutorial, we would be creating the below infrastructure.

In this diagram, the nodes 0, 2 and 3 are station nodes.

Node 1 is the access point of the infrastructure.

Now, let us learn about DSSS.
Show Slide:

About DSSS

DSSS rate is data rate in a Wifi system.

It uses Direct Sequence Spread Spectrum modulation.

In a DSSS system, data is spread over a wider bandwidth using a spreading code.

Show Slide:

About DSSS

The spreading code is a sequence of chips that modulates the data signal.

DSSS rate represents the speed of information transmitted after spreading.

DSSS can transfer up to 11 Mbps of data.

Open code editor I have created the source file wifi-simple-infra.cc for this program.

The source code contains the required functions to create an infrastructure based wireless network.

Now we will go through the source code in the text editor.

Highlight std::string phyMode("DsssRate1Mbps"); We set the dsss rate of the physical layer to 1 Mbps.
Highlight double rss = -80 Next, we’ll set the Received Signal Strength or RSS to -80 dBm.
Highlight uint32_t packetSize = 1000;

uint32_t numPackets = 100;

Now we shall set the packet size to 1000 bytes.

Then we’ll set the number of packets to be transmitted as 100.

Highlight Time interval = Seconds(0.003); Further, we set the time interval between the packet transfer as 0.003 seconds.
Highlight uint32_t sinkNode = 1;

uint32_t sourceNode = 0;

Let us set up the source and sink nodes for the flow that we are yet to create.
Highlight Config::SetDefault("ns3::WifiRemoteStationManager::NonUnicastMode", StringValue(phyMode)); Then we configure non-unicast mode of the wifi channel.

Non-unicast mode means that the data may be sent from one node to many nodes.

Highlight NodeContainer c;

c.Create(4);

Now, let us create a node container with four nodes.
Highlight WifiHelper wifi;

if (verbose) { WifiHelper::EnableLogComponents(); } wifi.SetStandard(WIFI_STANDARD_80211b);

We shall now put the wifi network interface cards together.

For that, let us use the WifiHelper class.

Using Wifi-helper class, we enable logging components and set the wifi standard.

Here, the standard set is IEEE 802.11b.

Highlight YansWifiPhyHelper wifiPhy;

wifiPhy.Set("RxGain", DoubleValue(0));

Then we shall use YansWifiPhyHelper class to set the RxGain attribute to zero.

RxGain is used to adjust the sensitivity of the receiving signal.

Highlight YansWifiChannelHelper wifiChannel;

wifiChannel.SetPropagationDelay("ns3::ConstantSpeedPropagationDelayModel");

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

We use YansWifiChannelHelper class to set attributes of the transmitting channel.

Let us set the Propagation delay and add the propagation loss to our model.

Highlight wifiPhy.SetChannel(wifiChannel.Create()); Next, we connect the wifi physical layer to the wifi-channel.
Highlight WifiMacHelper wifiMac;

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

Now let us add MAC protocol to the Network Interface Cards that we installed.

Then we set a constant rate for data and control modes of wifi stations.

Highlight Ssid ssid = Ssid("wifi-default"); Then, we assign SSID to the network.

SSID or Service Set Identifier is a sequence of characters uniquely identifying a network.

Highlight wifiMac.SetType("ns3::StaWifiMac", "Ssid", SsidValue(ssid));

NetDeviceContainer staDevice = wifi.Install(wifiPhy, wifiMac, c);

NetDeviceContainer devices = staDevice;

Let us now set up the station node by setting up MAC protocol and installing NIC.

We create a container staDevice to hold the installed Wifi devices.

As a next step, we shall take a copy of staDevice container in devices container.

Highlight

wifiMac.SetType("ns3::ApWifiMac", "Ssid", SsidValue(ssid));

NetDeviceContainer apDevice = wifi.Install(wifiPhy, wifiMac, c.Get(1));

devices.Add(apDevice);

Similarly, we shall set up the Access Point of the wireless network.

We have set up the AP node of the wireless network using ApWifiMac protocol.

We are also installing wifiphy to the node1 of the wireless network.

Then ssid is assigned to the AP node of the network.

Highlight MobilityHelper mobility;

Ptr<ListPositionAllocator> positionAlloc = CreateObject<ListPositionAllocator>();

positionAlloc->Add(Vector(3.0, 4.0, 3.0));

mobility.SetPositionAllocator(positionAlloc);

Now set up mobility for the nodes by allocating positions for the nodes created.
Highlight mobility.SetMobilityModel("ns3::ConstantPositionMobilityModel");

mobility.Install(c);

Let us set the model to be ConstantPositionMobilityModel.

It represents the stationary or static nodes in a network simulation.

Also, install the model that we set, to all the nodes that we created.

Highlight InternetStackHelper internet;

internet.Install(c);

Then let us install the internet stack on all the nodes.
Highlight Ipv4AddressHelper ipv4;

ipv4.SetBase("10.1.1.0", "255.255.255.0");

Ipv4InterfaceContainer i = ipv4.Assign(devices);

Now, we shall assign IP addresses to the nodes that we created
Highlight TypeId tid = TypeId::LookupByName("ns3::UdpSocketFactory"); The highlighted command is used to get the TypeId of UdpSocketFactory.
Highlight Ptr<Socket> recvSink = Socket::CreateSocket(c.Get(sinkNode), tid); We shall create a receiving socket for the UDP Flow.
Highlight InetSocketAddress local = InetSocketAddress(Ipv4Address::GetAny(), 80); Let us create an internet socket address using any IPv4 address and port 80.
Highlight recvSink->Bind(local); Then bind the receiving socket to the local address and to the port 80.
Highlight recvSink->SetRecvCallback(MakeCallback(&ReceivePacket)); Now set the receive callback function for the receiving socket.

When the packet is received in the sinknode, we call RecievePacket function.

Highlight Ptr<Socket> source = Socket::CreateSocket(c.Get(sourceNode), tid); Let us then create an UDP socket on node 0, which is our sourceNode.
Highlight InetSocketAddress remote = InetSocketAddress(i.GetAddress(sinkNode, 0), 80); We shall create an internet socket using Ipv4 address of sinknode and port 80.
Highlight source->Connect(remote); Let us connect the source socket to the remote address and port 80.
Highlight void

ReceivePacket(Ptr<Socket> socket)

{

while (socket->Recv()){ }

}

Now let’s define the function to call when the packets are received.

Here, we are invoking the receive functionality of the socket.

Highlight static void

GenerateTraffic(Ptr<Socket> socket, uint32_t pktSize, uint32_t pktCount, Time pktInterval)

Then we define a function called generate packet traffic.
Highlight if (pktCount > 0)

{

socket->Send(Create<Packet>(pktSize));

Simulator::Schedule(pktInterval,

&GenerateTraffic,

socket,

pktSize,

pktCount - 1,

pktInterval);

}

else

{

socket->Close();

}

When the number of packets is not zero, we invoke the send function.

We also schedule the simulator to invoke the GenerateTraffic function.

When the number of packets is zero, we close the socket.

Then, we stop invoking send function.

Only Narration We have created two other UDP flows as well.
Highlight Simulator::Schedule(Seconds(

10),&GenerateTraffic,source,packetSize,numPackets,interval);

Let us schedule the simulator to callback the generate_traffic function.

This procedure happens after ten seconds from the start of execution.

Highlight Ptr<FlowMonitor> flowMonitor; Then, Initialize flow monitor for tracing.
HIghlight FlowMonitorHelper flowHelper;

flowMonitor= flowHelper.InstallAll();

We shall then install a flow monitor on all the nodes.
Highlight AnimationInterface anim ("animationwifi-infra-2.xml"); Let us create the XML output of the program.
HIghlight Ptr<Ipv4FlowClassifier> classifier=DynamicCast<Ipv4FlowClassifier> (flowHelper.GetClassifier()); Let us further create an object of the Ipv4FlowClassifier class.

The created object returns a pointer to the flow classifier.

Highlight std::map<FlowId,FlowMonitor::FlowStats> stats=flowMonitor->GetFlowStats(); To store the information about the network flow, let us use this command.
Highlight the entire for loop. Let’s retrieve the details of the flow using a for loop.

iter arrow first is used to collect the ID of the flow.

iter arrow second is used to collect the data associated with the flow.

We will analyze the type of flow and print the delay and throughput.

Highlight Simulator::Destroy() The Destroy() function ends the simulation.
Press Ctrl, Alt and T keys simultaneously

Navigate to the ns-allinone-3.38/ns3.38 directory

Type mv ~/Downloads/wifi-simple-infra.cc scratch/wifi-simple-infra.cc to move the source file to scratch directory.

Now we will observe the simulation.

Open the terminal by pressing Ctrl, Alt and T keys simultaneously.

Using the cd command, navigate to the installation directory of ns-3.

Go to the ns-3.38 directory.

Move your source file to the scratch directory within the ns-3.38 directory.

Type ./ns3 run scratch/wifi-simple-infra.cc Run the command ./ns3 run scratch/wifi-simple-infra.cc

wifi-simple-infra.cc is the name of the source file.

Keep the terminal open and show the output of the command After compilation, we get the details of each packet transfer.

TxPackets refers to the packets sent whereas RxPackets refers to the packets received.

We also see the average end to end delay and throughput of the wireless network.

Navigate to netanim directory under ns-allinone-3.38

Type cd ..

Type cd netanim

Now, to visualize the network, we will use NetAnim.

Navigate to the netanim directory under ns-allinone-3.38.

For that, type cd .. in the terminal window.

Then type cd netanim

Type ./NetAnim Now type ./NetAnim.

The NetAnim window should open.

Click on the Open XML trace file icon on the top left corner of the window. Click on the Open XML trace file icon on the top left corner of the window.
In the file picker, navigate to the ns-allinone-3.38/ns3.38 directory and select the animationwifi-infra-2.xml file. In the file picker, navigate to the ns-allinone-3.38, then to ns3.38 directory.

Then select the animationwifi-infra-2.xml file.

On the toolbar, click on the play button

Close the NetAnim window

On the toolbar, click on the play button to view the simulation.

We see the flow details of the wireless network.

Now, we can close the NetAnim window.

Show Slide: Summary This brings us to the end of this tutorial. Let us summarize.

In this tutorial, we have

  • Created an infrastructure based wireless network.
  • Created three UDP flows in the channels.
  • Analyzed the flow using a flow monitor.
  • Visualized the network using NetAnim.
Show Slide : Assignment As an assignment, please do the following
  • Create a simulation for a wireless network with three nodes.
  • Create one access point (AP) and two stations.
  • The AP and stations should use an 802.11g physical layer.
  • Implement UDP traffic between the stations and the AP.
  • Set packet size as 1500 bytes and send 200 packets from each station to the AP.
  • Set the RSS at the AP to -70 dBm.
  • Set the interval between packets to 0.005 seconds.
  • Analyze the flow using flow monitor.
  • Visualize the network using NetAnim.
Show Slide:

Assignment- Observation

In the terminal window, you will get the following output.
Show Slide:

Assignment- Observation

In the NetAnim window, you would observe the following network.

Observe the packet transfer.

Show Slide:

About Spoken Tutorial Project

The video at the following link summarizes theSpoken Tutorial project.

Please download and watch it.

Show Slide:

Spoken Tutorial Workshops

TheSpoken Tutorial Project team conducts workshops and gives certificates.

For more details, please write to us.

Show Slide:

Answers for THIS Spoken Tutorial

Please post your timed queries in this forum.
Show Slide:

FOSSEE Forum

For any general or technical questions onns-3, visit the FOSSEE forum and post your question.
Show Slide:Acknowledgement Spoken Tutorial Project was established by theMinistry of Education, Government of India.
Show Slide: Acknowledgement We thankDr.Moyukh Laha fromIIT Kharagpur for his domain support.

We would also like to thankDr. R. Radha, Dr. X. Anita, and Dr.T.Subbulakshmi from VIT, Chennai for their support.

Show Slide: Thank you


This isArun Santhosh,a FOSSEE Summer Fellow 2023, IIT Bombay signing off.

Thank you for joining.

Contributors and Content Editors

Madhurig, Nirmala Venkat