A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
simple-ofdm-wimax-phy.cc
Go to the documentation of this file.
1/*
2 * Copyright (c) 2007,2008, 2009 INRIA, UDcast
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 as
6 * published by the Free Software Foundation;
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program; if not, write to the Free Software
15 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16 *
17 * Author: Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
18 * <amine.ismail@udcast.com>
19 */
20
22
24#include "wimax-channel.h"
25#include "wimax-mac-header.h"
26#include "wimax-net-device.h"
27
28#include "ns3/double.h"
29#include "ns3/node.h"
30#include "ns3/packet-burst.h"
31#include "ns3/packet.h"
32#include "ns3/simulator.h"
33#include "ns3/string.h"
34#include "ns3/trace-source-accessor.h"
35#include "ns3/uinteger.h"
36
37#include <cmath>
38#include <string>
39#include <vector>
40
41namespace ns3
42{
43
44NS_LOG_COMPONENT_DEFINE("SimpleOfdmWimaxPhy");
45
46NS_OBJECT_ENSURE_REGISTERED(SimpleOfdmWimaxPhy);
47
48TypeId
50{
51 static TypeId tid =
52 TypeId("ns3::SimpleOfdmWimaxPhy")
54 .SetGroupName("Wimax")
55
56 .AddConstructor<SimpleOfdmWimaxPhy>()
57
58 .AddAttribute(
59 "NoiseFigure",
60 "Loss (dB) in the Signal-to-Noise-Ratio due to non-idealities in the receiver.",
61 DoubleValue(5),
64 MakeDoubleChecker<double>())
65
66 .AddAttribute("TxPower",
67 "Transmission power (dB).",
68 DoubleValue(30),
71 MakeDoubleChecker<double>())
72
73 .AddAttribute("G",
74 "This is the ratio of CP time to useful time.",
75 DoubleValue(0.25),
78 MakeDoubleChecker<double>())
79
80 .AddAttribute(
81 "TxGain",
82 "Transmission gain (dB).",
83 DoubleValue(0),
85 MakeDoubleChecker<double>())
86
87 .AddAttribute(
88 "RxGain",
89 "Reception gain (dB).",
90 DoubleValue(0),
92 MakeDoubleChecker<double>())
93
94 .AddAttribute("Nfft",
95 "FFT size",
96 UintegerValue(256),
99 MakeUintegerChecker<uint16_t>(256, 1024))
100
101 .AddAttribute("TraceFilePath",
102 "Path to the directory containing SNR to block error rate files",
103 StringValue(""),
107
108 .AddTraceSource("Rx",
109 "Receive trace",
111 "ns3::PacketBurst::TracedCallback")
112 .AddTraceSource("Tx",
113 "Transmit trace",
115 "ns3::PacketBurst::TracedCallback")
116
117 .AddTraceSource(
118 "PhyTxBegin",
119 "Trace source indicating a packet has begun transmitting over the channel medium",
121 "ns3::PacketBurst::TracedCallback")
122
123 .AddTraceSource(
124 "PhyTxEnd",
125 "Trace source indicating a packet has been completely transmitted over the channel",
127 "ns3::PacketBurst::TracedCallback")
128
129 .AddTraceSource("PhyTxDrop",
130 "Trace source indicating a packet has been dropped by the device "
131 "during transmission",
133 "ns3::PacketBurst::TracedCallback")
134
135 .AddTraceSource("PhyRxBegin",
136 "Trace source indicating a packet has begun being received from the "
137 "channel medium by the device",
139 "ns3::PacketBurst::TracedCallback")
140
141 .AddTraceSource("PhyRxEnd",
142 "Trace source indicating a packet has been completely received from "
143 "the channel medium by the device",
145 "ns3::PacketBurst::TracedCallback")
146
147 .AddTraceSource(
148 "PhyRxDrop",
149 "Trace source indicating a packet has been dropped by the device during reception",
151 "ns3::PacketBurst::TracedCallback");
152 return tid;
153}
154
155void
157{
158 m_fecBlockSize = 0;
164
168
169 m_nrBlocks = 0;
170 m_blockSize = 0;
171 m_paddingBits = 0;
172 m_rxGain = 0;
173 m_txGain = 0;
174 m_nfft = 256;
175 m_g = 1.0 / 4;
176 SetNrCarriers(192);
177 m_fecBlocks = new std::list<Bvec>;
178 m_receivedFecBlocks = new std::list<Bvec>;
180 m_noiseFigure = 5; // dB
181 m_txPower = 30; // dBm
182 SetBandwidth(10000000); // 10Mhz
186}
187
189{
190 m_URNG = CreateObject<UniformRandomVariable>();
191
195}
196
198{
202}
203
205{
206}
207
208void
210{
212}
213
214void
216{
219}
220
223{
225}
226
227void
229{
231}
232
233double
235{
236 return m_txPower;
237}
238
239void
241{
242 m_txPower = txPower;
243}
244
245double
247{
248 return m_noiseFigure;
249}
250
251void
253{
254 m_noiseFigure = noiseFigure;
255}
256
257void
259{
260 delete m_receivedFecBlocks;
261 delete m_fecBlocks;
262 m_receivedFecBlocks = nullptr;
263 m_fecBlocks = nullptr;
266}
267
268void
270{
271 GetChannel()->Attach(this);
272}
273
274void
276{
277 auto o_params = dynamic_cast<OfdmSendParams*>(params);
278 NS_ASSERT(o_params != nullptr);
279 Send(o_params->GetBurst(),
280 (WimaxPhy::ModulationType)o_params->GetModulationType(),
281 o_params->GetDirection());
282}
283
286{
288}
289
290void
292 WimaxPhy::ModulationType modulationType,
293 uint8_t direction)
294{
295 if (GetState() != PHY_STATE_TX)
296 {
297 m_currentBurstSize = burst->GetSize();
299 m_currentBurst = burst;
300 SetBlockParameters(burst->GetSize(), modulationType);
302 StartSendDummyFecBlock(true, modulationType, direction);
303 m_traceTx(burst);
304 }
305}
306
307void
309 WimaxPhy::ModulationType modulationType,
310 uint8_t direction)
311{
313 bool isLastFecBlock = false;
314 if (isFirstBlock)
315 {
316 m_blockTime = GetBlockTransmissionTime(modulationType);
317 }
318
319 SimpleOfdmWimaxChannel* channel =
321 NS_ASSERT(channel != nullptr);
322
323 isLastFecBlock = (m_nrRemainingBlocksToSend == 1);
324 channel->Send(m_blockTime,
326 this,
327 isFirstBlock,
328 isLastFecBlock,
330 modulationType,
331 direction,
332 m_txPower,
334
338 this,
339 modulationType,
340 direction);
341}
342
343void
345{
348
350 {
351 // this is the last FEC block of the burst
352 NS_ASSERT_MSG(m_nrRemainingBlocksToSend == 0, "Error while sending a burst");
354 }
355 else
356 {
357 StartSendDummyFecBlock(false, modulationType, direction);
358 }
359}
360
361void
363{
365}
366
367void
369 bool isFirstBlock,
370 uint64_t frequency,
371 WimaxPhy::ModulationType modulationType,
372 uint8_t direction,
373 double rxPower,
374 Ptr<PacketBurst> burst)
375{
376 bool drop = false;
377 double Nwb = -114 + m_noiseFigure + 10 * std::log(GetBandwidth() / 1000000000.0) / 2.303;
378 double SNR = rxPower - Nwb;
379
382 double I1 = record->GetI1();
383 double I2 = record->GetI2();
384
385 double blockErrorRate = m_URNG->GetValue(I1, I2);
386
387 double rand = m_URNG->GetValue(0.0, 1.0);
388
389 if (rand < blockErrorRate)
390 {
391 drop = true;
392 }
393 if (rand > blockErrorRate)
394 {
395 drop = false;
396 }
397
398 if (blockErrorRate == 1.0)
399 {
400 drop = true;
401 }
402 if (blockErrorRate == 0.0)
403 {
404 drop = false;
405 }
406 delete record;
407
408 NS_LOG_INFO("PHY: Receive rxPower=" << rxPower << ", Nwb=" << Nwb << ", SNR=" << SNR
409 << ", Modulation=" << modulationType << ", BlockErrorRate="
410 << blockErrorRate << ", drop=" << std::boolalpha << drop);
411
412 switch (GetState())
413 {
415 if (frequency == GetScanningFrequency())
416 {
419 SetSimplex(frequency);
421 }
422 break;
423 case PHY_STATE_IDLE:
424 if (frequency == GetRxFrequency())
425 {
426 if (isFirstBlock)
427 {
428 NotifyRxBegin(burst);
429 m_receivedFecBlocks->clear();
431 SetBlockParameters(burstSize, modulationType);
432 m_blockTime = GetBlockTransmissionTime(modulationType);
433 }
434
437 this,
438 burstSize,
439 modulationType,
440 direction,
441 drop,
442 burst);
443
445 }
446 break;
447 case PHY_STATE_RX:
448 // drop
449 break;
450 case PHY_STATE_TX:
451 if (IsDuplex() && frequency == GetRxFrequency())
452 {
453 }
454 break;
455 }
456}
457
458void
460 WimaxPhy::ModulationType modulationType,
461 uint8_t direction,
462 bool drop,
463 Ptr<PacketBurst> burst)
464{
467
468 if (drop)
469 {
471 }
472
474 {
475 NotifyRxEnd(burst);
476 if (m_nbErroneousBlock == 0)
477 {
479 }
480 else
481 {
482 NotifyRxDrop(burst);
483 }
486 }
487}
488
489void
491{
492 Ptr<PacketBurst> b = burst->Copy();
494 m_traceRx(burst);
495}
496
497Bvec
499{
500 Bvec buffer(burst->GetSize() * 8, false);
501
502 std::list<Ptr<Packet>> packets = burst->GetPackets();
503
504 uint32_t j = 0;
505 for (auto iter = packets.begin(); iter != packets.end(); ++iter)
506 {
507 Ptr<Packet> packet = *iter;
508 auto pstart = (uint8_t*)std::malloc(packet->GetSize());
509 std::memset(pstart, 0, packet->GetSize());
510 packet->CopyData(pstart, packet->GetSize());
511 Bvec temp(8);
512 temp.resize(0, false);
513 temp.resize(8, false);
514 for (uint32_t i = 0; i < packet->GetSize(); i++)
515 {
516 for (uint8_t l = 0; l < 8; l++)
517 {
518 temp[l] = (bool)((((uint8_t)pstart[i]) >> (7 - l)) & 0x01);
519 buffer.at(j * 8 + l) = temp[l];
520 }
521 j++;
522 }
523 std::free(pstart);
524 }
525
526 return buffer;
527}
528
529/*
530 Converts back the bit buffer (Bvec) to the actual burst.
531 Actually creates byte buffer from the Bvec and resets the buffer
532 of each packet in the copy of the original burst stored before transmitting.
533 By doing this it preserves the metadata and tags in the packet.
534 Function could also be named DeserializeBurst because actually it
535 copying to the burst's byte buffer.
536 */
539{
540 const auto bufferSize = buffer.size() / 8;
541 std::vector<uint8_t> bytes(bufferSize, 0);
542 int32_t j = 0;
543 // recreating byte buffer from bit buffer (Bvec)
544 for (std::size_t i = 0; i < buffer.size(); i += 8)
545 {
546 uint8_t temp = 0;
547 for (std::size_t l = 0; l < 8; l++)
548 {
549 bool bin = buffer.at(i + l);
550 temp |= (bin << (7 - l));
551 }
552
553 bytes[j] = temp;
554 j++;
555 }
556 uint16_t pos = 0;
557 Ptr<PacketBurst> RecvBurst = Create<PacketBurst>();
558 while (pos < bufferSize)
559 {
560 uint16_t packetSize = 0;
561 // Get the header type: first bit
562 uint8_t ht = (bytes[pos] >> 7) & 0x01;
563 if (ht == 1)
564 {
565 // BW request header. Size is always 8 bytes
566 packetSize = 6;
567 }
568 else
569 {
570 // Read the size
571 uint8_t Len_MSB = bytes[pos + 1] & 0x07;
572 packetSize = (uint16_t)((uint16_t)(Len_MSB << 8) | (uint16_t)(bytes[pos + 2]));
573 if (packetSize == 0)
574 {
575 break; // padding
576 }
577 }
578
579 Ptr<Packet> p = Create<Packet>(&bytes[pos], packetSize);
580 RecvBurst->AddPacket(p);
581 pos += packetSize;
582 }
583 return RecvBurst;
584}
585
586void
588{
589 Bvec fecBlock(m_blockSize);
590 for (uint32_t i = 0, j = m_nrBlocks; j > 0; i += m_blockSize, j--)
591 {
592 if (j == 1 && m_paddingBits > 0) // last block can be smaller than block size
593 {
594 fecBlock = Bvec(buffer.begin() + i, buffer.end());
595 fecBlock.resize(m_blockSize, false);
596 }
597 else
598 {
599 fecBlock = Bvec(buffer.begin() + i, buffer.begin() + i + m_blockSize);
600 }
601
602 m_fecBlocks->push_back(fecBlock);
603 }
604}
605
606Bvec
608{
609 Bvec buffer(m_blockSize * (unsigned long)m_nrBlocks);
610 Bvec block(m_blockSize);
611 uint32_t i = 0;
612 for (uint32_t j = 0; j < m_nrBlocks; j++)
613 {
614 Bvec tmpRecFecBlock = m_receivedFecBlocks->front();
615 buffer.insert(buffer.begin() + i, tmpRecFecBlock.begin(), tmpRecFecBlock.end());
616 m_receivedFecBlocks->pop_front();
617 i += m_blockSize;
618 }
619 return buffer;
620}
621
622void
624{
632}
633
634void
636 uint8_t& bitsPerSymbol,
637 double& fecCode) const
638{
639 switch (modulationType)
640 {
642 bitsPerSymbol = 1;
643 fecCode = 1.0 / 2;
644 break;
646 bitsPerSymbol = 2;
647 fecCode = 1.0 / 2;
648 break;
650 bitsPerSymbol = 2;
651 fecCode = 3.0 / 4;
652 break;
654 bitsPerSymbol = 4;
655 fecCode = 1.0 / 2;
656 break;
658 bitsPerSymbol = 4;
659 fecCode = 3.0 / 4;
660 break;
662 bitsPerSymbol = 6;
663 fecCode = 2.0 / 3;
664 break;
666 bitsPerSymbol = 6;
667 fecCode = 0.75;
668 break;
669 }
670}
671
674{
675 uint8_t bitsPerSymbol = 0;
676 double fecCode = 0;
677 GetModulationFecParams(modulationType, bitsPerSymbol, fecCode);
678 double symbolsPerSecond = 1 / GetSymbolDuration().GetSeconds();
679 auto bitsTransmittedPerSymbol = (uint16_t)(bitsPerSymbol * GetNrCarriers() * fecCode);
680 // 96, 192, 288, 384, 576, 767 and 864 bits per symbol for the seven modulations, respectively
681
682 return (uint32_t)symbolsPerSecond * bitsTransmittedPerSymbol;
683}
684
687{
688 switch (modulationType)
689 {
691 return m_dataRateBpsk12;
693 return m_dataRateQpsk12;
695 return m_dataRateQpsk34;
697 return m_dataRateQam16_12;
699 return m_dataRateQam16_34;
701 return m_dataRateQam64_23;
703 return m_dataRateQam64_34;
704 }
705 NS_FATAL_ERROR("Invalid modulation type");
706 return 0;
707}
708
709Time
711{
712 return Seconds((double)GetFecBlockSize(modulationType) / DoGetDataRate(modulationType));
713}
714
715Time
717 WimaxPhy::ModulationType modulationType) const
718{
719 /*adding 3 extra nano second to cope with the loss of precision problem.
720 the time is internally stored in a 64 bit hence a floating-point time would loss
721 precision, e.g., 0.00001388888888888889 seconds will become 13888888888 femtoseconds.*/
722 return Seconds(DoGetNrSymbols(size, modulationType) * GetSymbolDuration().GetSeconds()) +
723 NanoSeconds(3);
724}
725
726uint64_t
728{
729 Time transmissionTime =
730 Seconds((double)(GetNrBlocks(size, modulationType) * GetFecBlockSize(modulationType)) /
731 DoGetDataRate(modulationType));
732 return (uint64_t)std::ceil(transmissionTime.GetSeconds() / GetSymbolDuration().GetSeconds());
733}
734
735uint64_t
737{
738 Time transmissionTime = Seconds(symbols * GetSymbolDuration().GetSeconds());
739 return (uint64_t)std::floor((transmissionTime.GetSeconds() * DoGetDataRate(modulationType)) /
740 8);
741}
742
745{
746 uint32_t blockSize = 0;
747 switch (modulationType)
748 {
750 blockSize = 12;
751 break;
753 blockSize = 24;
754 break;
756 blockSize = 36;
757 break;
759 blockSize = 48;
760 break;
762 blockSize = 72;
763 break;
765 blockSize = 96;
766 break;
768 blockSize = 108;
769 break;
770 default:
771 NS_FATAL_ERROR("Invalid modulation type");
772 break;
773 }
774 return blockSize * 8; // in bits
775}
776
777// Channel coding block size, Table 215, page 434
780{
781 uint32_t blockSize = 0;
782 switch (modulationType)
783 {
785 blockSize = 24;
786 break;
788 blockSize = 48;
789 break;
791 blockSize = 48;
792 break;
794 blockSize = 96;
795 break;
797 blockSize = 96;
798 break;
800 blockSize = 144;
801 break;
803 blockSize = 144;
804 break;
805 default:
806 NS_FATAL_ERROR("Invalid modulation type");
807 break;
808 }
809 return blockSize * 8; // in bits
810}
811
812void
814{
815 m_blockSize = GetFecBlockSize(modulationType);
816 m_nrBlocks = GetNrBlocks(burstSize, modulationType);
817 m_paddingBits = (m_nrBlocks * m_blockSize) - (burstSize * 8);
819 NS_ASSERT_MSG(static_cast<uint32_t>(m_nrBlocks * m_blockSize) >= (burstSize * 8),
820 "Size of padding bytes < 0");
821}
822
823uint16_t
825{
826 // assumed equal to 2 symbols
827 return 2 * GetPsPerSymbol();
828}
829
830uint16_t
832{
833 // assumed equal to 2 symbols
834 return 2 * GetPsPerSymbol();
835}
836
837uint8_t
839{
840 uint16_t duration = 0;
841 duration = (uint16_t)(GetFrameDuration().GetSeconds() * 10000);
842 uint8_t retval = 0;
843 switch (duration)
844 {
845 case 25: {
847 break;
848 }
849 case 40: {
850 retval = FRAME_DURATION_4_MS;
851 break;
852 }
853 case 50: {
854 retval = FRAME_DURATION_5_MS;
855 break;
856 }
857 case 80: {
858 retval = FRAME_DURATION_8_MS;
859 break;
860 }
861 case 100: {
862 retval = FRAME_DURATION_10_MS;
863 break;
864 }
865 case 125: {
867 break;
868 }
869 case 200: {
870 retval = FRAME_DURATION_20_MS;
871 break;
872 }
873 default: {
874 NS_FATAL_ERROR("Invalid frame duration = " << duration);
875 retval = 0;
876 }
877 }
878 return retval;
879}
880
881Time
882SimpleOfdmWimaxPhy::DoGetFrameDuration(uint8_t frameDurationCode) const
883{
884 switch (frameDurationCode)
885 {
887 return Seconds(2.5);
889 return Seconds(4);
891 return Seconds(5);
893 return Seconds(8);
895 return Seconds(10);
897 return Seconds(12.5);
899 return Seconds(20);
900 default:
901 NS_FATAL_ERROR("Invalid modulation type");
902 }
903 return Seconds(0);
904}
905
906/*
907 Returns number of blocks (FEC blocks) the burst will be split in.
908 The size of the block is specific for each modulation type.
909 */
910uint16_t
912{
913 uint32_t blockSize = GetFecBlockSize(modulationType);
914 uint16_t nrBlocks = (burstSize * 8) / blockSize;
915
916 if ((burstSize * 8) % blockSize > 0)
917 {
918 nrBlocks += 1;
919 }
920
921 return nrBlocks;
922}
923
924/*---------------------PHY parameters functions-----------------------*/
925
926void
928{
929 /*Calculations as per section 8.3.2.
930 Currently assuming license-exempt 5 GHz band. For channel bandwidth 20 MHz (Table B.28, page
931 812) and frame duration 10 ms (Table 232, page 460) i.e, 100 frames per second, sampling
932 frequency is 23040000, symbol (OFDM symbol) duration is 1.388888888888889e-05 seconds, PS
933 duration is 1.7361111111111112e-07 seconds. Hence PSs per frame is 57600, symbols per frame is
934 720 and PSs per symbol is 80. Note that defining these parameters (symbol and PS duration) as
935 Time may not result in exactly these values therefore lrint has been used (otherwise should be
936 defined as double). For licensed bands set channel bandwidth according to Table B.26, page
937 810.*/
938
939 double samplingFrequency = DoGetSamplingFrequency();
940 Time psDuration = Seconds(4.0 / samplingFrequency);
941
942 SetPsDuration(psDuration);
943 uint16_t psPerFrame = (uint16_t)(GetFrameDuration().GetSeconds() / psDuration.GetSeconds());
944 SetPsPerFrame(psPerFrame);
945 double subcarrierSpacing = samplingFrequency / DoGetNfft();
946 double tb = 1.0 / subcarrierSpacing; // Tb (useful symbol time)
947 double tg = DoGetGValue() * tb; // Tg (cyclic prefix time)
948 Time symbolDuration = Seconds(tb + tg); // OFDM Symbol Time
949 SetSymbolDuration(symbolDuration);
950 uint16_t psPerSymbol = lrint(symbolDuration.GetSeconds() / psDuration.GetSeconds());
951 SetPsPerSymbol(psPerSymbol);
952 uint32_t symbolsPerFrame = lrint(GetFrameDuration().GetSeconds() / symbolDuration.GetSeconds());
953 SetSymbolsPerFrame(symbolsPerFrame);
954}
955
956void
958{
959 m_nfft = nfft;
960}
961
962uint16_t
964{
965 return m_nfft;
966}
967
968double
970{
971 // sampling factor (n), see Table 213, page 429
972
973 uint32_t channelBandwidth = GetChannelBandwidth();
974
975 if (channelBandwidth % 1750000 == 0)
976 {
977 return 8.0 / 7;
978 }
979 else if (channelBandwidth % 1500000 == 0)
980 {
981 return 86.0 / 75;
982 }
983 else if (channelBandwidth % 1250000 == 0)
984 {
985 return 144.0 / 125;
986 }
987 else if (channelBandwidth % 2750000 == 0)
988 {
989 return 316.0 / 275;
990 }
991 else if (channelBandwidth % 2000000 == 0)
992 {
993 return 57.0 / 50;
994 }
995 else
996 {
997 NS_LOG_DEBUG("Oops may be wrong channel bandwidth for OFDM PHY!");
998 NS_FATAL_ERROR("wrong channel bandwidth for OFDM PHY");
999 }
1000
1001 return 8.0 / 7;
1002}
1003
1004double
1006{
1007 // sampling frequency (Fs), see 8.3.2.2
1008
1009 return (DoGetSamplingFactor() * GetChannelBandwidth() / 8000) * 8000;
1010}
1011
1012double
1014{
1015 return m_g;
1016}
1017
1018void
1020{
1021 m_g = g;
1022}
1023
1024void
1026{
1027 m_txGain = txGain;
1028}
1029
1030void
1032{
1033 m_rxGain = txRain;
1034}
1035
1036double
1038{
1039 return m_txGain;
1040}
1041
1042double
1044{
1045 return m_rxGain;
1046}
1047
1048std::string
1050{
1052}
1053
1054void
1056{
1057 m_snrToBlockErrorRateManager->SetTraceFilePath((char*)path.c_str());
1059}
1060
1061void
1063{
1064 m_phyTxBeginTrace(burst);
1065}
1066
1067void
1069{
1070 m_phyTxEndTrace(burst);
1071}
1072
1073void
1075{
1076 m_phyTxDropTrace(burst);
1077}
1078
1079void
1081{
1082 m_phyRxBeginTrace(burst);
1083}
1084
1085void
1087{
1088 m_phyRxEndTrace(burst);
1089}
1090
1091void
1093{
1094 m_phyRxDropTrace(burst);
1095}
1096
1097int64_t
1099{
1100 NS_LOG_FUNCTION(this << stream);
1101 m_URNG->SetStream(stream);
1102 return 1;
1103}
1104
1105} // namespace ns3
This class can be used to hold variables of floating point type such as 'double' or 'float'.
Definition: double.h:42
OfdmSendParams class.
Definition: send-params.h:68
Smart pointer class similar to boost::intrusive_ptr.
Definition: ptr.h:77
void SetStream(int64_t stream)
Specifies the stream number for the RngStream.
This class handles the SNR to BlcER traces.
void ActivateLoss(bool loss)
If activate loss is called with false, all the returned BlcER will be 0 (no losses)
void LoadTraces()
Loads the traces form the repository specified in the constructor or set by SetTraceFilePath function...
SNRToBlockErrorRateRecord * GetSNRToBlockErrorRateRecord(double SNR, uint8_t modulation)
returns a record of type SNRToBlockErrorRateRecord corresponding to a given modulation and SNR value
void SetTraceFilePath(char *traceFilePath)
Set the path of the repository containing the traces.
This class represents a record (handled by SnrToBlockErrorRate manager) that keeps a mapping between ...
The SendParams class defines the parameters with which Send() function of a particular PHY is called.
Definition: send-params.h:42
SimpleOfdmWimaxChannel class.
SimpleOfdmWimaxPhy class.
std::string GetTraceFilePath() const
Get trace file path.
void GetModulationFecParams(WimaxPhy::ModulationType modulationType, uint8_t &bitsPerSymbol, double &fecCode) const
Get moduleation FEC parameters.
void NotifyRxBegin(Ptr< PacketBurst > burst)
Public method used to fire a PhyRxBegin trace.
double GetTxGain() const
Get transmit gain.
double DoGetSamplingFrequency() const override
Get sampling frequency.
void CreateFecBlocks(const Bvec &buffer, WimaxPhy::ModulationType modulationType)
Create FEC blocks.
static TypeId GetTypeId()
Get the type ID.
void NotifyRxEnd(Ptr< PacketBurst > burst)
Public method used to fire a PhyRxEnd trace.
TracedCallback< Ptr< PacketBurst > > m_phyRxBeginTrace
The trace source fired when a packet begins the reception process from the medium.
uint32_t m_dataRateQpsk12
data rate
double m_txPower
transmit power
void EndReceiveFecBlock(uint32_t burstSize, WimaxPhy::ModulationType modulationType, uint8_t direction, bool drop, Ptr< PacketBurst > burst)
End receive FEC block.
void EndReceive(Ptr< const PacketBurst > burst)
End receive.
double DoGetGValue() const override
Get G value.
void DoSetGValue(double g)
Set G value.
uint32_t CalculateDataRate(WimaxPhy::ModulationType modulationType) const
Calculate data rate.
void StartSendDummyFecBlock(bool isFirstBlock, WimaxPhy::ModulationType modulationType, uint8_t direction)
Start end dummy FEC block.
void DoAttach(Ptr< WimaxChannel > channel) override
Attach the physical layer to a channel.
uint16_t DoGetTtg() const override
Get TTG.
uint8_t DoGetFrameDurationCode() const override
Get frame duration code.
int64_t AssignStreams(int64_t stream) override
Assign a fixed random variable stream number to the random variables used by this model.
double m_txGain
transmit gain
void ActivateLoss(bool loss)
if called with true it will enable the loss model
uint32_t m_dataRateQam16_34
data rate
uint16_t m_nbErroneousBlock
erroneous blocks
uint16_t m_nrBlocks
number of blocks
WimaxPhy::PhyType GetPhyType() const override
returns the type this physical layer
uint16_t m_blockSize
block size
void SetTraceFilePath(std::string path)
Set trace file path.
void SetNoiseFigure(double nf)
set the noise figure of the device
uint16_t m_nrReceivedFecBlocks
number received FEC blocks
void SetRxGain(double rxgain)
Set receive gsain.
Ptr< PacketBurst > ConvertBitsToBurst(Bvec buffer)
Convert bits to burst.
void EndSendFecBlock(WimaxPhy::ModulationType modulationType, uint8_t direction)
End send FEC block.
uint32_t m_dataRateQpsk34
data rate
Ptr< PacketBurst > m_currentBurst
current burst
Ptr< UniformRandomVariable > m_URNG
Provides uniform random variables.
void DoSetNfft(uint16_t nfft)
Set NFFT.
void NotifyRxDrop(Ptr< PacketBurst > burst)
Public method used to fire a PhyRxDrop trace.
uint16_t GetNrBlocks(uint32_t burstSize, WimaxPhy::ModulationType modulationType) const
Get number of blocks.
Bvec RecreateBuffer()
Recreate buffer.
TracedCallback< Ptr< PacketBurst > > m_phyRxEndTrace
The trace source fired when a packet ends the reception process from the medium.
TracedCallback< Ptr< PacketBurst > > m_phyTxBeginTrace
The trace source fired when a packet begins the transmission process on the medium.
void NotifyTxEnd(Ptr< PacketBurst > burst)
Public method used to fire a PhyTxEnd trace.
double m_noiseFigure
noise figure
void SetBlockParameters(uint32_t burstSize, WimaxPhy::ModulationType modulationType)
Set block parameters.
uint32_t m_dataRateQam64_34
data rate
uint32_t m_dataRateBpsk12
data rate
double DoGetSamplingFactor() const override
Get sampling factor.
void SetTxPower(double txPower)
set the transmission power
uint64_t DoGetNrBytes(uint32_t symbols, WimaxPhy::ModulationType modulationType) const override
Get number of bytes.
SNRToBlockErrorRateManager * m_snrToBlockErrorRateManager
SNR to block error rate manager.
TracedCallback< Ptr< const PacketBurst > > m_traceTx
trace transmit callback
void DoSetDataRates() override
Set data rates.
uint16_t DoGetNfft() const override
Get NFFT.
void DoSetPhyParameters() override
Set Phy parameters.
uint32_t m_dataRateQam16_12
data rate
uint16_t DoGetRtg() const override
Get RTG.
uint32_t GetCodedFecBlockSize(WimaxPhy::ModulationType modulationType) const
Get coded FEC block size.
std::list< Bvec > * m_receivedFecBlocks
a list of received FEC blocks until they are combined to recreate the full burst buffer
uint32_t GetFecBlockSize(WimaxPhy::ModulationType type) const
Get FEC block size.
void SetTxGain(double txgain)
Set transmit gain.
uint16_t m_nrRemainingBlocksToSend
number of remaining blocks to send
void SetBandwidth(uint32_t BW)
Set the bandwidth.
TracedCallback< Ptr< PacketBurst > > m_phyTxEndTrace
The trace source fired when a packet ends the transmission process on the medium.
Time GetBlockTransmissionTime(WimaxPhy::ModulationType modulationType) const
Get block transmission time.
void Send(Ptr< PacketBurst > burst, WimaxPhy::ModulationType modulationType, uint8_t direction)
Sends a burst on the channel.
Time DoGetTransmissionTime(uint32_t size, WimaxPhy::ModulationType modulationType) const override
Get transmission time.
TracedCallback< Ptr< PacketBurst > > m_phyRxDropTrace
The trace source fired when the phy layer drops a packet it has received.
Time DoGetFrameDuration(uint8_t frameDurationCode) const override
Get frame duration.
void SetSNRToBlockErrorRateTracesPath(char *tracesPath)
Set the path of the repository containing the traces.
uint32_t m_currentBurstSize
current burst size
uint32_t DoGetDataRate(WimaxPhy::ModulationType modulationType) const override
Get data rate.
void NotifyTxDrop(Ptr< PacketBurst > burst)
Public method used to fire a PhyTxDrop trace.
uint64_t DoGetNrSymbols(uint32_t size, WimaxPhy::ModulationType modulationType) const override
Get number of symbols.
void InitSimpleOfdmWimaxPhy()
Initialize simple OFDM WIMAX Phy.
void NotifyTxBegin(Ptr< PacketBurst > burst)
Public method used to fire a PhyTxBegin trace.
TracedCallback< Ptr< PacketBurst > > m_phyTxDropTrace
The trace source fired when the phy layer drops a packet as it tries to transmit it.
uint32_t m_paddingBits
padding bits
std::list< Bvec > * m_fecBlocks
the FEC blocks
double GetRxGain() const
Get receive gain.
uint16_t m_fecBlockSize
in bits, size of FEC block transmitted after PHY operations
TracedCallback< Ptr< const PacketBurst > > m_traceRx
trace receive callback
Bvec ConvertBurstToBits(Ptr< const PacketBurst > burst)
Convert burst to bits.
uint32_t m_dataRateQam64_23
data rate
void DoDispose() override
Destructor implementation.
void StartReceive(uint32_t burstSize, bool isFirstBlock, uint64_t frequency, WimaxPhy::ModulationType modulationType, uint8_t direction, double rxPower, Ptr< PacketBurst > burst)
start the reception of a fec block
uint32_t m_nrFecBlocksSent
counting the number of FEC blocks sent (within a burst)
static EventId Schedule(const Time &delay, FUNC f, Ts &&... args)
Schedule an event to expire after delay.
Definition: simulator.h:571
static void Cancel(const EventId &id)
Set the cancel bit on this event: the event's associated function will not be invoked when it expires...
Definition: simulator.cc:285
Hold variables of type string.
Definition: string.h:56
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:105
double GetSeconds() const
Get an approximation of the time stored in this instance in the indicated unit.
Definition: nstime.h:403
a unique identifier for an interface.
Definition: type-id.h:59
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition: type-id.cc:932
Hold an unsigned integer type.
Definition: uinteger.h:45
double GetValue(double min, double max)
Get the next random value drawn from the distribution.
WiMAX PHY entity.
Definition: wimax-phy.h:50
Time GetFrameDuration() const
Get the frame duration.
Definition: wimax-phy.cc:308
ModulationType
ModulationType enumeration.
Definition: wimax-phy.h:54
@ MODULATION_TYPE_QPSK_12
Definition: wimax-phy.h:56
@ MODULATION_TYPE_QAM16_12
Definition: wimax-phy.h:58
@ MODULATION_TYPE_QAM64_34
Definition: wimax-phy.h:61
@ MODULATION_TYPE_QAM16_34
Definition: wimax-phy.h:59
@ MODULATION_TYPE_QAM64_23
Definition: wimax-phy.h:60
@ MODULATION_TYPE_QPSK_34
Definition: wimax-phy.h:57
@ MODULATION_TYPE_BPSK_12
Definition: wimax-phy.h:55
void SetSymbolDuration(Time symbolDuration)
set the OFDM symbol duration
Definition: wimax-phy.cc:374
Ptr< WimaxChannel > GetChannel() const
Definition: wimax-phy.cc:117
void SetChannelBandwidth(uint32_t channelBandwidth)
Set the channel bandwidth.
Definition: wimax-phy.cc:332
uint64_t GetRxFrequency() const
Get the reception frequency.
Definition: wimax-phy.cc:180
PhyType
PhyType enumeration.
Definition: wimax-phy.h:75
@ simpleOfdmWimaxPhy
Definition: wimax-phy.h:77
Time GetSymbolDuration() const
Get the OFDM symbol duration.
Definition: wimax-phy.cc:380
uint8_t GetNrCarriers() const
Get the number of carriers in the physical frame.
Definition: wimax-phy.cc:296
PhyState GetState() const
Get the state of the device.
Definition: wimax-phy.cc:204
void SetSymbolsPerFrame(uint32_t symbolsPerFrame)
set the number of symbols per frame
Definition: wimax-phy.cc:416
void SetScanningCallback() const
calls the scanning call back function
Definition: wimax-phy.cc:222
void SetNrCarriers(uint8_t nrCarriers)
Set the number of carriers in the physical frame.
Definition: wimax-phy.cc:290
void DoDispose() override
Destructor implementation.
Definition: wimax-phy.cc:103
void SetPsPerFrame(uint16_t psPerFrame)
set the number of physical slots per frame
Definition: wimax-phy.cc:404
@ PHY_STATE_SCANNING
Definition: wimax-phy.h:68
void SetSimplex(uint64_t frequency)
configure the physical layer in simplex mode
Definition: wimax-phy.cc:173
uint64_t GetScanningFrequency() const
Get the scanning frequency.
Definition: wimax-phy.cc:192
void SetPsDuration(Time psDuration)
set the physical slot duration
Definition: wimax-phy.cc:362
uint16_t GetPsPerSymbol() const
Get the number of physical slots per symbol.
Definition: wimax-phy.cc:398
void SetState(PhyState state)
set the state of the device
Definition: wimax-phy.cc:198
uint32_t GetChannelBandwidth() const
Get the channel bandwidth.
Definition: wimax-phy.cc:338
EventId GetChnlSrchTimeoutEvent() const
Get channel search timeout event.
Definition: wimax-phy.cc:216
bool IsDuplex() const
Check if configured in duplex mode.
Definition: wimax-phy.cc:210
Callback< void, Ptr< const PacketBurst > > GetReceiveCallback() const
Definition: wimax-phy.cc:160
void SetPsPerSymbol(uint16_t psPerSymbol)
set the number of physical slots per symbol
Definition: wimax-phy.cc:392
uint64_t GetTxFrequency() const
Get the transmission frequency.
Definition: wimax-phy.cc:186
#define NS_ASSERT(condition)
At runtime, in debugging builds, if this condition is not true, the program prints the source file,...
Definition: assert.h:66
#define NS_ASSERT_MSG(condition, message)
At runtime, in debugging builds, if this condition is not true, the program prints the message to out...
Definition: assert.h:86
Ptr< const AttributeAccessor > MakeDoubleAccessor(T1 a1)
Definition: double.h:43
Ptr< const AttributeChecker > MakeStringChecker()
Definition: string.cc:30
Ptr< const AttributeAccessor > MakeStringAccessor(T1 a1)
Definition: string.h:57
Ptr< const AttributeAccessor > MakeUintegerAccessor(T1 a1)
Definition: uinteger.h:46
#define NS_FATAL_ERROR(msg)
Report a fatal error with a message and terminate.
Definition: fatal-error.h:179
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition: log.h:202
#define NS_LOG_DEBUG(msg)
Use NS_LOG to output a message of level LOG_DEBUG.
Definition: log.h:268
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by ",...
#define NS_LOG_INFO(msg)
Use NS_LOG to output a message of level LOG_INFO.
Definition: log.h:275
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Definition: object-base.h:46
Time NanoSeconds(uint64_t value)
Construct a Time in the indicated unit.
Definition: nstime.h:1362
Time Seconds(double value)
Construct a Time in the indicated unit.
Definition: nstime.h:1326
Ptr< const TraceSourceAccessor > MakeTraceSourceAccessor(T a)
Create a TraceSourceAccessor which will control access to the underlying trace source.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
U * PeekPointer(const Ptr< U > &p)
Definition: ptr.h:454
std::vector< bool > Bvec
boolean vector typedef
Definition: bvec.h:29
constexpr double BW
static const uint32_t packetSize
Packet size generated at the AP.