View | Details | Raw Unified | Return to bug 2312
Collapse All | Expand All

(-)a/src/lte/doc/source/lte-design.rst (-10 / +16 lines)
 Lines 120-126    Link Here 
120
120
121
The following design choices have been made for the EPC model:
121
The following design choices have been made for the EPC model:
122
122
123
 #. The only Packet Data Network (PDN) type supported is IPv4.
123
 #. The Packet Data Network (PDN) type supported is both IPv4 and IPv6.
124
 #. The SGW and PGW functional entities are implemented within a single
124
 #. The SGW and PGW functional entities are implemented within a single
125
    node, which is hence referred to as the SGW/PGW node.
125
    node, which is hence referred to as the SGW/PGW node.
126
 #. The scenarios with inter-SGW mobility are not of interests. Hence, a
126
 #. The scenarios with inter-SGW mobility are not of interests. Hence, a
 Lines 3098-3106    Link Here 
3098
IP networking. The first one is the end-to-end layer, which provides end-to-end 
3098
IP networking. The first one is the end-to-end layer, which provides end-to-end 
3099
connectivity to the users; this layers involves the UEs, the PGW and
3099
connectivity to the users; this layers involves the UEs, the PGW and
3100
the remote host (including eventual internet routers and hosts in
3100
the remote host (including eventual internet routers and hosts in
3101
between), but does not involve the eNB. By default, UEs are assigned a public IPv4 address in the 7.0.0.0/8
3101
between), but does not involve the eNB. In this version of LTE, the EPC
3102
network, and the PGW gets the address 7.0.0.1, which is used by all
3102
supports both IPv4 and IPv6 type users. The 3GPP unique 64 bit IPv6 prefix
3103
UEs as the gateway to reach the internet. 
3103
allocation process for each UE and PGW is followed here. Each EPC is assigned
3104
an unique 16 bit IPv4 and a 48 bit IPv6 network address from the pool of
3105
7.0.0.0/8 and 7777:f00d::/32 respectively. In the end-to-end IP connection
3106
between UE and PGW, all addresses are configured using these prefixes.
3107
The PGW's address is used by all UEs as the gateway to reach the internet. 
3104
3108
3105
The second layer of IP networking is the EPC local area network. This
3109
The second layer of IP networking is the EPC local area network. This
3106
involves all eNB nodes and the SGW/PGW node. This network is
3110
involves all eNB nodes and the SGW/PGW node. This network is
 Lines 3126-3142    Link Here 
3126
3130
3127
To begin with, we consider the case of the downlink, which is depicted
3131
To begin with, we consider the case of the downlink, which is depicted
3128
in Figure :ref:`fig-epc-data-flow-dl`.   
3132
in Figure :ref:`fig-epc-data-flow-dl`.   
3129
Downlink Ipv4 packets are generated from a generic remote host, and
3133
Downlink Ipv4/Ipv6 packets are generated from a generic remote host, and
3130
addressed to one of the UE device. Internet routing will take care of
3134
addressed to one of the UE device. Internet routing will take care of
3131
forwarding the packet to the generic NetDevice of the SGW/PGW node
3135
forwarding the packet to the generic NetDevice of the SGW/PGW node
3132
which is connected to the internet (this is the Gi interface according
3136
which is connected to the internet (this is the Gi interface according
3133
to 3GPP terminology). The SGW/PGW has a VirtualNetDevice which is
3137
to 3GPP terminology). The SGW/PGW has a VirtualNetDevice which is
3134
assigned the gateway IP address of the UE subnet; hence, static
3138
assigned the base IPv4 address of the EPC network; hence, static
3135
routing rules will cause the incoming packet from the internet to be
3139
routing rules will cause the incoming packet from the internet to be
3136
routed through this VirtualNetDevice. Such device starts the
3140
routed through this VirtualNetDevice. In case of IPv6 address as destination,
3137
GTP/UDP/IP tunneling procedure, by forwarding the packet to a
3141
a manual route towards the VirtualNetDevice is inserted in the routing table,
3138
dedicated application in the SGW/PGW  node which is called
3142
containg the 48 bit IPv6 prefix from which all the IPv6 addresses of the UEs
3139
EpcSgwPgwApplication. This application does the following operations:
3143
and PGW are configured. Such device starts the GTP/UDP/IP tunneling procedure,
3144
by forwarding the packet to a dedicated application in the SGW/PGW  node which
3145
is called EpcSgwPgwApplication. This application does the following operations:
3140
3146
3141
 #. it determines the eNB node to which the UE is attached, by looking
3147
 #. it determines the eNB node to which the UE is attached, by looking
3142
    at the IP destination address (which is the address of the UE);
3148
    at the IP destination address (which is the address of the UE);
(-)a/src/lte/doc/source/lte-user.rst (-13 / +8 lines)
 Lines 779-787    Link Here 
779
779
780
We now explain how to write a simulation program that allows to
780
We now explain how to write a simulation program that allows to
781
simulate the EPC in addition to the LTE radio access network. The use
781
simulate the EPC in addition to the LTE radio access network. The use
782
of EPC allows to use IPv4 networking with LTE devices. In other words,
782
of EPC allows to use IPv4 and IPv6 networking with LTE devices. In other words,
783
you will be able to use the regular ns-3 applications and sockets over
783
you will be able to use the regular ns-3 applications and sockets over
784
IPv4 over LTE, and also to connect an LTE network to any other IPv4
784
IPv4 and IPv6 over LTE, and also to connect an LTE network to any other IPv4 and IPv6
785
network you might have in your simulation.
785
network you might have in your simulation.
786
786
787
First of all, in addition to ``LteHelper`` that we already introduced
787
First of all, in addition to ``LteHelper`` that we already introduced
 Lines 820-828    Link Here 
820
create the PGW node and configure it so that it can properly handle
820
create the PGW node and configure it so that it can properly handle
821
traffic from/to the LTE radio access network.  Still,
821
traffic from/to the LTE radio access network.  Still,
822
you need to add some explicit code to connect the PGW to other
822
you need to add some explicit code to connect the PGW to other
823
IPv4 networks (e.g., the internet). Here is a very simple example about
823
IPv4/IPv6 networks (e.g., the internet, another EPC). Here is a very
824
how to connect a single remote host to the PGW via a point-to-point
824
simple example about how to connect a single remote host (IPv4 type)
825
link::
825
to the PGW via a point-to-point link::
826
826
827
  Ptr<Node> pgw = epcHelper->GetPgwNode ();
827
  Ptr<Node> pgw = epcHelper->GetPgwNode ();
828
828
 Lines 844-859    Link Here 
844
  Ipv4InterfaceContainer internetIpIfaces = ipv4h.Assign (internetDevices);
844
  Ipv4InterfaceContainer internetIpIfaces = ipv4h.Assign (internetDevices);
845
  // interface 0 is localhost, 1 is the p2p device
845
  // interface 0 is localhost, 1 is the p2p device
846
  Ipv4Address remoteHostAddr = internetIpIfaces.GetAddress (1);
846
  Ipv4Address remoteHostAddr = internetIpIfaces.GetAddress (1);
847
  
847
848
849
It's important to specify routes so that the remote host can reach LTE
850
UEs. One way of doing this is by exploiting the fact that the
851
``PointToPointEpcHelper`` will by default assign to LTE UEs an IP address in the
852
7.0.0.0 network. With this in mind, it suffices to do::
853
848
854
  Ipv4StaticRoutingHelper ipv4RoutingHelper;
849
  Ipv4StaticRoutingHelper ipv4RoutingHelper;
855
  Ptr<Ipv4StaticRouting> remoteHostStaticRouting = ipv4RoutingHelper.GetStaticRouting (remoteHost->GetObject<Ipv4> ());
850
  Ptr<Ipv4StaticRouting> remoteHostStaticRouting = ipv4RoutingHelper.GetStaticRouting (remoteHost->GetObject<Ipv4> ());
856
  remoteHostStaticRouting->AddNetworkRouteTo (Ipv4Address ("7.0.0.0"), Ipv4Mask ("255.0.0.0"), 1);
851
  remoteHostStaticRouting->AddNetworkRouteTo (epcHelper->GetEpcIpv4NetworkAddress (), Ipv4Mask ("255.255.0.0"), 1);
857
852
858
Now, you should go on and create LTE eNBs and UEs as explained in the
853
Now, you should go on and create LTE eNBs and UEs as explained in the
859
previous sections. You can of course configure other LTE aspects such
854
previous sections. You can of course configure other LTE aspects such
 Lines 1046-1052    Link Here 
1046
1041
1047
``LteHelper::InstallEnbDevice`` and ``LteHelper::InstallUeDevice`` functions
1042
``LteHelper::InstallEnbDevice`` and ``LteHelper::InstallUeDevice`` functions
1048
must have been called before attaching. In an EPC-enabled simulation, it is also
1043
must have been called before attaching. In an EPC-enabled simulation, it is also
1049
required to have IPv4 properly pre-installed in the UE.
1044
required to have IPv4/IPv6 properly pre-installed in the UE.
1050
1045
1051
This method is very simple, but requires you to know exactly which UE belongs to
1046
This method is very simple, but requires you to know exactly which UE belongs to
1052
to which eNodeB before the simulation begins. This can be difficult when the UE
1047
to which eNodeB before the simulation begins. This can be difficult when the UE
(-)a/src/lte/examples/lena-ipv6-addr-conf.cc (+198 lines)
Line 0    Link Here 
1
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2
/*
3
 * Copyright (c) 2017 Jadavpur University, India
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: Manoj Kumar Rana <manoj24.rana@gmail.com>
19
 */
20
21
#include "ns3/lte-helper.h"
22
#include "ns3/epc-helper.h"
23
#include "ns3/core-module.h"
24
#include "ns3/network-module.h"
25
#include "ns3/ipv4-global-routing-helper.h"
26
#include "ns3/ipv6-static-routing.h"
27
#include "ns3/internet-module.h"
28
#include "ns3/mobility-module.h"
29
#include "ns3/lte-module.h"
30
#include "ns3/applications-module.h"
31
#include "ns3/point-to-point-helper.h"
32
#include "ns3/config-store.h"
33
34
using namespace ns3;
35
36
/**
37
 * Sample simulation script for LTE+EPC. It instantiates several eNodeB,
38
 * attaches one UE per eNodeB starts a flow for each UE to  and from a remote host.
39
 * It configures IPv6 addresses for UEs by setting the 48 bit prefix attribute in epc helper
40
 */
41
42
NS_LOG_COMPONENT_DEFINE ("EpcFirstExampleForIpv6");
43
44
int
45
main (int argc, char *argv[])
46
{
47
  CommandLine cmd;
48
  cmd.Parse (argc, argv);
49
50
  //Set 32 bit prefix value
51
  Config::SetDefault ("ns3::PointToPointEpcHelper::BaseIpv6Prefix", Ipv6AddressValue (Ipv6Address ("8888:f00d:432a::")));
52
53
  Ptr<LteHelper> lteHelper = CreateObject<LteHelper> ();
54
  Ptr<PointToPointEpcHelper>  epcHelper = CreateObject<PointToPointEpcHelper> ();
55
  lteHelper->SetEpcHelper (epcHelper);
56
57
  Ptr<Node> pgw = epcHelper->GetPgwNode ();
58
59
  // Create a single RemoteHost
60
  NodeContainer remoteHostContainer;
61
  remoteHostContainer.Create (1);
62
  Ptr<Node> remoteHost = remoteHostContainer.Get (0);
63
  InternetStackHelper internet;
64
  internet.Install (remoteHostContainer);
65
66
  // Create the Internet
67
  PointToPointHelper p2ph;
68
  p2ph.SetDeviceAttribute ("DataRate", DataRateValue (DataRate ("100Gb/s")));
69
  p2ph.SetDeviceAttribute ("Mtu", UintegerValue (1500));
70
  p2ph.SetChannelAttribute ("Delay", TimeValue (Seconds (0.010)));
71
  NetDeviceContainer internetDevices = p2ph.Install (pgw, remoteHost);
72
73
  NodeContainer ueNodes;
74
  NodeContainer enbNodes;
75
  enbNodes.Create (2);
76
  ueNodes.Create (2);
77
78
  // Install Mobility Model
79
  Ptr<ListPositionAllocator> positionAlloc = CreateObject<ListPositionAllocator> ();
80
  for (uint16_t i = 0; i < 2; i++)
81
    {
82
      positionAlloc->Add (Vector (60.0 * i, 0, 0));
83
    }
84
  MobilityHelper mobility;
85
  mobility.SetMobilityModel ("ns3::ConstantPositionMobilityModel");
86
  mobility.SetPositionAllocator (positionAlloc);
87
  mobility.Install (enbNodes);
88
  mobility.Install (ueNodes);
89
90
  // Install the IP stack on the UEs
91
  internet.Install (ueNodes);
92
93
  // Install LTE Devices to the nodes
94
  NetDeviceContainer enbLteDevs = lteHelper->InstallEnbDevice (enbNodes);
95
  NetDeviceContainer ueLteDevs1 = lteHelper->InstallUeDevice (NodeContainer (ueNodes.Get (0)));
96
  NetDeviceContainer ueLteDevs2 = lteHelper->InstallUeDevice (NodeContainer (ueNodes.Get (1)));
97
98
  Ipv6InterfaceContainer ueIpIface;
99
100
  for (NetDeviceContainer::Iterator it = ueLteDevs1.Begin (); it != ueLteDevs1.End (); ++it)
101
    {
102
      (*it)->SetAddress (Mac48Address::Allocate ());
103
    }
104
105
  for (NetDeviceContainer::Iterator it = ueLteDevs2.Begin (); it != ueLteDevs2.End (); ++it)
106
    {
107
      (*it)->SetAddress (Mac48Address::Allocate ());
108
    }
109
110
111
  Ipv6AddressHelper ipv6h;
112
  ipv6h.SetBase (Ipv6Address ("6001:db80::"), Ipv6Prefix (64));
113
  Ipv6InterfaceContainer internetIpIfaces = ipv6h.Assign (internetDevices);
114
115
  internetIpIfaces.SetForwarding (0, true);
116
  internetIpIfaces.SetDefaultRouteInAllNodes (0);
117
118
119
  // Assign IP address to the first UE
120
  ueIpIface = epcHelper->AssignUeIpv6Address (NetDeviceContainer (ueLteDevs1));
121
122
123
  Ipv6StaticRoutingHelper ipv6RoutingHelper;
124
  Ptr<Ipv6StaticRouting> remoteHostStaticRouting = ipv6RoutingHelper.GetStaticRouting (remoteHost->GetObject<Ipv6> ());
125
  remoteHostStaticRouting->AddNetworkRouteTo ("7777:f00d::", Ipv6Prefix (64), internetIpIfaces.GetAddress (0, 1), 1, 0);
126
127
128
  // Assign IP address to the second UE
129
  ueIpIface.Add (epcHelper->AssignUeIpv6Address (NetDeviceContainer (ueLteDevs2)));
130
131
132
133
  for (uint32_t u = 0; u < ueNodes.GetN (); ++u)
134
    {
135
      Ptr<Node> ueNode = ueNodes.Get (u);
136
      // Set the default gateway for the UEs
137
      Ptr<Ipv6StaticRouting> ueStaticRouting = ipv6RoutingHelper.GetStaticRouting (ueNode->GetObject<Ipv6> ());
138
      ueStaticRouting->SetDefaultRoute (epcHelper->GetUeDefaultGatewayAddress6 (), 1);
139
    }
140
141
  // Attach one UE per eNodeB
142
  lteHelper->Attach (ueLteDevs1.Get (0), enbLteDevs.Get (0));
143
  lteHelper->Attach (ueLteDevs2.Get (0), enbLteDevs.Get (1));
144
145
146
  // interface 0 is localhost, 1 is the p2p device
147
  Ipv6Address remoteHostAddr = internetIpIfaces.GetAddress (1, 1);
148
149
150
  // Install and start applications on UEs and remote host
151
152
  UdpEchoServerHelper echoServer (9);
153
154
  ApplicationContainer serverApps = echoServer.Install (remoteHost);
155
156
  serverApps.Start (Seconds (4.0));
157
  serverApps.Stop (Seconds (50.0));
158
159
160
  UdpEchoClientHelper echoClient1 (remoteHostAddr, 9);
161
  UdpEchoClientHelper echoClient2 (remoteHostAddr, 9);
162
163
  echoClient1.SetAttribute ("MaxPackets", UintegerValue (1000));
164
  echoClient1.SetAttribute ("Interval", TimeValue (Seconds (1.0)));
165
  echoClient1.SetAttribute ("PacketSize", UintegerValue (1024));
166
167
  echoClient2.SetAttribute ("MaxPackets", UintegerValue (1000));
168
  echoClient2.SetAttribute ("Interval", TimeValue (Seconds (1.0)));
169
  echoClient2.SetAttribute ("PacketSize", UintegerValue (1024));
170
171
  ApplicationContainer clientApps1 = echoClient1.Install (ueNodes.Get (0));
172
  ApplicationContainer clientApps2 = echoClient2.Install (ueNodes.Get (1));
173
174
175
  clientApps1.Start (Seconds (4.0));
176
  clientApps1.Stop (Seconds (50.0));
177
178
  clientApps2.Start (Seconds (4.5));
179
  clientApps2.Stop (Seconds (50.0));
180
181
182
  LogComponentEnable ("UdpEchoClientApplication", LOG_LEVEL_ALL);
183
  LogComponentEnable ("UdpEchoServerApplication", LOG_LEVEL_ALL);
184
185
  internet.EnablePcapIpv6 ("lena9", ueNodes.Get (0));
186
  internet.EnablePcapIpv6 ("lena10", ueNodes.Get (1));
187
  internet.EnablePcapIpv6 ("lena11", remoteHostContainer.Get (0));
188
  internet.EnablePcapIpv6 ("lena12", pgw);
189
190
191
  Simulator::Stop (Seconds (50));
192
  Simulator::Run ();
193
194
  Simulator::Destroy ();
195
  return 0;
196
197
}
198
(-)a/src/lte/examples/lena-ipv6-ue-rh.cc (+184 lines)
Line 0    Link Here 
1
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2
/*
3
 * Copyright (c) 2017 Jadavpur University, India
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: Manoj Kumar Rana <manoj24.rana@gmail.com>
19
 */
20
21
#include "ns3/lte-helper.h"
22
#include "ns3/epc-helper.h"
23
#include "ns3/core-module.h"
24
#include "ns3/network-module.h"
25
#include "ns3/ipv4-global-routing-helper.h"
26
#include "ns3/ipv6-static-routing.h"
27
#include "ns3/internet-module.h"
28
#include "ns3/mobility-module.h"
29
#include "ns3/lte-module.h"
30
#include "ns3/applications-module.h"
31
#include "ns3/point-to-point-helper.h"
32
#include "ns3/config-store.h"
33
34
using namespace ns3;
35
36
/**
37
 * Sample simulation script for LTE+EPC. It instantiates several eNodeB,
38
 * attaches one UE per eNodeB starts a flow for each UE to  and from a remote host.
39
 */
40
41
NS_LOG_COMPONENT_DEFINE ("EpcFirstExampleForIpv6");
42
43
int
44
main (int argc, char *argv[])
45
{
46
  CommandLine cmd;
47
  cmd.Parse (argc, argv);
48
49
  Ptr<LteHelper> lteHelper = CreateObject<LteHelper> ();
50
  Ptr<PointToPointEpcHelper>  epcHelper = CreateObject<PointToPointEpcHelper> ();
51
  lteHelper->SetEpcHelper (epcHelper);
52
53
  Ptr<Node> pgw = epcHelper->GetPgwNode ();
54
55
  // Create a single RemoteHost
56
  NodeContainer remoteHostContainer;
57
  remoteHostContainer.Create (1);
58
  Ptr<Node> remoteHost = remoteHostContainer.Get (0);
59
  InternetStackHelper internet;
60
  internet.Install (remoteHostContainer);
61
62
  // Create the Internet
63
  PointToPointHelper p2ph;
64
  p2ph.SetDeviceAttribute ("DataRate", DataRateValue (DataRate ("100Gb/s")));
65
  p2ph.SetDeviceAttribute ("Mtu", UintegerValue (1500));
66
  p2ph.SetChannelAttribute ("Delay", TimeValue (Seconds (0.010)));
67
  NetDeviceContainer internetDevices = p2ph.Install (pgw, remoteHost);
68
69
  NodeContainer ueNodes;
70
  NodeContainer enbNodes;
71
  enbNodes.Create (2);
72
  ueNodes.Create (2);
73
74
  // Install Mobility Model
75
  Ptr<ListPositionAllocator> positionAlloc = CreateObject<ListPositionAllocator> ();
76
  for (uint16_t i = 0; i < 2; i++)
77
    {
78
      positionAlloc->Add (Vector (60.0 * i, 0, 0));
79
    }
80
  MobilityHelper mobility;
81
  mobility.SetMobilityModel ("ns3::ConstantPositionMobilityModel");
82
  mobility.SetPositionAllocator (positionAlloc);
83
  mobility.Install (enbNodes);
84
  mobility.Install (ueNodes);
85
86
  // Install the IP stack on the UEs
87
  internet.Install (ueNodes);
88
89
  // Install LTE Devices to the nodes
90
  NetDeviceContainer enbLteDevs = lteHelper->InstallEnbDevice (enbNodes);
91
  NetDeviceContainer ueLteDevs = lteHelper->InstallUeDevice (ueNodes);
92
93
  Ipv6InterfaceContainer ueIpIface;
94
95
  for (NetDeviceContainer::Iterator it = ueLteDevs.Begin (); it != ueLteDevs.End (); ++it)
96
    {
97
      (*it)->SetAddress (Mac48Address::Allocate ());
98
    }
99
100
  // Assign IP address to UEs
101
  ueIpIface = epcHelper->AssignUeIpv6Address (NetDeviceContainer (ueLteDevs));
102
103
104
  Ipv6StaticRoutingHelper ipv6RoutingHelper;
105
106
  for (uint32_t u = 0; u < ueNodes.GetN (); ++u)
107
    {
108
      Ptr<Node> ueNode = ueNodes.Get (u);
109
      // Set the default gateway for the UEs
110
      Ptr<Ipv6StaticRouting> ueStaticRouting = ipv6RoutingHelper.GetStaticRouting (ueNode->GetObject<Ipv6> ());
111
      ueStaticRouting->SetDefaultRoute (epcHelper->GetUeDefaultGatewayAddress6 (), 1);
112
    }
113
114
115
  // Attach one UE per eNodeB
116
  for (uint16_t i = 0; i < 2; i++)
117
    {
118
      lteHelper->Attach (ueLteDevs.Get (i), enbLteDevs.Get (i));
119
      // side effect: the default EPS bearer will be activated
120
    }
121
122
  Ipv6AddressHelper ipv6h;
123
  ipv6h.SetBase (Ipv6Address ("6001:db80::"), Ipv6Prefix (64));
124
  Ipv6InterfaceContainer internetIpIfaces = ipv6h.Assign (internetDevices);
125
126
  internetIpIfaces.SetForwarding (0, true);
127
  internetIpIfaces.SetDefaultRouteInAllNodes (0);
128
129
  Ptr<Ipv6StaticRouting> remoteHostStaticRouting = ipv6RoutingHelper.GetStaticRouting (remoteHost->GetObject<Ipv6> ());
130
  remoteHostStaticRouting->AddNetworkRouteTo ("7777:f00d::", Ipv6Prefix (64), internetIpIfaces.GetAddress (0, 1), 1, 0);
131
132
133
  // interface 0 is localhost, 1 is the p2p device
134
  Ipv6Address remoteHostAddr = internetIpIfaces.GetAddress (1, 1);
135
136
137
  // Start applications on UEs and remote host
138
139
  UdpEchoServerHelper echoServer (9);
140
141
  ApplicationContainer serverApps = echoServer.Install (remoteHost);
142
143
144
  serverApps.Start (Seconds (1.0));
145
  serverApps.Stop (Seconds (50.0));
146
147
148
  UdpEchoClientHelper echoClient1 (remoteHostAddr, 9);
149
  UdpEchoClientHelper echoClient2 (remoteHostAddr, 9);
150
151
  echoClient1.SetAttribute ("MaxPackets", UintegerValue (1000));
152
  echoClient1.SetAttribute ("Interval", TimeValue (Seconds (1.0)));
153
  echoClient1.SetAttribute ("PacketSize", UintegerValue (1024));
154
155
  echoClient2.SetAttribute ("MaxPackets", UintegerValue (1000));
156
  echoClient2.SetAttribute ("Interval", TimeValue (Seconds (1.0)));
157
  echoClient2.SetAttribute ("PacketSize", UintegerValue (1024));
158
159
  ApplicationContainer clientApps1 = echoClient1.Install (ueNodes.Get (0));
160
  ApplicationContainer clientApps2 = echoClient2.Install (ueNodes.Get (1));
161
162
163
  clientApps1.Start (Seconds (1.0));
164
  clientApps1.Stop (Seconds (50.0));
165
166
  clientApps2.Start (Seconds (1.5));
167
  clientApps2.Stop (Seconds (50.0));
168
169
  LogComponentEnable ("UdpEchoClientApplication", LOG_LEVEL_ALL);
170
  LogComponentEnable ("UdpEchoServerApplication", LOG_LEVEL_ALL);
171
172
  internet.EnablePcapIpv6 ("lena1", ueNodes.Get (0));
173
  internet.EnablePcapIpv6 ("lena2", ueNodes.Get (1));
174
  internet.EnablePcapIpv6 ("lena3", remoteHostContainer.Get (0));
175
  internet.EnablePcapIpv6 ("lena4", pgw);
176
177
  Simulator::Stop (Seconds (50));
178
  Simulator::Run ();
179
180
  Simulator::Destroy ();
181
  return 0;
182
183
}
184
(-)a/src/lte/examples/lena-ipv6-ue-ue.cc (+180 lines)
Line 0    Link Here 
1
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2
/*
3
 * Copyright (c) 2017 Jadavpur University, India
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: Manoj Kumar Rana <manoj24.rana@gmail.com>
19
 */
20
21
#include "ns3/lte-helper.h"
22
#include "ns3/epc-helper.h"
23
#include "ns3/core-module.h"
24
#include "ns3/network-module.h"
25
#include "ns3/ipv4-global-routing-helper.h"
26
#include "ns3/ipv6-static-routing.h"
27
#include "ns3/internet-module.h"
28
#include "ns3/mobility-module.h"
29
#include "ns3/lte-module.h"
30
#include "ns3/applications-module.h"
31
#include "ns3/point-to-point-helper.h"
32
#include "ns3/config-store.h"
33
34
using namespace ns3;
35
36
/**
37
 * Sample simulation script for LTE+EPC. It instantiates several eNodeB,
38
 * attaches one UE per eNodeB starts a flow for remote host to  and from the first UE.
39
 * It also starts yet another flow between other UE pair.
40
 */
41
42
NS_LOG_COMPONENT_DEFINE ("EpcSecondExampleForIpv6");
43
44
int
45
main (int argc, char *argv[])
46
{
47
  CommandLine cmd;
48
  cmd.Parse (argc, argv);
49
50
  Ptr<LteHelper> lteHelper = CreateObject<LteHelper> ();
51
  Ptr<PointToPointEpcHelper>  epcHelper = CreateObject<PointToPointEpcHelper> ();
52
  lteHelper->SetEpcHelper (epcHelper);
53
54
  Ptr<Node> pgw = epcHelper->GetPgwNode ();
55
56
  // Create a single RemoteHost
57
  NodeContainer remoteHostContainer;
58
  remoteHostContainer.Create (1);
59
  Ptr<Node> remoteHost = remoteHostContainer.Get (0);
60
  InternetStackHelper internet;
61
  internet.Install (remoteHostContainer);
62
63
  // Create the Internet
64
  PointToPointHelper p2ph;
65
  p2ph.SetDeviceAttribute ("DataRate", DataRateValue (DataRate ("100Gb/s")));
66
  p2ph.SetDeviceAttribute ("Mtu", UintegerValue (1500));
67
  p2ph.SetChannelAttribute ("Delay", TimeValue (Seconds (0.010)));
68
  NetDeviceContainer internetDevices = p2ph.Install (pgw, remoteHost);
69
70
  NodeContainer ueNodes;
71
  NodeContainer enbNodes;
72
  enbNodes.Create (2);
73
  ueNodes.Create (2);
74
75
  // Install Mobility Model
76
  Ptr<ListPositionAllocator> positionAlloc = CreateObject<ListPositionAllocator> ();
77
  for (uint16_t i = 0; i < 2; i++)
78
    {
79
      positionAlloc->Add (Vector (60.0 * i, 0, 0));
80
    }
81
  MobilityHelper mobility;
82
  mobility.SetMobilityModel ("ns3::ConstantPositionMobilityModel");
83
  mobility.SetPositionAllocator (positionAlloc);
84
  mobility.Install (enbNodes);
85
  mobility.Install (ueNodes);
86
87
  // Install the IP stack on the UEs
88
  internet.Install (ueNodes);
89
90
  // Install LTE Devices to the nodes
91
  NetDeviceContainer enbLteDevs = lteHelper->InstallEnbDevice (enbNodes);
92
  NetDeviceContainer ueLteDevs = lteHelper->InstallUeDevice (ueNodes);
93
94
  Ipv6InterfaceContainer ueIpIface;
95
96
  for (NetDeviceContainer::Iterator it = ueLteDevs.Begin (); it != ueLteDevs.End (); ++it)
97
    {
98
      (*it)->SetAddress (Mac48Address::Allocate ());
99
    }
100
101
  // Assign IP address to UEs
102
  ueIpIface = epcHelper->AssignUeIpv6Address (NetDeviceContainer (ueLteDevs));
103
104
105
  Ipv6StaticRoutingHelper ipv6RoutingHelper;
106
107
  for (uint32_t u = 0; u < ueNodes.GetN (); ++u)
108
    {
109
      Ptr<Node> ueNode = ueNodes.Get (u);
110
      // Set the default gateway for the UE
111
      Ptr<Ipv6StaticRouting> ueStaticRouting = ipv6RoutingHelper.GetStaticRouting (ueNode->GetObject<Ipv6> ());
112
      ueStaticRouting->SetDefaultRoute (epcHelper->GetUeDefaultGatewayAddress6 (), 1);
113
    }
114
115
  // Attach one UE per eNodeB
116
  for (uint16_t i = 0; i < 2; i++)
117
    {
118
      lteHelper->Attach (ueLteDevs.Get (i), enbLteDevs.Get (i));
119
      // side effect: the default EPS bearer will be activated
120
    }
121
122
  Ipv6AddressHelper ipv6h;
123
  ipv6h.SetBase (Ipv6Address ("6001:db80::"), Ipv6Prefix (64));
124
  Ipv6InterfaceContainer internetIpIfaces = ipv6h.Assign (internetDevices);
125
126
  internetIpIfaces.SetForwarding (0, true);
127
  internetIpIfaces.SetDefaultRouteInAllNodes (0);
128
129
  Ptr<Ipv6StaticRouting> remoteHostStaticRouting = ipv6RoutingHelper.GetStaticRouting (remoteHost->GetObject<Ipv6> ());
130
  remoteHostStaticRouting->AddNetworkRouteTo ("7777:f00d::", Ipv6Prefix (64), internetIpIfaces.GetAddress (0, 1), 1, 0);
131
132
133
  // Start applications on UEs and remote host
134
135
  UdpEchoServerHelper echoServer (9);
136
137
  ApplicationContainer serverApps = echoServer.Install (ueNodes.Get (0));
138
139
140
  serverApps.Start (Seconds (1.0));
141
  serverApps.Stop (Seconds (50.0));
142
143
144
  UdpEchoClientHelper echoClient1 (ueIpIface.GetAddress (0,1), 9);
145
  UdpEchoClientHelper echoClient2 (ueIpIface.GetAddress (0,1), 9);
146
147
  echoClient1.SetAttribute ("MaxPackets", UintegerValue (1000));
148
  echoClient1.SetAttribute ("Interval", TimeValue (Seconds (1.0)));
149
  echoClient1.SetAttribute ("PacketSize", UintegerValue (1024));
150
151
  echoClient2.SetAttribute ("MaxPackets", UintegerValue (1000));
152
  echoClient2.SetAttribute ("Interval", TimeValue (Seconds (1.0)));
153
  echoClient2.SetAttribute ("PacketSize", UintegerValue (1024));
154
155
  ApplicationContainer clientApps1 = echoClient1.Install (remoteHost);
156
  ApplicationContainer clientApps2 = echoClient2.Install (ueNodes.Get (1));
157
158
159
  clientApps1.Start (Seconds (1.0));
160
  clientApps1.Stop (Seconds (50.0));
161
162
  clientApps2.Start (Seconds (1.5));
163
  clientApps2.Stop (Seconds (50.0));
164
165
  LogComponentEnable ("UdpEchoClientApplication", LOG_LEVEL_ALL);
166
  LogComponentEnable ("UdpEchoServerApplication", LOG_LEVEL_ALL);
167
168
  internet.EnablePcapIpv6 ("lena5", ueNodes.Get (0));
169
  internet.EnablePcapIpv6 ("lena6", ueNodes.Get (1));
170
  internet.EnablePcapIpv6 ("lena7", remoteHostContainer.Get (0));
171
  internet.EnablePcapIpv6 ("lena8", pgw);
172
173
  Simulator::Stop (Seconds (50));
174
  Simulator::Run ();
175
176
  Simulator::Destroy ();
177
  return 0;
178
179
}
180
(-)a/src/lte/examples/wscript (+9 lines)
 Lines 13-18    Link Here 
13
    obj = bld.create_ns3_program('lena-intercell-interference',
13
    obj = bld.create_ns3_program('lena-intercell-interference',
14
                                 ['lte'])
14
                                 ['lte'])
15
    obj.source = 'lena-intercell-interference.cc'
15
    obj.source = 'lena-intercell-interference.cc'
16
    obj = bld.create_ns3_program('lena-ipv6-addr-conf',
17
                                 ['lte'])
18
    obj.source = 'lena-ipv6-addr-conf.cc'
19
    obj = bld.create_ns3_program('lena-ipv6-ue-rh',
20
                                 ['lte'])
21
    obj.source = 'lena-ipv6-ue-rh.cc'
22
    obj = bld.create_ns3_program('lena-ipv6-ue-ue',
23
                                 ['lte'])
24
    obj.source = 'lena-ipv6-ue-ue.cc'
16
    obj = bld.create_ns3_program('lena-pathloss-traces',
25
    obj = bld.create_ns3_program('lena-pathloss-traces',
17
                                 ['lte'])
26
                                 ['lte'])
18
    obj.source = 'lena-pathloss-traces.cc'
27
    obj.source = 'lena-pathloss-traces.cc'
(-)a/src/lte/helper/emu-epc-helper.cc (-21 / +87 lines)
 Lines 26-38    Link Here 
26
#include <ns3/mac48-address.h>
26
#include <ns3/mac48-address.h>
27
#include <ns3/eps-bearer.h>
27
#include <ns3/eps-bearer.h>
28
#include <ns3/ipv4-address.h>
28
#include <ns3/ipv4-address.h>
29
#include <ns3/ipv6-address.h>
29
#include <ns3/internet-stack-helper.h>
30
#include <ns3/internet-stack-helper.h>
30
#include <ns3/packet-socket-helper.h>
31
#include <ns3/packet-socket-helper.h>
31
#include <ns3/packet-socket-address.h>
32
#include <ns3/packet-socket-address.h>
32
#include <ns3/epc-enb-application.h>
33
#include <ns3/epc-enb-application.h>
33
#include <ns3/epc-sgw-pgw-application.h>
34
#include <ns3/epc-sgw-pgw-application.h>
34
#include <ns3/emu-fd-net-device-helper.h>
35
#include <ns3/emu-fd-net-device-helper.h>
35
36
#include "ns3/ipv6-static-routing.h"
37
#include "ns3/ipv6-static-routing-helper.h"
36
#include <ns3/lte-enb-rrc.h>
38
#include <ns3/lte-enb-rrc.h>
37
#include <ns3/epc-x2.h>
39
#include <ns3/epc-x2.h>
38
#include <ns3/lte-enb-net-device.h>
40
#include <ns3/lte-enb-net-device.h>
 Lines 41-46    Link Here 
41
#include <ns3/epc-ue-nas.h>
43
#include <ns3/epc-ue-nas.h>
42
#include <ns3/string.h>
44
#include <ns3/string.h>
43
#include <ns3/abort.h>
45
#include <ns3/abort.h>
46
#include <ns3/ipv4-address-generator.h>
47
#include <ns3/ipv6-address-generator.h>
44
48
45
#include <iomanip>
49
#include <iomanip>
46
#include <iostream>
50
#include <iostream>
 Lines 56-62    Link Here 
56
  : m_gtpuUdpPort (2152)  // fixed by the standard
60
  : m_gtpuUdpPort (2152)  // fixed by the standard
57
{
61
{
58
  NS_LOG_FUNCTION (this);
62
  NS_LOG_FUNCTION (this);
59
63
  // To access the attribute value within the constructor
64
  ObjectBase::ConstructSelf (AttributeConstructionList ());
60
}
65
}
61
66
62
EmuEpcHelper::~EmuEpcHelper ()
67
EmuEpcHelper::~EmuEpcHelper ()
 Lines 95-124    Link Here 
95
  return tid;
100
  return tid;
96
}
101
}
97
102
103
TypeId
104
EmuEpcHelper::GetInstanceTypeId () const
105
{
106
  return GetTypeId ();
107
}
108
98
void
109
void
99
EmuEpcHelper::DoInitialize ()
110
EmuEpcHelper::DoInitialize ()
100
{
111
{
101
  NS_LOG_LOGIC (this);   
112
  NS_LOG_LOGIC (this);   
102
113
114
  // we use a /8 net for all UEs
115
  m_uePgwAddressHelper.SetBase ("7.0.0.0", "255.0.0.0");
103
116
104
  // we use a /8 net for all UEs
117
  // we use a /64 IPv6 net all UEs
105
  m_ueAddressHelper.SetBase ("7.0.0.0", "255.0.0.0");
118
  m_uePgwAddressHelper6.SetBase ("7777:f00d::", Ipv6Prefix (64));
106
119
107
  
120
108
 
109
  // create SgwPgwNode
121
  // create SgwPgwNode
110
  m_sgwPgw = CreateObject<Node> ();
122
  m_sgwPgw = CreateObject<Node> ();
111
  InternetStackHelper internet;
123
  InternetStackHelper internet;
112
  internet.SetIpv4StackInstall (true);
113
  internet.Install (m_sgwPgw);
124
  internet.Install (m_sgwPgw);
125
126
  // The Tun device resides in different 64 bit subnet.
127
  // We must create an unique route to tun device for all the packets destined
128
  // to all 64 bit IPv6 prefixes of UEs, based by the unique 48 bit network prefix of this EPC network
129
  Ipv6StaticRoutingHelper ipv6RoutingHelper;
130
  Ptr<Ipv6StaticRouting> pgwStaticRouting = ipv6RoutingHelper.GetStaticRouting (m_sgwPgw->GetObject<Ipv6> ());
131
  pgwStaticRouting->AddNetworkRouteTo ("7777:f00d::", Ipv6Prefix (64), Ipv6Address ("::"), 1, 0);
114
  
132
  
115
  // create S1-U socket
133
  // create S1-U socket
116
  Ptr<Socket> sgwPgwS1uSocket = Socket::CreateSocket (m_sgwPgw, TypeId::LookupByName ("ns3::UdpSocketFactory"));
134
  Ptr<Socket> sgwPgwS1uSocket = Socket::CreateSocket (m_sgwPgw, TypeId::LookupByName ("ns3::UdpSocketFactory"));
117
  int retval = sgwPgwS1uSocket->Bind (InetSocketAddress (Ipv4Address::GetAny (), m_gtpuUdpPort));
135
  int retval = sgwPgwS1uSocket->Bind (InetSocketAddress (Ipv4Address::GetAny (), m_gtpuUdpPort));
118
  NS_ASSERT (retval == 0);
136
  NS_ASSERT (retval == 0);
119
137
120
  // create TUN device implementing tunneling of user data over GTP-U/UDP/IP 
138
  // create TUN device containg IPv4 address and implementing tunneling of user data over GTP-U/UDP/IP 
121
  m_tunDevice = CreateObject<VirtualNetDevice> ();
139
  m_tunDevice = CreateObject<VirtualNetDevice> ();
140
122
  // allow jumbo packets
141
  // allow jumbo packets
123
  m_tunDevice->SetAttribute ("Mtu", UintegerValue (30000));
142
  m_tunDevice->SetAttribute ("Mtu", UintegerValue (30000));
124
143
 Lines 130-138    Link Here 
130
  tunDeviceContainer.Add (m_tunDevice);
149
  tunDeviceContainer.Add (m_tunDevice);
131
  
150
  
132
  // the TUN device is on the same subnet as the UEs, so when a packet
151
  // the TUN device is on the same subnet as the UEs, so when a packet
133
  // addressed to an UE arrives at the intenet to the WAN interface of
152
  // addressed to an UE IPv4 address arrives at the intenet to the WAN interface of
134
  // the PGW it will be forwarded to the TUN device. 
153
  // the PGW it will be forwarded to the TUN device. 
135
  Ipv4InterfaceContainer tunDeviceIpv4IfContainer = m_ueAddressHelper.Assign (tunDeviceContainer);  
154
  Ipv4InterfaceContainer tunDeviceIpv4IfContainer = AssignUeIpv4Address (tunDeviceContainer); 
155
156
  // the TUN device for IPv6 address is on the different subnet as the
157
  // UEs, it will forward the UE packets as we have inserted the route
158
  // for all UEs at the time of assigning UE addresses
159
  Ipv6InterfaceContainer tunDeviceIpv6IfContainer = AssignUeIpv6Address (tunDeviceContainer);
160
161
  //Set Forwarding
162
  tunDeviceIpv6IfContainer.SetForwarding (0,true);
163
  tunDeviceIpv6IfContainer.SetDefaultRouteInAllNodes (0);
164
136
165
137
  // create EpcSgwPgwApplication
166
  // create EpcSgwPgwApplication
138
  m_sgwPgwApp = CreateObject<EpcSgwPgwApplication> (m_tunDevice, sgwPgwS1uSocket);
167
  m_sgwPgwApp = CreateObject<EpcSgwPgwApplication> (m_tunDevice, sgwPgwS1uSocket);
 Lines 141-146    Link Here 
141
  // connect SgwPgwApplication and virtual net device for tunneling
170
  // connect SgwPgwApplication and virtual net device for tunneling
142
  m_tunDevice->SetSendCallback (MakeCallback (&EpcSgwPgwApplication::RecvFromTunDevice, m_sgwPgwApp));
171
  m_tunDevice->SetSendCallback (MakeCallback (&EpcSgwPgwApplication::RecvFromTunDevice, m_sgwPgwApp));
143
172
173
144
  // Create MME and connect with SGW via S11 interface
174
  // Create MME and connect with SGW via S11 interface
145
  m_mme = CreateObject<EpcMme> ();
175
  m_mme = CreateObject<EpcMme> ();
146
  m_mme->SetS11SapSgw (m_sgwPgwApp->GetS11SapSgw ());
176
  m_mme->SetS11SapSgw (m_sgwPgwApp->GetS11SapSgw ());
 Lines 184-190    Link Here 
184
214
185
  NS_ASSERT (enb == lteEnbNetDevice->GetNode ());  
215
  NS_ASSERT (enb == lteEnbNetDevice->GetNode ());  
186
216
187
  // add an IPv4 stack to the previously created eNB
217
  // add an Internet stack to the previously created eNB
188
  InternetStackHelper internet;
218
  InternetStackHelper internet;
189
  internet.Install (enb);
219
  internet.Install (enb);
190
  NS_LOG_LOGIC ("number of Ipv4 ifaces of the eNB after node creation: " << enb->GetObject<Ipv4> ()->GetNInterfaces ());
220
  NS_LOG_LOGIC ("number of Ipv4 ifaces of the eNB after node creation: " << enb->GetObject<Ipv4> ()->GetNInterfaces ());
 Lines 231-240    Link Here 
231
  enbLteSocketConnectAddress.SetProtocol (Ipv4L3Protocol::PROT_NUMBER);
261
  enbLteSocketConnectAddress.SetProtocol (Ipv4L3Protocol::PROT_NUMBER);
232
  retval = enbLteSocket->Connect (enbLteSocketConnectAddress);
262
  retval = enbLteSocket->Connect (enbLteSocketConnectAddress);
233
  NS_ASSERT (retval == 0);  
263
  NS_ASSERT (retval == 0);  
264
265
  // create LTE socket for the ENB 
266
  Ptr<Socket> enbLteSocket6 = Socket::CreateSocket (enb, TypeId::LookupByName ("ns3::PacketSocketFactory"));
267
  PacketSocketAddress enbLteSocketBindAddress6;
268
  enbLteSocketBindAddress6.SetSingleDevice (lteEnbNetDevice->GetIfIndex ());
269
  enbLteSocketBindAddress6.SetProtocol (Ipv6L3Protocol::PROT_NUMBER);
270
  retval = enbLteSocket6->Bind (enbLteSocketBindAddress6);
271
  NS_ASSERT (retval == 0);  
272
  PacketSocketAddress enbLteSocketConnectAddress6;
273
  enbLteSocketConnectAddress6.SetPhysicalAddress (Mac48Address::GetBroadcast ());
274
  enbLteSocketConnectAddress6.SetSingleDevice (lteEnbNetDevice->GetIfIndex ());
275
  enbLteSocketConnectAddress6.SetProtocol (Ipv6L3Protocol::PROT_NUMBER);
276
  retval = enbLteSocket6->Connect (enbLteSocketConnectAddress6);
277
  NS_ASSERT (retval == 0);
234
  
278
  
235
236
  NS_LOG_INFO ("create EpcEnbApplication");
279
  NS_LOG_INFO ("create EpcEnbApplication");
237
  Ptr<EpcEnbApplication> enbApp = CreateObject<EpcEnbApplication> (enbLteSocket, enbS1uSocket, enbAddress, sgwAddress, cellId);
280
  Ptr<EpcEnbApplication> enbApp = CreateObject<EpcEnbApplication> (enbLteSocket, enbS1uSocket, enbAddress, sgwAddress, cellId);
281
  enbApp->SetLTESocket6(enbLteSocket6);
238
  enb->AddApplication (enbApp);
282
  enb->AddApplication (enbApp);
239
  NS_ASSERT (enb->GetNApplications () == 1);
283
  NS_ASSERT (enb->GetNApplications () == 1);
240
  NS_ASSERT_MSG (enb->GetApplication (0)->GetObject<EpcEnbApplication> () != 0, "cannot retrieve EpcEnbApplication");
284
  NS_ASSERT_MSG (enb->GetApplication (0)->GetObject<EpcEnbApplication> () != 0, "cannot retrieve EpcEnbApplication");
 Lines 312-334    Link Here 
312
  
356
  
313
}
357
}
314
358
359
315
uint8_t
360
uint8_t
316
EmuEpcHelper::ActivateEpsBearer (Ptr<NetDevice> ueDevice, uint64_t imsi, Ptr<EpcTft> tft, EpsBearer bearer)
361
EmuEpcHelper::ActivateEpsBearer (Ptr<NetDevice> ueDevice, uint64_t imsi, Ptr<EpcTft> tft, EpsBearer bearer)
317
{
362
{
318
  NS_LOG_FUNCTION (this << ueDevice << imsi);
363
  NS_LOG_FUNCTION (this << ueDevice << imsi);
319
364
320
  // we now retrieve the IPv4 address of the UE and notify it to the SGW;
365
  // we now retrieve the IPv4/IPv6 address of the UE and notify it to the SGW;
321
  // we couldn't do it before since address assignment is triggered by
366
  // we couldn't do it before since address assignment is triggered by
322
  // the user simulation program, rather than done by the EPC   
367
  // the user simulation program, rather than done by the EPC   
323
  Ptr<Node> ueNode = ueDevice->GetNode (); 
368
  Ptr<Node> ueNode = ueDevice->GetNode (); 
324
  Ptr<Ipv4> ueIpv4 = ueNode->GetObject<Ipv4> ();
369
  Ptr<Ipv4> ueIpv4 = ueNode->GetObject<Ipv4> ();
325
  NS_ASSERT_MSG (ueIpv4 != 0, "UEs need to have IPv4 installed before EPS bearers can be activated");
370
  Ptr<Ipv6> ueIpv6 = ueNode->GetObject<Ipv6> ();
371
  //NS_ASSERT_MSG (ueIpv4 != 0 || ueIpv6 != 0, "UEs need to have IPv4/IPv6 installed before EPS bearers can be activated");
326
  int32_t interface =  ueIpv4->GetInterfaceForDevice (ueDevice);
372
  int32_t interface =  ueIpv4->GetInterfaceForDevice (ueDevice);
327
  NS_ASSERT (interface >= 0);
373
  int32_t interface6 =  ueIpv6->GetInterfaceForDevice (ueDevice);
328
  NS_ASSERT (ueIpv4->GetNAddresses (interface) == 1);
374
  //NS_ASSERT (interface >= 0 || interface6 >= 0);
329
  Ipv4Address ueAddr = ueIpv4->GetAddress (interface, 0).GetLocal ();
375
  //NS_ASSERT (ueIpv4->GetNAddresses (interface) == 1 || ueIpv6->GetNAddresses (interface6) == 1);
330
  NS_LOG_LOGIC (" UE IP address: " << ueAddr);  m_sgwPgwApp->SetUeAddress (imsi, ueAddr);
376
331
  
377
  if(interface >= 0 && ueIpv4->GetNAddresses (interface) == 1)
378
    {
379
      Ipv4Address ueAddr = ueIpv4->GetAddress (interface, 0).GetLocal ();
380
      NS_LOG_LOGIC (" UE IPv4 address: " << ueAddr); 
381
      m_sgwPgwApp->SetUeAddress (imsi, ueAddr);
382
    }
383
  else
384
    {
385
      Ipv6Address ueAddr6 = ueIpv6->GetAddress (interface6, 0).GetAddress ();
386
      NS_LOG_LOGIC (" UE IPv6 address: " << ueAddr6);  m_sgwPgwApp->SetUeAddress6 (imsi, ueAddr6);
387
    }
332
  uint8_t bearerId = m_mme->AddBearer (imsi, tft, bearer);
388
  uint8_t bearerId = m_mme->AddBearer (imsi, tft, bearer);
333
  Ptr<LteUeNetDevice> ueLteDevice = ueDevice->GetObject<LteUeNetDevice> ();
389
  Ptr<LteUeNetDevice> ueLteDevice = ueDevice->GetObject<LteUeNetDevice> ();
334
  if (ueLteDevice)
390
  if (ueLteDevice)
 Lines 349-358    Link Here 
349
Ipv4InterfaceContainer 
405
Ipv4InterfaceContainer 
350
EmuEpcHelper::AssignUeIpv4Address (NetDeviceContainer ueDevices)
406
EmuEpcHelper::AssignUeIpv4Address (NetDeviceContainer ueDevices)
351
{
407
{
352
  return m_ueAddressHelper.Assign (ueDevices);
408
  return m_uePgwAddressHelper.Assign (ueDevices);
353
}
409
}
354
410
355
411
Ipv6InterfaceContainer 
412
EmuEpcHelper::AssignUeIpv6Address (NetDeviceContainer ueDevices)
413
{
414
  return m_uePgwAddressHelper6.Assign (ueDevices);
415
}
356
416
357
Ipv4Address
417
Ipv4Address
358
EmuEpcHelper::GetUeDefaultGatewayAddress ()
418
EmuEpcHelper::GetUeDefaultGatewayAddress ()
 Lines 361-365    Link Here 
361
  return m_sgwPgw->GetObject<Ipv4> ()->GetAddress (1, 0).GetLocal ();
421
  return m_sgwPgw->GetObject<Ipv4> ()->GetAddress (1, 0).GetLocal ();
362
}
422
}
363
423
424
Ipv6Address
425
EmuEpcHelper::GetUeDefaultGatewayAddress6 ()
426
{
427
  // return the address of the tun device 6
428
  return m_sgwPgw->GetObject<Ipv6> ()->GetAddress (1, 1).GetAddress ();
429
}
364
430
365
} // namespace ns3
431
} // namespace ns3
(-)a/src/lte/helper/emu-epc-helper.h (-4 / +13 lines)
 Lines 25-30    Link Here 
25
25
26
#include <ns3/object.h>
26
#include <ns3/object.h>
27
#include <ns3/ipv4-address-helper.h>
27
#include <ns3/ipv4-address-helper.h>
28
#include <ns3/ipv6-address-helper.h>
28
#include <ns3/data-rate.h>
29
#include <ns3/data-rate.h>
29
#include <ns3/epc-tft.h>
30
#include <ns3/epc-tft.h>
30
#include <ns3/eps-bearer.h>
31
#include <ns3/eps-bearer.h>
 Lines 70-75    Link Here 
70
   *  \return The object TypeId.
71
   *  \return The object TypeId.
71
   */
72
   */
72
  static TypeId GetTypeId (void);
73
  static TypeId GetTypeId (void);
74
  TypeId GetInstanceTypeId () const;
73
  virtual void DoInitialize ();
75
  virtual void DoInitialize ();
74
  virtual void DoDispose ();
76
  virtual void DoDispose ();
75
77
 Lines 80-95    Link Here 
80
  virtual uint8_t ActivateEpsBearer (Ptr<NetDevice> ueLteDevice, uint64_t imsi, Ptr<EpcTft> tft, EpsBearer bearer);
82
  virtual uint8_t ActivateEpsBearer (Ptr<NetDevice> ueLteDevice, uint64_t imsi, Ptr<EpcTft> tft, EpsBearer bearer);
81
  virtual Ptr<Node> GetPgwNode ();
83
  virtual Ptr<Node> GetPgwNode ();
82
  virtual Ipv4InterfaceContainer AssignUeIpv4Address (NetDeviceContainer ueDevices);
84
  virtual Ipv4InterfaceContainer AssignUeIpv4Address (NetDeviceContainer ueDevices);
85
  Ipv6InterfaceContainer AssignUeIpv6Address (NetDeviceContainer ueDevices);
83
  virtual Ipv4Address GetUeDefaultGatewayAddress ();
86
  virtual Ipv4Address GetUeDefaultGatewayAddress ();
84
87
  Ipv6Address GetUeDefaultGatewayAddress6 ();
85
88
86
89
87
private:
90
private:
88
91
89
  /** 
92
  /** 
90
   * helper to assign addresses to UE devices as well as to the TUN device of the SGW/PGW
93
   * helper to assign IPv4 addresses to UE devices as well as to the TUN device of the SGW/PGW
91
   */
94
   */
92
  Ipv4AddressHelper m_ueAddressHelper; 
95
  Ipv4AddressHelper m_uePgwAddressHelper; 
96
97
  /** 
98
   * helper to assign IPv6 addresses to UE devices as well as to the TUN device of the SGW/PGW
99
   */
100
  Ipv6AddressHelper m_uePgwAddressHelper6; 
93
101
94
  /**
102
  /**
95
   * SGW-PGW network element
103
   * SGW-PGW network element
 Lines 102-108    Link Here 
102
  Ptr<EpcSgwPgwApplication> m_sgwPgwApp;
110
  Ptr<EpcSgwPgwApplication> m_sgwPgwApp;
103
111
104
  /**
112
  /**
105
   * TUN device implementing tunneling of user data over GTP-U/UDP/IP
113
   * TUN device containing IPv4 address and implementing tunneling of user data over GTP-U/UDP/IP
106
   */
114
   */
107
  Ptr<VirtualNetDevice> m_tunDevice;
115
  Ptr<VirtualNetDevice> m_tunDevice;
108
116
 Lines 151-156    Link Here 
151
   * First 5 bytes of the Enb MAC address base
159
   * First 5 bytes of the Enb MAC address base
152
   */
160
   */
153
  std::string m_enbMacAddressBase;
161
  std::string m_enbMacAddressBase;
162
  
154
};
163
};
155
164
156
165
(-)a/src/lte/helper/epc-helper.cc (+1 lines)
 Lines 24-29    Link Here 
24
#include <ns3/log.h>
24
#include <ns3/log.h>
25
#include <ns3/node.h>
25
#include <ns3/node.h>
26
#include <ns3/ipv4-address.h>
26
#include <ns3/ipv4-address.h>
27
#include <ns3/ipv6-address.h>
27
28
28
namespace ns3 {
29
namespace ns3 {
29
30
(-)a/src/lte/helper/epc-helper.h (-1 / +2 lines)
 Lines 25-30    Link Here 
25
25
26
#include <ns3/object.h>
26
#include <ns3/object.h>
27
#include <ns3/ipv4-address-helper.h>
27
#include <ns3/ipv4-address-helper.h>
28
#include <ns3/ipv6-address-helper.h>
28
#include <ns3/data-rate.h>
29
#include <ns3/data-rate.h>
29
#include <ns3/epc-tft.h>
30
#include <ns3/epc-tft.h>
30
#include <ns3/eps-bearer.h>
31
#include <ns3/eps-bearer.h>
 Lines 133-139    Link Here 
133
134
134
  /** 
135
  /** 
135
   * 
136
   * 
136
   * \return the address of the Default Gateway to be used by UEs to reach the internet
137
   * \return the IPv4 address of the Default Gateway to be used by UEs to reach the internet
137
   */
138
   */
138
  virtual Ipv4Address GetUeDefaultGatewayAddress () = 0;
139
  virtual Ipv4Address GetUeDefaultGatewayAddress () = 0;
139
140
(-)a/src/lte/helper/point-to-point-epc-helper.cc (-23 / +96 lines)
 Lines 26-44    Link Here 
26
#include <ns3/mac48-address.h>
26
#include <ns3/mac48-address.h>
27
#include <ns3/eps-bearer.h>
27
#include <ns3/eps-bearer.h>
28
#include <ns3/ipv4-address.h>
28
#include <ns3/ipv4-address.h>
29
#include <ns3/ipv4-address.h>
29
#include <ns3/internet-stack-helper.h>
30
#include <ns3/internet-stack-helper.h>
30
#include <ns3/point-to-point-helper.h>
31
#include <ns3/point-to-point-helper.h>
31
#include <ns3/packet-socket-helper.h>
32
#include <ns3/packet-socket-helper.h>
32
#include <ns3/packet-socket-address.h>
33
#include <ns3/packet-socket-address.h>
33
#include <ns3/epc-enb-application.h>
34
#include <ns3/epc-enb-application.h>
34
#include <ns3/epc-sgw-pgw-application.h>
35
#include <ns3/epc-sgw-pgw-application.h>
35
36
#include "ns3/ipv6-static-routing.h"
37
#include "ns3/ipv6-static-routing-helper.h"
36
#include <ns3/lte-enb-rrc.h>
38
#include <ns3/lte-enb-rrc.h>
37
#include <ns3/epc-x2.h>
39
#include <ns3/epc-x2.h>
38
#include <ns3/lte-enb-net-device.h>
40
#include <ns3/lte-enb-net-device.h>
39
#include <ns3/lte-ue-net-device.h>
41
#include <ns3/lte-ue-net-device.h>
40
#include <ns3/epc-mme.h>
42
#include <ns3/epc-mme.h>
41
#include <ns3/epc-ue-nas.h>
43
#include <ns3/epc-ue-nas.h>
44
#include <ns3/ipv4-address-generator.h>
45
#include <ns3/ipv6-address-generator.h>
42
46
43
namespace ns3 {
47
namespace ns3 {
44
48
 Lines 51-56    Link Here 
51
  : m_gtpuUdpPort (2152)  // fixed by the standard
55
  : m_gtpuUdpPort (2152)  // fixed by the standard
52
{
56
{
53
  NS_LOG_FUNCTION (this);
57
  NS_LOG_FUNCTION (this);
58
  // To access the attribute value within the constructor
59
  ObjectBase::ConstructSelf (AttributeConstructionList ());
54
60
55
  // since we use point-to-point links for all S1-U links, 
61
  // since we use point-to-point links for all S1-U links, 
56
  // we use a /30 subnet which can hold exactly two addresses 
62
  // we use a /30 subnet which can hold exactly two addresses 
 Lines 60-71    Link Here 
60
  m_x2Ipv4AddressHelper.SetBase ("12.0.0.0", "255.255.255.252");
66
  m_x2Ipv4AddressHelper.SetBase ("12.0.0.0", "255.255.255.252");
61
67
62
  // we use a /8 net for all UEs
68
  // we use a /8 net for all UEs
63
  m_ueAddressHelper.SetBase ("7.0.0.0", "255.0.0.0");
69
  m_uePgwAddressHelper.SetBase ("7.0.0.0", "255.0.0.0");
64
  
70
71
  // we use a /64 IPv6 net all UEs
72
  m_uePgwAddressHelper6.SetBase ("7777:f00d::", Ipv6Prefix (64));
73
65
  // create SgwPgwNode
74
  // create SgwPgwNode
66
  m_sgwPgw = CreateObject<Node> ();
75
  m_sgwPgw = CreateObject<Node> ();
67
  InternetStackHelper internet;
76
  InternetStackHelper internet;
68
  internet.Install (m_sgwPgw);
77
  internet.Install (m_sgwPgw);
78
79
  // The Tun device resides in different 64 bit subnet.
80
  // We must create an unique route to tun device for all the packets destined
81
  // to all 64 bit IPv6 prefixes of UEs, based by the unique 48 bit network prefix of this EPC network
82
  Ipv6StaticRoutingHelper ipv6RoutingHelper;
83
  Ptr<Ipv6StaticRouting> pgwStaticRouting = ipv6RoutingHelper.GetStaticRouting (m_sgwPgw->GetObject<Ipv6> ());
84
  pgwStaticRouting->AddNetworkRouteTo ("7777:f00d::", Ipv6Prefix (64), Ipv6Address ("::"), 1, 0);
69
  
85
  
70
  // create S1-U socket
86
  // create S1-U socket
71
  Ptr<Socket> sgwPgwS1uSocket = Socket::CreateSocket (m_sgwPgw, TypeId::LookupByName ("ns3::UdpSocketFactory"));
87
  Ptr<Socket> sgwPgwS1uSocket = Socket::CreateSocket (m_sgwPgw, TypeId::LookupByName ("ns3::UdpSocketFactory"));
 Lines 74-84    Link Here 
74
90
75
  // create TUN device implementing tunneling of user data over GTP-U/UDP/IP 
91
  // create TUN device implementing tunneling of user data over GTP-U/UDP/IP 
76
  m_tunDevice = CreateObject<VirtualNetDevice> ();
92
  m_tunDevice = CreateObject<VirtualNetDevice> ();
93
77
  // allow jumbo packets
94
  // allow jumbo packets
78
  m_tunDevice->SetAttribute ("Mtu", UintegerValue (30000));
95
  m_tunDevice->SetAttribute ("Mtu", UintegerValue (30000));
79
96
80
  // yes we need this
97
  // yes we need this
81
  m_tunDevice->SetAddress (Mac48Address::Allocate ()); 
98
  m_tunDevice->SetAddress (Mac48Address::Allocate ());
99
100
82
101
83
  m_sgwPgw->AddDevice (m_tunDevice);
102
  m_sgwPgw->AddDevice (m_tunDevice);
84
  NetDeviceContainer tunDeviceContainer;
103
  NetDeviceContainer tunDeviceContainer;
 Lines 87-93    Link Here 
87
  // the TUN device is on the same subnet as the UEs, so when a packet
106
  // the TUN device is on the same subnet as the UEs, so when a packet
88
  // addressed to an UE arrives at the intenet to the WAN interface of
107
  // addressed to an UE arrives at the intenet to the WAN interface of
89
  // the PGW it will be forwarded to the TUN device. 
108
  // the PGW it will be forwarded to the TUN device. 
90
  Ipv4InterfaceContainer tunDeviceIpv4IfContainer = m_ueAddressHelper.Assign (tunDeviceContainer);  
109
  Ipv4InterfaceContainer tunDeviceIpv4IfContainer = AssignUeIpv4Address (tunDeviceContainer);  
110
111
112
  // the TUN device for IPv6 address is on the different subnet as the
113
  // UEs, it will forward the UE packets as we have inserted the route
114
  // for all UEs at the time of assigning UE addresses
115
  Ipv6InterfaceContainer tunDeviceIpv6IfContainer = AssignUeIpv6Address (tunDeviceContainer);
116
117
118
  //Set Forwarding of the IPv6 interface
119
  tunDeviceIpv6IfContainer.SetForwarding (0,true);
120
  tunDeviceIpv6IfContainer.SetDefaultRouteInAllNodes (0);
91
121
92
  // create EpcSgwPgwApplication
122
  // create EpcSgwPgwApplication
93
  m_sgwPgwApp = CreateObject<EpcSgwPgwApplication> (m_tunDevice, sgwPgwS1uSocket);
123
  m_sgwPgwApp = CreateObject<EpcSgwPgwApplication> (m_tunDevice, sgwPgwS1uSocket);
 Lines 96-101    Link Here 
96
  // connect SgwPgwApplication and virtual net device for tunneling
126
  // connect SgwPgwApplication and virtual net device for tunneling
97
  m_tunDevice->SetSendCallback (MakeCallback (&EpcSgwPgwApplication::RecvFromTunDevice, m_sgwPgwApp));
127
  m_tunDevice->SetSendCallback (MakeCallback (&EpcSgwPgwApplication::RecvFromTunDevice, m_sgwPgwApp));
98
128
129
99
  // Create MME and connect with SGW via S11 interface
130
  // Create MME and connect with SGW via S11 interface
100
  m_mme = CreateObject<EpcMme> ();
131
  m_mme = CreateObject<EpcMme> ();
101
  m_mme->SetS11SapSgw (m_sgwPgwApp->GetS11SapSgw ());
132
  m_mme->SetS11SapSgw (m_sgwPgwApp->GetS11SapSgw ());
 Lines 144-153    Link Here 
144
                   UintegerValue (3000),
175
                   UintegerValue (3000),
145
                   MakeUintegerAccessor (&PointToPointEpcHelper::m_x2LinkMtu),
176
                   MakeUintegerAccessor (&PointToPointEpcHelper::m_x2LinkMtu),
146
                   MakeUintegerChecker<uint16_t> ())
177
                   MakeUintegerChecker<uint16_t> ())
178
//    .AddAttribute ("BaseIpv4Prefix",
179
//                   "The 8 bit IPv4 prefix to be used for the assignment of IPv4 addresses to pgw and ue.",
180
//                   Ipv4AddressValue (Ipv4Address ("7.0.0.0")),
181
//                   MakeIpv4AddressAccessor (&PointToPointEpcHelper::m_uePgwbaseipv4prefix8),
182
//                   MakeIpv4AddressChecker ())
183
//    .AddAttribute ("BaseIpv6Prefix",
184
//                   "The 32 bit IPv6 prefix to be used for the assignment of IPv6 addresses to pgw and ue.",
185
//                   Ipv6AddressValue (Ipv6Address ("7777:f00d::")),
186
//                   MakeIpv6AddressAccessor (&PointToPointEpcHelper::m_uePgwbaseipv6prefix32),
187
//                   MakeIpv6AddressChecker ())
147
  ;
188
  ;
148
  return tid;
189
  return tid;
149
}
190
}
150
191
192
TypeId
193
PointToPointEpcHelper::GetInstanceTypeId () const
194
{
195
  return GetTypeId ();
196
}
197
151
void
198
void
152
PointToPointEpcHelper::DoDispose ()
199
PointToPointEpcHelper::DoDispose ()
153
{
200
{
 Lines 195-206    Link Here 
195
  Ptr<Socket> enbS1uSocket = Socket::CreateSocket (enb, TypeId::LookupByName ("ns3::UdpSocketFactory"));
242
  Ptr<Socket> enbS1uSocket = Socket::CreateSocket (enb, TypeId::LookupByName ("ns3::UdpSocketFactory"));
196
  int retval = enbS1uSocket->Bind (InetSocketAddress (enbAddress, m_gtpuUdpPort));
243
  int retval = enbS1uSocket->Bind (InetSocketAddress (enbAddress, m_gtpuUdpPort));
197
  NS_ASSERT (retval == 0);
244
  NS_ASSERT (retval == 0);
198
  
199
245
200
  // give PacketSocket powers to the eNB
201
  //PacketSocketHelper packetSocket;
202
  //packetSocket.Install (enb); 
203
  
204
  // create LTE socket for the ENB 
246
  // create LTE socket for the ENB 
205
  Ptr<Socket> enbLteSocket = Socket::CreateSocket (enb, TypeId::LookupByName ("ns3::PacketSocketFactory"));
247
  Ptr<Socket> enbLteSocket = Socket::CreateSocket (enb, TypeId::LookupByName ("ns3::PacketSocketFactory"));
206
  PacketSocketAddress enbLteSocketBindAddress;
248
  PacketSocketAddress enbLteSocketBindAddress;
 Lines 214-223    Link Here 
214
  enbLteSocketConnectAddress.SetProtocol (Ipv4L3Protocol::PROT_NUMBER);
256
  enbLteSocketConnectAddress.SetProtocol (Ipv4L3Protocol::PROT_NUMBER);
215
  retval = enbLteSocket->Connect (enbLteSocketConnectAddress);
257
  retval = enbLteSocket->Connect (enbLteSocketConnectAddress);
216
  NS_ASSERT (retval == 0);  
258
  NS_ASSERT (retval == 0);  
217
  
259
260
  // create LTE socket for the ENB 
261
  Ptr<Socket> enbLteSocket6 = Socket::CreateSocket (enb, TypeId::LookupByName ("ns3::PacketSocketFactory"));
262
  PacketSocketAddress enbLteSocketBindAddress6;
263
  enbLteSocketBindAddress6.SetSingleDevice (lteEnbNetDevice->GetIfIndex ());
264
  enbLteSocketBindAddress6.SetProtocol (Ipv6L3Protocol::PROT_NUMBER);
265
  retval = enbLteSocket6->Bind (enbLteSocketBindAddress6);
266
  NS_ASSERT (retval == 0);  
267
  PacketSocketAddress enbLteSocketConnectAddress6;
268
  enbLteSocketConnectAddress6.SetPhysicalAddress (Mac48Address::GetBroadcast ());
269
  enbLteSocketConnectAddress6.SetSingleDevice (lteEnbNetDevice->GetIfIndex ());
270
  enbLteSocketConnectAddress6.SetProtocol (Ipv6L3Protocol::PROT_NUMBER);
271
  retval = enbLteSocket6->Connect (enbLteSocketConnectAddress6);
272
  NS_ASSERT (retval == 0);  
218
273
219
  NS_LOG_INFO ("create EpcEnbApplication");
274
  NS_LOG_INFO ("create EpcEnbApplication");
220
  Ptr<EpcEnbApplication> enbApp = CreateObject<EpcEnbApplication> (enbLteSocket, enbS1uSocket, enbAddress, sgwAddress, cellId);
275
  Ptr<EpcEnbApplication> enbApp = CreateObject<EpcEnbApplication> (enbLteSocket, enbS1uSocket, enbAddress, sgwAddress, cellId);
276
  enbApp->SetLTESocket6(enbLteSocket6);
221
  enb->AddApplication (enbApp);
277
  enb->AddApplication (enbApp);
222
  NS_ASSERT (enb->GetNApplications () == 1);
278
  NS_ASSERT (enb->GetNApplications () == 1);
223
  NS_ASSERT_MSG (enb->GetApplication (0)->GetObject<EpcEnbApplication> () != 0, "cannot retrieve EpcEnbApplication");
279
  NS_ASSERT_MSG (enb->GetApplication (0)->GetObject<EpcEnbApplication> () != 0, "cannot retrieve EpcEnbApplication");
 Lines 298-339    Link Here 
298
{
354
{
299
  NS_LOG_FUNCTION (this << ueDevice << imsi);
355
  NS_LOG_FUNCTION (this << ueDevice << imsi);
300
356
301
  // we now retrieve the IPv4 address of the UE and notify it to the SGW;
357
  // we now retrieve the IPv4/IPv6 address of the UE and notify it to the SGW;
302
  // we couldn't do it before since address assignment is triggered by
358
  // we couldn't do it before since address assignment is triggered by
303
  // the user simulation program, rather than done by the EPC   
359
  // the user simulation program, rather than done by the EPC   
304
  Ptr<Node> ueNode = ueDevice->GetNode (); 
360
  Ptr<Node> ueNode = ueDevice->GetNode (); 
305
  Ptr<Ipv4> ueIpv4 = ueNode->GetObject<Ipv4> ();
361
  Ptr<Ipv4> ueIpv4 = ueNode->GetObject<Ipv4> ();
306
  NS_ASSERT_MSG (ueIpv4 != 0, "UEs need to have IPv4 installed before EPS bearers can be activated");
362
  Ptr<Ipv6> ueIpv6 = ueNode->GetObject<Ipv6> ();
363
  //NS_ASSERT_MSG (ueIpv4 != 0 && ueIpv6 != 0, "UEs need to have IPv4/IPv6 installed before EPS bearers can be activated");
307
  int32_t interface =  ueIpv4->GetInterfaceForDevice (ueDevice);
364
  int32_t interface =  ueIpv4->GetInterfaceForDevice (ueDevice);
308
  NS_ASSERT (interface >= 0);
365
  int32_t interface6 =  ueIpv6->GetInterfaceForDevice (ueDevice);
309
  NS_ASSERT (ueIpv4->GetNAddresses (interface) == 1);
366
  //NS_ASSERT (interface >= 0 || interface6 >= 0);
310
  Ipv4Address ueAddr = ueIpv4->GetAddress (interface, 0).GetLocal ();
367
  //NS_ASSERT (ueIpv4->GetNAddresses (interface) == 1 || ueIpv6->GetNAddresses (interface6) == 1);
311
  NS_LOG_LOGIC (" UE IP address: " << ueAddr);  m_sgwPgwApp->SetUeAddress (imsi, ueAddr);
368
  if(interface >= 0 && ueIpv4->GetNAddresses (interface) == 1)
312
  
369
   {
370
    Ipv4Address ueAddr = ueIpv4->GetAddress (interface, 0).GetLocal ();
371
    NS_LOG_LOGIC (" UE IPv4 address: " << ueAddr);  m_sgwPgwApp->SetUeAddress (imsi, ueAddr);
372
   }
373
  else
374
   {
375
    Ipv6Address ueAddr6 = ueIpv6->GetAddress (interface6, 1).GetAddress ();
376
    NS_LOG_LOGIC (" UE IPv6 address: " << ueAddr6);  m_sgwPgwApp->SetUeAddress6 (imsi, ueAddr6);
377
   }
313
  uint8_t bearerId = m_mme->AddBearer (imsi, tft, bearer);
378
  uint8_t bearerId = m_mme->AddBearer (imsi, tft, bearer);
314
  Ptr<LteUeNetDevice> ueLteDevice = ueDevice->GetObject<LteUeNetDevice> ();
379
  Ptr<LteUeNetDevice> ueLteDevice = ueDevice->GetObject<LteUeNetDevice> ();
315
  if (ueLteDevice)
380
  if (ueLteDevice)
316
    {
381
    {
317
      ueLteDevice->GetNas ()->ActivateEpsBearer (bearer, tft);
382
      Simulator::ScheduleNow (&EpcUeNas::ActivateEpsBearer, ueLteDevice->GetNas (), bearer, tft);
318
    }
383
    }
319
  return bearerId;
384
  return bearerId;
320
}
385
}
321
386
322
323
Ptr<Node>
387
Ptr<Node>
324
PointToPointEpcHelper::GetPgwNode ()
388
PointToPointEpcHelper::GetPgwNode ()
325
{
389
{
326
  return m_sgwPgw;
390
  return m_sgwPgw;
327
}
391
}
328
392
329
330
Ipv4InterfaceContainer 
393
Ipv4InterfaceContainer 
331
PointToPointEpcHelper::AssignUeIpv4Address (NetDeviceContainer ueDevices)
394
PointToPointEpcHelper::AssignUeIpv4Address (NetDeviceContainer ueDevices)
332
{
395
{
333
  return m_ueAddressHelper.Assign (ueDevices);
396
  return m_uePgwAddressHelper.Assign (ueDevices);
334
}
397
}
335
398
336
399
Ipv6InterfaceContainer 
400
PointToPointEpcHelper::AssignUeIpv6Address (NetDeviceContainer ueDevices)
401
{
402
  return m_uePgwAddressHelper6.Assign (ueDevices);
403
}
337
404
338
Ipv4Address
405
Ipv4Address
339
PointToPointEpcHelper::GetUeDefaultGatewayAddress ()
406
PointToPointEpcHelper::GetUeDefaultGatewayAddress ()
 Lines 342-346    Link Here 
342
  return m_sgwPgw->GetObject<Ipv4> ()->GetAddress (1, 0).GetLocal ();
409
  return m_sgwPgw->GetObject<Ipv4> ()->GetAddress (1, 0).GetLocal ();
343
}
410
}
344
411
412
Ipv6Address
413
PointToPointEpcHelper::GetUeDefaultGatewayAddress6 ()
414
{
415
  // return the address of the tun device
416
  return m_sgwPgw->GetObject<Ipv6> ()->GetAddress (1, 1).GetAddress ();
417
}
345
418
346
} // namespace ns3
419
} // namespace ns3
(-)a/src/lte/helper/point-to-point-epc-helper.h (-4 / +10 lines)
 Lines 25-30    Link Here 
25
25
26
#include <ns3/object.h>
26
#include <ns3/object.h>
27
#include <ns3/ipv4-address-helper.h>
27
#include <ns3/ipv4-address-helper.h>
28
#include <ns3/ipv6-address-helper.h>
28
#include <ns3/data-rate.h>
29
#include <ns3/data-rate.h>
29
#include <ns3/epc-tft.h>
30
#include <ns3/epc-tft.h>
30
#include <ns3/eps-bearer.h>
31
#include <ns3/eps-bearer.h>
 Lines 68-73    Link Here 
68
   *  \return The object TypeId.
69
   *  \return The object TypeId.
69
   */
70
   */
70
  static TypeId GetTypeId (void);
71
  static TypeId GetTypeId (void);
72
  TypeId GetInstanceTypeId () const;
71
  virtual void DoDispose ();
73
  virtual void DoDispose ();
72
74
73
  // inherited from EpcHelper
75
  // inherited from EpcHelper
 Lines 77-92    Link Here 
77
  virtual uint8_t ActivateEpsBearer (Ptr<NetDevice> ueLteDevice, uint64_t imsi, Ptr<EpcTft> tft, EpsBearer bearer);
79
  virtual uint8_t ActivateEpsBearer (Ptr<NetDevice> ueLteDevice, uint64_t imsi, Ptr<EpcTft> tft, EpsBearer bearer);
78
  virtual Ptr<Node> GetPgwNode ();
80
  virtual Ptr<Node> GetPgwNode ();
79
  virtual Ipv4InterfaceContainer AssignUeIpv4Address (NetDeviceContainer ueDevices);
81
  virtual Ipv4InterfaceContainer AssignUeIpv4Address (NetDeviceContainer ueDevices);
82
  Ipv6InterfaceContainer AssignUeIpv6Address (NetDeviceContainer ueDevices);
80
  virtual Ipv4Address GetUeDefaultGatewayAddress ();
83
  virtual Ipv4Address GetUeDefaultGatewayAddress ();
81
84
  Ipv6Address GetUeDefaultGatewayAddress6 ();
82
85
83
86
84
private:
87
private:
85
88
86
  /** 
89
  /** 
87
   * helper to assign addresses to UE devices as well as to the TUN device of the SGW/PGW
90
   * helper to assign IPv4 addresses to UE devices as well as to the TUN device of the SGW/PGW
88
   */
91
   */
89
  Ipv4AddressHelper m_ueAddressHelper; 
92
  Ipv4AddressHelper m_uePgwAddressHelper;
93
  /** 
94
   * helper to assign IPv6 addresses to UE devices as well as to the TUN device of the SGW/PGW
95
   */
96
  Ipv6AddressHelper m_uePgwAddressHelper6;
90
  
97
  
91
  /**
98
  /**
92
   * SGW-PGW network element
99
   * SGW-PGW network element
 Lines 165-171    Link Here 
165
   * because of some big X2 messages, you need a big MTU.
172
   * because of some big X2 messages, you need a big MTU.
166
   */
173
   */
167
  uint16_t m_x2LinkMtu;
174
  uint16_t m_x2LinkMtu;
168
169
};
175
};
170
176
171
177
(-)a/src/lte/model/epc-enb-application.cc (-4 / +48 lines)
 Lines 63-69    Link Here 
63
{
63
{
64
  static TypeId tid = TypeId ("ns3::EpcEnbApplication")
64
  static TypeId tid = TypeId ("ns3::EpcEnbApplication")
65
    .SetParent<Object> ()
65
    .SetParent<Object> ()
66
    .SetGroupName("Lte");
66
    .SetGroupName("Lte")
67
    .AddTraceSource ("RxfromEnb",
68
                     "Receive data packets from LTE Enb Net Device",
69
                     MakeTraceSourceAccessor (&EpcEnbApplication::m_rxLteenbPktTrace),
70
                     "ns3::EpcEnbApplication::RxTracedCallback")
71
    .AddTraceSource ("RxfromS1u",
72
                     "Receive data packets from S1-U Net Device",
73
                     MakeTraceSourceAccessor (&EpcEnbApplication::m_rxS1uPktTrace),
74
                     "ns3::EpcEnbApplication::RxTracedCallback")
75
    ;
67
  return tid;
76
  return tid;
68
}
77
}
69
78
 Lines 72-85    Link Here 
72
{
81
{
73
  NS_LOG_FUNCTION (this);
82
  NS_LOG_FUNCTION (this);
74
  m_lteSocket = 0;
83
  m_lteSocket = 0;
84
  m_lteSocket6 = 0;
75
  m_s1uSocket = 0;
85
  m_s1uSocket = 0;
76
  delete m_s1SapProvider;
86
  delete m_s1SapProvider;
77
  delete m_s1apSapEnb;
87
  delete m_s1apSapEnb;
78
}
88
}
79
89
80
81
EpcEnbApplication::EpcEnbApplication (Ptr<Socket> lteSocket, Ptr<Socket> s1uSocket, Ipv4Address enbS1uAddress, Ipv4Address sgwS1uAddress, uint16_t cellId)
90
EpcEnbApplication::EpcEnbApplication (Ptr<Socket> lteSocket, Ptr<Socket> s1uSocket, Ipv4Address enbS1uAddress, Ipv4Address sgwS1uAddress, uint16_t cellId)
82
  : m_lteSocket (lteSocket),
91
  : m_lteSocket (lteSocket),
92
    m_lteSocket6 (0),
83
    m_s1uSocket (s1uSocket),    
93
    m_s1uSocket (s1uSocket),    
84
    m_enbS1uAddress (enbS1uAddress),
94
    m_enbS1uAddress (enbS1uAddress),
85
    m_sgwS1uAddress (sgwS1uAddress),
95
    m_sgwS1uAddress (sgwS1uAddress),
 Lines 240-246    Link Here 
240
EpcEnbApplication::RecvFromLteSocket (Ptr<Socket> socket)
250
EpcEnbApplication::RecvFromLteSocket (Ptr<Socket> socket)
241
{
251
{
242
  NS_LOG_FUNCTION (this);  
252
  NS_LOG_FUNCTION (this);  
243
  NS_ASSERT (socket == m_lteSocket);
253
  if(m_lteSocket6)
254
    {
255
      NS_ASSERT (socket == m_lteSocket || socket == m_lteSocket6);
256
    }
257
  else
258
    {
259
      NS_ASSERT (socket == m_lteSocket);
260
    }
244
  Ptr<Packet> packet = socket->Recv ();
261
  Ptr<Packet> packet = socket->Recv ();
245
262
246
  EpsBearerTag tag;
263
  EpsBearerTag tag;
 Lines 259-264    Link Here 
259
      std::map<uint8_t, uint32_t>::iterator bidIt = rntiIt->second.find (bid);
276
      std::map<uint8_t, uint32_t>::iterator bidIt = rntiIt->second.find (bid);
260
      NS_ASSERT (bidIt != rntiIt->second.end ());
277
      NS_ASSERT (bidIt != rntiIt->second.end ());
261
      uint32_t teid = bidIt->second;
278
      uint32_t teid = bidIt->second;
279
      m_rxLteenbPktTrace (packet->Copy ());
262
      SendToS1uSocket (packet, teid);
280
      SendToS1uSocket (packet, teid);
263
    }
281
    }
264
}
282
}
 Lines 275-280    Link Here 
275
  std::map<uint32_t, EpsFlowId_t>::iterator it = m_teidRbidMap.find (teid);
293
  std::map<uint32_t, EpsFlowId_t>::iterator it = m_teidRbidMap.find (teid);
276
  NS_ASSERT (it != m_teidRbidMap.end ());
294
  NS_ASSERT (it != m_teidRbidMap.end ());
277
295
296
  m_rxS1uPktTrace (packet->Copy ());
278
  SendToLteSocket (packet, it->second.m_rnti, it->second.m_bid);
297
  SendToLteSocket (packet, it->second.m_rnti, it->second.m_bid);
279
}
298
}
280
299
 Lines 284-290    Link Here 
284
  NS_LOG_FUNCTION (this << packet << rnti << (uint16_t) bid << packet->GetSize ());  
303
  NS_LOG_FUNCTION (this << packet << rnti << (uint16_t) bid << packet->GetSize ());  
285
  EpsBearerTag tag (rnti, bid);
304
  EpsBearerTag tag (rnti, bid);
286
  packet->AddPacketTag (tag);
305
  packet->AddPacketTag (tag);
287
  int sentBytes = m_lteSocket->Send (packet);
306
  uint8_t ipType;
307
  Ptr<Packet> pCopy = packet->Copy ();
308
  pCopy->CopyData (&ipType, 1);
309
  ipType=(ipType>>4) & 0x0f;
310
  int sentBytes;
311
  if (ipType == 0x04)
312
    {
313
      sentBytes = m_lteSocket->Send (packet);
314
    }
315
  else
316
    {
317
      sentBytes = m_lteSocket6->Send (packet);
318
    }
319
288
  NS_ASSERT (sentBytes > 0);
320
  NS_ASSERT (sentBytes > 0);
289
}
321
}
290
322
 Lines 314-317    Link Here 
314
  //From 3GPP TS 23401-950 Section 5.4.4.2, enB sends EPS bearer Identity in Bearer Release Indication message to MME
346
  //From 3GPP TS 23401-950 Section 5.4.4.2, enB sends EPS bearer Identity in Bearer Release Indication message to MME
315
  m_s1apSapMme->ErabReleaseIndication (imsi, rnti, erabToBeReleaseIndication);
347
  m_s1apSapMme->ErabReleaseIndication (imsi, rnti, erabToBeReleaseIndication);
316
}
348
}
349
350
void EpcEnbApplication::SetLTESocket6(Ptr<Socket> lteSocket6)
351
{
352
  m_lteSocket6 = lteSocket6;
353
  m_lteSocket6->SetRecvCallback (MakeCallback (&EpcEnbApplication::RecvFromLteSocket, this));
354
}
355
356
Ptr<Socket> EpcEnbApplication::GetLTESocket6()
357
{
358
  return m_lteSocket6;
359
}
360
317
}  // namespace ns3
361
}  // namespace ns3
(-)a/src/lte/model/epc-enb-application.h (+24 lines)
 Lines 80-85    Link Here 
80
   */
80
   */
81
  EpcEnbApplication (Ptr<Socket> lteSocket, Ptr<Socket> s1uSocket, Ipv4Address enbS1uAddress, Ipv4Address sgwS1uAddress, uint16_t cellId);
81
  EpcEnbApplication (Ptr<Socket> lteSocket, Ptr<Socket> s1uSocket, Ipv4Address enbS1uAddress, Ipv4Address sgwS1uAddress, uint16_t cellId);
82
82
83
  void SetLTESocket6(Ptr<Socket> lteSocket6);
84
  Ptr<Socket> GetLTESocket6(); 
83
  /**
85
  /**
84
   * Destructor
86
   * Destructor
85
   * 
87
   * 
 Lines 128-133    Link Here 
128
   */
130
   */
129
  void RecvFromS1uSocket (Ptr<Socket> socket);
131
  void RecvFromS1uSocket (Ptr<Socket> socket);
130
132
133
  /**
134
   * TracedCallback signature for data Packet reception event.
135
   *
136
   * \param [in] packet The data packet sent from the internet.
137
   */
138
  typedef void (* RxTracedCallback)
139
    (Ptr<Packet> packet);
140
131
141
132
  /**
142
  /**
133
   * EPS flow ID structure
143
   * EPS flow ID structure
 Lines 246-251    Link Here 
246
  Ptr<Socket> m_lteSocket;
256
  Ptr<Socket> m_lteSocket;
247
257
248
  /**
258
  /**
259
   * raw packet socket to send and receive the packets to and from the LTE radio interface
260
   */
261
  Ptr<Socket> m_lteSocket6;
262
263
  /**
249
   * UDP socket to send and receive GTP-U the packets to and from the S1-U interface
264
   * UDP socket to send and receive GTP-U the packets to and from the S1-U interface
250
   */
265
   */
251
  Ptr<Socket> m_s1uSocket;
266
  Ptr<Socket> m_s1uSocket;
 Lines 307-312    Link Here 
307
322
308
  uint16_t m_cellId; ///< cell ID
323
  uint16_t m_cellId; ///< cell ID
309
324
325
  /**
326
   * \brief Callback to trace RX (reception) data packets from LTE Enb Net Device.
327
   */ 
328
  TracedCallback<Ptr<Packet> > m_rxLteenbPktTrace;
329
330
  /**
331
   * \brief Callback to trace RX (reception) data packets from S1-U Net Device.
332
   */ 
333
  TracedCallback<Ptr<Packet> > m_rxS1uPktTrace;
310
};
334
};
311
335
312
} //namespace ns3
336
} //namespace ns3
(-)a/src/lte/model/epc-sgw-pgw-application.cc (-20 / +98 lines)
 Lines 24-29    Link Here 
24
#include "ns3/log.h"
24
#include "ns3/log.h"
25
#include "ns3/mac48-address.h"
25
#include "ns3/mac48-address.h"
26
#include "ns3/ipv4.h"
26
#include "ns3/ipv4.h"
27
#include "ns3/ipv6.h"
28
#include "ns3/ipv6-header.h"
27
#include "ns3/inet-socket-address.h"
29
#include "ns3/inet-socket-address.h"
28
#include "ns3/epc-gtpu-header.h"
30
#include "ns3/epc-gtpu-header.h"
29
#include "ns3/abort.h"
31
#include "ns3/abort.h"
 Lines 91-96    Link Here 
91
  m_ueAddr = ueAddr;
93
  m_ueAddr = ueAddr;
92
}
94
}
93
95
96
Ipv6Address 
97
EpcSgwPgwApplication::UeInfo::GetUeAddr6 ()
98
{
99
  return m_ueAddr6;
100
}
101
102
void
103
EpcSgwPgwApplication::UeInfo::SetUeAddr6 (Ipv6Address ueAddr)
104
{
105
  m_ueAddr6 = ueAddr;
106
}
107
94
/////////////////////////
108
/////////////////////////
95
// EpcSgwPgwApplication
109
// EpcSgwPgwApplication
96
/////////////////////////
110
/////////////////////////
 Lines 101-107    Link Here 
101
{
115
{
102
  static TypeId tid = TypeId ("ns3::EpcSgwPgwApplication")
116
  static TypeId tid = TypeId ("ns3::EpcSgwPgwApplication")
103
    .SetParent<Object> ()
117
    .SetParent<Object> ()
104
    .SetGroupName("Lte");
118
    .SetGroupName("Lte")
119
    .AddTraceSource ("RxfromTun",
120
                     "Receive data packets from internet in Tunnel net device",
121
                     MakeTraceSourceAccessor (&EpcSgwPgwApplication::m_rxTunPktTrace),
122
                     "ns3::EpcSgwPgwApplication::RxTracedCallback")
123
    .AddTraceSource ("RxfromS1u",
124
                     "Receive data packets from S1 U Socket",
125
                     MakeTraceSourceAccessor (&EpcSgwPgwApplication::m_rxS1uPktTrace),
126
                     "ns3::EpcSgwPgwApplication::RxTracedCallback")
127
    ;
105
  return tid;
128
  return tid;
106
}
129
}
107
130
 Lines 115-121    Link Here 
115
}
138
}
116
139
117
  
140
  
118
119
EpcSgwPgwApplication::EpcSgwPgwApplication (const Ptr<VirtualNetDevice> tunDevice, const Ptr<Socket> s1uSocket)
141
EpcSgwPgwApplication::EpcSgwPgwApplication (const Ptr<VirtualNetDevice> tunDevice, const Ptr<Socket> s1uSocket)
120
  : m_s1uSocket (s1uSocket),
142
  : m_s1uSocket (s1uSocket),
121
    m_tunDevice (tunDevice),
143
    m_tunDevice (tunDevice),
 Lines 139-171    Link Here 
139
EpcSgwPgwApplication::RecvFromTunDevice (Ptr<Packet> packet, const Address& source, const Address& dest, uint16_t protocolNumber)
161
EpcSgwPgwApplication::RecvFromTunDevice (Ptr<Packet> packet, const Address& source, const Address& dest, uint16_t protocolNumber)
140
{
162
{
141
  NS_LOG_FUNCTION (this << source << dest << packet << packet->GetSize ());
163
  NS_LOG_FUNCTION (this << source << dest << packet << packet->GetSize ());
142
164
  m_rxTunPktTrace (packet->Copy ());
165
  uint8_t ipType;
143
  // get IP address of UE
166
  // get IP address of UE
144
  Ptr<Packet> pCopy = packet->Copy ();
167
  Ptr<Packet> pCopy = packet->Copy ();
145
  Ipv4Header ipv4Header;
168
  pCopy->CopyData (&ipType, 1);
146
  pCopy->RemoveHeader (ipv4Header);
169
  ipType=(ipType>>4) & 0x0f;
147
  Ipv4Address ueAddr =  ipv4Header.GetDestination ();
170
  if (ipType == 0x04)
148
  NS_LOG_LOGIC ("packet addressed to UE " << ueAddr);
171
    {
149
172
      Ipv4Header ipv4Header;
150
  // find corresponding UeInfo address
173
      pCopy->RemoveHeader (ipv4Header);
151
  std::map<Ipv4Address, Ptr<UeInfo> >::iterator it = m_ueInfoByAddrMap.find (ueAddr);
174
      Ipv4Address ueAddr =  ipv4Header.GetDestination ();
152
  if (it == m_ueInfoByAddrMap.end ())
175
      NS_LOG_LOGIC ("packet addressed to UE " << ueAddr);
153
    {        
176
      // find corresponding UeInfo address
154
      NS_LOG_WARN ("unknown UE address " << ueAddr);
177
      std::map<Ipv4Address, Ptr<UeInfo> >::iterator it = m_ueInfoByAddrMap.find (ueAddr);
178
      if (it == m_ueInfoByAddrMap.end ())
179
        {        
180
          NS_LOG_WARN ("unknown UE address " << ueAddr);
181
        }
182
      else
183
        {
184
          Ipv4Address enbAddr = it->second->GetEnbAddr ();      
185
          uint32_t teid = it->second->Classify (packet);   
186
          if (teid == 0)
187
            {
188
              NS_LOG_WARN ("no matching bearer for this packet");                   
189
            }
190
          else
191
            {
192
              SendToS1uSocket (packet, enbAddr, teid);
193
            }
194
        }
155
    }
195
    }
156
  else
196
  else
157
    {
197
    {
158
      Ipv4Address enbAddr = it->second->GetEnbAddr ();      
198
      Ipv6Header ipv6Header;
159
      uint32_t teid = it->second->Classify (packet);   
199
      pCopy->RemoveHeader (ipv6Header);
160
      if (teid == 0)
200
      Ipv6Address ueAddr =  ipv6Header.GetDestinationAddress ();
161
        {
201
      NS_LOG_LOGIC ("packet addressed to UE " << ueAddr);
162
          NS_LOG_WARN ("no matching bearer for this packet");                   
202
      // find corresponding UeInfo address
203
      std::map<Ipv6Address, Ptr<UeInfo> >::iterator it = m_ueInfoByAddrMap6.find (ueAddr);
204
      if (it == m_ueInfoByAddrMap6.end ())
205
        {        
206
          NS_LOG_WARN ("unknown UE address " << ueAddr);
163
        }
207
        }
164
      else
208
      else
165
        {
209
        {
166
          SendToS1uSocket (packet, enbAddr, teid);
210
          Ipv4Address enbAddr = it->second->GetEnbAddr ();      
211
          uint32_t teid = it->second->Classify (packet);   
212
          if (teid == 0)
213
            {
214
              NS_LOG_WARN ("no matching bearer for this packet");                   
215
            }
216
          else
217
            {
218
              SendToS1uSocket (packet, enbAddr, teid);
219
            }
167
        }
220
        }
168
    }
221
    }
222
169
  // there is no reason why we should notify the TUN
223
  // there is no reason why we should notify the TUN
170
  // VirtualNetDevice that he failed to send the packet: if we receive
224
  // VirtualNetDevice that he failed to send the packet: if we receive
171
  // any bogus packet, it will just be silently discarded.
225
  // any bogus packet, it will just be silently discarded.
 Lines 184-189    Link Here 
184
  uint32_t teid = gtpu.GetTeid ();
238
  uint32_t teid = gtpu.GetTeid ();
185
239
186
  SendToTunDevice (packet, teid);
240
  SendToTunDevice (packet, teid);
241
242
  m_rxS1uPktTrace (packet->Copy ());
187
}
243
}
188
244
189
void 
245
void 
 Lines 191-197    Link Here 
191
{
247
{
192
  NS_LOG_FUNCTION (this << packet << teid);
248
  NS_LOG_FUNCTION (this << packet << teid);
193
  NS_LOG_LOGIC (" packet size: " << packet->GetSize () << " bytes");
249
  NS_LOG_LOGIC (" packet size: " << packet->GetSize () << " bytes");
194
  m_tunDevice->Receive (packet, 0x0800, m_tunDevice->GetAddress (), m_tunDevice->GetAddress (), NetDevice::PACKET_HOST);
250
  uint8_t ipType;
251
  // get IP address of UE
252
  Ptr<Packet> pCopy = packet->Copy ();
253
  pCopy->CopyData (&ipType, 1);
254
  ipType=(ipType>>4) & 0x0f;
255
  if (ipType == 0x04)
256
    {
257
      m_tunDevice->Receive (packet, 0x0800, m_tunDevice->GetAddress (), m_tunDevice->GetAddress (), NetDevice::PACKET_HOST);
258
    }
259
  else
260
    {
261
      m_tunDevice->Receive (packet, 0x86DD, m_tunDevice->GetAddress (), m_tunDevice->GetAddress (), NetDevice::PACKET_HOST);
262
    }
195
}
263
}
196
264
197
void 
265
void 
 Lines 251-256    Link Here 
251
}
319
}
252
320
253
void 
321
void 
322
EpcSgwPgwApplication::SetUeAddress6 (uint64_t imsi, Ipv6Address ueAddr)
323
{
324
  NS_LOG_FUNCTION (this << imsi << ueAddr);
325
  std::map<uint64_t, Ptr<UeInfo> >::iterator ueit = m_ueInfoByImsiMap.find (imsi);
326
  NS_ASSERT_MSG (ueit != m_ueInfoByImsiMap.end (), "unknown IMSI " << imsi); 
327
  m_ueInfoByAddrMap6[ueAddr] = ueit->second;
328
  ueit->second->SetUeAddr6 (ueAddr);
329
}
330
331
void 
254
EpcSgwPgwApplication::DoCreateSessionRequest (EpcS11SapSgw::CreateSessionRequestMessage req)
332
EpcSgwPgwApplication::DoCreateSessionRequest (EpcS11SapSgw::CreateSessionRequestMessage req)
255
{
333
{
256
  NS_LOG_FUNCTION (this << req.imsi);
334
  NS_LOG_FUNCTION (this << req.imsi);
(-)a/src/lte/model/epc-sgw-pgw-application.h (-1 / +45 lines)
 Lines 67-72    Link Here 
67
   * internet over GTP-U/UDP/IP on the S1-U interface
67
   * internet over GTP-U/UDP/IP on the S1-U interface
68
   * \param s1uSocket socket used to send GTP-U packets to the eNBs
68
   * \param s1uSocket socket used to send GTP-U packets to the eNBs
69
   */
69
   */
70
70
  EpcSgwPgwApplication (const Ptr<VirtualNetDevice> tunDevice, const Ptr<Socket> s1uSocket);
71
  EpcSgwPgwApplication (const Ptr<VirtualNetDevice> tunDevice, const Ptr<Socket> s1uSocket);
71
72
72
  /** 
73
  /** 
 Lines 155-160    Link Here 
155
   */
156
   */
156
  void SetUeAddress (uint64_t imsi, Ipv4Address ueAddr);
157
  void SetUeAddress (uint64_t imsi, Ipv4Address ueAddr);
157
158
159
  /** 
160
   * set the address of a previously added UE
161
   * 
162
   * \param imsi the unique identifier of the UE
163
   * \param ueAddr the IPv6 address of the UE
164
   */
165
  void SetUeAddress6 (uint64_t imsi, Ipv6Address ueAddr);
166
167
  /**
168
   * TracedCallback signature for data Packet reception event.
169
   *
170
   * \param [in] packet The data packet sent from the internet.
171
   */
172
  typedef void (* RxTracedCallback)
173
    (Ptr<Packet> packet);
174
158
private:
175
private:
159
176
160
  // S11 SAP SGW methods
177
  // S11 SAP SGW methods
 Lines 238-248    Link Here 
238
     */
255
     */
239
    void SetUeAddr (Ipv4Address addr);
256
    void SetUeAddr (Ipv4Address addr);
240
257
258
    /**
259
     * \return the address of the UE
260
     */
261
    Ipv6Address GetUeAddr6 ();
262
263
    /**
264
     * set the address of the UE
265
     *
266
     * \param addr the address of the UE
267
     */
268
    void SetUeAddr6 (Ipv6Address addr);
241
269
242
  private:
270
  private:
243
    EpcTftClassifier m_tftClassifier; ///< TFT classifier
271
    EpcTftClassifier m_tftClassifier; ///< TFT classifier
244
    Ipv4Address m_enbAddr; ///< ENB address
272
    Ipv4Address m_enbAddr; ///< ENB address
245
    Ipv4Address m_ueAddr; ///< UE address
273
    Ipv4Address m_ueAddr; ///< UE address
274
    Ipv6Address m_ueAddr6; ///< UE address
246
    std::map<uint8_t, uint32_t> m_teidByBearerIdMap; ///< TEID By bearer ID Map
275
    std::map<uint8_t, uint32_t> m_teidByBearerIdMap; ///< TEID By bearer ID Map
247
  };
276
  };
248
277
 Lines 259-269    Link Here 
259
  Ptr<VirtualNetDevice> m_tunDevice;
288
  Ptr<VirtualNetDevice> m_tunDevice;
260
289
261
  /**
290
  /**
262
   * Map telling for each UE address the corresponding UE info 
291
   * Map telling for each UE IPv4 address the corresponding UE info 
263
   */
292
   */
264
  std::map<Ipv4Address, Ptr<UeInfo> > m_ueInfoByAddrMap;
293
  std::map<Ipv4Address, Ptr<UeInfo> > m_ueInfoByAddrMap;
265
294
266
  /**
295
  /**
296
   * Map telling for each UE IPv6 address the corresponding UE info 
297
   */
298
  std::map<Ipv6Address, Ptr<UeInfo> > m_ueInfoByAddrMap6;
299
300
  /**
267
   * Map telling for each IMSI the corresponding UE info 
301
   * Map telling for each IMSI the corresponding UE info 
268
   */
302
   */
269
  std::map<uint64_t, Ptr<UeInfo> > m_ueInfoByImsiMap;
303
  std::map<uint64_t, Ptr<UeInfo> > m_ueInfoByImsiMap;
 Lines 298-303    Link Here 
298
  };
332
  };
299
333
300
  std::map<uint16_t, EnbInfo> m_enbInfoByCellId; ///< eNB info by cell ID
334
  std::map<uint16_t, EnbInfo> m_enbInfoByCellId; ///< eNB info by cell ID
335
336
  /**
337
   * \brief Callback to trace RX (reception) data packets at Tun Net Device from internet.
338
   */
339
  TracedCallback<Ptr<Packet> > m_rxTunPktTrace;
340
341
  /**
342
   * \brief Callback to trace RX (reception) data packets from S1-U socket.
343
   */
344
  TracedCallback<Ptr<Packet> > m_rxS1uPktTrace;
301
};
345
};
302
346
303
} //namespace ns3
347
} //namespace ns3
(-)a/src/lte/model/epc-tft-classifier.cc (-60 / +130 lines)
 Lines 23-40    Link Here 
23
 *
23
 *
24
 */
24
 */
25
25
26
27
28
29
#include "epc-tft-classifier.h"
26
#include "epc-tft-classifier.h"
30
#include "epc-tft.h"
27
#include "epc-tft.h"
31
#include "ns3/log.h"
28
#include "ns3/log.h"
32
#include "ns3/packet.h"
29
#include "ns3/packet.h"
33
#include "ns3/ipv4-header.h"
30
#include "ns3/ipv4-header.h"
31
#include "ns3/ipv6-header.h"
34
#include "ns3/udp-header.h"
32
#include "ns3/udp-header.h"
35
#include "ns3/tcp-header.h"
33
#include "ns3/tcp-header.h"
36
#include "ns3/udp-l4-protocol.h"
34
#include "ns3/udp-l4-protocol.h"
37
#include "ns3/tcp-l4-protocol.h"
35
#include "ns3/tcp-l4-protocol.h"
36
#include "ns3/icmpv6-l4-protocol.h"
37
#include "ns3/icmpv4-l4-protocol.h"
38
38
39
namespace ns3 {
39
namespace ns3 {
40
40
 Lines 71-132    Link Here 
71
71
72
  Ptr<Packet> pCopy = p->Copy ();
72
  Ptr<Packet> pCopy = p->Copy ();
73
73
74
  Ipv4Header ipv4Header;
74
  uint8_t ipType;
75
  pCopy->RemoveHeader (ipv4Header);
75
  pCopy->CopyData (&ipType, 1);
76
76
  ipType = (ipType>>4) & 0x0f;
77
  Ipv4Address localAddress;
78
  Ipv4Address remoteAddress;
79
77
80
  
78
  Ipv4Address localAddressIpv4;
81
  if (direction ==  EpcTft::UPLINK)
79
  Ipv4Address remoteAddressIpv4;
82
    {
83
      localAddress = ipv4Header.GetSource ();
84
      remoteAddress = ipv4Header.GetDestination ();
85
    }
86
  else
87
    { 
88
      NS_ASSERT (direction ==  EpcTft::DOWNLINK);
89
      remoteAddress = ipv4Header.GetSource ();
90
      localAddress = ipv4Header.GetDestination ();      
91
    }
92
  
93
  uint8_t protocol = ipv4Header.GetProtocol ();
94
80
95
  uint8_t tos = ipv4Header.GetTos ();
81
  Ipv6Address localAddressIpv6;
82
  Ipv6Address remoteAddressIpv6;
83
84
  uint8_t protocol;
85
  uint8_t tos;
96
86
97
  uint16_t localPort = 0;
87
  uint16_t localPort = 0;
98
  uint16_t remotePort = 0;
88
  uint16_t remotePort = 0;
99
89
90
  if (ipType == 0x04)
91
    {
92
      Ipv4Header ipv4Header;
93
      pCopy->RemoveHeader (ipv4Header);
94
95
      if (direction ==  EpcTft::UPLINK)
96
        {
97
          localAddressIpv4 = ipv4Header.GetSource ();
98
          remoteAddressIpv4 = ipv4Header.GetDestination ();
99
        }
100
      else
101
        {
102
          NS_ASSERT (direction ==  EpcTft::DOWNLINK);
103
          remoteAddressIpv4 = ipv4Header.GetSource ();
104
          localAddressIpv4 = ipv4Header.GetDestination ();
105
        }
106
      NS_LOG_INFO ("local address: " << localAddressIpv4 << " remote address: " << remoteAddressIpv4);
107
108
      protocol = ipv4Header.GetProtocol ();
109
      tos = ipv4Header.GetTos ();
110
    }
111
  else
112
    {
113
      Ipv6Header ipv6Header;
114
      pCopy->RemoveHeader (ipv6Header);
115
116
      if (direction ==  EpcTft::UPLINK)
117
        {
118
          localAddressIpv6 = ipv6Header.GetSourceAddress ();
119
          remoteAddressIpv6 = ipv6Header.GetDestinationAddress ();
120
        }
121
      else
122
        {
123
          NS_ASSERT (direction ==  EpcTft::DOWNLINK);
124
          remoteAddressIpv6 = ipv6Header.GetSourceAddress ();
125
          localAddressIpv6 = ipv6Header.GetDestinationAddress ();
126
        }
127
      NS_LOG_INFO ("local address: " << localAddressIpv6 << " remote address: " << remoteAddressIpv6);
128
129
      protocol = ipv6Header.GetNextHeader ();
130
      tos = ipv6Header.GetTrafficClass ();
131
    }
132
100
  if (protocol == UdpL4Protocol::PROT_NUMBER)
133
  if (protocol == UdpL4Protocol::PROT_NUMBER)
101
    {
134
    {
102
      UdpHeader udpHeader;
135
      UdpHeader udpHeader;
103
      pCopy->RemoveHeader (udpHeader);
136
      pCopy->RemoveHeader (udpHeader);
104
137
105
      if (direction ==  EpcTft::UPLINK)
138
      if (direction ==  EpcTft::UPLINK)
106
	{
139
        {
107
	  localPort = udpHeader.GetSourcePort ();
140
          localPort = udpHeader.GetSourcePort ();
108
	  remotePort = udpHeader.GetDestinationPort ();
141
          remotePort = udpHeader.GetDestinationPort ();
109
	}
142
        }
110
      else
143
      else
111
	{
144
        {
112
	  remotePort = udpHeader.GetSourcePort ();
145
          remotePort = udpHeader.GetSourcePort ();
113
	  localPort = udpHeader.GetDestinationPort ();
146
          localPort = udpHeader.GetDestinationPort ();
114
	}
147
        }
115
    }
148
    }
116
  else if (protocol == TcpL4Protocol::PROT_NUMBER)
149
  else if (protocol == TcpL4Protocol::PROT_NUMBER)
117
    {
150
    {
118
      TcpHeader tcpHeader;
151
      TcpHeader tcpHeader;
119
      pCopy->RemoveHeader (tcpHeader);
152
      pCopy->RemoveHeader (tcpHeader);
120
      if (direction ==  EpcTft::UPLINK)
153
      if (direction ==  EpcTft::UPLINK)
121
	{
154
        {
122
	  localPort = tcpHeader.GetSourcePort ();
155
          localPort = tcpHeader.GetSourcePort ();
123
	  remotePort = tcpHeader.GetDestinationPort ();
156
          remotePort = tcpHeader.GetDestinationPort ();
124
	}
157
        }
125
      else
158
      else
126
	{
159
        {
127
	  remotePort = tcpHeader.GetSourcePort ();
160
          remotePort = tcpHeader.GetSourcePort ();
128
	  localPort = tcpHeader.GetDestinationPort ();
161
          localPort = tcpHeader.GetDestinationPort ();
129
	}
162
        }
163
    }
164
  else if (protocol == Icmpv6L4Protocol::PROT_NUMBER || protocol == Icmpv4L4Protocol::PROT_NUMBER)
165
    {
166
      remotePort = 0;
167
      localPort = 0;
130
    }
168
    }
131
  else
169
  else
132
    {
170
    {
 Lines 134-165    Link Here 
134
      return 0;  // no match
172
      return 0;  // no match
135
    }
173
    }
136
174
137
  NS_LOG_INFO ("Classifing packet:"
175
  if (ipType == 0x04)
138
	       << " localAddr="  << localAddress 
176
    {
139
	       << " remoteAddr=" << remoteAddress 
177
      NS_LOG_INFO ("Classifying packet:"
140
	       << " localPort="  << localPort 
178
          << " localAddr="  << localAddressIpv4
141
	       << " remotePort=" << remotePort 
179
          << " remoteAddr=" << remoteAddressIpv4
142
	       << " tos=0x" << (uint16_t) tos );
180
          << " localPort="  << localPort
181
          << " remotePort=" << remotePort
182
          << " tos=0x" << (uint16_t) tos );
143
183
144
  // now it is possible to classify the packet!
184
      // now it is possible to classify the packet!
145
  // we use a reverse iterator since filter priority is not implemented properly.
185
      // we use a reverse iterator since filter priority is not implemented properly.
146
  // This way, since the default bearer is expected to be added first, it will be evaluated last.
186
      // This way, since the default bearer is expected to be added first, it will be evaluated last.
147
  std::map <uint32_t, Ptr<EpcTft> >::const_reverse_iterator it;
187
      std::map <uint32_t, Ptr<EpcTft> >::const_reverse_iterator it;
148
  NS_LOG_LOGIC ("TFT MAP size: " << m_tftMap.size ());
188
      NS_LOG_LOGIC ("TFT MAP size: " << m_tftMap.size ());
149
189
150
  for (it = m_tftMap.rbegin (); it != m_tftMap.rend (); ++it)
190
      for (it = m_tftMap.rbegin (); it != m_tftMap.rend (); ++it)
151
    {
152
      NS_LOG_LOGIC ("TFT id: " << it->first );
153
      NS_LOG_LOGIC (" Ptr<EpcTft>: " << it->second);
154
      Ptr<EpcTft> tft = it->second;         
155
      if (tft->Matches (direction, remoteAddress, localAddress, remotePort, localPort, tos))
156
        {
191
        {
157
	  NS_LOG_LOGIC ("matches with TFT ID = " << it->first);
192
          NS_LOG_LOGIC ("TFT id: " << it->first );
158
	  return it->first; // the id of the matching TFT
193
          NS_LOG_LOGIC (" Ptr<EpcTft>: " << it->second);
194
          Ptr<EpcTft> tft = it->second;
195
          if (tft->Matches (direction, remoteAddressIpv4, localAddressIpv4, remotePort, localPort, tos))
196
            {
197
              NS_LOG_LOGIC ("matches with TFT ID = " << it->first);
198
              return it->first; // the id of the matching TFT
199
            }
159
        }
200
        }
201
      NS_LOG_LOGIC ("no match");
202
      return 0;  // no match
160
    }
203
    }
161
  NS_LOG_LOGIC ("no match");
204
  else
162
  return 0;  // no match
205
    {
206
      NS_LOG_INFO ("Classifying packet:"
207
          << " localAddr="  << localAddressIpv6
208
          << " remoteAddr=" << remoteAddressIpv6
209
          << " localPort="  << localPort
210
          << " remotePort=" << remotePort
211
          << " tos=0x" << (uint16_t) tos );
212
213
      // now it is possible to classify the packet!
214
      // we use a reverse iterator since filter priority is not implemented properly.
215
      // This way, since the default bearer is expected to be added first, it will be evaluated last.
216
      std::map <uint32_t, Ptr<EpcTft> >::const_reverse_iterator it;
217
      NS_LOG_LOGIC ("TFT MAP size: " << m_tftMap.size ());
218
219
      for (it = m_tftMap.rbegin (); it != m_tftMap.rend (); ++it)
220
        {
221
          NS_LOG_LOGIC ("TFT id: " << it->first );
222
          NS_LOG_LOGIC (" Ptr<EpcTft>: " << it->second);
223
          Ptr<EpcTft> tft = it->second;
224
          if (tft->Matches (direction, remoteAddressIpv6, localAddressIpv6, remotePort, localPort, tos))
225
            {
226
              NS_LOG_LOGIC ("matches with TFT ID = " << it->first);
227
              return it->first; // the id of the matching TFT
228
            }
229
        }
230
      NS_LOG_LOGIC ("no match");
231
      return 0;  // no match
232
    }
163
}
233
}
164
234
165
235
(-)a/src/lte/model/epc-tft.cc (-2 / +76 lines)
 Lines 65-73    Link Here 
65
std::ostream& operator<< (std::ostream& os, EpcTft::PacketFilter& f)
65
std::ostream& operator<< (std::ostream& os, EpcTft::PacketFilter& f)
66
{
66
{
67
  os << " direction: " << f.direction
67
  os << " direction: " << f.direction
68
     << " remoteAddress: "  << f.remoteAddress 
68
     << " remoteAddress: "  << f.remoteAddress
69
     << " remoteAddress6: "  << f.remoteAddress6
69
     << " remoteMask: "  << f.remoteMask 
70
     << " remoteMask: "  << f.remoteMask 
70
     << " localAddress: "  << f.localAddress 
71
     << " localAddress: "  << f.localAddress
72
     << " localAddress6: "  << f.localAddress6 
71
     << " localMask: "  << f.localMask 
73
     << " localMask: "  << f.localMask 
72
     << " remotePortStart: "   << f.remotePortStart
74
     << " remotePortStart: "   << f.remotePortStart
73
     << " remotePortEnd: "   << f.remotePortEnd 
75
     << " remotePortEnd: "   << f.remotePortEnd 
 Lines 150-155    Link Here 
150
  return false;      
152
  return false;      
151
}
153
}
152
154
155
bool 
156
EpcTft::PacketFilter::Matches (Direction d,
157
			       Ipv6Address ra, 
158
			       Ipv6Address la, 
159
			       uint16_t rp,
160
			       uint16_t lp,
161
			       uint8_t tos)
162
{
163
  NS_LOG_FUNCTION (this << d << ra << la << rp << lp << (uint16_t) tos);
164
  if (d & direction)
165
    {
166
      NS_LOG_LOGIC ("d matches");
167
	      if (rp >= remotePortStart)
168
		{
169
		  NS_LOG_LOGIC ("rps matches");
170
		  if (rp <= remotePortEnd)
171
		    {
172
		      NS_LOG_LOGIC ("rpe matches");
173
		      if (lp >= localPortStart)
174
			{
175
			  NS_LOG_LOGIC ("lps matches");
176
			  if (lp <= localPortEnd)
177
			    {
178
			      NS_LOG_LOGIC ("lpe matches");
179
			      if ((tos & typeOfServiceMask) == (typeOfService & typeOfServiceMask))
180
				{
181
				  NS_LOG_LOGIC ("tos matches --> have match!");
182
				  return true;
183
				}
184
			    }
185
			}
186
		    }
187
		
188
	    
189
	  else
190
	    {
191
	      NS_LOG_LOGIC ("la doesn't match: la=" << la << " f.la=" << localAddress << " f.lmask=" << localMask);
192
	    }
193
	}
194
      else
195
	{
196
	  NS_LOG_LOGIC ("ra doesn't match: ra=" << ra << " f.ra=" << remoteAddress << " f.rmask=" << remoteMask);
197
	}
198
    }
199
  else
200
    {
201
      NS_LOG_LOGIC ("d doesn't match: d=0x" << std::hex << d << " f.d=0x" << std::hex << direction << std::dec);
202
    }
203
  return false;      
204
}
205
153
206
154
Ptr<EpcTft> 
207
Ptr<EpcTft> 
155
EpcTft::Default ()
208
EpcTft::Default ()
 Lines 205-209    Link Here 
205
  return false;
258
  return false;
206
}
259
}
207
260
261
bool 
262
EpcTft::Matches (Direction direction,
263
		 Ipv6Address remoteAddress, 
264
		 Ipv6Address localAddress, 
265
		 uint16_t remotePort,
266
		 uint16_t localPort,
267
		 uint8_t typeOfService)
268
{
269
  NS_LOG_FUNCTION (this << direction << remoteAddress << localAddress << std::dec << remotePort << localPort << (uint16_t) typeOfService);
270
  for (std::list<PacketFilter>::iterator it = m_filters.begin ();
271
       it != m_filters.end ();
272
       ++it)
273
    {
274
      if (it->Matches (direction, remoteAddress, localAddress, remotePort, localPort, typeOfService))
275
	{
276
	  return true;
277
	}
278
    }  
279
  return false;
280
}
281
208
282
209
} // namespace ns3
283
} // namespace ns3
(-)a/src/lte/model/epc-tft.h (-5 / +46 lines)
 Lines 25-30    Link Here 
25
25
26
#include <ns3/simple-ref-count.h>
26
#include <ns3/simple-ref-count.h>
27
#include <ns3/ipv4-address.h>
27
#include <ns3/ipv4-address.h>
28
#include <ns3/ipv6-address.h>
28
29
29
#include <list>
30
#include <list>
30
31
 Lines 88-94    Link Here 
88
     */
89
     */
89
    bool Matches (Direction d,
90
    bool Matches (Direction d,
90
		  Ipv4Address ra, 
91
		  Ipv4Address ra, 
91
		  Ipv4Address la, 
92
		  Ipv4Address la,
93
		  uint16_t rp,
94
		  uint16_t lp,
95
		  uint8_t tos);
96
97
    /** 
98
     * 
99
     * \param d the direction 
100
     * \param ra the remote address 
101
     * \param la the local address 
102
     * \param rp the remote port 
103
     * \param lp the local port 
104
     * \param tos the type of service 
105
     * 
106
     * \return true if the parameters match with the PacketFilter,
107
     * false otherwise.
108
     */
109
    bool Matches (Direction d,
110
		  Ipv6Address ra, 
111
		  Ipv6Address la,
92
		  uint16_t rp,
112
		  uint16_t rp,
93
		  uint16_t lp,
113
		  uint16_t lp,
94
		  uint8_t tos);
114
		  uint8_t tos);
 Lines 105-112    Link Here 
105
			    to uplink / downlink only, or in both cases*/
125
			    to uplink / downlink only, or in both cases*/
106
126
107
    Ipv4Address remoteAddress;     /**< IPv4 address of the remote host  */
127
    Ipv4Address remoteAddress;     /**< IPv4 address of the remote host  */
108
    Ipv4Mask remoteMask; /**< IPv4 address mask of the remote host */
128
    Ipv6Address remoteAddress6;     /**< IPv6 address of the remote host  */
109
    Ipv4Address localAddress;      /**< IPv4 address of the UE */
129
    Ipv4Mask remoteMask;            /**< IPv4 address mask of the remote host */
130
    Ipv4Address localAddress;       /**< IPv4 address of the UE */
131
    Ipv6Address localAddress6;      /**< IPv6 address of the UE */
110
    Ipv4Mask localMask;  /**< IPv4 address mask of the UE */
132
    Ipv4Mask localMask;  /**< IPv4 address mask of the UE */
111
  
133
  
112
    uint16_t remotePortStart;  /**< start of the port number range of the remote host */
134
    uint16_t remotePortStart;  /**< start of the port number range of the remote host */
 Lines 144-151    Link Here 
144
     * parameters, false otherwise.
166
     * parameters, false otherwise.
145
     */
167
     */
146
    bool Matches (Direction direction,
168
    bool Matches (Direction direction,
147
		  Ipv4Address remoteAddress, 
169
		  Ipv4Address remoteAddress,
148
		  Ipv4Address localAddress, 
170
		  Ipv4Address localAddress,
171
		  uint16_t remotePort,
172
		  uint16_t localPort,
173
		  uint8_t typeOfService);
174
175
    /** 
176
     * 
177
     * \param direction 
178
     * \param remoteAddress 
179
     * \param localAddress 
180
     * \param remotePort 
181
     * \param localPort 
182
     * \param typeOfService 
183
     * 
184
     * \return true if any PacketFilter in the TFT matches with the
185
     * parameters, false otherwise.
186
     */
187
    bool Matches (Direction direction,
188
		  Ipv6Address remoteAddress,
189
		  Ipv6Address localAddress,
149
		  uint16_t remotePort,
190
		  uint16_t remotePort,
150
		  uint16_t localPort,
191
		  uint16_t localPort,
151
		  uint8_t typeOfService);
192
		  uint8_t typeOfService);
(-)a/src/lte/model/lte-enb-net-device.cc (-1 / +2 lines)
 Lines 43-48    Link Here 
43
#include <ns3/lte-anr.h>
43
#include <ns3/lte-anr.h>
44
#include <ns3/lte-ffr-algorithm.h>
44
#include <ns3/lte-ffr-algorithm.h>
45
#include <ns3/ipv4-l3-protocol.h>
45
#include <ns3/ipv4-l3-protocol.h>
46
#include <ns3/ipv6-l3-protocol.h>
46
#include <ns3/abort.h>
47
#include <ns3/abort.h>
47
#include <ns3/log.h>
48
#include <ns3/log.h>
48
#include <ns3/lte-enb-component-carrier-manager.h>
49
#include <ns3/lte-enb-component-carrier-manager.h>
 Lines 387-393    Link Here 
387
LteEnbNetDevice::Send (Ptr<Packet> packet, const Address& dest, uint16_t protocolNumber)
388
LteEnbNetDevice::Send (Ptr<Packet> packet, const Address& dest, uint16_t protocolNumber)
388
{
389
{
389
  NS_LOG_FUNCTION (this << packet   << dest << protocolNumber);
390
  NS_LOG_FUNCTION (this << packet   << dest << protocolNumber);
390
  NS_ASSERT_MSG (protocolNumber == Ipv4L3Protocol::PROT_NUMBER, "unsupported protocol " << protocolNumber << ", only IPv4 is supported");
391
  NS_ASSERT_MSG (protocolNumber == Ipv4L3Protocol::PROT_NUMBER || protocolNumber == Ipv6L3Protocol::PROT_NUMBER, "unsupported protocol " << protocolNumber << ", only IPv4/IPv6 is supported");
391
  return m_rrc->SendData (packet);
392
  return m_rrc->SendData (packet);
392
}
393
}
393
394
(-)a/src/lte/model/lte-net-device.cc (-1 / +10 lines)
 Lines 32-39    Link Here 
32
#include "ns3/enum.h"
32
#include "ns3/enum.h"
33
#include "lte-amc.h"
33
#include "lte-amc.h"
34
#include "ns3/ipv4-header.h"
34
#include "ns3/ipv4-header.h"
35
#include "ns3/ipv6-header.h"
35
#include <ns3/lte-radio-bearer-tag.h>
36
#include <ns3/lte-radio-bearer-tag.h>
36
#include <ns3/ipv4-l3-protocol.h>
37
#include <ns3/ipv4-l3-protocol.h>
38
#include <ns3/ipv6-l3-protocol.h>
37
#include <ns3/log.h>
39
#include <ns3/log.h>
38
40
39
namespace ns3 {
41
namespace ns3 {
 Lines 283-289    Link Here 
283
LteNetDevice::Receive (Ptr<Packet> p)
285
LteNetDevice::Receive (Ptr<Packet> p)
284
{
286
{
285
  NS_LOG_FUNCTION (this << p);
287
  NS_LOG_FUNCTION (this << p);
286
  m_rxCallback (this, p, Ipv4L3Protocol::PROT_NUMBER, Address ());
288
  uint8_t ipType;
289
  Ptr<Packet> pCopy = p->Copy ();
290
  pCopy->CopyData (&ipType, 1);
291
  ipType=(ipType>>4) & 0x0f;
292
  if (ipType == 0x04)
293
    m_rxCallback (this, p, Ipv4L3Protocol::PROT_NUMBER, Address ());
294
  else
295
    m_rxCallback (this, p, Ipv6L3Protocol::PROT_NUMBER, Address ());
287
}
296
}
288
297
289
298
(-)a/src/lte/model/lte-ue-net-device.cc (-2 / +5 lines)
 Lines 39-49    Link Here 
39
#include "lte-ue-mac.h"
39
#include "lte-ue-mac.h"
40
#include "lte-ue-rrc.h"
40
#include "lte-ue-rrc.h"
41
#include "ns3/ipv4-header.h"
41
#include "ns3/ipv4-header.h"
42
#include "ns3/ipv6-header.h"
42
#include "ns3/ipv4.h"
43
#include "ns3/ipv4.h"
44
#include "ns3/ipv6.h"
43
#include "lte-amc.h"
45
#include "lte-amc.h"
44
#include "lte-ue-phy.h"
46
#include "lte-ue-phy.h"
45
#include "epc-ue-nas.h"
47
#include "epc-ue-nas.h"
46
#include <ns3/ipv4-l3-protocol.h>
48
#include <ns3/ipv4-l3-protocol.h>
49
#include <ns3/ipv6-l3-protocol.h>
47
#include <ns3/log.h>
50
#include <ns3/log.h>
48
#include "epc-tft.h"
51
#include "epc-tft.h"
49
#include <ns3/lte-ue-component-carrier-manager.h>
52
#include <ns3/lte-ue-component-carrier-manager.h>
 Lines 284-292    Link Here 
284
LteUeNetDevice::Send (Ptr<Packet> packet, const Address& dest, uint16_t protocolNumber)
287
LteUeNetDevice::Send (Ptr<Packet> packet, const Address& dest, uint16_t protocolNumber)
285
{
288
{
286
  NS_LOG_FUNCTION (this << dest << protocolNumber);
289
  NS_LOG_FUNCTION (this << dest << protocolNumber);
287
  if (protocolNumber != Ipv4L3Protocol::PROT_NUMBER)
290
  if (protocolNumber != Ipv4L3Protocol::PROT_NUMBER && protocolNumber != Ipv6L3Protocol::PROT_NUMBER)
288
    {
291
    {
289
      NS_LOG_INFO ("unsupported protocol " << protocolNumber << ", only IPv4 is supported");
292
      NS_LOG_INFO ("unsupported protocol " << protocolNumber << ", only IPv4 and IPv6 are supported");
290
      return true;
293
      return true;
291
    }  
294
    }  
292
  return m_nas->Send (packet);
295
  return m_nas->Send (packet);
(-)a/src/lte/test/lte-test-ipv6-routing.cc (+414 lines)
Line 0    Link Here 
1
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2
/*
3
 * Copyright (c) 2017 Jadavpur University, India
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: Manoj Kumar Rana <manoj24.rana@gmail.com>
19
 */
20
21
#include "ns3/lte-helper.h"
22
#include "ns3/epc-helper.h"
23
#include "ns3/core-module.h"
24
#include "ns3/network-module.h"
25
#include "ns3/ipv4-global-routing-helper.h"
26
#include "ns3/ipv6-static-routing.h"
27
#include "ns3/internet-module.h"
28
#include "ns3/mobility-module.h"
29
#include "ns3/lte-module.h"
30
#include "ns3/applications-module.h"
31
#include "ns3/point-to-point-helper.h"
32
#include "ns3/config-store.h"
33
#include <algorithm>
34
35
36
/* *
37
   * Scenario:  3 UEs, 2 ENBs, 1 Remote Host, UE0<-->ENB0, UE1<-->ENB0, UE2<-->ENB1
38
                Servers: UE1, UE2, Remote Host
39
                Client: UE0 (3 clients)
40
                UDP Echo Packets transmitted between client and server
41
42
   * Pass criteria: 1) Every UDP Echo Request and Reply messages sent and received respectively
43
                       at UE0 must be matched by their UID, source address, destination address,
44
                       source port and destination port
45
                    2) Every request reply must follow proper route (e.g. In case of UE0->UE1,
46
                       packet must travel this route: UE0->ENB0->PGW->ENB1->UE1->ENB1->PGW->ENB0->UE0)
47
                    3) The above check also ensures no redundancy of the followed route for a packet
48
* */
49
50
51
52
using namespace ns3;
53
54
class LteIpv6RoutingTestCase : public TestCase
55
{
56
public:
57
  LteIpv6RoutingTestCase ();
58
  virtual ~LteIpv6RoutingTestCase ();
59
60
  /**
61
   * \brief Initialize testing parameters.
62
   */
63
  void Checker ();
64
65
  /**
66
   * \brief sent Packets from client's IPv6 interface.
67
   * \param: p packet
68
   * \param: ipv6 Ipv6 object
69
   * \param: interface Ipv6interface from which the packet is transmitted
70
   */
71
  void SentAtClient (Ptr<const Packet> p, Ptr<Ipv6> ipv6, uint32_t interface);
72
73
  /**
74
   * \brief Received Packets at client's IPv6 interface.
75
   * \param: p packet
76
   * \param: ipv6 Ipv6 object
77
   * \param: interface Ipv6interface at which the packet is received
78
   */
79
  void ReceivedAtClient (Ptr<const Packet> p, Ptr<Ipv6> ipv6, uint32_t interface);
80
81
  /**
82
   * \brief Received Packet at pgw from enb.
83
   * \param: p packet
84
   */
85
  void EnbToPgw (Ptr<Packet> p);
86
87
  /**
88
   * \brief Received Packet at pgw from enb.
89
   * \param: p packet
90
   */
91
  void TunToPgw (Ptr<Packet> p);
92
93
  /**
94
   * \brief search uid in a list and delete if found.
95
   * \param: l list
96
   * \param: item a uid
97
   */
98
  bool SearchAndDelete (std::list<uint64_t> *l, uint64_t item);
99
100
101
private:
102
  virtual void DoRun (void);
103
  Ipv6InterfaceContainer ueIpIface; //IPv6 interface container for ue
104
  Ipv6Address remoteHostAddr; //remote host address
105
  std::list<uint64_t> * EnbPgw; //list of uids of packets received at pgw from enb
106
  std::list<uint64_t> * TunPgw; //list of uids of packets received at pgw from tunnel net device
107
108
  std::list<Ptr<Packet> > ClientSent; //list of sent packets from client
109
  std::list<Ptr<Packet> > ClientReceived; //list of received packets at client
110
};
111
112
113
LteIpv6RoutingTestCase::LteIpv6RoutingTestCase ()
114
  : TestCase ("Test IPv6 Routing at LTE")
115
{
116
  EnbPgw = new std::list<uint64_t>;
117
  TunPgw = new std::list<uint64_t>;
118
}
119
120
LteIpv6RoutingTestCase::~LteIpv6RoutingTestCase ()
121
{
122
}
123
124
void LteIpv6RoutingTestCase::SentAtClient (Ptr<const Packet> p, Ptr<Ipv6> ipv6, uint32_t interface)
125
{
126
  Ipv6Header ipv6Header;
127
  p->PeekHeader (ipv6Header);
128
  if (ipv6Header.GetNextHeader () == UdpL4Protocol::PROT_NUMBER)
129
    {
130
      ClientSent.push_back (p->Copy ());
131
    }
132
}
133
134
void LteIpv6RoutingTestCase::ReceivedAtClient (Ptr<const Packet> p, Ptr<Ipv6> ipv6, uint32_t interface)
135
{
136
  Ipv6Header ipv6Header;
137
  p->PeekHeader (ipv6Header);
138
  if (ipv6Header.GetNextHeader () == UdpL4Protocol::PROT_NUMBER)
139
    {
140
      ClientReceived.push_back (p->Copy ());
141
    }
142
}
143
144
void LteIpv6RoutingTestCase::EnbToPgw (Ptr<Packet> p)
145
{
146
  Ipv6Header ipv6Header;
147
  p->PeekHeader (ipv6Header);
148
  if (ipv6Header.GetNextHeader () == UdpL4Protocol::PROT_NUMBER)
149
    {
150
      EnbPgw->push_back (p->GetUid ());
151
    }
152
}
153
154
void LteIpv6RoutingTestCase::TunToPgw (Ptr<Packet> p)
155
{
156
  Ipv6Header ipv6Header;
157
  p->PeekHeader (ipv6Header);
158
  if (ipv6Header.GetNextHeader () == UdpL4Protocol::PROT_NUMBER)
159
    {
160
      TunPgw->push_back (p->GetUid ());
161
    }
162
}
163
164
bool LteIpv6RoutingTestCase::SearchAndDelete (std::list<uint64_t> *l, uint64_t item)
165
{
166
  bool b = false;
167
  std::list<uint64_t>::iterator it;
168
  it = std::find (l->begin (), l->end (), item);
169
  if (it != l->end ())
170
    {
171
      b = true;
172
      l->erase (it);
173
    }
174
  return b;
175
}
176
177
void LteIpv6RoutingTestCase::Checker ()
178
{
179
  bool b = false;
180
  bool check = true;
181
  //Extract each received reply packet of the client
182
  for (std::list<Ptr<Packet> >::iterator it1 = ClientReceived.begin (); it1 != ClientReceived.end (); it1++)
183
    {
184
      Ipv6Header ipv6header1;
185
      UdpHeader udpHeader1;
186
      Ptr<Packet> p1 = (*it1)->Copy ();
187
      p1->RemoveHeader (ipv6header1);
188
      uint64_t uid = p1->GetUid ();
189
      p1->RemoveHeader (udpHeader1);
190
      //Search each packet in list of sent request packet of the client
191
      for (std::list<Ptr<Packet> >::iterator it2 = ClientSent.begin (); it2 != ClientSent.end (); it2++)
192
        {
193
          Ptr<Packet> p2 = (*it2)->Copy ();
194
          Ipv6Header ipv6header2;
195
          p2->RemoveHeader (ipv6header2);
196
          Ipv6Address sorceAddress = ipv6header2.GetSourceAddress ();
197
          Ipv6Address destinationAddress = ipv6header2.GetDestinationAddress ();
198
          UdpHeader udpHeader2;
199
          p2->RemoveHeader (udpHeader2);
200
          uint16_t sourcePort;
201
          uint16_t destinationPort;
202
          sourcePort = udpHeader2.GetSourcePort ();
203
          destinationPort = udpHeader2.GetDestinationPort ();
204
          //Check whether the uids, addresses and ports match
205
          if ((p2->GetUid () == p1->GetUid ()) && sorceAddress.IsEqual (ipv6header1.GetDestinationAddress ()) && destinationAddress.IsEqual (ipv6header1.GetSourceAddress ()) && sourcePort == udpHeader1.GetDestinationPort () && destinationPort == udpHeader1.GetSourcePort ())
206
            {
207
              b = true;
208
              break;
209
            }
210
        }
211
      check &= b;
212
      if (ipv6header1.GetSourceAddress ().IsEqual (remoteHostAddr))
213
        {
214
          check &= (SearchAndDelete (EnbPgw, uid) && SearchAndDelete (TunPgw, uid));
215
        }
216
      else
217
        {
218
          check &= (SearchAndDelete (EnbPgw, uid) && SearchAndDelete (TunPgw, uid) && SearchAndDelete (EnbPgw, uid) && SearchAndDelete (TunPgw, uid));
219
        }
220
221
      b = false;
222
    }
223
224
  NS_TEST_ASSERT_MSG_EQ (check, true, "Failure Happens IPv6 routing of LENA");
225
  NS_TEST_ASSERT_MSG_EQ (ClientSent.size (), ClientReceived.size (), "No. of Request and Reply messages mismatch");
226
  NS_TEST_ASSERT_MSG_EQ (EnbPgw->size (), 0, "Route is not Redundant in Lte IPv6 test");
227
  NS_TEST_ASSERT_MSG_EQ (TunPgw->size (), 0, "Route is not Redundant in Lte IPv6 test");
228
229
}
230
231
void
232
LteIpv6RoutingTestCase::DoRun (void)
233
{
234
  double distance = 60.0;
235
236
  Ptr<LteHelper> lteHelper = CreateObject<LteHelper> ();
237
  Ptr<PointToPointEpcHelper>  epcHelper = CreateObject<PointToPointEpcHelper> ();
238
  lteHelper->SetEpcHelper (epcHelper);
239
240
  ConfigStore inputConfig;
241
  inputConfig.ConfigureDefaults ();
242
243
  Ptr<Node> pgw = epcHelper->GetPgwNode ();
244
245
  // Create a single RemoteHost
246
  NodeContainer remoteHostContainer;
247
  remoteHostContainer.Create (1);
248
  Ptr<Node> remoteHost = remoteHostContainer.Get (0);
249
  InternetStackHelper internet;
250
  internet.Install (remoteHostContainer);
251
252
  // Create the Internet
253
  PointToPointHelper p2ph;
254
  p2ph.SetDeviceAttribute ("DataRate", DataRateValue (DataRate ("100Gb/s")));
255
  p2ph.SetDeviceAttribute ("Mtu", UintegerValue (1500));
256
  p2ph.SetChannelAttribute ("Delay", TimeValue (Seconds (0.010)));
257
  NetDeviceContainer internetDevices = p2ph.Install (pgw, remoteHost);
258
259
  NodeContainer ueNodes;
260
  NodeContainer enbNodes;
261
  enbNodes.Create (2);
262
  ueNodes.Create (3);
263
264
  // Install Mobility Model
265
  Ptr<ListPositionAllocator> positionAlloc1 = CreateObject<ListPositionAllocator> ();
266
  Ptr<ListPositionAllocator> positionAlloc2 = CreateObject<ListPositionAllocator> ();
267
268
  positionAlloc1->Add (Vector (distance * 0, 0, 0));
269
  positionAlloc1->Add (Vector (distance * 0 + 5, 0, 0));
270
  positionAlloc1->Add (Vector (distance * 1, 0, 0));
271
272
  positionAlloc2->Add (Vector (distance * 0, 0, 0));
273
  positionAlloc2->Add (Vector (distance * 1, 0, 0));
274
275
  MobilityHelper mobility;
276
  mobility.SetMobilityModel ("ns3::ConstantPositionMobilityModel");
277
  mobility.SetPositionAllocator (positionAlloc1);
278
  mobility.Install (ueNodes);
279
280
  mobility.SetPositionAllocator (positionAlloc2);
281
  mobility.Install (enbNodes);
282
283
  // Install the IP stack on the UEs
284
  internet.Install (ueNodes);
285
286
  // Install LTE Devices to the nodes
287
  NetDeviceContainer enbLteDevs = lteHelper->InstallEnbDevice (enbNodes);
288
  NetDeviceContainer ueLteDevs = lteHelper->InstallUeDevice (ueNodes);
289
290
291
292
  for (NetDeviceContainer::Iterator it = ueLteDevs.Begin (); it != ueLteDevs.End (); ++it)
293
    {
294
      (*it)->SetAddress (Mac48Address::Allocate ());
295
    }
296
297
  // Assign IP address to UEs, and install applications
298
  ueIpIface = epcHelper->AssignUeIpv6Address (NetDeviceContainer (ueLteDevs));
299
300
301
  Ipv6StaticRoutingHelper ipv6RoutingHelper;
302
303
  for (uint32_t u = 0; u < ueNodes.GetN (); ++u)
304
    {
305
      Ptr<Node> ueNode = ueNodes.Get (u);
306
      // Set the default gateway for the UE
307
      Ptr<Ipv6StaticRouting> ueStaticRouting = ipv6RoutingHelper.GetStaticRouting (ueNode->GetObject<Ipv6> ());
308
      ueStaticRouting->SetDefaultRoute (epcHelper->GetUeDefaultGatewayAddress6 (), 1);
309
    }
310
311
312
  // Attach two UEs at first eNodeB and one UE at second eNodeB
313
  lteHelper->Attach (ueLteDevs.Get (0), enbLteDevs.Get (0));
314
  lteHelper->Attach (ueLteDevs.Get (1), enbLteDevs.Get (0));
315
  lteHelper->Attach (ueLteDevs.Get (2), enbLteDevs.Get (1));
316
317
318
  Ipv6AddressHelper ipv6h;
319
  ipv6h.SetBase (Ipv6Address ("6001:db80::"), Ipv6Prefix (64));
320
  Ipv6InterfaceContainer internetIpIfaces = ipv6h.Assign (internetDevices);
321
322
  internetIpIfaces.SetForwarding (0, true);
323
  internetIpIfaces.SetDefaultRouteInAllNodes (0);
324
325
326
  Ptr<Ipv6StaticRouting> remoteHostStaticRouting = ipv6RoutingHelper.GetStaticRouting (remoteHost->GetObject<Ipv6> ());
327
  remoteHostStaticRouting->AddNetworkRouteTo ("7777:f00d::", Ipv6Prefix (64), internetIpIfaces.GetAddress (0, 1), 1, 0);
328
329
330
  // interface 0 is localhost, 1 is the p2p device
331
  remoteHostAddr = internetIpIfaces.GetAddress (1, 1);
332
333
334
  // Install and start applications on UEs and remote host
335
  UdpEchoServerHelper echoServer1 (10);
336
  UdpEchoServerHelper echoServer2 (11);
337
  UdpEchoServerHelper echoServer3 (12);
338
339
  ApplicationContainer serverApps = echoServer1.Install (remoteHost);
340
  serverApps.Add (echoServer2.Install (ueNodes.Get (1)));
341
  serverApps.Add (echoServer3.Install (ueNodes.Get (2)));
342
343
344
  serverApps.Start (Seconds (4.0));
345
  serverApps.Stop (Seconds (12.0));
346
347
348
  UdpEchoClientHelper echoClient1 (remoteHostAddr, 10);
349
  UdpEchoClientHelper echoClient2 (ueIpIface.GetAddress (1,1), 11);
350
  UdpEchoClientHelper echoClient3 (ueIpIface.GetAddress (2,1), 12);
351
352
  echoClient1.SetAttribute ("MaxPackets", UintegerValue (1000));
353
  echoClient1.SetAttribute ("Interval", TimeValue (Seconds (0.2)));
354
  echoClient1.SetAttribute ("PacketSize", UintegerValue (1024));
355
356
  echoClient2.SetAttribute ("MaxPackets", UintegerValue (1000));
357
  echoClient2.SetAttribute ("Interval", TimeValue (Seconds (0.2)));
358
  echoClient2.SetAttribute ("PacketSize", UintegerValue (1024));
359
360
  echoClient3.SetAttribute ("MaxPackets", UintegerValue (1000));
361
  echoClient3.SetAttribute ("Interval", TimeValue (Seconds (0.2)));
362
  echoClient3.SetAttribute ("PacketSize", UintegerValue (1024));
363
364
  ApplicationContainer clientApps1 = echoClient1.Install (ueNodes.Get (0));
365
  ApplicationContainer clientApps2 = echoClient2.Install (ueNodes.Get (0));
366
  ApplicationContainer clientApps3 = echoClient3.Install (ueNodes.Get (0));
367
368
  clientApps1.Start (Seconds (4.0));
369
  clientApps1.Stop (Seconds (6.0));
370
371
  clientApps2.Start (Seconds (6.1));
372
  clientApps2.Stop (Seconds (8.0));
373
374
  clientApps3.Start (Seconds (8.1));
375
  clientApps3.Stop (Seconds (10.0));
376
377
  EnbPgw = new std::list<uint64_t>;
378
  TunPgw = new std::list<uint64_t>;
379
380
  //Set Cllback for Client Sent and Received packets
381
  Ptr<Ipv6L3Protocol> ipl3 = (ueNodes.Get (0))->GetObject<Ipv6L3Protocol> ();
382
  ipl3->TraceConnectWithoutContext ("Tx", MakeCallback (&LteIpv6RoutingTestCase::SentAtClient, this));
383
  ipl3->TraceConnectWithoutContext ("Rx", MakeCallback (&LteIpv6RoutingTestCase::ReceivedAtClient, this));
384
385
  //Set Callback at SgwPgWApplication of epc to get the packets from enb and from tunnel net device
386
  Ptr<Application> apppgw = pgw->GetApplication (0);
387
  apppgw->TraceConnectWithoutContext ("RxfromS1u", MakeCallback (&LteIpv6RoutingTestCase::EnbToPgw, this));
388
  apppgw->TraceConnectWithoutContext ("RxfromTun", MakeCallback (&LteIpv6RoutingTestCase::TunToPgw, this));
389
390
  Simulator::Schedule (Time (Seconds (12.0)), &LteIpv6RoutingTestCase::Checker, this);
391
392
  Simulator::Stop (Seconds (14));
393
  Simulator::Run ();
394
395
  Simulator::Destroy ();
396
}
397
398
399
/**
400
 * \brief test suite 1
401
 */
402
class LteIpv6RoutingTestSuite : public TestSuite
403
{
404
public:
405
  LteIpv6RoutingTestSuite ();
406
};
407
408
LteIpv6RoutingTestSuite::LteIpv6RoutingTestSuite ()
409
  : TestSuite ("lte-ipv6-routing-test", UNIT)
410
{
411
  AddTestCase (new LteIpv6RoutingTestCase, TestCase::QUICK);
412
}
413
414
static LteIpv6RoutingTestSuite lteipv6testsuite;
(-)a/src/lte/wscript (+1 lines)
 Lines 191-196    Link Here 
191
        'test/lte-simple-spectrum-phy.cc',
191
        'test/lte-simple-spectrum-phy.cc',
192
        'test/lte-test-carrier-aggregation.cc',
192
        'test/lte-test-carrier-aggregation.cc',
193
        'test/lte-test-aggregation-throughput-scale.cc',
193
        'test/lte-test-aggregation-throughput-scale.cc',
194
        'test/lte-test-ipv6-routing.cc'
194
        ]
195
        ]
195
196
196
    headers = bld(features='ns3header')
197
    headers = bld(features='ns3header')

Return to bug 2312