A Discrete-Event Network Simulator
API
epc-test-gtpu.cc
Go to the documentation of this file.
1 /* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * Copyright (c) 2011 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  * Author: Jaume Nin <jaume.nin@cttc.cat>
19  */
20 
21 
22 #include "ns3/log.h"
23 #include "ns3/object.h"
24 #include "ns3/packet.h"
25 #include "ns3/epc-gtpu-header.h"
26 
27 #include "epc-test-gtpu.h"
28 
29 using namespace ns3;
30 
31 NS_LOG_COMPONENT_DEFINE ("EpcGtpuTest");
32 
38  : TestSuite ("epc-gtpu", SYSTEM)
39 {
40  AddTestCase (new EpsGtpuHeaderTestCase (), TestCase::QUICK);
41 }
42 
44 
45 
51  : TestCase ("Check header coding and decoding")
52 {
53  NS_LOG_INFO ("Creating EpsGtpuHeaderTestCase");
54 }
55 
57 {
58 }
59 
60 void
62 {
64 
65  LogComponentEnable ("EpcGtpuTest", logLevel);
66  GtpuHeader h1;
67  h1.SetExtensionHeaderFlag (true);
68  h1.SetLength (1234);
69  h1.SetMessageType (123);
70  h1.SetNPduNumber (123);
71  h1.SetNPduNumberFlag (true);
72  h1.SetNextExtensionType (123);
73  h1.SetProtocolType (true);
74  h1.SetSequenceNumber (1234);
75  h1.SetSequenceNumberFlag (true);
76  h1.SetTeid (1234567);
77  h1.SetVersion (123);
78 
79  Packet p;
80  GtpuHeader h2;
81  p.AddHeader (h1);
82  p.RemoveHeader (h2);
83 
84  NS_TEST_ASSERT_MSG_EQ (h1, h2, "Wrong value!");
85 }
86 
uint32_t RemoveHeader(Header &header)
Deserialize and remove the header from the internal buffer.
Definition: packet.cc:268
virtual ~EpsGtpuHeaderTestCase()
Test 1.Check header coding and decoding.
Definition: epc-test-gtpu.h:42
A suite of tests to run.
Definition: test.h:1333
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition: log.h:201
#define NS_LOG_INFO(msg)
Use NS_LOG to output a message of level LOG_INFO.
Definition: log.h:244
encapsulates test code
Definition: test.h:1147
void SetVersion(uint8_t m_version)
network packets
Definition: packet.h:227
virtual void DoRun(void)
Implementation to actually run this TestCase.
void LogComponentEnable(char const *name, enum LogLevel level)
Enable the logging output associated with that log component.
Definition: log.cc:351
void AddTestCase(TestCase *testCase, enum TestDuration duration)
Add an individual child TestCase to this test suite.
Definition: test.cc:298
void SetNPduNumber(uint8_t m_nPduNumber)
void SetExtensionHeaderFlag(bool m_extensionHeaderFlag)
#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:161
void SetProtocolType(bool m_protocolType)
void SetNPduNumberFlag(bool m_nPduNumberFlag)
EpsGtpuTestSuite()
TestSuite.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
void SetMessageType(uint8_t m_messageType)
void SetTeid(uint32_t m_teid)
Prefix all trace prints with simulation time.
Definition: log.h:115
Prefix all trace prints with function.
Definition: log.h:114
void SetSequenceNumberFlag(bool m_sequenceNumberFlag)
void SetSequenceNumber(uint16_t m_sequenceNumber)
LogLevel
Logging severity classes and levels.
Definition: log.h:90
EpsGtpuHeaderTestCase()
TestCase.
void SetLength(uint16_t m_length)
Print everything.
Definition: log.h:112
void SetNextExtensionType(uint8_t m_nextExtensionType)
static EpsGtpuTestSuite epsGtpuTestSuite
void AddHeader(const Header &header)
Add header to this packet.
Definition: packet.cc:257
Implementation of the GTPv1-U Release 10 as per 3Gpp TS 29.281 document.