src/wifi/model/wifi-phy.cc
changeset 10580 2a29a9bd6fd6
parent 10424 9d29c9a5ddcb
child 10652 dc18deba4502
equal deleted inserted replaced
10579:4ec4b3dcb42a 10580:2a29a9bd6fd6
   157           case 5000000:
   157           case 5000000:
   158             return WifiPhy::GetOfdmRate1_5MbpsBW5MHz ();
   158             return WifiPhy::GetOfdmRate1_5MbpsBW5MHz ();
   159           case 10000000:
   159           case 10000000:
   160             return WifiPhy::GetOfdmRate3MbpsBW10MHz ();
   160             return WifiPhy::GetOfdmRate3MbpsBW10MHz ();
   161           default:
   161           default:
   162             // IEEE Std 802.11-2007, 17.3.2
   162             // (Section 18.3.2 "PLCP frame format"; IEEE Std 802.11-2012)
   163             // actually this is only the first part of the PlcpHeader,
   163             // actually this is only the first part of the PlcpHeader,
   164             // because the last 16 bits of the PlcpHeader are using the
   164             // because the last 16 bits of the PlcpHeader are using the
   165             // same mode of the payload
   165             // same mode of the payload
   166             return WifiPhy::GetOfdmRate6Mbps ();
   166             return WifiPhy::GetOfdmRate6Mbps ();
   167           }
   167           }
   200       return WifiPhy::GetErpOfdmRate6Mbps ();
   200       return WifiPhy::GetErpOfdmRate6Mbps ();
   201 
   201 
   202     case WIFI_MOD_CLASS_DSSS:
   202     case WIFI_MOD_CLASS_DSSS:
   203       if (preamble == WIFI_PREAMBLE_LONG)
   203       if (preamble == WIFI_PREAMBLE_LONG)
   204         {
   204         {
   205           // IEEE Std 802.11-2007, sections 15.2.3 and 18.2.2.1
   205           // (Section 16.2.3 "PLCP field definitions" and Section 17.2.2.2 "Long PPDU format"; IEEE Std 802.11-2012)
   206           return WifiPhy::GetDsssRate1Mbps ();
   206           return WifiPhy::GetDsssRate1Mbps ();
   207         }
   207         }
   208       else  //  WIFI_PREAMBLE_SHORT
   208       else  //  WIFI_PREAMBLE_SHORT
   209         {
   209         {
   210           // IEEE Std 802.11-2007, section 18.2.2.2
   210           // (Section 17.2.2.3 "Short PPDU format"; IEEE Std 802.11-2012)
   211           return WifiPhy::GetDsssRate2Mbps ();
   211           return WifiPhy::GetDsssRate2Mbps ();
   212         }
   212         }
   213 
   213 
   214     default:
   214     default:
   215       NS_FATAL_ERROR ("unsupported modulation class");
   215       NS_FATAL_ERROR ("unsupported modulation class");
   227       {
   227       {
   228         switch (payloadMode.GetBandwidth ())
   228         switch (payloadMode.GetBandwidth ())
   229           {
   229           {
   230           case 20000000:
   230           case 20000000:
   231           default:
   231           default:
   232             // IEEE Std 802.11-2007, section 17.3.3 and figure 17-4
   232             // (Section 18.3.3 "PLCP preamble (SYNC))" and Figure 18-4 "OFDM training structure"; IEEE Std 802.11-2012)
   233             // also section 17.3.2.3, table 17-4
   233             // also (Section 18.3.2.4 "Timing related parameters" Table 18-5 "Timing-related parameters"; IEEE Std 802.11-2012)
   234             // We return the duration of the SIGNAL field only, since the
   234             // We return the duration of the SIGNAL field only, since the
   235             // SERVICE field (which strictly speaking belongs to the PLCP
   235             // SERVICE field (which strictly speaking belongs to the PLCP
   236             // header, see section 17.3.2 and figure 17-1) is sent using the
   236             // header, see Section 18.3.2 and Figure 18-1) is sent using the
   237             // payload mode.
   237             // payload mode.
   238             return 4;
   238             return 4;
   239           case 10000000:
   239           case 10000000:
   240             // IEEE Std 802.11-2007, section 17.3.2.3, table 17-4
   240             // (Section 18.3.2.4 "Timing related parameters" Table 18-5 "Timing-related parameters"; IEEE Std 802.11-2012)
   241             return 8;
   241             return 8;
   242           case 5000000:
   242           case 5000000:
   243             // IEEE Std 802.11-2007, section 17.3.2.3, table 17-4
   243             // (Section 18.3.2.4 "Timing related parameters" Table 18-5 "Timing-related parameters"; IEEE Std 802.11-2012)
   244             return 16;
   244             return 16;
   245           }
   245           }
   246       }
   246       }
   247      //Added by Ghada to support 11n
   247      //Added by Ghada to support 11n
   248     case WIFI_MOD_CLASS_HT:
   248     case WIFI_MOD_CLASS_HT:
   264       return 4;
   264       return 4;
   265 
   265 
   266     case WIFI_MOD_CLASS_DSSS:
   266     case WIFI_MOD_CLASS_DSSS:
   267       if (preamble == WIFI_PREAMBLE_SHORT)
   267       if (preamble == WIFI_PREAMBLE_SHORT)
   268         {
   268         {
   269           // IEEE Std 802.11-2007, section 18.2.2.2 and figure 18-2
   269           // (Section 17.2.2.3 "Short PPDU format" and Figure 17-2 "Short PPDU format"; IEEE Std 802.11-2012)
   270           return 24;
   270           return 24;
   271         }
   271         }
   272       else // WIFI_PREAMBLE_LONG
   272       else // WIFI_PREAMBLE_LONG
   273         {
   273         {
   274           // IEEE Std 802.11-2007, sections 18.2.2.1 and figure 18-1
   274           // (Section 17.2.2.2 "Long PPDU format" and Figure 17-1 "Short PPDU format"; IEEE Std 802.11-2012)
   275           return 48;
   275           return 48;
   276         }
   276         }
   277 
   277 
   278     default:
   278     default:
   279       NS_FATAL_ERROR ("unsupported modulation class");
   279       NS_FATAL_ERROR ("unsupported modulation class");
   290       {
   290       {
   291         switch (payloadMode.GetBandwidth ())
   291         switch (payloadMode.GetBandwidth ())
   292           {
   292           {
   293           case 20000000:
   293           case 20000000:
   294           default:
   294           default:
   295             // IEEE Std 802.11-2007, section 17.3.3,  figure 17-4
   295             // (Section 18.3.3 "PLCP preamble (SYNC))" Figure 18-4 "OFDM training structure"
   296             // also section 17.3.2.3, table 17-4
   296             // also Section 18.3.2.3 "Modulation-dependent parameters" Table 18-4 "Modulation-dependent parameters"; IEEE Std 802.11-2012)
   297             return 16;
   297             return 16;
   298           case 10000000:
   298           case 10000000:
   299             // IEEE Std 802.11-2007, section 17.3.3, table 17-4
   299             // (Section 18.3.3 "PLCP preamble (SYNC))" Figure 18-4 "OFDM training structure"
   300             // also section 17.3.2.3, table 17-4
   300             // also Section 18.3.2.3 "Modulation-dependent parameters" Table 18-4 "Modulation-dependent parameters"; IEEE Std 802.11-2012)
   301             return 32;
   301             return 32;
   302           case 5000000:
   302           case 5000000:
   303             // IEEE Std 802.11-2007, section 17.3.3
   303             // (Section 18.3.3 "PLCP preamble (SYNC))" Figure 18-4 "OFDM training structure"
   304             // also section 17.3.2.3, table 17-4
   304             // also Section 18.3.2.3 "Modulation-dependent parameters" Table 18-4 "Modulation-dependent parameters"; IEEE Std 802.11-2012)
   305             return 64;
   305             return 64;
   306           }
   306           }
   307       }
   307       }
   308     case WIFI_MOD_CLASS_HT:
   308     case WIFI_MOD_CLASS_HT:
   309       { //IEEE 802.11n Figure 20.1 the training symbols before L_SIG or HT_SIG
   309       { //IEEE 802.11n Figure 20.1 the training symbols before L_SIG or HT_SIG
   313       return 16;
   313       return 16;
   314 
   314 
   315     case WIFI_MOD_CLASS_DSSS:
   315     case WIFI_MOD_CLASS_DSSS:
   316       if (preamble == WIFI_PREAMBLE_SHORT)
   316       if (preamble == WIFI_PREAMBLE_SHORT)
   317         {
   317         {
   318           // IEEE Std 802.11-2007, section 18.2.2.2 and figure 18-2
   318           // (Section 17.2.2.3 "Short PPDU format)" Figure 17-2 "Short PPDU format"; IEEE Std 802.11-2012)
   319           return 72;
   319           return 72;
   320         }
   320         }
   321       else // WIFI_PREAMBLE_LONG
   321       else // WIFI_PREAMBLE_LONG
   322         {
   322         {
   323           // IEEE Std 802.11-2007, sections 18.2.2.1 and figure 18-1
   323           // (Section 17.2.2.2 "Long PPDU format)" Figure 17-1 "Long PPDU format"; IEEE Std 802.11-2012)
   324           return 144;
   324           return 144;
   325         }
   325         }
   326     default:
   326     default:
   327       NS_FATAL_ERROR ("unsupported modulation class");
   327       NS_FATAL_ERROR ("unsupported modulation class");
   328       return 0;
   328       return 0;
   339   switch (payloadMode.GetModulationClass ())
   339   switch (payloadMode.GetModulationClass ())
   340     {
   340     {
   341     case WIFI_MOD_CLASS_OFDM:
   341     case WIFI_MOD_CLASS_OFDM:
   342     case WIFI_MOD_CLASS_ERP_OFDM:
   342     case WIFI_MOD_CLASS_ERP_OFDM:
   343       {
   343       {
   344         // IEEE Std 802.11-2007, section 17.3.2.3, table 17-4
   344         // (Section 18.3.2.4 "Timing related parameters" Table 18-5 "Timing-related parameters"; IEEE Std 802.11-2012
   345         // corresponds to T_{SYM} in the table
   345         // corresponds to T_{SYM} in the table)
   346         uint32_t symbolDurationUs;
   346         uint32_t symbolDurationUs;
   347 
   347 
   348         switch (payloadMode.GetBandwidth ())
   348         switch (payloadMode.GetBandwidth ())
   349           {
   349           {
   350           case 20000000:
   350           case 20000000:
   357           case 5000000:
   357           case 5000000:
   358             symbolDurationUs = 16;
   358             symbolDurationUs = 16;
   359             break;
   359             break;
   360           }
   360           }
   361 
   361 
   362         // IEEE Std 802.11-2007, section 17.3.2.2, table 17-3
   362         // (Section 18.3.2.3 "Modulation-dependent parameters" Table 18-4 "Modulation-dependent parameters"; IEEE Std 802.11-2012)
   363         // corresponds to N_{DBPS} in the table
   363         // corresponds to N_{DBPS} in the table
   364         double numDataBitsPerSymbol = payloadMode.GetDataRate () * symbolDurationUs / 1e6;
   364         double numDataBitsPerSymbol = payloadMode.GetDataRate () * symbolDurationUs / 1e6;
   365 
   365 
   366         // IEEE Std 802.11-2007, section 17.3.5.3, equation (17-11)
   366         // (Section 18.3.5.4 "Pad bits (PAD)" Equation 18-11; IEEE Std 802.11-2012)
   367         uint32_t numSymbols = lrint (ceil ((16 + size * 8.0 + 6.0) / numDataBitsPerSymbol));
   367         uint32_t numSymbols = lrint (ceil ((16 + size * 8.0 + 6.0) / numDataBitsPerSymbol));
   368 
   368 
   369         // Add signal extension for ERP PHY
   369         // Add signal extension for ERP PHY
   370         if (payloadMode.GetModulationClass () == WIFI_MOD_CLASS_ERP_OFDM)
   370         if (payloadMode.GetModulationClass () == WIFI_MOD_CLASS_ERP_OFDM)
   371           {
   371           {
   422        
   422        
   423         return numSymbols * symbolDurationUs;
   423         return numSymbols * symbolDurationUs;
   424          
   424          
   425       }
   425       }
   426     case WIFI_MOD_CLASS_DSSS:
   426     case WIFI_MOD_CLASS_DSSS:
   427       // IEEE Std 802.11-2007, section 18.2.3.5
   427       // (Section 17.2.3.6 "Long PLCP LENGTH field"; IEEE Std 802.11-2012)
   428       NS_LOG_LOGIC (" size=" << size
   428       NS_LOG_LOGIC (" size=" << size
   429                              << " mode=" << payloadMode
   429                              << " mode=" << payloadMode
   430                              << " rate=" << payloadMode.GetDataRate () );
   430                              << " rate=" << payloadMode.GetDataRate () );
   431       return lrint (ceil ((size * 8.0) / (payloadMode.GetDataRate () / 1.0e6)));
   431       return lrint (ceil ((size * 8.0) / (payloadMode.GetDataRate () / 1.0e6)));
   432 
   432