internet: Remove FqCoDelIpv{4,6}PacketFilter classes

This commit is contained in:
Stefano Avallone
2018-05-24 00:33:51 +02:00
parent 61e43c89a6
commit 8172c7eed7
7 changed files with 47 additions and 240 deletions

View File

@@ -170,11 +170,9 @@ int main (int argc, char *argv[])
}
else if (queueDiscType.compare ("FqCoDel") == 0)
{
uint32_t handle = tchBottleneck.SetRootQueueDisc ("ns3::FqCoDelQueueDisc");
tchBottleneck.SetRootQueueDisc ("ns3::FqCoDelQueueDisc");
Config::SetDefault ("ns3::FqCoDelQueueDisc::MaxSize",
QueueSizeValue (QueueSize (QueueSizeUnit::PACKETS, queueDiscSize)));
tchBottleneck.AddPacketFilter (handle, "ns3::FqCoDelIpv4PacketFilter");
tchBottleneck.AddPacketFilter (handle, "ns3::FqCoDelIpv6PacketFilter");
}
else if (queueDiscType.compare ("PIE") == 0)
{

View File

@@ -64,88 +64,5 @@ Ipv4PacketFilter::CheckProtocol (Ptr<QueueDiscItem> item) const
// ------------------------------------------------------------------------- //
NS_OBJECT_ENSURE_REGISTERED (FqCoDelIpv4PacketFilter);
TypeId
FqCoDelIpv4PacketFilter::GetTypeId (void)
{
static TypeId tid = TypeId ("ns3::FqCoDelIpv4PacketFilter")
.SetParent<Ipv4PacketFilter> ()
.SetGroupName ("Internet")
.AddConstructor<FqCoDelIpv4PacketFilter> ()
.AddAttribute ("Perturbation",
"The salt used as an additional input to the hash function of this filter",
UintegerValue (0),
MakeUintegerAccessor (&FqCoDelIpv4PacketFilter::m_perturbation),
MakeUintegerChecker<uint32_t> ())
;
return tid;
}
FqCoDelIpv4PacketFilter::FqCoDelIpv4PacketFilter ()
{
NS_LOG_FUNCTION (this);
}
FqCoDelIpv4PacketFilter::~FqCoDelIpv4PacketFilter ()
{
NS_LOG_FUNCTION (this);
}
int32_t
FqCoDelIpv4PacketFilter::DoClassify (Ptr<QueueDiscItem> item) const
{
NS_LOG_FUNCTION (this << item);
Ptr<Ipv4QueueDiscItem> ipv4Item = DynamicCast<Ipv4QueueDiscItem> (item);
NS_ASSERT (ipv4Item != 0);
Ipv4Header hdr = ipv4Item->GetHeader ();
Ipv4Address src = hdr.GetSource ();
Ipv4Address dest = hdr.GetDestination ();
uint8_t prot = hdr.GetProtocol ();
uint16_t fragOffset = hdr.GetFragmentOffset ();
TcpHeader tcpHdr;
UdpHeader udpHdr;
uint16_t srcPort = 0;
uint16_t destPort = 0;
Ptr<Packet> pkt = ipv4Item->GetPacket ();
if (prot == 6 && fragOffset == 0) // TCP
{
pkt->PeekHeader (tcpHdr);
srcPort = tcpHdr.GetSourcePort ();
destPort = tcpHdr.GetDestinationPort ();
}
else if (prot == 17 && fragOffset == 0) // UDP
{
pkt->PeekHeader (udpHdr);
srcPort = udpHdr.GetSourcePort ();
destPort = udpHdr.GetDestinationPort ();
}
/* serialize the 5-tuple and the perturbation in buf */
uint8_t buf[17];
src.Serialize (buf);
dest.Serialize (buf + 4);
buf[8] = prot;
buf[9] = (srcPort >> 8) & 0xff;
buf[10] = srcPort & 0xff;
buf[11] = (destPort >> 8) & 0xff;
buf[12] = destPort & 0xff;
buf[13] = (m_perturbation >> 24) & 0xff;
buf[14] = (m_perturbation >> 16) & 0xff;
buf[15] = (m_perturbation >> 8) & 0xff;
buf[16] = m_perturbation & 0xff;
/* Linux calculates the jhash2 (jenkins hash), we calculate the murmur3 */
uint32_t hash = Hash32 ((char*) buf, 17);
NS_LOG_DEBUG ("Found Ipv4 packet; hash value " << hash);
return hash;
}
} // namespace ns3

View File

@@ -51,31 +51,6 @@ private:
virtual int32_t DoClassify (Ptr<QueueDiscItem> item) const = 0;
};
/**
* \ingroup internet
*
* FqCoDelIpv4PacketFilter is the filter to be added to the FQCoDel
* queue disc to simulate the behavior of the fq-codel Linux queue disc.
*
*/
class FqCoDelIpv4PacketFilter : public Ipv4PacketFilter {
public:
/**
* \brief Get the type ID.
* \return the object TypeId
*/
static TypeId GetTypeId (void);
FqCoDelIpv4PacketFilter ();
virtual ~FqCoDelIpv4PacketFilter ();
private:
virtual int32_t DoClassify (Ptr<QueueDiscItem> item) const;
uint32_t m_perturbation; //!< hash perturbation value
};
} // namespace ns3
#endif /* IPV4_PACKET_FILTER */

View File

@@ -64,87 +64,5 @@ Ipv6PacketFilter::CheckProtocol (Ptr<QueueDiscItem> item) const
// ------------------------------------------------------------------------- //
NS_OBJECT_ENSURE_REGISTERED (FqCoDelIpv6PacketFilter);
TypeId
FqCoDelIpv6PacketFilter::GetTypeId (void)
{
static TypeId tid = TypeId ("ns3::FqCoDelIpv6PacketFilter")
.SetParent<Ipv6PacketFilter> ()
.SetGroupName ("Internet")
.AddConstructor<FqCoDelIpv6PacketFilter> ()
.AddAttribute ("Perturbation",
"The salt used as an additional input to the hash function of this filter",
UintegerValue (0),
MakeUintegerAccessor (&FqCoDelIpv6PacketFilter::m_perturbation),
MakeUintegerChecker<uint32_t> ())
;
return tid;
}
FqCoDelIpv6PacketFilter::FqCoDelIpv6PacketFilter ()
{
NS_LOG_FUNCTION (this);
}
FqCoDelIpv6PacketFilter::~FqCoDelIpv6PacketFilter ()
{
NS_LOG_FUNCTION (this);
}
int32_t
FqCoDelIpv6PacketFilter::DoClassify (Ptr< QueueDiscItem > item) const
{
NS_LOG_FUNCTION (this << item);
Ptr<Ipv6QueueDiscItem> ipv6Item = DynamicCast<Ipv6QueueDiscItem> (item);
NS_ASSERT (ipv6Item != 0);
Ipv6Header hdr = ipv6Item->GetHeader ();
Ipv6Address src = hdr.GetSourceAddress ();
Ipv6Address dest = hdr.GetDestinationAddress ();
uint8_t prot = hdr.GetNextHeader ();
TcpHeader tcpHdr;
UdpHeader udpHdr;
uint16_t srcPort = 0;
uint16_t destPort = 0;
Ptr<Packet> pkt = ipv6Item->GetPacket ();
if (prot == 6) // TCP
{
pkt->PeekHeader (tcpHdr);
srcPort = tcpHdr.GetSourcePort ();
destPort = tcpHdr.GetDestinationPort ();
}
else if (prot == 17) // UDP
{
pkt->PeekHeader (udpHdr);
srcPort = udpHdr.GetSourcePort ();
destPort = udpHdr.GetDestinationPort ();
}
/* serialize the 5-tuple and the perturbation in buf */
uint8_t buf[41];
src.Serialize (buf);
dest.Serialize (buf + 16);
buf[32] = prot;
buf[33] = (srcPort >> 8) & 0xff;
buf[34] = srcPort & 0xff;
buf[35] = (destPort >> 8) & 0xff;
buf[36] = destPort & 0xff;
buf[37] = (m_perturbation >> 24) & 0xff;
buf[38] = (m_perturbation >> 16) & 0xff;
buf[39] = (m_perturbation >> 8) & 0xff;
buf[40] = m_perturbation & 0xff;
/* Linux calculates the jhash2 (jenkins hash), we calculate the murmur3 */
uint32_t hash = Hash32 ((char*) buf, 41);
NS_LOG_DEBUG ("Found Ipv6 packet; hash of the five tuple " << hash);
return hash;
}
} // namespace ns3

View File

@@ -51,31 +51,6 @@ private:
virtual int32_t DoClassify (Ptr<QueueDiscItem> item) const = 0;
};
/**
* \ingroup internet
*
* FqCoDelIpv6PacketFilter is the filter to be added to the FQCoDel
* queue disc to simulate the behavior of the fq-codel Linux queue disc.
*
*/
class FqCoDelIpv6PacketFilter : public Ipv6PacketFilter {
public:
/**
* \brief Get the type ID.
* \return the object TypeId
*/
static TypeId GetTypeId (void);
FqCoDelIpv6PacketFilter ();
virtual ~FqCoDelIpv6PacketFilter ();
private:
virtual int32_t DoClassify (Ptr<QueueDiscItem> item) const;
uint32_t m_perturbation; //!< hash perturbation value
};
} // namespace ns3
#endif /* IPV6_PACKET_FILTER */

View File

@@ -36,6 +36,50 @@
using namespace ns3;
/**
* Simple test packet filter able to classify IPv4 packets
*
*/
class Ipv4TestPacketFilter : public Ipv4PacketFilter {
public:
/**
* \brief Get the type ID.
* \return the object TypeId
*/
static TypeId GetTypeId (void);
Ipv4TestPacketFilter ();
virtual ~Ipv4TestPacketFilter ();
private:
virtual int32_t DoClassify (Ptr<QueueDiscItem> item) const;
};
TypeId
Ipv4TestPacketFilter::GetTypeId (void)
{
static TypeId tid = TypeId ("ns3::Ipv4TestPacketFilter")
.SetParent<Ipv4PacketFilter> ()
.SetGroupName ("Internet")
.AddConstructor<Ipv4TestPacketFilter> ()
;
return tid;
}
Ipv4TestPacketFilter::Ipv4TestPacketFilter ()
{
}
Ipv4TestPacketFilter::~Ipv4TestPacketFilter ()
{
}
int32_t
Ipv4TestPacketFilter::DoClassify (Ptr<QueueDiscItem> item) const
{
return 0;
}
/**
* This class tests packets for which there is no suitable filter
*/
@@ -63,7 +107,7 @@ FqCoDelQueueDiscNoSuitableFilter::DoRun (void)
{
// Packets that cannot be classified by the available filters should be dropped
Ptr<FqCoDelQueueDisc> queueDisc = CreateObjectWithAttributes<FqCoDelQueueDisc> ("MaxSize", StringValue ("4p"));
Ptr<FqCoDelIpv4PacketFilter> filter = CreateObject<FqCoDelIpv4PacketFilter> ();
Ptr<Ipv4TestPacketFilter> filter = CreateObject<Ipv4TestPacketFilter> ();
queueDisc->AddPacketFilter (filter);
queueDisc->SetQuantum (1500);
@@ -122,10 +166,6 @@ void
FqCoDelQueueDiscIPFlowsSeparationAndPacketLimit::DoRun (void)
{
Ptr<FqCoDelQueueDisc> queueDisc = CreateObjectWithAttributes<FqCoDelQueueDisc> ("MaxSize", StringValue ("4p"));
Ptr<FqCoDelIpv6PacketFilter> ipv6Filter = CreateObject<FqCoDelIpv6PacketFilter> ();
Ptr<FqCoDelIpv4PacketFilter> ipv4Filter = CreateObject<FqCoDelIpv4PacketFilter> ();
queueDisc->AddPacketFilter (ipv6Filter);
queueDisc->AddPacketFilter (ipv4Filter);
queueDisc->SetQuantum (1500);
queueDisc->Initialize ();
@@ -195,10 +235,6 @@ void
FqCoDelQueueDiscDeficit::DoRun (void)
{
Ptr<FqCoDelQueueDisc> queueDisc = CreateObjectWithAttributes<FqCoDelQueueDisc> ();
Ptr<FqCoDelIpv6PacketFilter> ipv6Filter = CreateObject<FqCoDelIpv6PacketFilter> ();
Ptr<FqCoDelIpv4PacketFilter> ipv4Filter = CreateObject<FqCoDelIpv4PacketFilter> ();
queueDisc->AddPacketFilter (ipv6Filter);
queueDisc->AddPacketFilter (ipv4Filter);
queueDisc->SetQuantum (90);
queueDisc->Initialize ();
@@ -342,10 +378,6 @@ void
FqCoDelQueueDiscTCPFlowsSeparation::DoRun (void)
{
Ptr<FqCoDelQueueDisc> queueDisc = CreateObjectWithAttributes<FqCoDelQueueDisc> ("MaxSize", StringValue ("10p"));
Ptr<FqCoDelIpv6PacketFilter> ipv6Filter = CreateObject<FqCoDelIpv6PacketFilter> ();
Ptr<FqCoDelIpv4PacketFilter> ipv4Filter = CreateObject<FqCoDelIpv4PacketFilter> ();
queueDisc->AddPacketFilter (ipv6Filter);
queueDisc->AddPacketFilter (ipv4Filter);
queueDisc->SetQuantum (1500);
queueDisc->Initialize ();
@@ -432,10 +464,6 @@ void
FqCoDelQueueDiscUDPFlowsSeparation::DoRun (void)
{
Ptr<FqCoDelQueueDisc> queueDisc = CreateObjectWithAttributes<FqCoDelQueueDisc> ("MaxSize", StringValue ("10p"));
Ptr<FqCoDelIpv6PacketFilter> ipv6Filter = CreateObject<FqCoDelIpv6PacketFilter> ();
Ptr<FqCoDelIpv4PacketFilter> ipv4Filter = CreateObject<FqCoDelIpv4PacketFilter> ();
queueDisc->AddPacketFilter (ipv6Filter);
queueDisc->AddPacketFilter (ipv4Filter);
queueDisc->SetQuantum (1500);
queueDisc->Initialize ();

View File

@@ -46,11 +46,7 @@ discs:
TrafficControlHelper tch;
uint16_t handle = tch.SetRootQueueDisc ("ns3::MqQueueDisc");
TrafficControlHelper::ClassIdList cls = tch.AddQueueDiscClasses (handle, numTxQueues, "ns3::QueueDiscClass");
TrafficControlHelper::HandleList hdl = tch.AddChildQueueDiscs (handle, cls, "ns3::FqCoDelQueueDisc");
for (auto h : hdl)
{
tch.AddPacketFilter (h, "ns3::FqCoDelIpv4PacketFilter");
}
tch.AddChildQueueDiscs (handle, cls, "ns3::FqCoDelQueueDisc");
QueueDiscContainer qdiscs = tch.Install (devices);
Note that the child queue discs attached to the classes do not necessarily have to be of the same type.