--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/lte/model/lte-tft-classifier.cc Fri Jul 29 14:50:57 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 LteTftClassifier class)
+ * Giuseppe Piro <g.piro@poliba.it> (part of the code in LteTftClassifier::Classify ()
+ * which comes from RrcEntity::Classify of the GSoC 2010 LTE module)
+ *
+ */
+
+
+
+
+#include "lte-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 ("LteTftClassifier");
+
+namespace ns3 {
+
+LteTftClassifier::LteTftClassifier ()
+ : m_tftCount (0)
+{
+ NS_LOG_FUNCTION (this);
+}
+
+uint32_t
+LteTftClassifier::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
+LteTftClassifier::Delete (uint32_t id)
+{
+ NS_LOG_FUNCTION (this << id);
+ m_tftMap.erase (id);
+}
+
+
+uint32_t
+LteTftClassifier::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/lte-tft-classifier.h Fri Jul 29 14:50:57 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 LTE_TFT_CLASSIFIER_H
+#define LTE_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 LteTftClassifier : public SimpleRefCount<LteTftClassifier>
+{
+public:
+
+ LteTftClassifier ();
+
+ /**
+ * 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 Fri Jul 29 14:50:57 2011 +0200
@@ -0,0 +1,165 @@
+/* -*- 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::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 Fri Jul 29 14:50:57 2011 +0200
@@ -0,0 +1,153 @@
+/* -*- 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 {
+
+
+
+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
+ */
+ 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;
+
+};
+
+
+
+
+} // namespace ns3
+
+#endif /* LTE_TFT_H */
+
+
--- a/src/lte/model/tft-packet-filter.h Thu Jul 28 12:16:30 2011 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,59 +0,0 @@
-/* -*- 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 TFT_PACKET_FILTER_H
-#define TFT_PACKET_FILTER_H
-
-
-/**
- * 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
- */
-struct TftPacketFilter : public SimpleRefCount<TftPacketFilter>
-{
-
- Ipv4Address remoteAddress; /**< IPv4 address of the remote host */
- Ipv4Address remoteAddressMask; /**< IPv4 address mask of the remote host */
- Ipv4Address localAddress; /**< IPv4 address of the UE */
- Ipv4Address localAddressMask; /**< 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 */
-}
-
-
-
-
-#endif /* TFT_PACKET_FILTER_H */
-
-
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/lte/test/lte-test-tft-classifier.cc Fri Jul 29 14:50:57 2011 +0200
@@ -0,0 +1,171 @@
+/* -*- 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/lte-tft-classifier.h"
+
+#include <iomanip>
+
+NS_LOG_COMPONENT_DEFINE ("LteTestTftClassifier");
+
+namespace ns3 {
+
+class LteTftClassifierTestCase : public TestCase
+{
+public:
+ LteTftClassifierTestCase (Ptr<LteTftClassifier> c,
+ LteTft::Direction d,
+ Ipv4Address sa,
+ Ipv4Address da,
+ uint16_t sp,
+ uint16_t dp,
+ uint8_t tos,
+ uint32_t tftId);
+ virtual ~LteTftClassifierTestCase ();
+
+private:
+
+ Ptr<LteTftClassifier> m_c;
+ LteTft::Direction m_d;
+ uint8_t m_tftId;
+ Ipv4Header m_ipHeader;
+ UdpHeader m_udpHeader;
+ TcpHeader m_tcpHeader;
+
+ virtual void DoRun (void);
+};
+
+LteTftClassifierTestCase::LteTftClassifierTestCase (Ptr<LteTftClassifier> 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;
+ switch (d)
+ {
+ case LteTft::DOWNLINK:
+ oss << " DL, ";
+ break;
+ case LteTft::UPLINK:
+ oss << " UL, ";
+ break;
+ default:
+ oss << " BD, ";
+ break;
+ }
+ oss << ", 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);
+
+
+}
+
+LteTftClassifierTestCase::~LteTftClassifierTestCase ()
+{
+}
+
+void
+LteTftClassifierTestCase::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");
+}
+
+
+
+
+
+/**
+ * Test the calculation of carrier frequency based on EARFCN
+ */
+class LteTftClassifierTestSuite : public TestSuite
+{
+public:
+ LteTftClassifierTestSuite ();
+};
+
+static LteTftClassifierTestSuite g_lteTftClassifierTestSuite;
+
+LteTftClassifierTestSuite::LteTftClassifierTestSuite ()
+ : TestSuite ("lte-tft-classifier", UNIT)
+{
+ NS_LOG_FUNCTION (this);
+
+ Ptr<LteTftClassifier> c1 = Create<LteTftClassifier> ();
+
+ 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);
+
+ c1->Add (tft1_1);
+
+ AddTestCase (new LteTftClassifierTestCase (c1, LteTft::UPLINK, Ipv4Address ("2.2.3.4"), Ipv4Address ("1.12.0.132"), 4, 1234, 0, 1));
+ AddTestCase (new LteTftClassifierTestCase (c1, LteTft::UPLINK, Ipv4Address ("6.2.3.4"), Ipv4Address ("1.12.0.132"), 4, 1234, 0, 0));
+
+}
+
+
+} // namespace ns3
--- a/src/lte/wscript Thu Jul 28 12:16:30 2011 +0200
+++ b/src/lte/wscript Fri Jul 29 14:50:57 2011 +0200
@@ -2,7 +2,7 @@
def build(bld):
- module = bld.create_ns3_module('lte', ['core', 'network', 'spectrum', 'stats'])
+ module = bld.create_ns3_module('lte', ['core', 'network', 'point-to-point', 'virtual-net-device', 'spectrum', 'stats'])
module.source = [
'model/lte-common.cc',
'model/lte-spectrum-phy.cc',
@@ -47,9 +47,12 @@
'model/lte-interference.cc',
'model/lte-sinr-chunk-processor.cc',
'model/pf-ff-mac-scheduler.cc',
- 'model/epc-gtpu-header.cc',
- 'model/epc-gtpu-l5-protocol.cc',
- 'model/epc-gtpu-tunnel.cc',
+# 'model/epc-gtpu-header.cc',
+# 'model/epc-gtpu-l5-protocol.cc',
+# 'model/epc-gtpu-tunnel.cc',
+# 'model/epc-gtpu-l5-protocol.cc',
+ 'model/lte-tft.cc',
+ 'model/lte-tft-classifier.cc',
]
module_test = bld.create_ns3_module_test_library('lte')
@@ -64,7 +67,8 @@
'test/lte-test-pf-ff-mac-scheduler.cc',
'test/lte-test-earfcn.cc',
'test/lte-test-spectrum-value-helper.cc',
- 'test/epc-test-gtpu.cc',
+# 'test/epc-test-gtpu.cc',
+ 'test/lte-test-tft-classifier.cc',
]
headers = bld.new_task_gen('ns3header')
@@ -127,6 +131,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/lte-tft-classifier.h',
]
if (bld.env['ENABLE_EXAMPLES']):