--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/lte/model/eps-tft-classifier.cc Tue Aug 02 18:22:23 2011 +0200
@@ -0,0 +1,165 @@
+/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
+/*
+ * Copyright (c) 2011 CTTC
+ * Copyright (c) 2010 TELEMATICS LAB, DEE - Politecnico di Bari
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation;
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ * Authors:
+ * Nicola Baldo <nbaldo@cttc.es> (the EpsTftClassifier class)
+ * Giuseppe Piro <g.piro@poliba.it> (part of the code in EpsTftClassifier::Classify ()
+ * which comes from RrcEntity::Classify of the GSoC 2010 LTE module)
+ *
+ */
+
+
+
+
+#include "eps-tft-classifier.h"
+#include "lte-tft.h"
+#include "ns3/abort.h"
+#include "ns3/log.h"
+#include "ns3/packet.h"
+#include "ns3/ipv4-header.h"
+#include "ns3/udp-header.h"
+#include "ns3/tcp-header.h"
+#include "ns3/udp-l4-protocol.h"
+#include "ns3/tcp-l4-protocol.h"
+
+NS_LOG_COMPONENT_DEFINE ("EpsTftClassifier");
+
+namespace ns3 {
+
+EpsTftClassifier::EpsTftClassifier ()
+ : m_tftCount (0)
+{
+ NS_LOG_FUNCTION (this);
+}
+
+uint32_t
+EpsTftClassifier::Add (Ptr<LteTft> tft)
+{
+ NS_LOG_FUNCTION (this << tft);
+ // simple sanity check. If you ever need more than 4M TFTs within a same classifiers, you'll need to implement a smarter id management algorithm.
+ NS_ABORT_IF (m_tftCount == 0xFFFFFFFF);
+ ++m_tftCount;
+ m_tftMap[m_tftCount] = tft;
+ return m_tftCount;
+}
+
+void
+EpsTftClassifier::Delete (uint32_t id)
+{
+ NS_LOG_FUNCTION (this << id);
+ m_tftMap.erase (id);
+}
+
+
+uint32_t
+EpsTftClassifier::Classify (Ptr<Packet> p, LteTft::Direction direction)
+{
+ NS_LOG_FUNCTION (this << *p << direction);
+
+ Ptr<Packet> pCopy = p->Copy ();
+
+ Ipv4Header ipv4Header;
+ pCopy->RemoveHeader (ipv4Header);
+
+ Ipv4Address localAddress;
+ Ipv4Address remoteAddress;
+
+
+ if (direction == LteTft::UPLINK)
+ {
+ localAddress = ipv4Header.GetSource ();
+ remoteAddress = ipv4Header.GetDestination ();
+ }
+ else
+ {
+ NS_ASSERT (direction == LteTft::DOWNLINK);
+ remoteAddress = ipv4Header.GetSource ();
+ localAddress = ipv4Header.GetDestination ();
+ }
+
+ uint8_t protocol = ipv4Header.GetProtocol ();
+
+ uint8_t tos = ipv4Header.GetTos ();
+
+ uint16_t localPort = 0;
+ uint16_t remotePort = 0;
+
+ if (protocol == UdpL4Protocol::PROT_NUMBER)
+ {
+ UdpHeader udpHeader;
+ pCopy->RemoveHeader (udpHeader);
+
+ if (direction == LteTft::UPLINK)
+ {
+ localPort = udpHeader.GetSourcePort ();
+ remotePort = udpHeader.GetDestinationPort ();
+ }
+ else
+ {
+ remotePort = udpHeader.GetSourcePort ();
+ localPort = udpHeader.GetDestinationPort ();
+ }
+ }
+ else if (protocol == TcpL4Protocol::PROT_NUMBER)
+ {
+ TcpHeader tcpHeader;
+ pCopy->RemoveHeader (tcpHeader);
+ if (direction == LteTft::UPLINK)
+ {
+ localPort = tcpHeader.GetSourcePort ();
+ remotePort = tcpHeader.GetDestinationPort ();
+ }
+ else
+ {
+ remotePort = tcpHeader.GetSourcePort ();
+ localPort = tcpHeader.GetDestinationPort ();
+ }
+ }
+ else
+ {
+ NS_LOG_INFO ("Unknown protocol: " << protocol);
+ return 0; // no match
+ }
+
+ NS_LOG_INFO ("Classifing packet:"
+ << " localAddr=" << localAddress
+ << " remoteAddr=" << remoteAddress
+ << " localPort=" << localPort
+ << " remotePort=" << remotePort
+ << " tos=0x" << std::hex << tos);
+
+ // now it is possible to classify the packet!
+ std::map <uint32_t, Ptr<LteTft> >::const_iterator it;
+ NS_LOG_LOGIC ("TFT MAP size: " << m_tftMap.size ());
+ for (it = m_tftMap.begin (); it != m_tftMap.end (); ++it)
+ {
+ NS_LOG_LOGIC ("TFT id: " << it->first );
+ NS_LOG_LOGIC (" Ptr<LteTft>: " << it->second);
+ Ptr<LteTft> tft = it->second;
+ if (tft->Matches (direction, remoteAddress, localAddress, remotePort, localPort, tos))
+ {
+ NS_LOG_LOGIC ("matches with TFT ID = " << it->first);
+ return it->first; // the id of the matching TFT
+ }
+ }
+ NS_LOG_LOGIC ("no match");
+ return 0; // no match
+}
+
+
+} // namespace ns3
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/lte/model/eps-tft-classifier.h Tue Aug 02 18:22:23 2011 +0200
@@ -0,0 +1,86 @@
+/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
+/*
+ * Copyright (c) 2011 Centre Tecnologic de Telecomunicacions de Catalunya (CTTC)
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation;
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ * Author: Nicola Baldo <nbaldo@cttc.es>
+ */
+
+
+#ifndef EPS_TFT_CLASSIFIER_H
+#define EPS_TFT_CLASSIFIER_H
+
+
+#include "ns3/ptr.h"
+#include "ns3/simple-ref-count.h"
+#include "ns3/lte-tft.h"
+
+#include <map>
+
+
+namespace ns3 {
+
+class LteTft;
+class Packet;
+
+/**
+ * \brief classifies IP packets accoding to Traffic Flow Templates (TFTs)
+ *
+ * \note this implementation works with IPv4 only.
+ */
+class EpsTftClassifier : public SimpleRefCount<EpsTftClassifier>
+{
+public:
+
+ EpsTftClassifier ();
+
+ /**
+ * add a TFT to the Classifier
+ *
+ * \param tft the TFT to be added
+ *
+ * \return the unique identifier of the added TFT within this Classifier instance
+ */
+ uint32_t Add (Ptr<LteTft> tft);
+
+ /**
+ * delete an existing TFT from the classifier
+ *
+ * \param id the identifier of the TFT to be deleted
+ */
+ void Delete (uint32_t id);
+
+
+ /**
+ * classify an IP packet
+ *
+ * \param p the IP packet. It is assumed that the outmost header is an IPv4 header.
+ *
+ * \return the identifier (>0) of the first TFT that matches with the IP packet; 0 if no TFT matched.
+ */
+ uint32_t Classify (Ptr<Packet> p, LteTft::Direction direction);
+
+protected:
+
+ std::map <uint32_t, Ptr<LteTft> > m_tftMap;
+ uint32_t m_tftCount;
+
+};
+
+
+
+} // namespace ns3
+
+#endif /* TFT_CLASSIFIER_H */
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/lte/model/lte-tft.cc Tue Aug 02 18:22:23 2011 +0200
@@ -0,0 +1,183 @@
+/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
+/*
+ * Copyright (c) 2011 CTTC
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation;
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ * Author: Nicola Baldo <nbaldo@cttc.es>
+ */
+
+
+
+
+#include "lte-tft.h"
+#include "ns3/abort.h"
+#include "ns3/log.h"
+
+
+namespace ns3 {
+
+NS_LOG_COMPONENT_DEFINE ("LteTft");
+
+std::ostream& operator<< (std::ostream& os, LteTft::Direction& d)
+{
+ switch (d)
+ {
+ case LteTft::DOWNLINK:
+ os << "DOWNLINK";
+ break;
+ case LteTft::UPLINK:
+ os << "UPLINK";
+ break;
+ default:
+ os << "BIDIRECTIONAL";
+ break;
+ }
+ return os;
+}
+
+
+std::ostream& operator<< (std::ostream& os, LteTft::PacketFilter& f)
+{
+ os << " direction: " << f.direction
+ << " remoteAddress: " << f.remoteAddress
+ << " remoteMask: " << f.remoteMask
+ << " localAddress: " << f.localAddress
+ << " localMask: " << f.localMask
+ << " remotePortStart: " << f.remotePortStart
+ << " remotePortEnd: " << f.remotePortEnd
+ << " localPortStart: " << f.localPortStart
+ << " localPortEnd: " << f.localPortEnd
+ << " typeOfService: 0x" << std::hex << (uint16_t) f.typeOfService
+ << " typeOfServiceMask: 0x" << std::hex << (uint16_t) f.typeOfServiceMask;
+ return os;
+}
+
+LteTft::PacketFilter::PacketFilter ()
+ : precedence (255),
+ direction (BIDIRECTIONAL),
+ remoteMask ("0.0.0.0"),
+ localMask ("0.0.0.0"),
+ remotePortStart (0),
+ remotePortEnd (65535),
+ localPortStart (0),
+ localPortEnd (65535),
+ typeOfServiceMask (0)
+{
+ NS_LOG_FUNCTION (this);
+}
+
+bool
+LteTft::PacketFilter::Matches (Direction d,
+ Ipv4Address ra,
+ Ipv4Address la,
+ uint16_t rp,
+ uint16_t lp,
+ uint8_t tos)
+{
+ NS_LOG_FUNCTION (this << d << ra << la << rp << lp << tos);
+ if (d & direction)
+ {
+ NS_LOG_LOGIC ("d matches");
+ if (remoteMask.IsMatch (remoteAddress, ra))
+ {
+ NS_LOG_LOGIC ("ra matches");
+ if (localMask.IsMatch (localAddress, la))
+ {
+ NS_LOG_LOGIC ("ls matches");
+ if (rp >= remotePortStart)
+ {
+ NS_LOG_LOGIC ("rps matches");
+ if (rp <= remotePortEnd)
+ {
+ NS_LOG_LOGIC ("rpe matches");
+ if (lp >= localPortStart)
+ {
+ NS_LOG_LOGIC ("lps matches");
+ if (lp <= localPortEnd)
+ {
+ NS_LOG_LOGIC ("lpe matches");
+ if ((tos & typeOfServiceMask) == (typeOfService & typeOfServiceMask))
+ {
+ NS_LOG_LOGIC ("tos matches --> have match!");
+ return true;
+ }
+ }
+ }
+ }
+ }
+ }
+ else
+ {
+ NS_LOG_LOGIC ("la doesn't match: la=" << la << " f.la=" << localAddress << " f.lmask=" << localMask);
+ }
+ }
+ else
+ {
+ NS_LOG_LOGIC ("ra doesn't match: ra=" << ra << " f.ra=" << remoteAddress << " f.rmask=" << remoteMask);
+ }
+ }
+ else
+ {
+ NS_LOG_LOGIC ("d doesn't match: d=0x" << std::hex << d << " f.d=0x" << std::hex << direction);
+ }
+ return false;
+}
+
+LteTft::LteTft ()
+ : m_numFilters (0)
+{
+ NS_LOG_FUNCTION (this);
+}
+
+uint8_t
+LteTft::Add (PacketFilter f)
+{
+ NS_LOG_FUNCTION (this << f);
+ NS_ABORT_IF (m_numFilters >= 16);
+
+ std::list<PacketFilter>::iterator it;
+ for (it = m_filters.begin ();
+ (it != m_filters.end ()) && (it->precedence <= f.precedence);
+ ++it)
+ {
+ }
+ m_filters.insert (it, f);
+ ++m_numFilters;
+ return (m_numFilters - 1);
+}
+
+bool
+LteTft::Matches (Direction direction,
+ Ipv4Address remoteAddress,
+ Ipv4Address localAddress,
+ uint16_t remotePort,
+ uint16_t localPort,
+ uint8_t typeOfService)
+{
+ NS_LOG_FUNCTION (this << direction << remoteAddress << localAddress << remotePort << localPort << typeOfService);
+ for (std::list<PacketFilter>::iterator it = m_filters.begin ();
+ it != m_filters.end ();
+ ++it)
+ {
+ if (it->Matches (direction, remoteAddress, localAddress, remotePort, localPort, typeOfService))
+ {
+ return true;
+ }
+ }
+ return false;
+}
+
+
+} // namespace ns3
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/lte/model/lte-tft.h Tue Aug 02 18:22:23 2011 +0200
@@ -0,0 +1,161 @@
+/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
+/*
+ * Copyright (c) 2011 Centre Tecnologic de Telecomunicacions de Catalunya (CTTC)
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation;
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ * Author: Nicola Baldo <nbaldo@cttc.es>
+ */
+
+
+#ifndef LTE_TFT_H
+#define LTE_TFT_H
+
+
+#include <ns3/simple-ref-count.h>
+#include <ns3/ipv4-address.h>
+
+#include <list>
+
+namespace ns3 {
+
+
+
+/**
+ * This class implements the EPS bearer Traffic Flow Template (TFT),
+ * which is the set of all packet filters associated with an EPS bearer.
+ *
+ */
+class LteTft : public SimpleRefCount<LteTft>
+{
+
+public:
+
+ /**
+ * Indicates the direction of the traffic that is to be classified.
+ */
+ enum Direction {DOWNLINK = 1,
+ UPLINK = 2,
+ BIDIRECTIONAL = 3};
+
+ /**
+ * Implement the data structure representing a TrafficFlowTemplate
+ * Packet Filter.
+ * See 3GPP TS 24.008 version 8.7.0 Release 8, Table 10.5.162/3GPP TS
+ * 24.008: Traffic flow template information element
+ *
+ * With respect to the Packet Filter specification in the above doc,
+ * the following features are NOT supported:
+ * - IPv6 filtering (including flow labels)
+ * - IPSec filtering
+ * - filter precedence field is not evaluated, hence it is recommended to setup
+ * the TFTs within a PDP context such that TFTs are mutually exclusive
+ */
+ struct PacketFilter
+ {
+ PacketFilter ();
+
+ /**
+ *
+ * \param d the direction
+ * \param ra the remote address
+ * \param la the local address
+ * \param rp the remote port
+ * \param lp the local port
+ * \param tos the type of service
+ *
+ * \return true if the parameters match with the PacketFilter,
+ * false otherwise.
+ */
+ bool Matches (Direction d,
+ Ipv4Address ra,
+ Ipv4Address la,
+ uint16_t rp,
+ uint16_t lp,
+ uint8_t tos);
+
+
+
+ uint8_t precedence; /**< used to specify the precedence for the
+ * packet filter among all packet filters in
+ * the TFT; higher values will be evaluated
+ * last.
+ */
+
+ Direction direction; /**< whether the filter needs to be applied
+ to uplink / downlink only, or in both cases*/
+
+ Ipv4Address remoteAddress; /**< IPv4 address of the remote host */
+ Ipv4Mask remoteMask; /**< IPv4 address mask of the remote host */
+ Ipv4Address localAddress; /**< IPv4 address of the UE */
+ Ipv4Mask localMask; /**< IPv4 address mask of the UE */
+
+ uint16_t remotePortStart; /**< start of the port number range of the remote host */
+ uint16_t remotePortEnd; /**< end of the port number range of the remote host */
+ uint16_t localPortStart; /**< start of the port number range of the UE */
+ uint16_t localPortEnd; /**< end of the port number range of the UE */
+
+ uint8_t typeOfService; /**< type of service field */
+ uint8_t typeOfServiceMask; /**< type of service field mask */
+ };
+
+ LteTft ();
+
+
+ /**
+ * add a PacketFilter to the Traffic Flow Template
+ *
+ * \param the PacketFilter to be added
+ *
+ * \return the id( 0 <= id < 16) of the newly added filter, if the addition was successful. Will fail if you try to add more than 15 filters. This is to be compliant with TS 24.008.
+ */
+ uint8_t Add (PacketFilter f);
+
+
+ /**
+ *
+ * \param direction
+ * \param remoteAddress
+ * \param localAddress
+ * \param remotePort
+ * \param localPort
+ * \param typeOfService
+ *
+ * \return true if any PacketFilter in the TFT matches with the
+ * parameters, false otherwise.
+ */
+ bool Matches (Direction direction,
+ Ipv4Address remoteAddress,
+ Ipv4Address localAddress,
+ uint16_t remotePort,
+ uint16_t localPort,
+ uint8_t typeOfService);
+
+
+private:
+
+ std::list<PacketFilter> m_filters;
+ uint8_t m_numFilters;
+
+};
+
+
+std::ostream& operator<< (std::ostream& os, LteTft::Direction& d);
+
+
+} // namespace ns3
+
+#endif /* LTE_TFT_H */
+
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/lte/test/test-eps-tft-classifier.cc Tue Aug 02 18:22:23 2011 +0200
@@ -0,0 +1,205 @@
+/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
+/*
+ * Copyright (c) 2011 Centre Tecnologic de Telecomunicacions de Catalunya (CTTC)
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation;
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ * Author: Nicola Baldo <nbaldo@cttc.es>
+ */
+
+
+
+#include "ns3/test.h"
+#include "ns3/log.h"
+#include "ns3/packet.h"
+#include "ns3/ipv4-header.h"
+#include "ns3/udp-header.h"
+#include "ns3/tcp-header.h"
+#include "ns3/udp-l4-protocol.h"
+#include "ns3/tcp-l4-protocol.h"
+
+#include "ns3/eps-tft-classifier.h"
+
+#include <iomanip>
+
+NS_LOG_COMPONENT_DEFINE ("TestEpsTftClassifier");
+
+namespace ns3 {
+
+class EpsTftClassifierTestCase : public TestCase
+{
+public:
+ EpsTftClassifierTestCase (Ptr<EpsTftClassifier> c,
+ LteTft::Direction d,
+ Ipv4Address sa,
+ Ipv4Address da,
+ uint16_t sp,
+ uint16_t dp,
+ uint8_t tos,
+ uint32_t tftId);
+ virtual ~EpsTftClassifierTestCase ();
+
+private:
+
+ Ptr<EpsTftClassifier> m_c;
+ LteTft::Direction m_d;
+ uint8_t m_tftId;
+ Ipv4Header m_ipHeader;
+ UdpHeader m_udpHeader;
+ TcpHeader m_tcpHeader;
+
+ virtual void DoRun (void);
+};
+
+EpsTftClassifierTestCase::EpsTftClassifierTestCase (Ptr<EpsTftClassifier> c,
+ LteTft::Direction d,
+ Ipv4Address sa,
+ Ipv4Address da,
+ uint16_t sp,
+ uint16_t dp,
+ uint8_t tos,
+ uint32_t tftId)
+ : TestCase (""),
+ m_c (c),
+ m_d (d),
+ m_tftId (tftId)
+{
+ std::ostringstream oss;
+ oss << c
+ << " d = " << d
+ << ", sa = " << sa
+ << ", da = " << da
+ << ", sp = " << sp
+ << ", dp = " << dp
+ << ", tos = 0x" << std::hex << tos
+ << " --> tftId = " << tftId;
+ SetName (oss.str ());
+
+ NS_LOG_FUNCTION (this << oss.str ());
+
+
+ m_ipHeader.SetSource (sa);
+ m_ipHeader.SetDestination (da);
+ m_ipHeader.SetTos (tos);
+
+
+ m_udpHeader.SetSourcePort (sp);
+ m_udpHeader.SetDestinationPort (dp);
+
+
+}
+
+EpsTftClassifierTestCase::~EpsTftClassifierTestCase ()
+{
+}
+
+void
+EpsTftClassifierTestCase::DoRun (void)
+{
+ ns3::PacketMetadata::Enable ();
+
+ Ptr<Packet> udpPacket = Create<Packet> ();
+ m_ipHeader.SetProtocol (UdpL4Protocol::PROT_NUMBER);
+ udpPacket->AddHeader (m_udpHeader);
+ udpPacket->AddHeader (m_ipHeader);
+ NS_LOG_LOGIC (this << *udpPacket);
+ uint32_t obtainedTftId = m_c ->Classify (udpPacket, m_d);
+ NS_TEST_ASSERT_MSG_EQ (obtainedTftId, m_tftId, "bad classification of UDP packet");
+}
+
+
+
+
+class EpsTftClassifierTestSuite : public TestSuite
+{
+public:
+ EpsTftClassifierTestSuite ();
+};
+
+static EpsTftClassifierTestSuite g_lteTftClassifierTestSuite;
+
+EpsTftClassifierTestSuite::EpsTftClassifierTestSuite ()
+ : TestSuite ("eps-tft-classifier", UNIT)
+{
+ NS_LOG_FUNCTION (this);
+
+ Ptr<EpsTftClassifier> c1 = Create<EpsTftClassifier> ();
+
+
+ Ptr<LteTft> tft1_1 = Create<LteTft> ();
+
+ LteTft::PacketFilter pf1_1_1;
+ pf1_1_1.remoteAddress.Set ("1.0.0.0");
+ pf1_1_1.localAddress.Set ("2.0.0.0");
+ pf1_1_1.remoteMask.Set (0xFF000000);
+ pf1_1_1.localMask.Set (0xFF000000);
+ tft1_1->Add (pf1_1_1);
+
+ LteTft::PacketFilter pf1_1_2;
+ pf1_1_2.remoteAddress.Set ("3.3.3.0");
+ pf1_1_2.localAddress.Set ("4.4.4.0");
+ pf1_1_2.remoteMask.Set (0xFFFFFF00);
+ pf1_1_2.localMask.Set (0xFFFFFF00);
+ tft1_1->Add (pf1_1_2);
+
+ c1->Add (tft1_1);
+
+
+
+ Ptr<LteTft> tft1_2 = Create<LteTft> ();
+
+ LteTft::PacketFilter pf1_2_1;
+ pf1_2_1.remotePortStart = 1024;
+ pf1_2_1.remotePortEnd = 1035;
+ tft1_2->Add (pf1_2_1);
+
+ LteTft::PacketFilter pf1_2_2;
+ pf1_2_2.localPortStart = 3456;
+ pf1_2_2.localPortEnd = 3489;
+ tft1_2->Add (pf1_2_2);
+
+ c1->Add (tft1_2);
+
+
+
+ // ------------------------------------classifier---direction--------------src address---------------dst address---src port--dst port--ToS--TFT id
+
+ // test IP addresses
+ AddTestCase (new EpsTftClassifierTestCase (c1, LteTft::UPLINK, Ipv4Address ("2.2.3.4"), Ipv4Address ("1.1.1.1"), 4, 1234, 0, 1));
+ AddTestCase (new EpsTftClassifierTestCase (c1, LteTft::UPLINK, Ipv4Address ("2.2.3.4"), Ipv4Address ("1.0.0.0"), 2, 123, 5, 1));
+ AddTestCase (new EpsTftClassifierTestCase (c1, LteTft::UPLINK, Ipv4Address ("6.2.3.4"), Ipv4Address ("1.1.1.1"), 4, 1234, 0, 0));
+ AddTestCase (new EpsTftClassifierTestCase (c1, LteTft::DOWNLINK, Ipv4Address ("3.3.3.4"), Ipv4Address ("4.4.4.1"), 4, 1234, 0, 1));
+ AddTestCase (new EpsTftClassifierTestCase (c1, LteTft::DOWNLINK, Ipv4Address ("3.3.4.4"), Ipv4Address ("4.4.4.1"), 4, 1234, 0, 0));
+ AddTestCase (new EpsTftClassifierTestCase (c1, LteTft::UPLINK, Ipv4Address ("3.3.3.4"), Ipv4Address ("4.4.2.1"), 4, 1234, 0, 0));
+
+ // test remote port
+ AddTestCase (new EpsTftClassifierTestCase (c1, LteTft::UPLINK, Ipv4Address ("9.1.1.1"), Ipv4Address ("8.1.1.1"), 4, 1024, 0, 2));
+ AddTestCase (new EpsTftClassifierTestCase (c1, LteTft::UPLINK, Ipv4Address ("9.1.1.1"), Ipv4Address ("8.1.1.1"), 4, 1025, 0, 2));
+ AddTestCase (new EpsTftClassifierTestCase (c1, LteTft::UPLINK, Ipv4Address ("9.1.1.1"), Ipv4Address ("8.1.1.1"), 4, 1035, 0, 2));
+ AddTestCase (new EpsTftClassifierTestCase (c1, LteTft::UPLINK, Ipv4Address ("9.1.1.1"), Ipv4Address ("8.1.1.1"), 4, 1234, 0, 0));
+ AddTestCase (new EpsTftClassifierTestCase (c1, LteTft::DOWNLINK, Ipv4Address ("9.1.1.1"), Ipv4Address ("8.1.1.1"), 4, 1024, 0, 0));
+ AddTestCase (new EpsTftClassifierTestCase (c1, LteTft::DOWNLINK, Ipv4Address ("9.1.1.1"), Ipv4Address ("8.1.1.1"), 4, 1025, 0, 0));
+ AddTestCase (new EpsTftClassifierTestCase (c1, LteTft::DOWNLINK, Ipv4Address ("9.1.1.1"), Ipv4Address ("8.1.1.1"), 4, 1035, 0, 0));
+
+ // test local port
+ AddTestCase (new EpsTftClassifierTestCase (c1, LteTft::UPLINK, Ipv4Address ("9.1.1.1"), Ipv4Address ("8.1.1.1"), 4, 3456, 0, 0));
+ AddTestCase (new EpsTftClassifierTestCase (c1, LteTft::UPLINK, Ipv4Address ("9.1.1.1"), Ipv4Address ("8.1.1.1"), 4, 3457, 0, 0));
+ AddTestCase (new EpsTftClassifierTestCase (c1, LteTft::UPLINK, Ipv4Address ("9.1.1.1"), Ipv4Address ("8.1.1.1"), 4, 3489, 0, 0));
+ AddTestCase (new EpsTftClassifierTestCase (c1, LteTft::UPLINK, Ipv4Address ("9.1.1.1"), Ipv4Address ("8.1.1.1"), 3456, 6, 0, 2));
+ AddTestCase (new EpsTftClassifierTestCase (c1, LteTft::DOWNLINK, Ipv4Address ("9.1.1.1"), Ipv4Address ("8.1.1.1"), 3461, 3461, 0, 2));
+ AddTestCase (new EpsTftClassifierTestCase (c1, LteTft::DOWNLINK, Ipv4Address ("9.1.1.1"), Ipv4Address ("8.1.1.1"), 9, 3489, 0, 2));
+}
+
+
+} // namespace ns3
--- a/src/lte/wscript Tue Aug 02 15:59:36 2011 +0200
+++ b/src/lte/wscript Tue Aug 02 18:22:23 2011 +0200
@@ -50,6 +50,8 @@
'model/epc-gtpu-header.cc',
'model/epc-gtpu-l5-protocol.cc',
'model/epc-gtpu-tunnel-endpoint.cc',
+ 'model/lte-tft.cc',
+ 'model/eps-tft-classifier.cc',
]
module_test = bld.create_ns3_module_test_library('lte')
@@ -65,6 +67,7 @@
'test/lte-test-earfcn.cc',
'test/lte-test-spectrum-value-helper.cc',
'test/epc-test-gtpu.cc',
+ 'test/test-eps-tft-classifier.cc',
]
headers = bld.new_task_gen('ns3header')
@@ -127,6 +130,8 @@
'test/lte-test-pf-ff-mac-scheduler.h',
'test/lte-test-pf-ff-mac-scheduler.h',
'test/epc-test-gtpu.h',
+ 'model/lte-tft.h',
+ 'model/eps-tft-classifier.h',
]
if (bld.env['ENABLE_EXAMPLES']):