A Discrete-Event Network Simulator
API
test-epc-tft-classifier.cc
Go to the documentation of this file.
1 /* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * Copyright (c) 2011-2018 Centre Tecnologic de Telecomunicacions de Catalunya (CTTC)
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License version 2 as
7  * published by the Free Software Foundation;
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17  *
18  * Authors: Nicola Baldo <nbaldo@cttc.es>
19  * Manuel Requena <manuel.requena@cttc.es>
20  */
21 
22 #include "ns3/test.h"
23 #include "ns3/log.h"
24 #include "ns3/packet.h"
25 #include "ns3/ipv4-header.h"
26 #include "ns3/ipv6-header.h"
27 #include "ns3/udp-header.h"
28 #include "ns3/tcp-header.h"
29 #include "ns3/ipv4-l3-protocol.h"
30 #include "ns3/ipv6-l3-protocol.h"
31 #include "ns3/udp-l4-protocol.h"
32 #include "ns3/tcp-l4-protocol.h"
33 
34 #include "ns3/epc-tft-classifier.h"
35 
36 #include <iomanip>
37 
38 using namespace ns3;
39 
40 NS_LOG_COMPONENT_DEFINE ("TestEpcTftClassifier");
41 
52 {
53 public:
69  std::string sa,
70  std::string da,
71  uint16_t sp,
72  uint16_t dp,
73  uint8_t tos,
74  uint32_t tftId,
75  bool useIpv6);
76 
77  virtual ~EpcTftClassifierTestCase ();
78 
79 private:
80 
83  uint8_t m_tftId;
84  bool m_useIpv6;
89 
103  static std::string BuildNameString (Ptr<EpcTftClassifier> c,
105  std::string sa,
106  std::string da,
107  uint16_t sp,
108  uint16_t dp,
109  uint8_t tos,
110  uint32_t tftId,
111  bool useIpv6);
112 
113  virtual void DoRun (void);
114 };
115 
116 
119  std::string sa,
120  std::string da,
121  uint16_t sp,
122  uint16_t dp,
123  uint8_t tos,
124  uint32_t tftId,
125  bool useIpv6)
126  : TestCase (BuildNameString (c, d, sa, da, sp, dp, tos, tftId, useIpv6)),
127  m_c (c),
128  m_d (d),
129  m_tftId (tftId),
130  m_useIpv6 (useIpv6)
131 {
132  NS_LOG_FUNCTION (this << c << d << sa << da << sp << dp << tos << tftId << useIpv6);
133 
134  if (m_useIpv6)
135  {
136  m_ipv6Header.SetSourceAddress (Ipv6Address::MakeIpv4MappedAddress (Ipv4Address (sa.c_str ())));
137  m_ipv6Header.SetDestinationAddress (Ipv6Address::MakeIpv4MappedAddress (Ipv4Address (da.c_str ())));
139  m_ipv6Header.SetPayloadLength (8); // Full UDP header
140  m_ipv6Header.SetNextHeader (UdpL4Protocol::PROT_NUMBER);
141  }
142  else
143  {
144  m_ipHeader.SetSource (Ipv4Address (sa.c_str ()));
145  m_ipHeader.SetDestination (Ipv4Address (da.c_str ()));
146  m_ipHeader.SetTos (tos);
147  m_ipHeader.SetPayloadSize (8); // Full UDP header
148  m_ipHeader.SetProtocol (UdpL4Protocol::PROT_NUMBER);
149  }
150 
153 }
154 
156 {
157 }
158 
159 std::string
162  std::string sa,
163  std::string da,
164  uint16_t sp,
165  uint16_t dp,
166  uint8_t tos,
167  uint32_t tftId,
168  bool useIpv6)
169 {
170  std::ostringstream oss;
171  oss << c
172  << " d = " << d;
173  if (useIpv6)
174  {
175  oss << ", sa = " << Ipv6Address::MakeIpv4MappedAddress (Ipv4Address (sa.c_str ()))
176  << ", da = " << Ipv6Address::MakeIpv4MappedAddress (Ipv4Address (da.c_str ()));
177  }
178  else
179  {
180  oss << ", sa = " << sa
181  << ", da = " << da;
182  }
183  oss << ", sp = " << sp
184  << ", dp = " << dp
185  << ", tos = 0x" << std::hex << (int) tos
186  << " --> tftId = " << tftId;
187  return oss.str ();
188 }
189 
190 
191 void
193 {
195 
196  Ptr<Packet> udpPacket = Create<Packet> ();
197  udpPacket->AddHeader (m_udpHeader);
198  if (m_useIpv6)
199  {
200  udpPacket->AddHeader (m_ipv6Header);
201  }
202  else
203  {
204  udpPacket->AddHeader (m_ipHeader);
205  }
206  NS_LOG_LOGIC (this << *udpPacket);
207  uint32_t obtainedTftId = m_c->Classify (udpPacket, m_d,
208  m_useIpv6 ? Ipv6L3Protocol::PROT_NUMBER : Ipv4L3Protocol::PROT_NUMBER);
209  NS_TEST_ASSERT_MSG_EQ (obtainedTftId, (uint16_t) m_tftId, "bad classification of UDP packet");
210 }
211 
212 
213 
214 
222 {
223 public:
225 };
226 
228 
230  : TestSuite ("eps-tft-classifier", UNIT)
231 {
232  NS_LOG_FUNCTION (this);
233 
234 
236  // Same testcases using IPv4 and IPv6 addresses
237  // IPv6 addresses are IPv4 mapped addresses, i.e. 1.2.3.4 -> 0::ffff:1.2.3.4
238  // Currently, we use the format '0::ffff:0102:0304' because
239  // the format '0::ffff:1.2.3.4' is not supported by the Ipv6Address class
241 
242  for (bool useIpv6: {false, true})
243  {
245  // check some TFT matches
247 
248  Ptr<EpcTftClassifier> c1 = Create<EpcTftClassifier> ();
249 
250  Ptr<EpcTft> tft1_1 = Create<EpcTft> ();
251 
252  EpcTft::PacketFilter pf1_1_1;
253  if (useIpv6)
254  {
255  pf1_1_1.remoteIpv6Address.Set ("0::ffff:0100:0000");
256  pf1_1_1.remoteIpv6Prefix = Ipv6Prefix (96 + 8);
257  pf1_1_1.localIpv6Address.Set ("0::ffff:0200:0000");
258  pf1_1_1.localIpv6Prefix = Ipv6Prefix (96 + 8);
259  }
260  else
261  {
262  pf1_1_1.remoteAddress.Set ("1.0.0.0");
263  pf1_1_1.remoteMask.Set (0xff000000);
264  pf1_1_1.localAddress.Set ("2.0.0.0");
265  pf1_1_1.localMask.Set (0xff000000);
266  }
267  tft1_1->Add (pf1_1_1);
268 
269  EpcTft::PacketFilter pf1_1_2;
270  if (useIpv6)
271  {
272  pf1_1_2.remoteIpv6Address.Set ("0::ffff:0303:0300");
273  pf1_1_2.remoteIpv6Prefix = Ipv6Prefix (96 + 24);
274  pf1_1_2.localIpv6Address.Set ("0::ffff:0404:0400");
275  pf1_1_2.localIpv6Prefix = Ipv6Prefix (96 + 24);
276  }
277  else
278  {
279  pf1_1_2.remoteAddress.Set ("3.3.3.0");
280  pf1_1_2.remoteMask.Set (0xffffff00);
281  pf1_1_2.localAddress.Set ("4.4.4.0");
282  pf1_1_2.localMask.Set (0xffffff00);
283  }
284  tft1_1->Add (pf1_1_2);
285 
286  c1->Add (tft1_1, 1);
287 
288  Ptr<EpcTft> tft1_2 = Create<EpcTft> ();
289 
290  EpcTft::PacketFilter pf1_2_1;
291  pf1_2_1.remotePortStart = 1024;
292  pf1_2_1.remotePortEnd = 1035;
293  tft1_2->Add (pf1_2_1);
294 
295  EpcTft::PacketFilter pf1_2_2;
296  pf1_2_2.localPortStart = 3456;
297  pf1_2_2.localPortEnd = 3489;
298  tft1_2->Add (pf1_2_2);
299 
300  EpcTft::PacketFilter pf1_2_3;
301  pf1_2_3.localPortStart = 7895;
302  pf1_2_3.localPortEnd = 7895;
303  tft1_2->Add (pf1_2_3);
304 
305  EpcTft::PacketFilter pf1_2_4;
306  pf1_2_4.remotePortStart = 5897;
307  pf1_2_4.remotePortEnd = 5897;
308  tft1_2->Add (pf1_2_4);
309 
310  c1->Add (tft1_2, 2);
311 
312  // --------------------------------classifier----direction-------src_addr---dst_addr--src_port--dst_port--ToS--TFT_id
313 
314  // test IP addresses
315  AddTestCase (new EpcTftClassifierTestCase (c1, EpcTft::UPLINK, "2.2.3.4", "1.1.1.1", 4, 1234, 0, 1, useIpv6), TestCase::QUICK);
316  AddTestCase (new EpcTftClassifierTestCase (c1, EpcTft::UPLINK, "2.2.3.4", "1.0.0.0", 2, 123, 5, 1, useIpv6), TestCase::QUICK);
317  AddTestCase (new EpcTftClassifierTestCase (c1, EpcTft::UPLINK, "6.2.3.4", "1.1.1.1", 4, 1234, 0, 0, useIpv6), TestCase::QUICK);
318  AddTestCase (new EpcTftClassifierTestCase (c1, EpcTft::DOWNLINK, "3.3.3.4", "4.4.4.1", 4, 1234, 0, 1, useIpv6), TestCase::QUICK);
319  AddTestCase (new EpcTftClassifierTestCase (c1, EpcTft::DOWNLINK, "3.3.4.4", "4.4.4.1", 4, 1234, 0, 0, useIpv6), TestCase::QUICK);
320  AddTestCase (new EpcTftClassifierTestCase (c1, EpcTft::UPLINK, "3.3.3.4", "4.4.2.1", 4, 1234, 0, 0, useIpv6), TestCase::QUICK);
321 
322  // test remote port
323  AddTestCase (new EpcTftClassifierTestCase (c1, EpcTft::UPLINK, "9.1.1.1", "8.1.1.1", 4, 1024, 0, 2, useIpv6), TestCase::QUICK);
324  AddTestCase (new EpcTftClassifierTestCase (c1, EpcTft::UPLINK, "9.1.1.1", "8.1.1.1", 4, 1025, 0, 2, useIpv6), TestCase::QUICK);
325  AddTestCase (new EpcTftClassifierTestCase (c1, EpcTft::UPLINK, "9.1.1.1", "8.1.1.1", 4, 1035, 0, 2, useIpv6), TestCase::QUICK);
326  AddTestCase (new EpcTftClassifierTestCase (c1, EpcTft::UPLINK, "9.1.1.1", "8.1.1.1", 4, 1234, 0, 0, useIpv6), TestCase::QUICK);
327  AddTestCase (new EpcTftClassifierTestCase (c1, EpcTft::DOWNLINK, "9.1.1.1", "8.1.1.1", 4, 1024, 0, 0, useIpv6), TestCase::QUICK);
328  AddTestCase (new EpcTftClassifierTestCase (c1, EpcTft::DOWNLINK, "9.1.1.1", "8.1.1.1", 4, 1025, 0, 0, useIpv6), TestCase::QUICK);
329  AddTestCase (new EpcTftClassifierTestCase (c1, EpcTft::DOWNLINK, "9.1.1.1", "8.1.1.1", 4, 1035, 0, 0, useIpv6), TestCase::QUICK);
330 
331  // test local port
332  AddTestCase (new EpcTftClassifierTestCase (c1, EpcTft::UPLINK, "9.1.1.1", "8.1.1.1", 4, 3456, 0, 0, useIpv6), TestCase::QUICK);
333  AddTestCase (new EpcTftClassifierTestCase (c1, EpcTft::UPLINK, "9.1.1.1", "8.1.1.1", 4, 3457, 0, 0, useIpv6), TestCase::QUICK);
334  AddTestCase (new EpcTftClassifierTestCase (c1, EpcTft::UPLINK, "9.1.1.1", "8.1.1.1", 4, 3489, 0, 0, useIpv6), TestCase::QUICK);
335  AddTestCase (new EpcTftClassifierTestCase (c1, EpcTft::UPLINK, "9.1.1.1", "8.1.1.1", 3456, 6, 0, 2, useIpv6), TestCase::QUICK);
336  AddTestCase (new EpcTftClassifierTestCase (c1, EpcTft::DOWNLINK, "9.1.1.1", "8.1.1.1", 3461, 3461, 0, 2, useIpv6), TestCase::QUICK);
337  AddTestCase (new EpcTftClassifierTestCase (c1, EpcTft::DOWNLINK, "9.1.1.1", "8.1.1.1", 9, 3489, 0, 2, useIpv6), TestCase::QUICK);
338  AddTestCase (new EpcTftClassifierTestCase (c1, EpcTft::DOWNLINK, "9.1.1.1", "8.1.1.1", 9, 7895, 0, 2, useIpv6), TestCase::QUICK);
339  AddTestCase (new EpcTftClassifierTestCase (c1, EpcTft::UPLINK, "9.1.1.1", "8.1.1.1", 7895, 10, 0, 2, useIpv6), TestCase::QUICK);
340  AddTestCase (new EpcTftClassifierTestCase (c1, EpcTft::UPLINK, "9.1.1.1", "8.1.1.1", 9, 5897, 0, 2, useIpv6), TestCase::QUICK);
341  AddTestCase (new EpcTftClassifierTestCase (c1, EpcTft::DOWNLINK, "9.1.1.1", "8.1.1.1", 5897, 10, 0, 2, useIpv6), TestCase::QUICK);
342 
343 
345  // check default TFT
347 
348  Ptr<EpcTftClassifier> c2 = Create<EpcTftClassifier> ();
349  c2->Add (EpcTft::Default (), 1);
350 
351  // --------------------------------classifier---direction--------src_addr---dst_addr--src_port--dst_port--ToS--TFT id
352 
353  // test IP addresses
354  AddTestCase (new EpcTftClassifierTestCase (c2, EpcTft::UPLINK, "2.2.3.4", "1.1.1.1", 4, 1234, 0, 1, useIpv6), TestCase::QUICK);
355  AddTestCase (new EpcTftClassifierTestCase (c2, EpcTft::UPLINK, "2.2.3.4", "1.0.0.0", 2, 123, 5, 1, useIpv6), TestCase::QUICK);
356  AddTestCase (new EpcTftClassifierTestCase (c2, EpcTft::UPLINK, "6.2.3.4", "1.1.1.1", 4, 1234, 0, 1, useIpv6), TestCase::QUICK);
357  AddTestCase (new EpcTftClassifierTestCase (c2, EpcTft::DOWNLINK, "3.3.3.4", "4.4.4.1", 4, 1234, 0, 1, useIpv6), TestCase::QUICK);
358  AddTestCase (new EpcTftClassifierTestCase (c2, EpcTft::DOWNLINK, "3.3.4.4", "4.4.4.1", 4, 1234, 0, 1, useIpv6), TestCase::QUICK);
359  AddTestCase (new EpcTftClassifierTestCase (c2, EpcTft::UPLINK, "3.3.3.4", "4.4.2.1", 4, 1234, 0, 1, useIpv6), TestCase::QUICK);
360 
361  // test remote port
362  AddTestCase (new EpcTftClassifierTestCase (c2, EpcTft::UPLINK, "9.1.1.1", "8.1.1.1", 4, 1024, 0, 1, useIpv6), TestCase::QUICK);
363  AddTestCase (new EpcTftClassifierTestCase (c2, EpcTft::UPLINK, "9.1.1.1", "8.1.1.1", 4, 1025, 0, 1, useIpv6), TestCase::QUICK);
364  AddTestCase (new EpcTftClassifierTestCase (c2, EpcTft::UPLINK, "9.1.1.1", "8.1.1.1", 4, 1035, 0, 1, useIpv6), TestCase::QUICK);
365  AddTestCase (new EpcTftClassifierTestCase (c2, EpcTft::UPLINK, "9.1.1.1", "8.1.1.1", 4, 1234, 0, 1, useIpv6), TestCase::QUICK);
366  AddTestCase (new EpcTftClassifierTestCase (c2, EpcTft::DOWNLINK, "9.1.1.1", "8.1.1.1", 4, 1024, 0, 1, useIpv6), TestCase::QUICK);
367  AddTestCase (new EpcTftClassifierTestCase (c2, EpcTft::DOWNLINK, "9.1.1.1", "8.1.1.1", 4, 1025, 0, 1, useIpv6), TestCase::QUICK);
368  AddTestCase (new EpcTftClassifierTestCase (c2, EpcTft::DOWNLINK, "9.1.1.1", "8.1.1.1", 4, 1035, 0, 1, useIpv6), TestCase::QUICK);
369 
370  // test local port
371  AddTestCase (new EpcTftClassifierTestCase (c2, EpcTft::UPLINK, "9.1.1.1", "8.1.1.1", 4, 3456, 0, 1, useIpv6), TestCase::QUICK);
372  AddTestCase (new EpcTftClassifierTestCase (c2, EpcTft::UPLINK, "9.1.1.1", "8.1.1.1", 4, 3457, 0, 1, useIpv6), TestCase::QUICK);
373  AddTestCase (new EpcTftClassifierTestCase (c2, EpcTft::UPLINK, "9.1.1.1", "8.1.1.1", 4, 3489, 0, 1, useIpv6), TestCase::QUICK);
374  AddTestCase (new EpcTftClassifierTestCase (c2, EpcTft::UPLINK, "9.1.1.1", "8.1.1.1", 3456, 6, 0, 1, useIpv6), TestCase::QUICK);
375  AddTestCase (new EpcTftClassifierTestCase (c2, EpcTft::DOWNLINK, "9.1.1.1", "8.1.1.1", 3461, 3461, 0, 1, useIpv6), TestCase::QUICK);
376  AddTestCase (new EpcTftClassifierTestCase (c2, EpcTft::DOWNLINK, "9.1.1.1", "8.1.1.1", 9, 3489, 0, 1, useIpv6), TestCase::QUICK);
377 
378 
380  // check default TFT plus dedicated ones
382 
383  Ptr<EpcTftClassifier> c3 = Create<EpcTftClassifier> ();
384  c3->Add (EpcTft::Default (), 1);
385  c3->Add (tft1_1, 2);
386  c3->Add (tft1_2, 3);
387 
388  // --------------------------------classifier---direction--------src_addr---dst_addr---src_port--dst_port--ToS--TFT_id
389 
390  // test IP addresses
391  AddTestCase (new EpcTftClassifierTestCase (c3, EpcTft::UPLINK, "2.2.3.4", "1.1.1.1", 4, 1234, 0, 2, useIpv6), TestCase::QUICK);
392  AddTestCase (new EpcTftClassifierTestCase (c3, EpcTft::UPLINK, "2.2.3.4", "1.0.0.0", 2, 123, 5, 2, useIpv6), TestCase::QUICK);
393  AddTestCase (new EpcTftClassifierTestCase (c3, EpcTft::UPLINK, "6.2.3.4", "1.1.1.1", 4, 1234, 0, 1, useIpv6), TestCase::QUICK);
394  AddTestCase (new EpcTftClassifierTestCase (c3, EpcTft::DOWNLINK, "3.3.3.4", "4.4.4.1", 4, 1234, 0, 2, useIpv6), TestCase::QUICK);
395  AddTestCase (new EpcTftClassifierTestCase (c3, EpcTft::DOWNLINK, "3.3.4.4", "4.4.4.1", 4, 1234, 0, 1, useIpv6), TestCase::QUICK);
396  AddTestCase (new EpcTftClassifierTestCase (c3, EpcTft::UPLINK, "3.3.3.4", "4.4.2.1", 4, 1234, 0, 1, useIpv6), TestCase::QUICK);
397 
398  // test remote port
399  AddTestCase (new EpcTftClassifierTestCase (c3, EpcTft::UPLINK, "9.1.1.1", "8.1.1.1", 4, 1024, 0, 3, useIpv6), TestCase::QUICK);
400  AddTestCase (new EpcTftClassifierTestCase (c3, EpcTft::UPLINK, "9.1.1.1", "8.1.1.1", 4, 1025, 0, 3, useIpv6), TestCase::QUICK);
401  AddTestCase (new EpcTftClassifierTestCase (c3, EpcTft::UPLINK, "9.1.1.1", "8.1.1.1", 4, 1035, 0, 3, useIpv6), TestCase::QUICK);
402  AddTestCase (new EpcTftClassifierTestCase (c3, EpcTft::UPLINK, "9.1.1.1", "8.1.1.1", 4, 1234, 0, 1, useIpv6), TestCase::QUICK);
403  AddTestCase (new EpcTftClassifierTestCase (c3, EpcTft::DOWNLINK, "9.1.1.1", "8.1.1.1", 4, 1024, 0, 1, useIpv6), TestCase::QUICK);
404  AddTestCase (new EpcTftClassifierTestCase (c3, EpcTft::DOWNLINK, "9.1.1.1", "8.1.1.1", 4, 1025, 0, 1, useIpv6), TestCase::QUICK);
405  AddTestCase (new EpcTftClassifierTestCase (c3, EpcTft::DOWNLINK, "9.1.1.1", "8.1.1.1", 4, 1035, 0, 1, useIpv6), TestCase::QUICK);
406 
407  // test local port
408  AddTestCase (new EpcTftClassifierTestCase (c3, EpcTft::UPLINK, "9.1.1.1", "8.1.1.1", 4, 3456, 0, 1, useIpv6), TestCase::QUICK);
409  AddTestCase (new EpcTftClassifierTestCase (c3, EpcTft::UPLINK, "9.1.1.1", "8.1.1.1", 4, 3457, 0, 1, useIpv6), TestCase::QUICK);
410  AddTestCase (new EpcTftClassifierTestCase (c3, EpcTft::UPLINK, "9.1.1.1", "8.1.1.1", 4, 3489, 0, 1, useIpv6), TestCase::QUICK);
411  AddTestCase (new EpcTftClassifierTestCase (c3, EpcTft::UPLINK, "9.1.1.1", "8.1.1.1", 3456, 6, 0, 3, useIpv6), TestCase::QUICK);
412  AddTestCase (new EpcTftClassifierTestCase (c3, EpcTft::DOWNLINK, "9.1.1.1", "8.1.1.1", 3461, 3461, 0, 3, useIpv6), TestCase::QUICK);
413  AddTestCase (new EpcTftClassifierTestCase (c3, EpcTft::DOWNLINK, "9.1.1.1", "8.1.1.1", 9, 3489, 0, 3, useIpv6), TestCase::QUICK);
414 
415 
417  // check two TFTs with different ports
419 
420  Ptr<EpcTftClassifier> c4 = Create<EpcTftClassifier> ();
421  Ptr<EpcTft> tft4_1 = Create<EpcTft> ();
422  tft4_1->Add (pf1_2_3);
423  c4->Add (tft4_1, 1);
424  Ptr<EpcTft> tft4_2 = Create<EpcTft> ();
425  tft4_2->Add (pf1_2_4);
426  c4->Add (tft4_2, 2);
427  AddTestCase (new EpcTftClassifierTestCase (c4, EpcTft::DOWNLINK, "9.1.1.1", "8.1.1.1", 9, 3489, 0, 0, useIpv6), TestCase::QUICK);
428  AddTestCase (new EpcTftClassifierTestCase (c4, EpcTft::DOWNLINK, "9.1.1.1", "8.1.1.1", 9, 7895, 0, 1, useIpv6), TestCase::QUICK);
429  AddTestCase (new EpcTftClassifierTestCase (c4, EpcTft::UPLINK, "9.1.1.1", "8.1.1.1", 7895, 10, 0, 1, useIpv6), TestCase::QUICK);
430  AddTestCase (new EpcTftClassifierTestCase (c4, EpcTft::UPLINK, "9.1.1.1", "8.1.1.1", 9, 5897, 0, 2, useIpv6), TestCase::QUICK);
431  AddTestCase (new EpcTftClassifierTestCase (c4, EpcTft::DOWNLINK, "9.1.1.1", "8.1.1.1", 5897, 10, 0, 2, useIpv6), TestCase::QUICK);
432  }
433 }
void SetSource(Ipv4Address source)
Definition: ipv4-header.cc:285
static std::string BuildNameString(Ptr< EpcTftClassifier > c, EpcTft::Direction d, std::string sa, std::string da, uint16_t sp, uint16_t dp, uint8_t tos, uint32_t tftId, bool useIpv6)
Build name string.
void SetPayloadSize(uint16_t size)
Definition: ipv4-header.cc:56
Ipv6Prefix remoteIpv6Prefix
IPv6 address prefix of the remote host.
Definition: epc-tft.h:133
void SetPayloadLength(uint16_t len)
Set the "Payload length" field.
Definition: ipv6-header.cc:65
Direction
Indicates the direction of the traffic that is to be classified.
Definition: epc-tft.h:57
uint8_t Add(PacketFilter f)
add a PacketFilter to the Traffic Flow Template
Definition: epc-tft.cc:240
Ipv6Header m_ipv6Header
the IPv6 header
static EpcTftClassifierTestSuite g_lteTftClassifierTestSuite
Packet header for IPv6.
Definition: ipv6-header.h:34
void SetDestination(Ipv4Address destination)
Definition: ipv4-header.cc:298
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by "...
Test case to check the functionality of the Tft Classifier.
void Add(Ptr< EpcTft > tft, uint32_t id)
add a TFT to the Classifier
uint32_t Classify(Ptr< Packet > p, EpcTft::Direction direction, uint16_t protocolNumber)
classify an IP packet
A suite of tests to run.
Definition: test.h:1343
void SetDestinationPort(uint16_t port)
Definition: udp-header.cc:55
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition: log.h:205
uint16_t localPortEnd
end of the port number range of the UE
Definition: epc-tft.h:140
void SetSourcePort(uint16_t port)
Definition: udp-header.cc:60
void SetNextHeader(uint8_t next)
Set the "Next header" field.
Definition: ipv6-header.cc:75
Ptr< EpcTftClassifier > m_c
the EPC TFT classifier
void SetProtocol(uint8_t num)
Definition: ipv4-header.cc:278
bool m_useIpv6
use IPv4 or IPv6 header/addresses
encapsulates test code
Definition: test.h:1153
Epc Tft Classifier Test Suite.
Ipv6Address localIpv6Address
IPv6 address of the UE.
Definition: epc-tft.h:134
UdpHeader m_udpHeader
the UDP header
Packet header for IPv4.
Definition: ipv4-header.h:33
void AddTestCase(TestCase *testCase, TestDuration duration=QUICK)
Add an individual child TestCase to this test suite.
Definition: test.cc:299
#define NS_TEST_ASSERT_MSG_EQ(actual, limit, msg)
Test that an actual and expected (limit) value are equal and report and abort if not.
Definition: test.h:166
Ipv4Mask localMask
IPv4 address mask of the UE.
Definition: epc-tft.h:130
EpcTft::Direction m_d
the EPC TFT direction
#define NS_LOG_LOGIC(msg)
Use NS_LOG to output a message of level LOG_LOGIC.
Definition: log.h:289
EpcTftClassifierTestCase(Ptr< EpcTftClassifier > c, EpcTft::Direction d, std::string sa, std::string da, uint16_t sp, uint16_t dp, uint8_t tos, uint32_t tftId, bool useIpv6)
Constructor.
Ipv6Prefix localIpv6Prefix
IPv6 address prefix of the UE.
Definition: epc-tft.h:135
void Set(char const *address)
Sets an Ipv6Address by parsing the input C-string.
Ipv4Address remoteAddress
IPv4 address of the remote host.
Definition: epc-tft.h:127
uint16_t remotePortEnd
end of the port number range of the remote host
Definition: epc-tft.h:138
static void Enable(void)
Enable the packet metadata.
Ipv4Header m_ipHeader
the IPv4 header
Every class exported by the ns3 library is enclosed in the ns3 namespace.
Header for the Transmission Control Protocol.
Definition: tcp-header.h:44
Packet header for UDP packets.
Definition: udp-header.h:39
void SetTos(uint8_t tos)
Definition: ipv4-header.cc:82
Ipv4Address localAddress
IPv4 address of the UE.
Definition: epc-tft.h:129
void Set(uint32_t mask)
input mask is in host order.
Ipv6Address remoteIpv6Address
IPv6 address of the remote host.
Definition: epc-tft.h:132
void SetSourceAddress(Ipv6Address src)
Set the "Source address" field.
Definition: ipv6-header.cc:95
virtual void DoRun(void)
Implementation to actually run this TestCase.
void Set(uint32_t address)
input address is in host order.
Ipv4 addresses are stored in host order in this class.
Definition: ipv4-address.h:41
Ipv4Mask remoteMask
IPv4 address mask of the remote host.
Definition: epc-tft.h:128
Describes an IPv6 prefix.
Definition: ipv6-address.h:455
void SetTrafficClass(uint8_t traffic)
Set the "Traffic class" field.
Definition: ipv6-header.cc:45
void SetDestinationAddress(Ipv6Address dst)
Set the "Destination address" field.
Definition: ipv6-header.cc:105
TcpHeader m_tcpHeader
the TCP header
void AddHeader(const Header &header)
Add header to this packet.
Definition: packet.cc:256
uint16_t remotePortStart
start of the port number range of the remote host
Definition: epc-tft.h:137
Implement the data structure representing a TrafficFlowTemplate Packet Filter.
Definition: epc-tft.h:74
uint16_t localPortStart
start of the port number range of the UE
Definition: epc-tft.h:139