diff --git a/examples/wireless/wifi-spectrum-per-example.cc b/examples/wireless/wifi-spectrum-per-example.cc index 5ec205e09..fd30b6262 100644 --- a/examples/wireless/wifi-spectrum-per-example.cc +++ b/examples/wireless/wifi-spectrum-per-example.cc @@ -413,30 +413,10 @@ main(int argc, char* argv[]) apDevice = wifi.Install(spectrumPhy, mac, wifiApNode); } - if (i <= 7) - { - Config::Set("/NodeList/*/DeviceList/*/$ns3::WifiNetDevice/HtConfiguration/" - "ShortGuardIntervalSupported", - BooleanValue(false)); - } - else if (i > 7 && i <= 15) - { - Config::Set("/NodeList/*/DeviceList/*/$ns3::WifiNetDevice/HtConfiguration/" - "ShortGuardIntervalSupported", - BooleanValue(true)); - } - else if (i > 15 && i <= 23) - { - Config::Set("/NodeList/*/DeviceList/*/$ns3::WifiNetDevice/HtConfiguration/" - "ShortGuardIntervalSupported", - BooleanValue(false)); - } - else - { - Config::Set("/NodeList/*/DeviceList/*/$ns3::WifiNetDevice/HtConfiguration/" - "ShortGuardIntervalSupported", - BooleanValue(true)); - } + bool shortGuardIntervalSupported = (i > 7 && i <= 15) || (i > 23); + Config::Set("/NodeList/*/DeviceList/*/$ns3::WifiNetDevice/HtConfiguration/" + "ShortGuardIntervalSupported", + BooleanValue(shortGuardIntervalSupported)); // mobility. MobilityHelper mobility; diff --git a/examples/wireless/wifi-spectrum-per-interference.cc b/examples/wireless/wifi-spectrum-per-interference.cc index 3c1d9be3a..6e2ae44d7 100644 --- a/examples/wireless/wifi-spectrum-per-interference.cc +++ b/examples/wireless/wifi-spectrum-per-interference.cc @@ -468,30 +468,10 @@ main(int argc, char* argv[]) apDevice = wifi.Install(spectrumPhy, mac, wifiApNode); } - if (i <= 7) - { - Config::Set("/NodeList/*/DeviceList/*/$ns3::WifiNetDevice/HtConfiguration/" - "ShortGuardIntervalSupported", - BooleanValue(false)); - } - else if (i > 7 && i <= 15) - { - Config::Set("/NodeList/*/DeviceList/*/$ns3::WifiNetDevice/HtConfiguration/" - "ShortGuardIntervalSupported", - BooleanValue(true)); - } - else if (i > 15 && i <= 23) - { - Config::Set("/NodeList/*/DeviceList/*/$ns3::WifiNetDevice/HtConfiguration/" - "ShortGuardIntervalSupported", - BooleanValue(false)); - } - else - { - Config::Set("/NodeList/*/DeviceList/*/$ns3::WifiNetDevice/HtConfiguration/" - "ShortGuardIntervalSupported", - BooleanValue(true)); - } + bool shortGuardIntervalSupported = (i > 7 && i <= 15) || (i > 23); + Config::Set("/NodeList/*/DeviceList/*/$ns3::WifiNetDevice/HtConfiguration/" + "ShortGuardIntervalSupported", + BooleanValue(shortGuardIntervalSupported)); // mobility. MobilityHelper mobility; diff --git a/examples/wireless/wifi-spectrum-saturation-example.cc b/examples/wireless/wifi-spectrum-saturation-example.cc index b57380a59..11dd67263 100644 --- a/examples/wireless/wifi-spectrum-saturation-example.cc +++ b/examples/wireless/wifi-spectrum-saturation-example.cc @@ -152,25 +152,7 @@ main(int argc, char* argv[]) phy.Set("TxPowerStart", DoubleValue(1)); phy.Set("TxPowerEnd", DoubleValue(1)); - if (i > 31 && i <= 39) - { - phy.Set("Antennas", UintegerValue(2)); - phy.Set("MaxSupportedTxSpatialStreams", UintegerValue(2)); - phy.Set("MaxSupportedRxSpatialStreams", UintegerValue(2)); - } - else if (i > 39 && i <= 47) - { - phy.Set("Antennas", UintegerValue(2)); - phy.Set("MaxSupportedTxSpatialStreams", UintegerValue(2)); - phy.Set("MaxSupportedRxSpatialStreams", UintegerValue(2)); - } - else if (i > 47 && i <= 55) - { - phy.Set("Antennas", UintegerValue(2)); - phy.Set("MaxSupportedTxSpatialStreams", UintegerValue(2)); - phy.Set("MaxSupportedRxSpatialStreams", UintegerValue(2)); - } - else if (i > 55 && i <= 63) + if (i > 31 && i <= 63) { phy.Set("Antennas", UintegerValue(2)); phy.Set("MaxSupportedTxSpatialStreams", UintegerValue(2)); @@ -193,25 +175,7 @@ main(int argc, char* argv[]) spectrumPhy.Set("TxPowerStart", DoubleValue(1)); spectrumPhy.Set("TxPowerEnd", DoubleValue(1)); - if (i > 31 && i <= 39) - { - spectrumPhy.Set("Antennas", UintegerValue(2)); - spectrumPhy.Set("MaxSupportedTxSpatialStreams", UintegerValue(2)); - spectrumPhy.Set("MaxSupportedRxSpatialStreams", UintegerValue(2)); - } - else if (i > 39 && i <= 47) - { - spectrumPhy.Set("Antennas", UintegerValue(2)); - spectrumPhy.Set("MaxSupportedTxSpatialStreams", UintegerValue(2)); - spectrumPhy.Set("MaxSupportedRxSpatialStreams", UintegerValue(2)); - } - else if (i > 47 && i <= 55) - { - spectrumPhy.Set("Antennas", UintegerValue(2)); - spectrumPhy.Set("MaxSupportedTxSpatialStreams", UintegerValue(2)); - spectrumPhy.Set("MaxSupportedRxSpatialStreams", UintegerValue(2)); - } - else if (i > 55 && i <= 63) + if (i > 31 && i <= 63) { spectrumPhy.Set("Antennas", UintegerValue(2)); spectrumPhy.Set("MaxSupportedTxSpatialStreams", UintegerValue(2)); @@ -588,30 +552,11 @@ main(int argc, char* argv[]) apDevice = wifi.Install(spectrumPhy, mac, wifiApNode); } - if ((i <= 7) || (i > 31 && i <= 39)) - { - Config::Set("/NodeList/*/DeviceList/*/$ns3::WifiNetDevice/HtConfiguration/" - "ShortGuardIntervalSupported", - BooleanValue(false)); - } - else if ((i > 7 && i <= 15) || (i > 39 && i <= 47)) - { - Config::Set("/NodeList/*/DeviceList/*/$ns3::WifiNetDevice/HtConfiguration/" - "ShortGuardIntervalSupported", - BooleanValue(true)); - } - else if ((i > 15 && i <= 23) || (i > 47 && i <= 55)) - { - Config::Set("/NodeList/*/DeviceList/*/$ns3::WifiNetDevice/HtConfiguration/" - "ShortGuardIntervalSupported", - BooleanValue(false)); - } - else - { - Config::Set("/NodeList/*/DeviceList/*/$ns3::WifiNetDevice/HtConfiguration/" - "ShortGuardIntervalSupported", - BooleanValue(true)); - } + bool shortGuardIntervalSupported = + (i > 7 && i <= 15) || (i > 23 && i <= 31) || (i > 39 && i <= 47) || (i > 55); + Config::Set("/NodeList/*/DeviceList/*/$ns3::WifiNetDevice/HtConfiguration/" + "ShortGuardIntervalSupported", + BooleanValue(shortGuardIntervalSupported)); // mobility. MobilityHelper mobility; diff --git a/src/aodv/model/aodv-routing-protocol.cc b/src/aodv/model/aodv-routing-protocol.cc index 158dccde1..4d46b8027 100644 --- a/src/aodv/model/aodv-routing-protocol.cc +++ b/src/aodv/model/aodv-routing-protocol.cc @@ -1685,33 +1685,24 @@ RoutingProtocol::RecvReply(Ptr p, Ipv4Address receiver, Ipv4Address send RoutingTableEntry toDst; if (m_routingTable.LookupRoute(dst, toDst)) { - /* - * The existing entry is updated only in the following circumstances: - * (i) the sequence number in the routing table is marked as invalid in route table entry. - */ - if (!toDst.GetValidSeqNo()) - { - m_routingTable.Update(newEntry); - } - // (ii)the Destination Sequence Number in the RREP is greater than the node's copy of the - // destination sequence number and the known value is valid, - else if ((int32_t(rrepHeader.GetDstSeqno()) - int32_t(toDst.GetSeqNo())) > 0) - { - m_routingTable.Update(newEntry); - } - else - { + // The existing entry is updated only in the following circumstances: + if ( + // (i) the sequence number in the routing table is marked as invalid in route table + // entry. + (!toDst.GetValidSeqNo()) || + + // (ii) the Destination Sequence Number in the RREP is greater than the node's copy of + // the destination sequence number and the known value is valid, + ((int32_t(rrepHeader.GetDstSeqno()) - int32_t(toDst.GetSeqNo())) > 0) || + // (iii) the sequence numbers are the same, but the route is marked as inactive. - if ((rrepHeader.GetDstSeqno() == toDst.GetSeqNo()) && (toDst.GetFlag() != VALID)) - { - m_routingTable.Update(newEntry); - } - // (iv) the sequence numbers are the same, and the New Hop Count is smaller than the + (rrepHeader.GetDstSeqno() == toDst.GetSeqNo() && toDst.GetFlag() != VALID) || + + // (iv) the sequence numbers are the same, and the New Hop Count is smaller than the // hop count in route table entry. - else if ((rrepHeader.GetDstSeqno() == toDst.GetSeqNo()) && (hop < toDst.GetHop())) - { - m_routingTable.Update(newEntry); - } + (rrepHeader.GetDstSeqno() == toDst.GetSeqNo() && hop < toDst.GetHop())) + { + m_routingTable.Update(newEntry); } } else diff --git a/src/config-store/model/display-functions.cc b/src/config-store/model/display-functions.cc index ac3ed0055..a8b0abb07 100644 --- a/src/config-store/model/display-functions.cc +++ b/src/config-store/model/display-functions.cc @@ -84,20 +84,15 @@ cell_data_function_col_0(GtkTreeViewColumn* col, node->object->GetInstanceTypeId().GetName().c_str(), nullptr); break; + case ModelNode::NODE_ATTRIBUTE: case ModelNode::NODE_POINTER: - g_object_set(renderer, "text", node->name.c_str(), nullptr); - break; case ModelNode::NODE_VECTOR: g_object_set(renderer, "text", node->name.c_str(), nullptr); break; - case ModelNode::NODE_VECTOR_ITEM: { + case ModelNode::NODE_VECTOR_ITEM: std::stringstream oss; oss << node->index; g_object_set(renderer, "text", oss.str().c_str(), nullptr); - } - break; - case ModelNode::NODE_ATTRIBUTE: - g_object_set(renderer, "text", node->name.c_str(), nullptr); break; } } diff --git a/src/core/helper/csv-reader.cc b/src/core/helper/csv-reader.cc index c62e30b27..a44e42e5e 100644 --- a/src/core/helper/csv-reader.cc +++ b/src/core/helper/csv-reader.cc @@ -459,7 +459,6 @@ CsvReader::ParseColumn(std::string::const_iterator begin, std::string::const_ite } break; case State::FIND_DELIMITER: - break; case State::END: break; } diff --git a/src/core/model/callback.h b/src/core/model/callback.h index 8e3dafa8c..df4a2dfb8 100644 --- a/src/core/model/callback.h +++ b/src/core/model/callback.h @@ -650,18 +650,12 @@ class Callback : public CallbackBase */ bool DoCheckType(Ptr other) const { - if (other && dynamic_cast*>(PeekPointer(other)) != nullptr) + if (!other) { return true; } - else if (!other) - { - return true; - } - else - { - return false; - } + + return (dynamic_cast*>(PeekPointer(other)) != nullptr); } }; diff --git a/src/core/model/scheduler.h b/src/core/model/scheduler.h index 096102e8c..7635953ef 100644 --- a/src/core/model/scheduler.h +++ b/src/core/model/scheduler.h @@ -272,18 +272,7 @@ operator!=(const Scheduler::EventKey& a, const Scheduler::EventKey& b) inline bool operator<(const Scheduler::EventKey& a, const Scheduler::EventKey& b) { - if (a.m_ts < b.m_ts) - { - return true; - } - else if (a.m_ts == b.m_ts && a.m_uid < b.m_uid) - { - return true; - } - else - { - return false; - } + return (a.m_ts < b.m_ts || (a.m_ts == b.m_ts && a.m_uid < b.m_uid)); } /** @@ -296,18 +285,7 @@ operator<(const Scheduler::EventKey& a, const Scheduler::EventKey& b) inline bool operator>(const Scheduler::EventKey& a, const Scheduler::EventKey& b) { - if (a.m_ts > b.m_ts) - { - return true; - } - else if (a.m_ts == b.m_ts && a.m_uid > b.m_uid) - { - return true; - } - else - { - return false; - } + return (a.m_ts > b.m_ts || (a.m_ts == b.m_ts && a.m_uid > b.m_uid)); } /** diff --git a/src/core/model/test.cc b/src/core/model/test.cc index 5c85b16fa..af8063118 100644 --- a/src/core/model/test.cc +++ b/src/core/model/test.cc @@ -927,11 +927,6 @@ TestRunnerImpl::Run(int argc, char* argv[]) { m_updateData = true; } - else if (arg == "--help") - { - PrintHelp(progname); - return 0; - } else if (arg == "--print-test-name-list" || arg == "--list") { printTestNameList = true; @@ -956,11 +951,8 @@ TestRunnerImpl::Run(int argc, char* argv[]) { testTypeString = arg.substr(arg.find_first_of('=') + 1); } - else if (arg.find("--test-name=") != std::string::npos) - { - testName = arg.substr(arg.find_first_of('=') + 1); - } - else if (arg.find("--suite=") != std::string::npos) + else if (arg.find("--test-name=") != std::string::npos || + arg.find("--suite=") != std::string::npos) { testName = arg.substr(arg.find_first_of('=') + 1); } @@ -998,18 +990,14 @@ TestRunnerImpl::Run(int argc, char* argv[]) } else { - // un-recognized command-line argument + // Print the help if arg == "--help" or arg is an un-recognized command-line argument PrintHelp(progname); return 0; } argi++; } TestSuite::Type testType; - if (testTypeString.empty()) - { - testType = TestSuite::Type::ALL; - } - else if (testTypeString == "core") + if (testTypeString.empty() || testTypeString == "core") { testType = TestSuite::Type::ALL; } diff --git a/src/internet/model/arp-cache.cc b/src/internet/model/arp-cache.cc index 1301b34dd..1e2c7157b 100644 --- a/src/internet/model/arp-cache.cc +++ b/src/internet/model/arp-cache.cc @@ -536,7 +536,6 @@ ArpCache::Entry::GetTimeout() const case ArpCache::Entry::ALIVE: return m_arp->GetAliveTimeout(); case ArpCache::Entry::PERMANENT: - return Time::Max(); case ArpCache::Entry::STATIC_AUTOGENERATED: return Time::Max(); } diff --git a/src/internet/model/global-route-manager-impl.cc b/src/internet/model/global-route-manager-impl.cc index aef8da06c..573bc9231 100644 --- a/src/internet/model/global-route-manager-impl.cc +++ b/src/internet/model/global-route-manager-impl.cc @@ -1254,12 +1254,8 @@ GlobalRouteManagerImpl::CheckForStubNode(Ipv4Address root) for (uint32_t i = 0; i < rlsa->GetNLinkRecords(); i++) { GlobalRoutingLinkRecord* l = rlsa->GetLinkRecord(i); - if (l->GetLinkType() == GlobalRoutingLinkRecord::TransitNetwork) - { - transits++; - transitLink = l; - } - else if (l->GetLinkType() == GlobalRoutingLinkRecord::PointToPoint) + if (l->GetLinkType() == GlobalRoutingLinkRecord::TransitNetwork || + l->GetLinkType() == GlobalRoutingLinkRecord::PointToPoint) { transits++; transitLink = l; diff --git a/src/internet/model/ipv6-l3-protocol.cc b/src/internet/model/ipv6-l3-protocol.cc index 7bd0835d8..f90c46aef 100644 --- a/src/internet/model/ipv6-l3-protocol.cc +++ b/src/internet/model/ipv6-l3-protocol.cc @@ -1102,12 +1102,8 @@ Ipv6L3Protocol::Receive(Ptr device, } } - if (hdr.GetDestination().IsAllNodesMulticast()) - { - LocalDeliver(packet, hdr, interface); - return; - } - else if (hdr.GetDestination().IsAllRoutersMulticast() && ipv6Interface->IsForwarding()) + if (hdr.GetDestination().IsAllNodesMulticast() || + (hdr.GetDestination().IsAllRoutersMulticast() && ipv6Interface->IsForwarding())) { LocalDeliver(packet, hdr, interface); return; @@ -1555,9 +1551,7 @@ Ipv6L3Protocol::LocalDeliver(Ptr packet, const Ipv6Header& ip, uin switch (status) { case IpL4Protocol::RX_OK: - break; case IpL4Protocol::RX_CSUM_FAILED: - break; case IpL4Protocol::RX_ENDPOINT_CLOSED: break; case IpL4Protocol::RX_ENDPOINT_UNREACH: diff --git a/src/internet/model/ipv6-static-routing.cc b/src/internet/model/ipv6-static-routing.cc index 82dd4c06e..b3c086d04 100644 --- a/src/internet/model/ipv6-static-routing.cc +++ b/src/internet/model/ipv6-static-routing.cc @@ -444,21 +444,17 @@ Ipv6StaticRouting::LookupStatic(Ipv6Address dst, Ptr interface) uint32_t interfaceIdx = route->GetInterface(); rtentry = Create(); - if (route->GetGateway().IsAny()) + if (route->GetGateway().IsAny() || !route->GetDest().IsAny()) { rtentry->SetSource( m_ipv6->SourceAddressSelection(interfaceIdx, route->GetDest())); } - else if (route->GetDest().IsAny()) /* default route */ - { - rtentry->SetSource(m_ipv6->SourceAddressSelection( - interfaceIdx, - route->GetPrefixToUse().IsAny() ? dst : route->GetPrefixToUse())); - } else { - rtentry->SetSource( - m_ipv6->SourceAddressSelection(interfaceIdx, route->GetDest())); + // Default route + rtentry->SetSource(m_ipv6->SourceAddressSelection( + interfaceIdx, + route->GetPrefixToUse().IsAny() ? dst : route->GetPrefixToUse())); } rtentry->SetDestination(route->GetDest()); diff --git a/src/internet/model/loopback-net-device.cc b/src/internet/model/loopback-net-device.cc index e30c0f967..bb02588c2 100644 --- a/src/internet/model/loopback-net-device.cc +++ b/src/internet/model/loopback-net-device.cc @@ -58,11 +58,7 @@ LoopbackNetDevice::Receive(Ptr packet, { NS_LOG_FUNCTION(packet << " " << protocol << " " << to << " " << from); NetDevice::PacketType packetType; - if (to == m_address) - { - packetType = NetDevice::PACKET_HOST; - } - else if (to.IsBroadcast()) + if (to == m_address || to.IsBroadcast()) { packetType = NetDevice::PACKET_HOST; } diff --git a/src/internet/model/rip.cc b/src/internet/model/rip.cc index 51c68f1ac..9b6478024 100644 --- a/src/internet/model/rip.cc +++ b/src/internet/model/rip.cc @@ -1241,11 +1241,8 @@ Rip::DoSendRouteUpdate(bool periodic) rte.SetRouteMetric(rtIter->first->GetRouteMetric()); } rte.SetRouteTag(rtIter->first->GetRouteTag()); - if (m_splitHorizonStrategy == SPLIT_HORIZON && !splitHorizoning) - { - hdr.AddRte(rte); - } - else if (m_splitHorizonStrategy != SPLIT_HORIZON) + if ((m_splitHorizonStrategy == SPLIT_HORIZON && !splitHorizoning) || + (m_splitHorizonStrategy != SPLIT_HORIZON)) { hdr.AddRte(rte); } diff --git a/src/internet/model/ripng.cc b/src/internet/model/ripng.cc index 87b7c0f24..85304550d 100644 --- a/src/internet/model/ripng.cc +++ b/src/internet/model/ripng.cc @@ -1242,11 +1242,8 @@ RipNg::DoSendRouteUpdate(bool periodic) rte.SetRouteMetric(rtIter->first->GetRouteMetric()); } rte.SetRouteTag(rtIter->first->GetRouteTag()); - if (m_splitHorizonStrategy == SPLIT_HORIZON && !splitHorizoning) - { - hdr.AddRte(rte); - } - else if (m_splitHorizonStrategy != SPLIT_HORIZON) + if ((m_splitHorizonStrategy == SPLIT_HORIZON && !splitHorizoning) || + (m_splitHorizonStrategy != SPLIT_HORIZON)) { hdr.AddRte(rte); } diff --git a/src/internet/model/tcp-highspeed.cc b/src/internet/model/tcp-highspeed.cc index f93b78a96..c69da3d37 100644 --- a/src/internet/model/tcp-highspeed.cc +++ b/src/internet/model/tcp-highspeed.cc @@ -447,15 +447,14 @@ TcpHighSpeed::TableLookupA(uint32_t w) { return 73; } - else - { - return 73; - } + + return 73; } double TcpHighSpeed::TableLookupB(uint32_t w) { + // NOLINTBEGIN(bugprone-branch-clone) if (w <= 38) { return 0.50; @@ -752,6 +751,7 @@ TcpHighSpeed::TableLookupB(uint32_t w) { return 0.09; } + // NOLINTEND(bugprone-branch-clone) } } // namespace ns3 diff --git a/src/internet/model/tcp-socket-base.cc b/src/internet/model/tcp-socket-base.cc index ad1ec1a78..b681c1204 100644 --- a/src/internet/model/tcp-socket-base.cc +++ b/src/internet/model/tcp-socket-base.cc @@ -1536,13 +1536,13 @@ TcpSocketBase::ProcessEstablished(Ptr packet, const TcpHeader& tcpHeader ReceivedAck(packet, tcpHeader); } } - else if (tcpflags == TcpHeader::SYN) - { // Received SYN, old NS-3 behaviour is to set state to SYN_RCVD and - // respond with a SYN+ACK. But it is not a legal state transition as of - // RFC793. Thus this is ignored. - } - else if (tcpflags == (TcpHeader::SYN | TcpHeader::ACK)) - { // No action for received SYN+ACK, it is probably a duplicated packet + else if (tcpflags == TcpHeader::SYN || tcpflags == (TcpHeader::SYN | TcpHeader::ACK)) + { + // (a) Received SYN, old NS-3 behaviour is to set state to SYN_RCVD and + // respond with a SYN+ACK. But it is not a legal state transition as of + // RFC793. Thus this is ignored. + + // (b) No action for received SYN+ACK, it is probably a duplicated packet } else if (tcpflags == TcpHeader::FIN || tcpflags == (TcpHeader::FIN | TcpHeader::ACK)) { // Received FIN or FIN+ACK, bring down this socket nicely diff --git a/src/internet/model/tcp-tx-buffer.cc b/src/internet/model/tcp-tx-buffer.cc index 0b5627b8c..e190835bc 100644 --- a/src/internet/model/tcp-tx-buffer.cc +++ b/src/internet/model/tcp-tx-buffer.cc @@ -1103,14 +1103,10 @@ TcpTxBuffer::BytesInFlightRFC() const { bool isLost = IsLostRFC(beginOfCurrentPkt, it); // (a) If IsLost (S1) returns false: Pipe is incremented by 1 octet. - if (!isLost) - { - size += item->m_packet->GetSize(); - } // (b) If S1 <= HighRxt: Pipe is incremented by 1 octet. // (NOTE: we use the m_retrans flag instead of keeping and updating // another variable). Only if the item is not marked as lost - else if (item->m_retrans) + if (!isLost || item->m_retrans) { size += item->m_packet->GetSize(); } diff --git a/src/internet/test/tcp-ecn-test.cc b/src/internet/test/tcp-ecn-test.cc index 831765fc7..0aececc61 100644 --- a/src/internet/test/tcp-ecn-test.cc +++ b/src/internet/test/tcp-ecn-test.cc @@ -195,11 +195,8 @@ TcpSocketCongestedRouter::SendDataPacket(SequenceNumber32 seq, uint32_t maxSize, if (GetIpTos()) { SocketIpTosTag ipTosTag; - if (m_testcase == 5 && (m_dataPacketSent == 1 || m_dataPacketSent == 3)) - { - ipTosTag.SetTos(MarkEcnCe(GetIpTos())); - } - else if (m_testcase == 6 && (m_dataPacketSent == 4 || m_dataPacketSent == 5)) + if ((m_testcase == 5 && (m_dataPacketSent == 1 || m_dataPacketSent == 3)) || + (m_testcase == 6 && (m_dataPacketSent == 4 || m_dataPacketSent == 5))) { ipTosTag.SetTos(MarkEcnCe(GetIpTos())); } @@ -219,11 +216,8 @@ TcpSocketCongestedRouter::SendDataPacket(SequenceNumber32 seq, uint32_t maxSize, else { SocketIpTosTag ipTosTag; - if (m_testcase == 5 && (m_dataPacketSent == 1 || m_dataPacketSent == 3)) - { - ipTosTag.SetTos(MarkEcnCe(GetIpTos())); - } - else if (m_testcase == 6 && (m_dataPacketSent == 4 || m_dataPacketSent == 5)) + if ((m_testcase == 5 && (m_dataPacketSent == 1 || m_dataPacketSent == 3)) || + (m_testcase == 6 && (m_dataPacketSent == 4 || m_dataPacketSent == 5))) { ipTosTag.SetTos(MarkEcnCe(GetIpTos())); } @@ -240,11 +234,8 @@ TcpSocketCongestedRouter::SendDataPacket(SequenceNumber32 seq, uint32_t maxSize, if (IsManualIpv6Tclass()) { SocketIpv6TclassTag ipTclassTag; - if (m_testcase == 5 && (m_dataPacketSent == 1 || m_dataPacketSent == 3)) - { - ipTclassTag.SetTclass(MarkEcnCe(GetIpv6Tclass())); - } - else if (m_testcase == 6 && (m_dataPacketSent == 4 || m_dataPacketSent == 5)) + if ((m_testcase == 5 && (m_dataPacketSent == 1 || m_dataPacketSent == 3)) || + (m_testcase == 6 && (m_dataPacketSent == 4 || m_dataPacketSent == 5))) { ipTclassTag.SetTclass(MarkEcnCe(GetIpv6Tclass())); } @@ -264,11 +255,8 @@ TcpSocketCongestedRouter::SendDataPacket(SequenceNumber32 seq, uint32_t maxSize, else { SocketIpv6TclassTag ipTclassTag; - if (m_testcase == 5 && (m_dataPacketSent == 1 || m_dataPacketSent == 3)) - { - ipTclassTag.SetTclass(MarkEcnCe(GetIpv6Tclass())); - } - else if (m_testcase == 6 && (m_dataPacketSent == 4 || m_dataPacketSent == 5)) + if ((m_testcase == 5 && (m_dataPacketSent == 1 || m_dataPacketSent == 3)) || + (m_testcase == 6 && (m_dataPacketSent == 4 || m_dataPacketSent == 5))) { ipTclassTag.SetTclass(MarkEcnCe(GetIpv6Tclass())); } diff --git a/src/internet/test/tcp-fast-retr-test.cc b/src/internet/test/tcp-fast-retr-test.cc index 64eb09f7f..6567d0f49 100644 --- a/src/internet/test/tcp-fast-retr-test.cc +++ b/src/internet/test/tcp-fast-retr-test.cc @@ -208,14 +208,10 @@ TcpFastRetrTest::Tx(const Ptr p, const TcpHeader& h, SocketWho who } } - if (m_sndNextExpSeq.GetValue() == 0) + // SYN or Pure ACK in three-way handshake, then we expect data + if ((m_sndNextExpSeq.GetValue() == 0) || + (m_sndNextExpSeq.GetValue() == 1 && p->GetSize() == 32)) { - // SYN - m_sndNextExpSeq = SequenceNumber32(1); - } - else if (m_sndNextExpSeq.GetValue() == 1 && p->GetSize() == 32) - { - // Pure ACK in three-way handshake, then we expect data m_sndNextExpSeq = SequenceNumber32(1); } else diff --git a/src/internet/test/tcp-sack-permitted-test.cc b/src/internet/test/tcp-sack-permitted-test.cc index 736ed7eb7..61dda3e3c 100644 --- a/src/internet/test/tcp-sack-permitted-test.cc +++ b/src/internet/test/tcp-sack-permitted-test.cc @@ -101,17 +101,11 @@ SackPermittedTestCase::CreateSenderSocket(Ptr node) switch (m_configuration) { case DISABLED: - socket->SetAttribute("Sack", BooleanValue(false)); - break; - case ENABLED_RECEIVER: socket->SetAttribute("Sack", BooleanValue(false)); break; case ENABLED_SENDER: - socket->SetAttribute("Sack", BooleanValue(true)); - break; - case ENABLED: socket->SetAttribute("Sack", BooleanValue(true)); break; diff --git a/src/internet/test/tcp-timestamp-test.cc b/src/internet/test/tcp-timestamp-test.cc index 3bd985278..b9916500e 100644 --- a/src/internet/test/tcp-timestamp-test.cc +++ b/src/internet/test/tcp-timestamp-test.cc @@ -103,17 +103,11 @@ TimestampTestCase::CreateSenderSocket(Ptr node) switch (m_configuration) { case DISABLED: - socket->SetAttribute("Timestamp", BooleanValue(false)); - break; - case ENABLED_RECEIVER: socket->SetAttribute("Timestamp", BooleanValue(false)); break; case ENABLED_SENDER: - socket->SetAttribute("Timestamp", BooleanValue(true)); - break; - case ENABLED: socket->SetAttribute("Timestamp", BooleanValue(true)); break; @@ -199,12 +193,12 @@ TimestampTestCase::Tx(const Ptr p, const TcpHeader& h, SocketWho w void TimestampTestCase::Rx(const Ptr p, const TcpHeader& h, SocketWho who) { - if (who == SENDER) - { - } - else if (who == RECEIVER) - { - } + // if (who == SENDER) + // { + // } + // else if (who == RECEIVER) + // { + // } } /** diff --git a/src/internet/test/tcp-wscaling-test.cc b/src/internet/test/tcp-wscaling-test.cc index 73f50ed3b..794f9cc96 100644 --- a/src/internet/test/tcp-wscaling-test.cc +++ b/src/internet/test/tcp-wscaling-test.cc @@ -118,17 +118,11 @@ WScalingTestCase::CreateSenderSocket(Ptr node) switch (m_configuration) { case DISABLED: - socket->SetAttribute("WindowScaling", BooleanValue(false)); - break; - case ENABLED_RECEIVER: socket->SetAttribute("WindowScaling", BooleanValue(false)); break; case ENABLED_SENDER: - socket->SetAttribute("WindowScaling", BooleanValue(true)); - break; - case ENABLED: socket->SetAttribute("WindowScaling", BooleanValue(true)); break; diff --git a/src/lr-wpan/model/lr-wpan-mac-pl-headers.cc b/src/lr-wpan/model/lr-wpan-mac-pl-headers.cc index b3f582296..3d8bcb703 100644 --- a/src/lr-wpan/model/lr-wpan-mac-pl-headers.cc +++ b/src/lr-wpan/model/lr-wpan-mac-pl-headers.cc @@ -174,20 +174,15 @@ CommandPayloadHeader::GetSerializedSize() const size += 3; // (short address + Association Status) break; case DISASSOCIATION_NOTIF: - break; case DATA_REQ: - break; case PANID_CONFLICT: - break; case ORPHAN_NOTIF: - break; case BEACON_REQ: break; case COOR_REALIGN: size += 8; break; case GTS_REQ: - break; case CMD_RESERVED: break; } @@ -210,13 +205,9 @@ CommandPayloadHeader::Serialize(Buffer::Iterator start) const i.WriteU8(m_assocStatus); break; case DISASSOCIATION_NOTIF: - break; case DATA_REQ: - break; case PANID_CONFLICT: - break; case ORPHAN_NOTIF: - break; case BEACON_REQ: break; case COOR_REALIGN: @@ -227,7 +218,6 @@ CommandPayloadHeader::Serialize(Buffer::Iterator start) const i.WriteU8(m_logChPage); break; case GTS_REQ: - break; case CMD_RESERVED: break; } @@ -249,13 +239,9 @@ CommandPayloadHeader::Deserialize(Buffer::Iterator start) m_assocStatus = i.ReadU8(); break; case DISASSOCIATION_NOTIF: - break; case DATA_REQ: - break; case PANID_CONFLICT: - break; case ORPHAN_NOTIF: - break; case BEACON_REQ: break; case COOR_REALIGN: @@ -266,7 +252,6 @@ CommandPayloadHeader::Deserialize(Buffer::Iterator start) m_logChPage = i.ReadU8(); break; case GTS_REQ: - break; case CMD_RESERVED: break; } @@ -294,13 +279,9 @@ CommandPayloadHeader::Print(std::ostream& os) const << "| Status Response | = " << m_assocStatus; break; case DISASSOCIATION_NOTIF: - break; case DATA_REQ: - break; case PANID_CONFLICT: - break; case ORPHAN_NOTIF: - break; case BEACON_REQ: break; case COOR_REALIGN: @@ -311,9 +292,7 @@ CommandPayloadHeader::Print(std::ostream& os) const << "| Page Num.| = " << static_cast(m_logChPage); break; case GTS_REQ: - break; case CMD_RESERVED: - break; default: break; } diff --git a/src/lte/model/lte-common.cc b/src/lte/model/lte-common.cc index aaa2eb9a6..fe7ff354e 100644 --- a/src/lte/model/lte-common.cc +++ b/src/lte/model/lte-common.cc @@ -206,23 +206,15 @@ TransmissionModesLayers::TxMode2LayerNum(uint8_t txMode) switch (txMode) { case 0: // Tx MODE 1: SISO - nLayer = 1; - break; case 1: // Tx MODE 2: MIMO Tx Diversity nLayer = 1; break; case 2: // Tx MODE 3: MIMO Spatial Multiplexity Open Loop - nLayer = 2; - break; case 3: // Tx MODE 4: MIMO Spatial Multiplexity Closed Loop - nLayer = 2; - break; case 4: // Tx MODE 5: MIMO Multi-User nLayer = 2; break; case 5: // Tx MODE 6: Closer loop single layer percoding - nLayer = 1; - break; case 6: // Tx MODE 7: Single antenna port 5 nLayer = 1; break; diff --git a/src/lte/model/lte-enb-rrc.cc b/src/lte/model/lte-enb-rrc.cc index ab6ad8d89..e4ae364bc 100644 --- a/src/lte/model/lte-enb-rrc.cc +++ b/src/lte/model/lte-enb-rrc.cc @@ -1715,8 +1715,6 @@ UeManager::SwitchToState(State newState) break; case CONNECTION_SETUP: - break; - case ATTACH_REQUEST: break; @@ -1733,14 +1731,8 @@ UeManager::SwitchToState(State newState) break; case CONNECTION_RECONFIGURATION: - break; - case CONNECTION_REESTABLISHMENT: - break; - case HANDOVER_LEAVING: - break; - default: break; } diff --git a/src/lte/model/lte-rrc-header.cc b/src/lte/model/lte-rrc-header.cc index 278d393af..1424f59ad 100644 --- a/src/lte/model/lte-rrc-header.cc +++ b/src/lte/model/lte-rrc-header.cc @@ -3983,12 +3983,10 @@ RrcAsn1Header::DeserializeMeasConfig(LteRrcSap::MeasConfig* measConfig, Buffer:: case 1: // Deserialize measObjectUTRA // ... - break; case 2: // Deserialize measObjectGERAN // ... - break; case 3: // Deserialize measObjectCDMA2000 diff --git a/src/lte/model/lte-ue-rrc.cc b/src/lte/model/lte-ue-rrc.cc index 4bb123e52..e61290721 100644 --- a/src/lte/model/lte-ue-rrc.cc +++ b/src/lte/model/lte-ue-rrc.cc @@ -901,7 +901,6 @@ LteUeRrc::DoRecvSystemInformationBlockType1(uint16_t cellId, case IDLE_WAIT_MIB_SIB1: // MIB has not been received, so ignore this SIB1 - break; default: // e.g. IDLE_START, IDLE_CELL_SEARCH, IDLE_WAIT_MIB, IDLE_WAIT_SIB2 // do nothing @@ -3273,8 +3272,6 @@ LteUeRrc::SwitchToState(State newState) case CONNECTED_HANDOVER: case CONNECTED_PHY_PROBLEM: case CONNECTED_REESTABLISHING: - break; - default: break; } diff --git a/src/mobility/helper/ns2-mobility-helper.cc b/src/mobility/helper/ns2-mobility-helper.cc index acd5182a7..79743cda6 100644 --- a/src/mobility/helper/ns2-mobility-helper.cc +++ b/src/mobility/helper/ns2-mobility-helper.cc @@ -620,7 +620,8 @@ IsVal(const std::string& str, T& ret) { return false; } - else if (IsNumber(str)) + + if (IsNumber(str)) { std::istringstream s(str); s >> ret; @@ -681,8 +682,6 @@ GetNodeIdInt(ParseResult pr) result = pr.ivals[0]; break; case 7: // line like $ns_ at 4 "$node_(0) set X_ 28" - result = pr.ivals[3]; - break; case 8: // line like $ns_ at 1 "$node_(0) setdest 2 3 4" result = pr.ivals[3]; break; @@ -701,7 +700,6 @@ GetNodeIdString(ParseResult pr) case 4: // line like $node_(0) set X_ 11 return pr.svals[0]; case 7: // line like $ns_ at 4 "$node_(0) set X_ 28" - return pr.svals[3]; case 8: // line like $ns_ at 1 "$node_(0) setdest 2 3 4" return pr.svals[3]; default: diff --git a/src/network/utils/data-rate.cc b/src/network/utils/data-rate.cc index 256b19d88..8f17f9a23 100644 --- a/src/network/utils/data-rate.cc +++ b/src/network/utils/data-rate.cc @@ -43,62 +43,22 @@ DataRate::DoParse(const std::string s, uint64_t* v) double r; iss >> r; std::string trailer = s.substr(n, std::string::npos); - if (trailer == "bps") + if (trailer == "bps" || trailer == "b/s") { // bit/s *v = (uint64_t)r; } - else if (trailer == "b/s") - { - // bit/s - *v = (uint64_t)r; - } - else if (trailer == "Bps") + else if (trailer == "Bps" || trailer == "B/s") { // byte/s *v = (uint64_t)(r * 8); } - else if (trailer == "B/s") - { - // byte/s - *v = (uint64_t)(r * 8); - } - else if (trailer == "kbps") + else if (trailer == "kbps" || trailer == "kb/s" || trailer == "Kbps" || trailer == "Kb/s") { // kilobits/s *v = (uint64_t)(r * 1000); } - else if (trailer == "kb/s") - { - // kilobits/s - *v = (uint64_t)(r * 1000); - } - else if (trailer == "Kbps") - { - // kilobits/s - *v = (uint64_t)(r * 1000); - } - else if (trailer == "Kb/s") - { - // kilobits/s - *v = (uint64_t)(r * 1000); - } - else if (trailer == "kBps") - { - // kiloByte/s - *v = (uint64_t)(r * 8000); - } - else if (trailer == "kB/s") - { - // KiloByte/s - *v = (uint64_t)(r * 8000); - } - else if (trailer == "KBps") - { - // kiloByte/s - *v = (uint64_t)(r * 8000); - } - else if (trailer == "KB/s") + else if (trailer == "kBps" || trailer == "kB/s" || trailer == "KBps" || trailer == "KB/s") { // KiloByte/s *v = (uint64_t)(r * 8000); @@ -113,22 +73,12 @@ DataRate::DoParse(const std::string s, uint64_t* v) // kibibyte/s *v = (uint64_t)(r * 8192); } - else if (trailer == "Mbps") + else if (trailer == "Mbps" || trailer == "Mb/s") { // MegaBits/s *v = (uint64_t)(r * 1000000); } - else if (trailer == "Mb/s") - { - // MegaBits/s - *v = (uint64_t)(r * 1000000); - } - else if (trailer == "MBps") - { - // MegaBytes/s - *v = (uint64_t)(r * 8000000); - } - else if (trailer == "MB/s") + else if (trailer == "MBps" || trailer == "MB/s") { // MegaBytes/s *v = (uint64_t)(r * 8000000); @@ -143,22 +93,12 @@ DataRate::DoParse(const std::string s, uint64_t* v) // MebiByte/s *v = (uint64_t)(r * 1048576 * 8); } - else if (trailer == "Gbps") + else if (trailer == "Gbps" || trailer == "Gb/s") { // GigaBit/s *v = (uint64_t)(r * 1000000000); } - else if (trailer == "Gb/s") - { - // GigaBit/s - *v = (uint64_t)(r * 1000000000); - } - else if (trailer == "GBps") - { - // GigaByte/s - *v = (uint64_t)(r * 8 * 1000000000); - } - else if (trailer == "GB/s") + else if (trailer == "GBps" || trailer == "GB/s") { // GigaByte/s *v = (uint64_t)(r * 8 * 1000000000); diff --git a/src/network/utils/lollipop-counter.h b/src/network/utils/lollipop-counter.h index b794cb1f3..8187da338 100644 --- a/src/network/utils/lollipop-counter.h +++ b/src/network/utils/lollipop-counter.h @@ -279,11 +279,7 @@ class LollipopCounter return false; } - if (lhs > rhs) - { - return false; - } - else if (lhs == rhs) + if (lhs > rhs || lhs == rhs) { return false; } diff --git a/src/propagation/model/three-gpp-propagation-loss-model.cc b/src/propagation/model/three-gpp-propagation-loss-model.cc index 6e25f2b2e..b6a210816 100644 --- a/src/propagation/model/three-gpp-propagation-loss-model.cc +++ b/src/propagation/model/three-gpp-propagation-loss-model.cc @@ -183,21 +183,10 @@ ThreeGppPropagationLossModel::DoCalcRxPower(double txPowerDbm, } // get o2i losses - if (cond->GetO2iCondition() == ChannelCondition::O2iConditionValue::O2I && - m_buildingPenLossesEnabled) - { - if (IsO2iLowPenetrationLoss(cond)) - { - rxPow -= GetO2iLowPenetrationLoss(a, b, cond->GetLosCondition()); - } - else - { - rxPow -= GetO2iHighPenetrationLoss(a, b, cond->GetLosCondition()); - } - } - else if (cond->GetO2iCondition() == ChannelCondition::O2iConditionValue::I2I && - cond->GetLosCondition() == ChannelCondition::LosConditionValue::NLOS && - m_buildingPenLossesEnabled) + if (m_buildingPenLossesEnabled && + ((cond->GetO2iCondition() == ChannelCondition::O2iConditionValue::O2I) || + (cond->GetO2iCondition() == ChannelCondition::O2iConditionValue::I2I && + cond->GetLosCondition() == ChannelCondition::LosConditionValue::NLOS))) { if (IsO2iLowPenetrationLoss(cond)) { diff --git a/src/sixlowpan/model/sixlowpan-header.cc b/src/sixlowpan/model/sixlowpan-header.cc index 93cf77b86..c617f07bd 100644 --- a/src/sixlowpan/model/sixlowpan-header.cc +++ b/src/sixlowpan/model/sixlowpan-header.cc @@ -144,8 +144,6 @@ SixLowPanHc1::GetSerializedSize() const serializedSize += 16; break; case HC1_PIIC: - serializedSize += 8; - break; case HC1_PCII: serializedSize += 8; break; @@ -158,8 +156,6 @@ SixLowPanHc1::GetSerializedSize() const serializedSize += 16; break; case HC1_PIIC: - serializedSize += 8; - break; case HC1_PCII: serializedSize += 8; break; diff --git a/src/spectrum/model/half-duplex-ideal-phy.cc b/src/spectrum/model/half-duplex-ideal-phy.cc index 87b23a3fe..c1522b715 100644 --- a/src/spectrum/model/half-duplex-ideal-phy.cc +++ b/src/spectrum/model/half-duplex-ideal-phy.cc @@ -348,7 +348,6 @@ HalfDuplexIdealPhy::StartRx(Ptr spectrumParams) { case TX: // the PHY will not notice this incoming signal - break; case RX: // we should check if we should re-sync on a new incoming signal and discard the old one diff --git a/src/spectrum/model/tv-spectrum-transmitter.cc b/src/spectrum/model/tv-spectrum-transmitter.cc index 87547609d..d449575bd 100644 --- a/src/spectrum/model/tv-spectrum-transmitter.cc +++ b/src/spectrum/model/tv-spectrum-transmitter.cc @@ -507,8 +507,6 @@ TvSpectrumTransmitter::CreateTvPsd() case 82: case 83: case 84: - (*psd)[i] = 3.16228e-06 * basePsdWattsHz; - break; case 85: case 86: case 87: diff --git a/src/spectrum/model/wifi-spectrum-value-helper.cc b/src/spectrum/model/wifi-spectrum-value-helper.cc index 5fb9244ac..c7e02e09b 100644 --- a/src/spectrum/model/wifi-spectrum-value-helper.cc +++ b/src/spectrum/model/wifi-spectrum-value-helper.cc @@ -668,7 +668,8 @@ WifiSpectrumValueHelper::CreateSpectrumMaskForOfdm( { txPowerW = DbmToW(txPowerMiddleBandMinDbm + ((i - middleBandLeft.first) * middleSlope)); } - else if (i <= flatJunctionLeft.second && i >= flatJunctionLeft.first) + else if ((i <= flatJunctionLeft.second && i >= flatJunctionLeft.first) || + (i <= flatJunctionRight.second && i >= flatJunctionRight.first)) { txPowerW = DbmToW(txPowerInnerBandMinDbm); } @@ -736,10 +737,6 @@ WifiSpectrumValueHelper::CreateSpectrumMaskForOfdm( DbmToW(txPowerRefDbm - ((i - innerBandRight.first + 1) * innerSlope))); // +1 so as to be symmetric with left slope } - else if (i <= flatJunctionRight.second && i >= flatJunctionRight.first) - { - txPowerW = DbmToW(txPowerInnerBandMinDbm); - } else if (i <= middleBandRight.second && i >= middleBandRight.first) { txPowerW = DbmToW(txPowerInnerBandMinDbm - diff --git a/src/stats/helper/file-helper.cc b/src/stats/helper/file-helper.cc index c3e0405fb..310a37be2 100644 --- a/src/stats/helper/file-helper.cc +++ b/src/stats/helper/file-helper.cc @@ -476,7 +476,8 @@ FileHelper::ConnectProbeToAggregator(const std::string& typeId, AddTimeSeriesAdaptor(probeContext); // Connect the probe to the adaptor. - if (m_probeMap[probeName].second == "ns3::DoubleProbe") + if (m_probeMap[probeName].second == "ns3::DoubleProbe" || + m_probeMap[probeName].second == "ns3::TimeProbe") { m_probeMap[probeName].first->TraceConnectWithoutContext( probeTraceSource, @@ -490,28 +491,11 @@ FileHelper::ConnectProbeToAggregator(const std::string& typeId, MakeCallback(&TimeSeriesAdaptor::TraceSinkBoolean, m_timeSeriesAdaptorMap[probeContext])); } - else if (m_probeMap[probeName].second == "ns3::PacketProbe") - { - m_probeMap[probeName].first->TraceConnectWithoutContext( - probeTraceSource, - MakeCallback(&TimeSeriesAdaptor::TraceSinkUinteger32, - m_timeSeriesAdaptorMap[probeContext])); - } - else if (m_probeMap[probeName].second == "ns3::ApplicationPacketProbe") - { - m_probeMap[probeName].first->TraceConnectWithoutContext( - probeTraceSource, - MakeCallback(&TimeSeriesAdaptor::TraceSinkUinteger32, - m_timeSeriesAdaptorMap[probeContext])); - } - else if (m_probeMap[probeName].second == "ns3::Ipv4PacketProbe") - { - m_probeMap[probeName].first->TraceConnectWithoutContext( - probeTraceSource, - MakeCallback(&TimeSeriesAdaptor::TraceSinkUinteger32, - m_timeSeriesAdaptorMap[probeContext])); - } - else if (m_probeMap[probeName].second == "ns3::Ipv6PacketProbe") + else if (m_probeMap[probeName].second == "ns3::Uinteger32Probe" || + m_probeMap[probeName].second == "ns3::PacketProbe" || + m_probeMap[probeName].second == "ns3::ApplicationPacketProbe" || + m_probeMap[probeName].second == "ns3::Ipv4PacketProbe" || + m_probeMap[probeName].second == "ns3::Ipv6PacketProbe") { m_probeMap[probeName].first->TraceConnectWithoutContext( probeTraceSource, @@ -532,20 +516,6 @@ FileHelper::ConnectProbeToAggregator(const std::string& typeId, MakeCallback(&TimeSeriesAdaptor::TraceSinkUinteger16, m_timeSeriesAdaptorMap[probeContext])); } - else if (m_probeMap[probeName].second == "ns3::Uinteger32Probe") - { - m_probeMap[probeName].first->TraceConnectWithoutContext( - probeTraceSource, - MakeCallback(&TimeSeriesAdaptor::TraceSinkUinteger32, - m_timeSeriesAdaptorMap[probeContext])); - } - else if (m_probeMap[probeName].second == "ns3::TimeProbe") - { - m_probeMap[probeName].first->TraceConnectWithoutContext( - probeTraceSource, - MakeCallback(&TimeSeriesAdaptor::TraceSinkDouble, - m_timeSeriesAdaptorMap[probeContext])); - } else { NS_FATAL_ERROR("Unknown probe type " << m_probeMap[probeName].second diff --git a/src/stats/helper/gnuplot-helper.cc b/src/stats/helper/gnuplot-helper.cc index 476467a4c..b5e30f02c 100644 --- a/src/stats/helper/gnuplot-helper.cc +++ b/src/stats/helper/gnuplot-helper.cc @@ -333,7 +333,8 @@ GnuplotHelper::ConnectProbeToAggregator(const std::string& typeId, AddTimeSeriesAdaptor(probeContext); // Connect the probe to the adaptor. - if (m_probeMap[probeName].second == "ns3::DoubleProbe") + if (m_probeMap[probeName].second == "ns3::DoubleProbe" || + m_probeMap[probeName].second == "ns3::TimeProbe") { m_probeMap[probeName].first->TraceConnectWithoutContext( probeTraceSource, @@ -347,28 +348,11 @@ GnuplotHelper::ConnectProbeToAggregator(const std::string& typeId, MakeCallback(&TimeSeriesAdaptor::TraceSinkBoolean, m_timeSeriesAdaptorMap[probeContext])); } - else if (m_probeMap[probeName].second == "ns3::PacketProbe") - { - m_probeMap[probeName].first->TraceConnectWithoutContext( - probeTraceSource, - MakeCallback(&TimeSeriesAdaptor::TraceSinkUinteger32, - m_timeSeriesAdaptorMap[probeContext])); - } - else if (m_probeMap[probeName].second == "ns3::ApplicationPacketProbe") - { - m_probeMap[probeName].first->TraceConnectWithoutContext( - probeTraceSource, - MakeCallback(&TimeSeriesAdaptor::TraceSinkUinteger32, - m_timeSeriesAdaptorMap[probeContext])); - } - else if (m_probeMap[probeName].second == "ns3::Ipv4PacketProbe") - { - m_probeMap[probeName].first->TraceConnectWithoutContext( - probeTraceSource, - MakeCallback(&TimeSeriesAdaptor::TraceSinkUinteger32, - m_timeSeriesAdaptorMap[probeContext])); - } - else if (m_probeMap[probeName].second == "ns3::Ipv6PacketProbe") + else if (m_probeMap[probeName].second == "ns3::Uinteger32Probe" || + m_probeMap[probeName].second == "ns3::PacketProbe" || + m_probeMap[probeName].second == "ns3::ApplicationPacketProbe" || + m_probeMap[probeName].second == "ns3::Ipv4PacketProbe" || + m_probeMap[probeName].second == "ns3::Ipv6PacketProbe") { m_probeMap[probeName].first->TraceConnectWithoutContext( probeTraceSource, @@ -389,20 +373,6 @@ GnuplotHelper::ConnectProbeToAggregator(const std::string& typeId, MakeCallback(&TimeSeriesAdaptor::TraceSinkUinteger16, m_timeSeriesAdaptorMap[probeContext])); } - else if (m_probeMap[probeName].second == "ns3::Uinteger32Probe") - { - m_probeMap[probeName].first->TraceConnectWithoutContext( - probeTraceSource, - MakeCallback(&TimeSeriesAdaptor::TraceSinkUinteger32, - m_timeSeriesAdaptorMap[probeContext])); - } - else if (m_probeMap[probeName].second == "ns3::TimeProbe") - { - m_probeMap[probeName].first->TraceConnectWithoutContext( - probeTraceSource, - MakeCallback(&TimeSeriesAdaptor::TraceSinkDouble, - m_timeSeriesAdaptorMap[probeContext])); - } else { NS_FATAL_ERROR("Unknown probe type " << m_probeMap[probeName].second diff --git a/src/stats/model/omnet-data-output.cc b/src/stats/model/omnet-data-output.cc index 77e99be0e..6beb670d9 100644 --- a/src/stats/model/omnet-data-output.cc +++ b/src/stats/model/omnet-data-output.cc @@ -77,7 +77,8 @@ isNumeric(const std::string& s) for (auto it = s.begin(); it != s.end(); it++) { - if ((*it == '.') && (decimalPtSeen)) + if ((*it == '.' && decimalPtSeen) || (*it == 'e' && exponentSeen) || + (*it == '-' && it != s.begin() && last != 'e')) { return false; } @@ -85,19 +86,11 @@ isNumeric(const std::string& s) { decimalPtSeen = true; } - else if ((*it == 'e') && exponentSeen) - { - return false; - } else if (*it == 'e') { exponentSeen = true; decimalPtSeen = false; } - else if (*it == '-' && it != s.begin() && last != 'e') - { - return false; - } last = *it; } diff --git a/src/traffic-control/model/pie-queue-disc.cc b/src/traffic-control/model/pie-queue-disc.cc index d701f727a..c9d315a63 100644 --- a/src/traffic-control/model/pie-queue-disc.cc +++ b/src/traffic-control/model/pie-queue-disc.cc @@ -297,15 +297,9 @@ PieQueueDisc::DropEarly(Ptr item, uint32_t qSize) } // Safeguard PIE to be work conserving (Section 4.1 of RFC 8033) - if ((m_qDelayOld.GetSeconds() < (0.5 * m_qDelayRef.GetSeconds())) && (m_dropProb < 0.2)) - { - return false; - } - else if (GetMaxSize().GetUnit() == QueueSizeUnit::BYTES && qSize <= 2 * m_meanPktSize) - { - return false; - } - else if (GetMaxSize().GetUnit() == QueueSizeUnit::PACKETS && qSize <= 2) + if ((m_qDelayOld.GetSeconds() < (0.5 * m_qDelayRef.GetSeconds()) && m_dropProb < 0.2) || + (GetMaxSize().GetUnit() == QueueSizeUnit::BYTES && qSize <= 2 * m_meanPktSize) || + (GetMaxSize().GetUnit() == QueueSizeUnit::PACKETS && qSize <= 2)) { return false; } diff --git a/src/uan/model/uan-mac-rc.cc b/src/uan/model/uan-mac-rc.cc index f6a5abbfc..5714d0026 100644 --- a/src/uan/model/uan-mac-rc.cc +++ b/src/uan/model/uan-mac-rc.cc @@ -711,11 +711,8 @@ UanMacRc::IsPhy1Ok() Ptr pkt = phyDual->GetPhy1PacketRx(); UanHeaderCommon ch; pkt->PeekHeader(ch); - if (ch.GetType() == TYPE_CTS || ch.GetType() == TYPE_ACK) - { - phy1ok = false; - } - else if (ch.GetDest() == Mac8Address::ConvertFrom(GetAddress())) + if (ch.GetType() == TYPE_CTS || ch.GetType() == TYPE_ACK || + ch.GetDest() == Mac8Address::ConvertFrom(GetAddress())) { phy1ok = false; } diff --git a/src/visualizer/model/pyviz.cc b/src/visualizer/model/pyviz.cc index 5605fbeaf..d1a42d8d2 100644 --- a/src/visualizer/model/pyviz.cc +++ b/src/visualizer/model/pyviz.cc @@ -601,21 +601,13 @@ PyViz::TraceNetDevTxWifi(std::string context, Ptr packet) WifiMacHeader hdr; NS_ABORT_IF(packet->PeekHeader(hdr) == 0); Mac48Address destinationAddress; - if (hdr.IsToDs() && !hdr.IsFromDs()) + if (hdr.IsToDs()) { destinationAddress = hdr.GetAddr3(); } - else if (!hdr.IsToDs() && hdr.IsFromDs()) - { - destinationAddress = hdr.GetAddr1(); - } - else if (!hdr.IsToDs() && !hdr.IsFromDs()) - { - destinationAddress = hdr.GetAddr1(); - } else { - destinationAddress = hdr.GetAddr3(); + destinationAddress = hdr.GetAddr1(); } TraceNetDevTxCommon(context, packet, destinationAddress); } @@ -769,19 +761,15 @@ PyViz::TraceNetDevRxWifi(std::string context, Ptr packet) WifiMacHeader hdr; NS_ABORT_IF(packet->PeekHeader(hdr) == 0); Mac48Address sourceAddress; - if (hdr.IsToDs() && !hdr.IsFromDs()) + if (!hdr.IsFromDs()) { sourceAddress = hdr.GetAddr2(); } - else if (!hdr.IsToDs() && hdr.IsFromDs()) + else if (!hdr.IsToDs()) { sourceAddress = hdr.GetAddr3(); } - else if (!hdr.IsToDs() && !hdr.IsFromDs()) - { - sourceAddress = hdr.GetAddr2(); - } - else + else // if (hdr.IsToDs()) { sourceAddress = hdr.GetAddr4(); } diff --git a/src/wifi/examples/wifi-bianchi.cc b/src/wifi/examples/wifi-bianchi.cc index d90f5a749..05a53f8fd 100644 --- a/src/wifi/examples/wifi-bianchi.cc +++ b/src/wifi/examples/wifi-bianchi.cc @@ -2867,11 +2867,7 @@ main(int argc, char* argv[]) } else if (standard == "11n") { - if (frequency == 2.4) - { - wifiStandard = WIFI_STANDARD_80211n; - } - else if (frequency == 5) + if (frequency == 2.4 || frequency == 5) { wifiStandard = WIFI_STANDARD_80211n; } @@ -2888,15 +2884,7 @@ main(int argc, char* argv[]) } else if (standard == "11ax") { - if (frequency == 2.4) - { - wifiStandard = WIFI_STANDARD_80211ax; - } - else if (frequency == 5) - { - wifiStandard = WIFI_STANDARD_80211ax; - } - else if (frequency == 6) + if (frequency == 2.4 || frequency == 5 || frequency == 6) { wifiStandard = WIFI_STANDARD_80211ax; } diff --git a/src/wifi/model/ap-wifi-mac.cc b/src/wifi/model/ap-wifi-mac.cc index 6d9a02feb..e57a69f65 100644 --- a/src/wifi/model/ap-wifi-mac.cc +++ b/src/wifi/model/ap-wifi-mac.cc @@ -1949,12 +1949,14 @@ ApWifiMac::Receive(Ptr mpdu, uint8_t linkId) ForwardUp(packet, from, to); } } + // NOLINTBEGIN(bugprone-branch-clone) else if (hdr->IsFromDs() && hdr->IsToDs()) { // this is an AP-to-AP frame // we ignore for now. NotifyRxDrop(packet); } + // NOLINTEND(bugprone-branch-clone) else { // we can ignore these frames since diff --git a/src/wifi/model/ht/ht-frame-exchange-manager.cc b/src/wifi/model/ht/ht-frame-exchange-manager.cc index 1ab476759..2b42a5e0c 100644 --- a/src/wifi/model/ht/ht-frame-exchange-manager.cc +++ b/src/wifi/model/ht/ht-frame-exchange-manager.cc @@ -111,14 +111,10 @@ bool HtFrameExchangeManager::NeedSetupBlockAck(Mac48Address recipient, uint8_t tid) { Ptr qosTxop = m_mac->GetQosTxop(tid); + auto agreement = qosTxop->GetBaManager()->GetAgreementAsOriginator(recipient, tid); bool establish; - if (!m_mac->GetHtSupported(recipient)) - { - establish = false; - } - else if (auto agreement = qosTxop->GetBaManager()->GetAgreementAsOriginator(recipient, tid); - agreement && !agreement->get().IsReset()) + if (!m_mac->GetHtSupported(recipient) || (agreement && !agreement->get().IsReset())) { establish = false; } diff --git a/src/wifi/model/mgt-action-headers.cc b/src/wifi/model/mgt-action-headers.cc index 9759853ce..ab8b1f846 100644 --- a/src/wifi/model/mgt-action-headers.cc +++ b/src/wifi/model/mgt-action-headers.cc @@ -299,9 +299,7 @@ WifiActionHeader::GetAction() const case MULTIHOP: // not yet supported switch (m_actionValue) { - case PROXY_UPDATE: // not used so far - retval.multihopAction = PROXY_UPDATE; - break; + case PROXY_UPDATE: // not used so far case PROXY_UPDATE_CONFIRMATION: // not used so far retval.multihopAction = PROXY_UPDATE; break; diff --git a/src/wifi/model/rate-control/aparf-wifi-manager.cc b/src/wifi/model/rate-control/aparf-wifi-manager.cc index 7fb579581..0ef87c7ef 100644 --- a/src/wifi/model/rate-control/aparf-wifi-manager.cc +++ b/src/wifi/model/rate-control/aparf-wifi-manager.cc @@ -278,13 +278,10 @@ AparfWifiManager::DoReportDataOk(WifiRemoteStation* st, NS_LOG_DEBUG("station=" << station << " data ok success=" << station->m_nSuccess << ", rate=" << +station->m_rateIndex << ", power=" << +station->m_powerLevel); - if ((station->m_aparfState == AparfWifiManager::High) && - (station->m_nSuccess >= station->m_successThreshold)) - { - station->m_aparfState = AparfWifiManager::Spread; - } - else if ((station->m_aparfState == AparfWifiManager::Low) && - (station->m_nSuccess >= station->m_successThreshold)) + if ((station->m_aparfState == AparfWifiManager::High || + station->m_aparfState == AparfWifiManager::Low) && + station->m_nSuccess >= station->m_successThreshold) + { station->m_aparfState = AparfWifiManager::Spread; } diff --git a/src/wifi/model/rate-control/minstrel-wifi-manager.cc b/src/wifi/model/rate-control/minstrel-wifi-manager.cc index 7e951218c..28f67000c 100644 --- a/src/wifi/model/rate-control/minstrel-wifi-manager.cc +++ b/src/wifi/model/rate-control/minstrel-wifi-manager.cc @@ -730,14 +730,10 @@ MinstrelWifiManager::UpdateStats(MinstrelWifiRemoteStation* station) uint8_t index_max_prob = 0; for (uint8_t i = 0; i < station->m_nModes; i++) { - if ((station->m_minstrelTable[i].ewmaProb >= 95 * 180) && - (station->m_minstrelTable[i].throughput >= - station->m_minstrelTable[index_max_prob].throughput)) - { - index_max_prob = i; - max_prob = station->m_minstrelTable[i].ewmaProb; - } - else if (station->m_minstrelTable[i].ewmaProb >= max_prob) + if ((station->m_minstrelTable[i].ewmaProb >= 95 * 180 && + station->m_minstrelTable[i].throughput >= + station->m_minstrelTable[index_max_prob].throughput) || + (station->m_minstrelTable[i].ewmaProb >= max_prob)) { index_max_prob = i; max_prob = station->m_minstrelTable[i].ewmaProb; diff --git a/src/wifi/model/sta-wifi-mac.cc b/src/wifi/model/sta-wifi-mac.cc index 94407fcc4..462f8fc20 100644 --- a/src/wifi/model/sta-wifi-mac.cc +++ b/src/wifi/model/sta-wifi-mac.cc @@ -737,7 +737,6 @@ StaWifiMac::TryToEnsureAssociated() wait until either assoc-request-timeout or until we get an association response. */ - break; case REFUSED: /* we have sent an association request and received a negative association response. We wait until someone restarts an diff --git a/src/wifi/model/wifi-mac-header.cc b/src/wifi/model/wifi-mac-header.cc index 7c561d538..bcdd357d2 100644 --- a/src/wifi/model/wifi-mac-header.cc +++ b/src/wifi/model/wifi-mac-header.cc @@ -1156,12 +1156,6 @@ WifiMacHeader::Print(std::ostream& os) const case WIFI_MAC_MGT_PROBE_RESPONSE: case WIFI_MAC_MGT_AUTHENTICATION: case WIFI_MAC_MGT_DEAUTHENTICATION: - PrintFrameControl(os); - os << " Duration/ID=" << m_duration << "us" - << ", DA=" << m_addr1 << ", SA=" << m_addr2 << ", BSSID=" << m_addr3 - << ", FragNumber=" << std::hex << (int)m_seqFrag << std::dec - << ", SeqNumber=" << m_seqSeq; - break; case WIFI_MAC_MGT_ACTION: case WIFI_MAC_MGT_ACTION_NO_ACK: PrintFrameControl(os); diff --git a/src/wifi/model/wifi-phy-common.cc b/src/wifi/model/wifi-phy-common.cc index 9c6b8be80..b742cf99a 100644 --- a/src/wifi/model/wifi-phy-common.cc +++ b/src/wifi/model/wifi-phy-common.cc @@ -257,11 +257,13 @@ GetMaximumChannelWidth(WifiModulationClass modulation) return 20; case WIFI_MOD_CLASS_HT: return 40; + // NOLINTBEGIN(bugprone-branch-clone) case WIFI_MOD_CLASS_VHT: case WIFI_MOD_CLASS_HE: return 160; case WIFI_MOD_CLASS_EHT: - return 160; // TODO update when 320 MHz channels are supported + return 160; // TODO update when 320 MHz channels are supported and remove clang-tidy guards + // NOLINTEND(bugprone-branch-clone) default: NS_ABORT_MSG("Unknown modulation class: " << modulation); return 0; diff --git a/src/wimax/model/bandwidth-manager.cc b/src/wimax/model/bandwidth-manager.cc index a44e48da4..b83488ce4 100644 --- a/src/wimax/model/bandwidth-manager.cc +++ b/src/wimax/model/bandwidth-manager.cc @@ -98,13 +98,9 @@ BandwidthManager::CalculateAllocationSize(const SSRecord* ssRecord, const Servic } } break; - case ServiceFlow::SF_TYPE_NRTPS: { + case ServiceFlow::SF_TYPE_NRTPS: /* nrtPS shall be serviced only if sufficient bandwidth is available after servicing UGS and rtPS scheduling types, hence no specific service interval is used */ - - allocationSize = bs->GetBwReqOppSize(); - } - break; case ServiceFlow::SF_TYPE_BE: { /* BE shall be serviced only if sufficient bandwidth is available after servicing the rest of three scheduling types, hence no specific service interval is used */ diff --git a/src/wimax/model/bs-net-device.cc b/src/wimax/model/bs-net-device.cc index 15f400e5f..11109076a 100644 --- a/src/wimax/model/bs-net-device.cc +++ b/src/wimax/model/bs-net-device.cc @@ -790,7 +790,6 @@ BaseStationNetDevice::DoReceive(Ptr packet) { case ManagementMessageType::MESSAGE_TYPE_REG_REQ: // not yet implemented - break; case ManagementMessageType::MESSAGE_TYPE_REG_RSP: // from other base station, ignore break; diff --git a/src/wimax/model/bs-uplink-scheduler-mbqos.cc b/src/wimax/model/bs-uplink-scheduler-mbqos.cc index 59c40b109..2b2b25764 100644 --- a/src/wimax/model/bs-uplink-scheduler-mbqos.cc +++ b/src/wimax/model/bs-uplink-scheduler-mbqos.cc @@ -1178,14 +1178,10 @@ UplinkSchedulerMBQoS::ProcessBandwidthRequest(const BandwidthRequestHeader& bwRe switch (serviceFlow->GetSchedulingType()) { case ServiceFlow::SF_TYPE_RTPS: - EnqueueJob(UlJob::INTERMEDIATE, job); - break; case ServiceFlow::SF_TYPE_NRTPS: EnqueueJob(UlJob::INTERMEDIATE, job); break; case ServiceFlow::SF_TYPE_BE: - EnqueueJob(UlJob::LOW, job); - break; default: EnqueueJob(UlJob::LOW, job); break; diff --git a/src/wimax/model/bs-uplink-scheduler-rtps.cc b/src/wimax/model/bs-uplink-scheduler-rtps.cc index d27221db4..816c03447 100644 --- a/src/wimax/model/bs-uplink-scheduler-rtps.cc +++ b/src/wimax/model/bs-uplink-scheduler-rtps.cc @@ -720,14 +720,11 @@ UplinkSchedulerRtps::SetupServiceFlow(SSRecord* ssRecord, ServiceFlow* serviceFl serviceFlow->SetUnsolicitedPollingInterval(interval); } break; - case ServiceFlow::SF_TYPE_NRTPS: { + case ServiceFlow::SF_TYPE_NRTPS: // no real-time guarantees are given to NRTPS, serviced based on available bandwidth - } - break; - case ServiceFlow::SF_TYPE_BE: { + case ServiceFlow::SF_TYPE_BE: // no real-time guarantees are given to BE, serviced based on available bandwidth - } - break; + break; default: NS_FATAL_ERROR("Invalid scheduling type"); } diff --git a/src/wimax/model/bs-uplink-scheduler-simple.cc b/src/wimax/model/bs-uplink-scheduler-simple.cc index f1f0e6983..6e36a11de 100644 --- a/src/wimax/model/bs-uplink-scheduler-simple.cc +++ b/src/wimax/model/bs-uplink-scheduler-simple.cc @@ -569,14 +569,11 @@ UplinkSchedulerSimple::SetupServiceFlow(SSRecord* ssRecord, ServiceFlow* service serviceFlow->SetUnsolicitedPollingInterval(interval); } break; - case ServiceFlow::SF_TYPE_NRTPS: { + case ServiceFlow::SF_TYPE_NRTPS: // no real-time guarantees are given to NRTPS, serviced based on available bandwidth - } - break; - case ServiceFlow::SF_TYPE_BE: { + case ServiceFlow::SF_TYPE_BE: // no real-time guarantees are given to BE, serviced based on available bandwidth - } - break; + break; default: NS_FATAL_ERROR("Invalid scheduling type"); } diff --git a/src/wimax/model/simple-ofdm-wimax-phy.cc b/src/wimax/model/simple-ofdm-wimax-phy.cc index 7e5200f3f..b1779ac6e 100644 --- a/src/wimax/model/simple-ofdm-wimax-phy.cc +++ b/src/wimax/model/simple-ofdm-wimax-phy.cc @@ -785,20 +785,14 @@ SimpleOfdmWimaxPhy::GetCodedFecBlockSize(WimaxPhy::ModulationType modulationType blockSize = 24; break; case MODULATION_TYPE_QPSK_12: - blockSize = 48; - break; case MODULATION_TYPE_QPSK_34: blockSize = 48; break; case MODULATION_TYPE_QAM16_12: - blockSize = 96; - break; case MODULATION_TYPE_QAM16_34: blockSize = 96; break; case MODULATION_TYPE_QAM64_23: - blockSize = 144; - break; case MODULATION_TYPE_QAM64_34: blockSize = 144; break; diff --git a/src/wimax/model/ss-net-device.cc b/src/wimax/model/ss-net-device.cc index 7f8d8b890..ec45c6f85 100644 --- a/src/wimax/model/ss-net-device.cc +++ b/src/wimax/model/ss-net-device.cc @@ -1029,10 +1029,8 @@ SubscriberStationNetDevice::DoReceive(Ptr packet) { case ManagementMessageType::MESSAGE_TYPE_REG_REQ: // not yet implemented - break; case ManagementMessageType::MESSAGE_TYPE_REG_RSP: // intended for base station, ignore - break; case ManagementMessageType::MESSAGE_TYPE_DSA_REQ: /*from other station as DSA initiation by BS is not supported, ignore*/ diff --git a/src/wimax/model/wimax-tlv.cc b/src/wimax/model/wimax-tlv.cc index 003ee303a..dd6639c6e 100644 --- a/src/wimax/model/wimax-tlv.cc +++ b/src/wimax/model/wimax-tlv.cc @@ -438,19 +438,12 @@ SfVectorTlvValue::Deserialize(Buffer::Iterator i, uint64_t valueLen) break; } case ARQ_RETRY_TIMEOUT_Transmitter_Delay: - break; case ARQ_RETRY_TIMEOUT_Receiver_Delay: - break; case ARQ_BLOCK_LIFETIME: - break; case ARQ_SYNC_LOSS: - break; case ARQ_DELIVER_IN_ORDER: - break; case ARQ_PURGE_TIMEOUT: - break; case ARQ_BLOCK_SIZE: - break; case reserved2: break; case CS_Specification: {