diff --git a/RELEASE_NOTES b/RELEASE_NOTES index 8b9864296..31b438c22 100644 --- a/RELEASE_NOTES +++ b/RELEASE_NOTES @@ -27,6 +27,8 @@ New user-visible features Bugs fixed ---------- +- Bug 2992 - lte: Send method of the LteUeNetDevice doesn't use protocolNumber parameter + Known issues ------------ In general, known issues are tracked on the project tracker available diff --git a/src/lte/model/epc-sgw-pgw-application.cc b/src/lte/model/epc-sgw-pgw-application.cc index 35cda4d32..ea51478a2 100644 --- a/src/lte/model/epc-sgw-pgw-application.cc +++ b/src/lte/model/epc-sgw-pgw-application.cc @@ -24,8 +24,10 @@ #include "ns3/log.h" #include "ns3/mac48-address.h" #include "ns3/ipv4.h" +#include "ns3/ipv4-l3-protocol.h" #include "ns3/ipv6.h" #include "ns3/ipv6-header.h" +#include "ns3/ipv6-l3-protocol.h" #include "ns3/inet-socket-address.h" #include "ns3/epc-gtpu-header.h" #include "ns3/abort.h" @@ -60,13 +62,13 @@ EpcSgwPgwApplication::UeInfo::RemoveBearer (uint8_t bearerId) } uint32_t -EpcSgwPgwApplication::UeInfo::Classify (Ptr p) +EpcSgwPgwApplication::UeInfo::Classify (Ptr p, uint16_t protocolNumber) { NS_LOG_FUNCTION (this << p); // we hardcode DOWNLINK direction since the PGW is espected to // classify only downlink packets (uplink packets will go to the // internet without any classification). - return m_tftClassifier.Classify (p, EpcTft::DOWNLINK); + return m_tftClassifier.Classify (p, EpcTft::DOWNLINK, protocolNumber); } Ipv4Address @@ -160,16 +162,12 @@ EpcSgwPgwApplication::~EpcSgwPgwApplication () bool EpcSgwPgwApplication::RecvFromTunDevice (Ptr packet, const Address& source, const Address& dest, uint16_t protocolNumber) { - NS_LOG_FUNCTION (this << source << dest << packet << packet->GetSize ()); + NS_LOG_FUNCTION (this << source << dest << protocolNumber << packet << packet->GetSize ()); m_rxTunPktTrace (packet->Copy ()); Ptr pCopy = packet->Copy (); - uint8_t ipType; - pCopy->CopyData (&ipType, 1); - ipType = (ipType>>4) & 0x0f; - // get IP address of UE - if (ipType == 0x04) + if (protocolNumber == Ipv4L3Protocol::PROT_NUMBER) { Ipv4Header ipv4Header; pCopy->RemoveHeader (ipv4Header); @@ -184,7 +182,7 @@ EpcSgwPgwApplication::RecvFromTunDevice (Ptr packet, const Address& sour else { Ipv4Address enbAddr = it->second->GetEnbAddr (); - uint32_t teid = it->second->Classify (packet); + uint32_t teid = it->second->Classify (packet, protocolNumber); if (teid == 0) { NS_LOG_WARN ("no matching bearer for this packet"); @@ -195,7 +193,7 @@ EpcSgwPgwApplication::RecvFromTunDevice (Ptr packet, const Address& sour } } } - else if (ipType == 0x06) + else if (protocolNumber == Ipv6L3Protocol::PROT_NUMBER) { Ipv6Header ipv6Header; pCopy->RemoveHeader (ipv6Header); @@ -210,7 +208,7 @@ EpcSgwPgwApplication::RecvFromTunDevice (Ptr packet, const Address& sour else { Ipv4Address enbAddr = it->second->GetEnbAddr (); - uint32_t teid = it->second->Classify (packet); + uint32_t teid = it->second->Classify (packet, protocolNumber); if (teid == 0) { NS_LOG_WARN ("no matching bearer for this packet"); diff --git a/src/lte/model/epc-sgw-pgw-application.h b/src/lte/model/epc-sgw-pgw-application.h index ca424ef4b..45be08a92 100644 --- a/src/lte/model/epc-sgw-pgw-application.h +++ b/src/lte/model/epc-sgw-pgw-application.h @@ -224,12 +224,13 @@ public: * * * \param p the IP packet from the internet to be classified + * \param protocolNumber the protocol number of the IP packet * * \return the corresponding bearer ID > 0 identifying the bearer * among all the bearers of this UE; returns 0 if no bearers * matches with the previously declared TFTs */ - uint32_t Classify (Ptr p); + uint32_t Classify (Ptr p, uint16_t protocolNumber); /** * \return the address of the eNB to which the UE is connected diff --git a/src/lte/model/epc-tft-classifier.cc b/src/lte/model/epc-tft-classifier.cc index d1e2ac7d0..7500c65b3 100644 --- a/src/lte/model/epc-tft-classifier.cc +++ b/src/lte/model/epc-tft-classifier.cc @@ -31,10 +31,12 @@ #include "ns3/ipv6-header.h" #include "ns3/udp-header.h" #include "ns3/tcp-header.h" +#include "ns3/ipv4-l3-protocol.h" +#include "ns3/icmpv4-l4-protocol.h" #include "ns3/udp-l4-protocol.h" #include "ns3/tcp-l4-protocol.h" +#include "ns3/ipv6-l3-protocol.h" #include "ns3/icmpv6-l4-protocol.h" -#include "ns3/icmpv4-l4-protocol.h" namespace ns3 { @@ -62,18 +64,13 @@ EpcTftClassifier::Delete (uint32_t id) m_tftMap.erase (id); } - uint32_t -EpcTftClassifier::Classify (Ptr p, EpcTft::Direction direction) +EpcTftClassifier::Classify (Ptr p, EpcTft::Direction direction, uint16_t protocolNumber) { NS_LOG_FUNCTION (this << p << p->GetSize () << direction); Ptr pCopy = p->Copy (); - uint8_t ipType; - pCopy->CopyData (&ipType, 1); - ipType = (ipType>>4) & 0x0f; - Ipv4Address localAddressIpv4; Ipv4Address remoteAddressIpv4; @@ -86,7 +83,7 @@ EpcTftClassifier::Classify (Ptr p, EpcTft::Direction direction) uint16_t localPort = 0; uint16_t remotePort = 0; - if (ipType == 0x04) + if (protocolNumber == Ipv4L3Protocol::PROT_NUMBER) { Ipv4Header ipv4Header; pCopy->RemoveHeader (ipv4Header); @@ -202,7 +199,7 @@ EpcTftClassifier::Classify (Ptr p, EpcTft::Direction direction) } } } - else if (ipType == 0x06) + else if (protocolNumber == Ipv6L3Protocol::PROT_NUMBER) { Ipv6Header ipv6Header; pCopy->RemoveHeader (ipv6Header); @@ -261,7 +258,7 @@ EpcTftClassifier::Classify (Ptr p, EpcTft::Direction direction) } - if (ipType == 0x04) + if (protocolNumber == Ipv4L3Protocol::PROT_NUMBER) { NS_LOG_INFO ("Classifying packet:" << " localAddr=" << localAddressIpv4 @@ -288,7 +285,7 @@ EpcTftClassifier::Classify (Ptr p, EpcTft::Direction direction) } } } - else if (ipType == 0x06) + else if (protocolNumber == Ipv6L3Protocol::PROT_NUMBER) { NS_LOG_INFO ("Classifying packet:" << " localAddr=" << localAddressIpv6 diff --git a/src/lte/model/epc-tft-classifier.h b/src/lte/model/epc-tft-classifier.h index 5e0aef84d..844f9c597 100644 --- a/src/lte/model/epc-tft-classifier.h +++ b/src/lte/model/epc-tft-classifier.h @@ -77,12 +77,13 @@ public: /** * classify an IP packet * - * \param p the IP packet. It is assumed that the outmost header is an IPv4 header. + * \param p the IP packet. The outmost header can only be an IPv4 or an IPv6 header. * \param direction the EPC TFT direction (can be downlink, uplink or bi-directional) - * + * \param protocolNumber the protocol of the packet. Only IPv4 and IPv6 are supported. + * * \return the identifier (>0) of the first TFT that matches with the IP packet; 0 if no TFT matched. */ - uint32_t Classify (Ptr p, EpcTft::Direction direction); + uint32_t Classify (Ptr p, EpcTft::Direction direction, uint16_t protocolNumber); protected: diff --git a/src/lte/model/epc-ue-nas.cc b/src/lte/model/epc-ue-nas.cc index e733831ce..058597343 100644 --- a/src/lte/model/epc-ue-nas.cc +++ b/src/lte/model/epc-ue-nas.cc @@ -203,15 +203,15 @@ EpcUeNas::ActivateEpsBearer (EpsBearer bearer, Ptr tft) } bool -EpcUeNas::Send (Ptr packet) +EpcUeNas::Send (Ptr packet, uint16_t protocolNumber) { - NS_LOG_FUNCTION (this << packet); + NS_LOG_FUNCTION (this << packet << protocolNumber); switch (m_state) { case ACTIVE: { - uint32_t id = m_tftClassifier.Classify (packet, EpcTft::UPLINK); + uint32_t id = m_tftClassifier.Classify (packet, EpcTft::UPLINK, protocolNumber); NS_ASSERT ((id & 0xFFFFFF00) == 0); uint8_t bid = (uint8_t) (id & 0x000000FF); if (bid == 0) diff --git a/src/lte/model/epc-ue-nas.h b/src/lte/model/epc-ue-nas.h index 175f1be79..0546c09ab 100644 --- a/src/lte/model/epc-ue-nas.h +++ b/src/lte/model/epc-ue-nas.h @@ -147,10 +147,11 @@ public: * Enqueue an IP packet on the proper bearer for uplink transmission * * \param p the packet + * \param protocolNumber the protocol number of the packet * * \return true if successful, false if an error occurred */ - bool Send (Ptr p); + bool Send (Ptr p, uint16_t protocolNumber); /** diff --git a/src/lte/model/lte-enb-net-device.cc b/src/lte/model/lte-enb-net-device.cc index 81fdd7ba4..7d6f21f4b 100644 --- a/src/lte/model/lte-enb-net-device.cc +++ b/src/lte/model/lte-enb-net-device.cc @@ -387,8 +387,10 @@ LteEnbNetDevice::DoInitialize (void) bool LteEnbNetDevice::Send (Ptr packet, const Address& dest, uint16_t protocolNumber) { - NS_LOG_FUNCTION (this << packet << dest << protocolNumber); - NS_ASSERT_MSG (protocolNumber == Ipv4L3Protocol::PROT_NUMBER || protocolNumber == Ipv6L3Protocol::PROT_NUMBER, "unsupported protocol " << protocolNumber << ", only IPv4/IPv6 is supported"); + NS_LOG_FUNCTION (this << packet << dest << protocolNumber); + NS_ABORT_MSG_IF (protocolNumber != Ipv4L3Protocol::PROT_NUMBER + && protocolNumber != Ipv6L3Protocol::PROT_NUMBER, + "unsupported protocol " << protocolNumber << ", only IPv4 and IPv6 are supported"); return m_rrc->SendData (packet); } diff --git a/src/lte/model/lte-ue-net-device.cc b/src/lte/model/lte-ue-net-device.cc index 24a592b3d..13ca07ec3 100644 --- a/src/lte/model/lte-ue-net-device.cc +++ b/src/lte/model/lte-ue-net-device.cc @@ -286,13 +286,11 @@ LteUeNetDevice::DoInitialize (void) bool LteUeNetDevice::Send (Ptr packet, const Address& dest, uint16_t protocolNumber) { - NS_LOG_FUNCTION (this << dest << protocolNumber); - if (protocolNumber != Ipv4L3Protocol::PROT_NUMBER && protocolNumber != Ipv6L3Protocol::PROT_NUMBER) - { - NS_LOG_INFO ("unsupported protocol " << protocolNumber << ", only IPv4 and IPv6 are supported"); - return true; - } - return m_nas->Send (packet); + NS_LOG_FUNCTION (this << packet << dest << protocolNumber); + NS_ABORT_MSG_IF (protocolNumber != Ipv4L3Protocol::PROT_NUMBER + && protocolNumber != Ipv6L3Protocol::PROT_NUMBER, + "unsupported protocol " << protocolNumber << ", only IPv4 and IPv6 are supported"); + return m_nas->Send (packet, protocolNumber); } diff --git a/src/lte/test/test-epc-tft-classifier.cc b/src/lte/test/test-epc-tft-classifier.cc index 9717331b1..f02f84444 100644 --- a/src/lte/test/test-epc-tft-classifier.cc +++ b/src/lte/test/test-epc-tft-classifier.cc @@ -26,6 +26,7 @@ #include "ns3/ipv4-header.h" #include "ns3/udp-header.h" #include "ns3/tcp-header.h" +#include "ns3/ipv4-l3-protocol.h" #include "ns3/udp-l4-protocol.h" #include "ns3/tcp-l4-protocol.h" @@ -163,7 +164,7 @@ EpcTftClassifierTestCase::DoRun (void) udpPacket->AddHeader (m_udpHeader); udpPacket->AddHeader (m_ipHeader); NS_LOG_LOGIC (this << *udpPacket); - uint32_t obtainedTftId = m_c ->Classify (udpPacket, m_d); + uint32_t obtainedTftId = m_c ->Classify (udpPacket, m_d, Ipv4L3Protocol::PROT_NUMBER); NS_TEST_ASSERT_MSG_EQ (obtainedTftId, (uint16_t) m_tftId, "bad classification of UDP packet"); }