A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
epc-test-gtpu.cc
Go to the documentation of this file.
1/*
2 * Copyright (c) 2011 Centre Tecnologic de Telecomunicacions de Catalunya (CTTC)
3 *
4 * SPDX-License-Identifier: GPL-2.0-only
5 *
6 * Author: Jaume Nin <jaume.nin@cttc.cat>
7 */
8
9#include "epc-test-gtpu.h"
10
11#include "ns3/epc-gtpu-header.h"
12#include "ns3/log.h"
13#include "ns3/object.h"
14#include "ns3/packet.h"
15
16using namespace ns3;
17
18NS_LOG_COMPONENT_DEFINE("EpcGtpuTest");
19
20/**
21 * TestSuite
22 */
23
25 : TestSuite("epc-gtpu", Type::SYSTEM)
26{
27 AddTestCase(new EpsGtpuHeaderTestCase(), TestCase::Duration::QUICK);
28}
29
31
32/**
33 * TestCase
34 */
35
37 : TestCase("Check header coding and decoding")
38{
39 NS_LOG_INFO("Creating EpsGtpuHeaderTestCase");
40}
41
45
46void
48{
50
51 LogComponentEnable("EpcGtpuTest", logLevel);
52 GtpuHeader h1;
54 h1.SetLength(1234);
55 h1.SetMessageType(123);
56 h1.SetNPduNumber(123);
57 h1.SetNPduNumberFlag(true);
59 h1.SetProtocolType(true);
60 h1.SetSequenceNumber(1234);
61 h1.SetSequenceNumberFlag(true);
62 h1.SetTeid(1234567);
63 h1.SetVersion(123);
64
65 Packet p;
66 GtpuHeader h2;
67 p.AddHeader(h1);
68 p.RemoveHeader(h2);
69
70 NS_TEST_ASSERT_MSG_EQ(h1, h2, "Wrong value!");
71}
Test 1.Check header coding and decoding.
void DoRun() override
Implementation to actually run this TestCase.
~EpsGtpuHeaderTestCase() override
EpsGtpuHeaderTestCase()
TestCase.
Test suite for testing GPRS tunnelling protocol header coding and decoding.
EpsGtpuTestSuite()
TestSuite.
Implementation of the GPRS Tunnelling Protocol header according to GTPv1-U Release 10 as per 3Gpp TS ...
void SetSequenceNumber(uint16_t sequenceNumber)
Set sequence number function.
void SetExtensionHeaderFlag(bool extensionHeaderFlag)
Set extension header flag function.
void SetTeid(uint32_t teid)
Set TEID function.
void SetVersion(uint8_t version)
Set version function.
void SetNPduNumber(uint8_t nPduNumber)
Set NPDU number function.
void SetNPduNumberFlag(bool nPduNumberFlag)
Sets the flag that indicates the presence of a meaningful value of the N-PDU Number field.
void SetMessageType(uint8_t messageType)
Set message type function.
void SetSequenceNumberFlag(bool sequenceNumberFlag)
Set sequence number flag function.
void SetProtocolType(bool protocolType)
Set protocol type function.
void SetNextExtensionType(uint8_t nextExtensionType)
Set next extension type function.
void SetLength(uint16_t length)
Set the length in octets of the payload.
network packets
Definition packet.h:228
uint32_t RemoveHeader(Header &header)
Deserialize and remove the header from the internal buffer.
Definition packet.cc:283
void AddHeader(const Header &header)
Add header to this packet.
Definition packet.cc:257
encapsulates test code
Definition test.h:1050
void AddTestCase(TestCase *testCase, Duration duration=Duration::QUICK)
Add an individual child TestCase to this test suite.
Definition test.cc:292
A suite of tests to run.
Definition test.h:1267
Type
Type of test.
Definition test.h:1274
static EpsGtpuTestSuite epsGtpuTestSuite
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition log.h:191
#define NS_LOG_INFO(msg)
Use NS_LOG to output a message of level LOG_INFO.
Definition log.h:264
#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:134
Every class exported by the ns3 library is enclosed in the ns3 namespace.
void LogComponentEnable(const std::string &name, LogLevel level)
Enable the logging output associated with that log component.
Definition log.cc:291
LogLevel
Logging severity classes and levels.
Definition log.h:83
@ LOG_LEVEL_ALL
Print everything.
Definition log.h:105
@ LOG_PREFIX_FUNC
Prefix all trace prints with function.
Definition log.h:107
@ LOG_PREFIX_TIME
Prefix all trace prints with simulation time.
Definition log.h:108