LEFT | RIGHT |
1 /* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */ | 1 /* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */ |
2 /* | 2 /* |
3 * Copyright (c) 2011-2013 Centre Tecnologic de Telecomunicacions de Catalunya (
CTTC) | 3 * Copyright (c) 2011-2013 Centre Tecnologic de Telecomunicacions de Catalunya (
CTTC) |
4 * | 4 * |
5 * This program is free software; you can redistribute it and/or modify | 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 | 6 * it under the terms of the GNU General Public License version 2 as |
7 * published by the Free Software Foundation; | 7 * published by the Free Software Foundation; |
8 * | 8 * |
9 * This program is distributed in the hope that it will be useful, | 9 * This program is distributed in the hope that it will be useful, |
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 * GNU General Public License for more details. | 12 * GNU General Public License for more details. |
13 * | 13 * |
14 * You should have received a copy of the GNU General Public License | 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 | 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 | 16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
17 * | 17 * |
18 * Author: Jaume Nin <jnin@cttc.es> | 18 * Author: Jaume Nin <jnin@cttc.es> |
19 * Nicola Baldo <nbaldo@cttc.es> | 19 * Nicola Baldo <nbaldo@cttc.es> |
20 * Manuel Requena <manuel.requena@cttc.es> | 20 * Manuel Requena <manuel.requena@cttc.es> |
21 */ | 21 */ |
22 | 22 |
23 #include <ns3/emu-epc-helper.h> | 23 #include <ns3/emu-epc-helper.h> |
24 #include <ns3/log.h> | 24 #include <ns3/log.h> |
25 #include <ns3/inet-socket-address.h> | 25 #include <ns3/inet-socket-address.h> |
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> |
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> |
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> |
| 48 #include <ns3/icmpv6-l4-protocol.h> |
44 | 49 |
45 #include <iomanip> | 50 #include <iomanip> |
46 #include <iostream> | 51 #include <iostream> |
47 | 52 |
48 namespace ns3 { | 53 namespace ns3 { |
49 | 54 |
50 NS_LOG_COMPONENT_DEFINE ("EmuEpcHelper"); | 55 NS_LOG_COMPONENT_DEFINE ("EmuEpcHelper"); |
51 | 56 |
52 NS_OBJECT_ENSURE_REGISTERED (EmuEpcHelper); | 57 NS_OBJECT_ENSURE_REGISTERED (EmuEpcHelper); |
53 | 58 |
54 | 59 |
55 EmuEpcHelper::EmuEpcHelper ()· | 60 EmuEpcHelper::EmuEpcHelper ()· |
56 : m_gtpuUdpPort (2152) // fixed by the standard | 61 : m_gtpuUdpPort (2152) // fixed by the standard |
57 { | 62 { |
58 NS_LOG_FUNCTION (this); | 63 NS_LOG_FUNCTION (this); |
59 | 64 // To access the attribute value within the constructor |
| 65 ObjectBase::ConstructSelf (AttributeConstructionList ()); |
60 } | 66 } |
61 | 67 |
62 EmuEpcHelper::~EmuEpcHelper () | 68 EmuEpcHelper::~EmuEpcHelper () |
63 { | 69 { |
64 NS_LOG_FUNCTION (this); | 70 NS_LOG_FUNCTION (this); |
65 } | 71 } |
66 | 72 |
67 TypeId | 73 TypeId |
68 EmuEpcHelper::GetTypeId (void) | 74 EmuEpcHelper::GetTypeId (void) |
69 { | 75 { |
(...skipping 18 matching lines...) Expand all Loading... |
88 MakeStringChecker ()) | 94 MakeStringChecker ()) |
89 .AddAttribute ("EnbMacAddressBase",· | 95 .AddAttribute ("EnbMacAddressBase",· |
90 "First 5 bytes of the Enb MAC address base", | 96 "First 5 bytes of the Enb MAC address base", |
91 StringValue ("00:00:00:eb:00"), | 97 StringValue ("00:00:00:eb:00"), |
92 MakeStringAccessor (&EmuEpcHelper::m_enbMacAddressBase), | 98 MakeStringAccessor (&EmuEpcHelper::m_enbMacAddressBase), |
93 MakeStringChecker ()) | 99 MakeStringChecker ()) |
94 ; | 100 ; |
95 return tid; | 101 return tid; |
96 } | 102 } |
97 | 103 |
| 104 TypeId |
| 105 EmuEpcHelper::GetInstanceTypeId () const |
| 106 { |
| 107 return GetTypeId (); |
| 108 } |
| 109 |
98 void | 110 void |
99 EmuEpcHelper::DoInitialize () | 111 EmuEpcHelper::DoInitialize () |
100 { | 112 { |
101 NS_LOG_LOGIC (this);··· | 113 NS_LOG_LOGIC (this);··· |
102 | 114 |
103 | |
104 // we use a /8 net for all UEs | 115 // we use a /8 net for all UEs |
105 m_ueAddressHelper.SetBase ("7.0.0.0", "255.0.0.0"); | 116 m_uePgwAddressHelper.SetBase ("7.0.0.0", "255.0.0.0"); |
106 · | 117 |
| 118 // we use a /64 IPv6 net all UEs |
| 119 m_uePgwAddressHelper6.SetBase ("7777:f00d::", Ipv6Prefix (64)); |
| 120 |
| 121 |
107 // create SgwPgwNode | 122 // create SgwPgwNode |
108 m_sgwPgw = CreateObject<Node> (); | 123 m_sgwPgw = CreateObject<Node> (); |
109 InternetStackHelper internet; | 124 InternetStackHelper internet; |
110 internet.SetIpv4StackInstall (true); | |
111 internet.Install (m_sgwPgw); | 125 internet.Install (m_sgwPgw); |
| 126 |
| 127 // The Tun device resides in different 64 bit subnet. |
| 128 // We must create an unique route to tun device for all the packets destined |
| 129 // to all 64 bit IPv6 prefixes of UEs, based by the unique 48 bit network pref
ix of this EPC network |
| 130 Ipv6StaticRoutingHelper ipv6RoutingHelper; |
| 131 Ptr<Ipv6StaticRouting> pgwStaticRouting = ipv6RoutingHelper.GetStaticRouting (
m_sgwPgw->GetObject<Ipv6> ()); |
| 132 pgwStaticRouting->AddNetworkRouteTo ("7777:f00d::", Ipv6Prefix (64), Ipv6Addre
ss ("::"), 1, 0); |
112 ·· | 133 ·· |
113 // create S1-U socket | 134 // create S1-U socket |
114 Ptr<Socket> sgwPgwS1uSocket = Socket::CreateSocket (m_sgwPgw, TypeId::LookupBy
Name ("ns3::UdpSocketFactory")); | 135 Ptr<Socket> sgwPgwS1uSocket = Socket::CreateSocket (m_sgwPgw, TypeId::LookupBy
Name ("ns3::UdpSocketFactory")); |
115 int retval = sgwPgwS1uSocket->Bind (InetSocketAddress (Ipv4Address::GetAny (),
m_gtpuUdpPort)); | 136 int retval = sgwPgwS1uSocket->Bind (InetSocketAddress (Ipv4Address::GetAny (),
m_gtpuUdpPort)); |
116 NS_ASSERT (retval == 0); | 137 NS_ASSERT (retval == 0); |
117 (void)retval; //make compiler happy | 138 (void)retval; //make compiler happy |
118 | 139 |
119 // create TUN device implementing tunneling of user data over GTP-U/UDP/IP· | 140 // create TUN device containg IPv4 address and implementing tunneling of user
data over GTP-U/UDP/IP· |
120 m_tunDevice = CreateObject<VirtualNetDevice> (); | 141 m_tunDevice = CreateObject<VirtualNetDevice> (); |
| 142 |
121 // allow jumbo packets | 143 // allow jumbo packets |
122 m_tunDevice->SetAttribute ("Mtu", UintegerValue (30000)); | 144 m_tunDevice->SetAttribute ("Mtu", UintegerValue (30000)); |
123 | 145 |
124 // yes we need this | 146 // yes we need this |
125 m_tunDevice->SetAddress (Mac48Address::Allocate ());· | 147 m_tunDevice->SetAddress (Mac48Address::Allocate ());· |
126 | 148 |
127 m_sgwPgw->AddDevice (m_tunDevice); | 149 m_sgwPgw->AddDevice (m_tunDevice); |
128 NetDeviceContainer tunDeviceContainer; | 150 NetDeviceContainer tunDeviceContainer; |
129 tunDeviceContainer.Add (m_tunDevice); | 151 tunDeviceContainer.Add (m_tunDevice); |
130 ·· | 152 ·· |
131 // the TUN device is on the same subnet as the UEs, so when a packet | 153 // the TUN device is on the same subnet as the UEs, so when a packet |
132 // addressed to an UE arrives at the intenet to the WAN interface of | 154 // addressed to an UE IPv4 address arrives at the intenet to the WAN interface
of |
133 // the PGW it will be forwarded to the TUN device.· | 155 // the PGW it will be forwarded to the TUN device.· |
134 Ipv4InterfaceContainer tunDeviceIpv4IfContainer = m_ueAddressHelper.Assign (tu
nDeviceContainer);·· | 156 Ipv4InterfaceContainer tunDeviceIpv4IfContainer = AssignUeIpv4Address (tunDevi
ceContainer);· |
| 157 |
| 158 // the TUN device for IPv6 address is on the different subnet as the |
| 159 // UEs, it will forward the UE packets as we have inserted the route |
| 160 // for all UEs at the time of assigning UE addresses |
| 161 Ipv6InterfaceContainer tunDeviceIpv6IfContainer = AssignUeIpv6Address (tunDevi
ceContainer); |
| 162 |
| 163 //Set Forwarding |
| 164 tunDeviceIpv6IfContainer.SetForwarding (0,true); |
| 165 tunDeviceIpv6IfContainer.SetDefaultRouteInAllNodes (0); |
| 166 |
135 | 167 |
136 // create EpcSgwPgwApplication | 168 // create EpcSgwPgwApplication |
137 m_sgwPgwApp = CreateObject<EpcSgwPgwApplication> (m_tunDevice, sgwPgwS1uSocket
); | 169 m_sgwPgwApp = CreateObject<EpcSgwPgwApplication> (m_tunDevice, sgwPgwS1uSocket
); |
138 m_sgwPgw->AddApplication (m_sgwPgwApp); | 170 m_sgwPgw->AddApplication (m_sgwPgwApp); |
139 ·· | 171 ·· |
140 // connect SgwPgwApplication and virtual net device for tunneling | 172 // connect SgwPgwApplication and virtual net device for tunneling |
141 m_tunDevice->SetSendCallback (MakeCallback (&EpcSgwPgwApplication::RecvFromTun
Device, m_sgwPgwApp)); | 173 m_tunDevice->SetSendCallback (MakeCallback (&EpcSgwPgwApplication::RecvFromTun
Device, m_sgwPgwApp)); |
| 174 |
142 | 175 |
143 // Create MME and connect with SGW via S11 interface | 176 // Create MME and connect with SGW via S11 interface |
144 m_mme = CreateObject<EpcMme> (); | 177 m_mme = CreateObject<EpcMme> (); |
145 m_mme->SetS11SapSgw (m_sgwPgwApp->GetS11SapSgw ()); | 178 m_mme->SetS11SapSgw (m_sgwPgwApp->GetS11SapSgw ()); |
146 m_sgwPgwApp->SetS11SapMme (m_mme->GetS11SapMme ()); | 179 m_sgwPgwApp->SetS11SapMme (m_mme->GetS11SapMme ()); |
147 | 180 |
148 // Create EmuFdNetDevice for SGW | 181 // Create EmuFdNetDevice for SGW |
149 EmuFdNetDeviceHelper emu; | 182 EmuFdNetDeviceHelper emu; |
150 NS_LOG_LOGIC ("SGW device: " << m_sgwDeviceName); | 183 NS_LOG_LOGIC ("SGW device: " << m_sgwDeviceName); |
151 emu.SetDeviceName (m_sgwDeviceName); | 184 emu.SetDeviceName (m_sgwDeviceName); |
(...skipping 24 matching lines...) Expand all Loading... |
176 | 209 |
177 void | 210 void |
178 EmuEpcHelper::AddEnb (Ptr<Node> enb, Ptr<NetDevice> lteEnbNetDevice, uint16_t ce
llId) | 211 EmuEpcHelper::AddEnb (Ptr<Node> enb, Ptr<NetDevice> lteEnbNetDevice, uint16_t ce
llId) |
179 { | 212 { |
180 NS_LOG_FUNCTION (this << enb << lteEnbNetDevice << cellId); | 213 NS_LOG_FUNCTION (this << enb << lteEnbNetDevice << cellId); |
181 | 214 |
182 Initialize (); | 215 Initialize (); |
183 | 216 |
184 NS_ASSERT (enb == lteEnbNetDevice->GetNode ());·· | 217 NS_ASSERT (enb == lteEnbNetDevice->GetNode ());·· |
185 | 218 |
186 // add an IPv4 stack to the previously created eNB | 219 // add an Internet stack to the previously created eNB |
187 InternetStackHelper internet; | 220 InternetStackHelper internet; |
188 internet.Install (enb); | 221 internet.Install (enb); |
189 NS_LOG_LOGIC ("number of Ipv4 ifaces of the eNB after node creation: " << enb-
>GetObject<Ipv4> ()->GetNInterfaces ()); | 222 NS_LOG_LOGIC ("number of Ipv4 ifaces of the eNB after node creation: " << enb-
>GetObject<Ipv4> ()->GetNInterfaces ()); |
190 | 223 |
191 | 224 |
192 | 225 |
193 // Create an EmuFdNetDevice for the eNB to connect with the SGW and other eNBs | 226 // Create an EmuFdNetDevice for the eNB to connect with the SGW and other eNBs |
194 EmuFdNetDeviceHelper emu; | 227 EmuFdNetDeviceHelper emu; |
195 NS_LOG_LOGIC ("eNB device: " << m_enbDeviceName); | 228 NS_LOG_LOGIC ("eNB device: " << m_enbDeviceName); |
196 emu.SetDeviceName (m_enbDeviceName);·· | 229 emu.SetDeviceName (m_enbDeviceName);·· |
(...skipping 26 matching lines...) Expand all Loading... |
223 enbLteSocketBindAddress.SetSingleDevice (lteEnbNetDevice->GetIfIndex ()); | 256 enbLteSocketBindAddress.SetSingleDevice (lteEnbNetDevice->GetIfIndex ()); |
224 enbLteSocketBindAddress.SetProtocol (Ipv4L3Protocol::PROT_NUMBER); | 257 enbLteSocketBindAddress.SetProtocol (Ipv4L3Protocol::PROT_NUMBER); |
225 retval = enbLteSocket->Bind (enbLteSocketBindAddress); | 258 retval = enbLteSocket->Bind (enbLteSocketBindAddress); |
226 NS_ASSERT (retval == 0);·· | 259 NS_ASSERT (retval == 0);·· |
227 PacketSocketAddress enbLteSocketConnectAddress; | 260 PacketSocketAddress enbLteSocketConnectAddress; |
228 enbLteSocketConnectAddress.SetPhysicalAddress (Mac48Address::GetBroadcast ()); | 261 enbLteSocketConnectAddress.SetPhysicalAddress (Mac48Address::GetBroadcast ()); |
229 enbLteSocketConnectAddress.SetSingleDevice (lteEnbNetDevice->GetIfIndex ()); | 262 enbLteSocketConnectAddress.SetSingleDevice (lteEnbNetDevice->GetIfIndex ()); |
230 enbLteSocketConnectAddress.SetProtocol (Ipv4L3Protocol::PROT_NUMBER); | 263 enbLteSocketConnectAddress.SetProtocol (Ipv4L3Protocol::PROT_NUMBER); |
231 retval = enbLteSocket->Connect (enbLteSocketConnectAddress); | 264 retval = enbLteSocket->Connect (enbLteSocketConnectAddress); |
232 NS_ASSERT (retval == 0);·· | 265 NS_ASSERT (retval == 0);·· |
233 ·· | 266 |
234 | 267 // create LTE socket for the ENB· |
| 268 Ptr<Socket> enbLteSocket6 = Socket::CreateSocket (enb, TypeId::LookupByName ("
ns3::PacketSocketFactory")); |
| 269 PacketSocketAddress enbLteSocketBindAddress6; |
| 270 enbLteSocketBindAddress6.SetSingleDevice (lteEnbNetDevice->GetIfIndex ()); |
| 271 enbLteSocketBindAddress6.SetProtocol (Ipv6L3Protocol::PROT_NUMBER); |
| 272 retval = enbLteSocket6->Bind (enbLteSocketBindAddress6); |
| 273 NS_ASSERT (retval == 0);·· |
| 274 PacketSocketAddress enbLteSocketConnectAddress6; |
| 275 enbLteSocketConnectAddress6.SetPhysicalAddress (Mac48Address::GetBroadcast ())
; |
| 276 enbLteSocketConnectAddress6.SetSingleDevice (lteEnbNetDevice->GetIfIndex ()); |
| 277 enbLteSocketConnectAddress6.SetProtocol (Ipv6L3Protocol::PROT_NUMBER); |
| 278 retval = enbLteSocket6->Connect (enbLteSocketConnectAddress6); |
| 279 NS_ASSERT (retval == 0); |
| 280 ·· |
235 NS_LOG_INFO ("create EpcEnbApplication"); | 281 NS_LOG_INFO ("create EpcEnbApplication"); |
236 Ptr<EpcEnbApplication> enbApp = CreateObject<EpcEnbApplication> (enbLteSocket,
enbS1uSocket, enbAddress, sgwAddress, cellId); | 282 Ptr<EpcEnbApplication> enbApp = CreateObject<EpcEnbApplication> (enbLteSocket,
enbLteSocket6, enbS1uSocket, enbAddress, sgwAddress, cellId); |
237 enb->AddApplication (enbApp); | 283 enb->AddApplication (enbApp); |
238 NS_ASSERT (enb->GetNApplications () == 1); | 284 NS_ASSERT (enb->GetNApplications () == 1); |
239 NS_ASSERT_MSG (enb->GetApplication (0)->GetObject<EpcEnbApplication> () != 0,
"cannot retrieve EpcEnbApplication"); | 285 NS_ASSERT_MSG (enb->GetApplication (0)->GetObject<EpcEnbApplication> () != 0,
"cannot retrieve EpcEnbApplication"); |
240 NS_LOG_LOGIC ("enb: " << enb << ", enb->GetApplication (0): " << enb->GetAppli
cation (0)); | 286 NS_LOG_LOGIC ("enb: " << enb << ", enb->GetApplication (0): " << enb->GetAppli
cation (0)); |
241 | 287 |
242 ·· | 288 ·· |
243 NS_LOG_INFO ("Create EpcX2 entity"); | 289 NS_LOG_INFO ("Create EpcX2 entity"); |
244 Ptr<EpcX2> x2 = CreateObject<EpcX2> (); | 290 Ptr<EpcX2> x2 = CreateObject<EpcX2> (); |
245 enb->AggregateObject (x2); | 291 enb->AggregateObject (x2); |
246 | 292 |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
304 void· | 350 void· |
305 EmuEpcHelper::AddUe (Ptr<NetDevice> ueDevice, uint64_t imsi) | 351 EmuEpcHelper::AddUe (Ptr<NetDevice> ueDevice, uint64_t imsi) |
306 { | 352 { |
307 NS_LOG_FUNCTION (this << imsi << ueDevice ); | 353 NS_LOG_FUNCTION (this << imsi << ueDevice ); |
308 ·· | 354 ·· |
309 m_mme->AddUe (imsi); | 355 m_mme->AddUe (imsi); |
310 m_sgwPgwApp->AddUe (imsi); | 356 m_sgwPgwApp->AddUe (imsi); |
311 ·· | 357 ·· |
312 } | 358 } |
313 | 359 |
| 360 |
314 uint8_t | 361 uint8_t |
315 EmuEpcHelper::ActivateEpsBearer (Ptr<NetDevice> ueDevice, uint64_t imsi, Ptr<Epc
Tft> tft, EpsBearer bearer) | 362 EmuEpcHelper::ActivateEpsBearer (Ptr<NetDevice> ueDevice, uint64_t imsi, Ptr<Epc
Tft> tft, EpsBearer bearer) |
316 { | 363 { |
317 NS_LOG_FUNCTION (this << ueDevice << imsi); | 364 NS_LOG_FUNCTION (this << ueDevice << imsi); |
318 | 365 |
319 // we now retrieve the IPv4 address of the UE and notify it to the SGW; | 366 // we now retrieve the IPv4/IPv6 address of the UE and notify it to the SGW; |
320 // we couldn't do it before since address assignment is triggered by | 367 // we couldn't do it before since address assignment is triggered by |
321 // the user simulation program, rather than done by the EPC··· | 368 // the user simulation program, rather than done by the EPC··· |
322 Ptr<Node> ueNode = ueDevice->GetNode ();· | 369 Ptr<Node> ueNode = ueDevice->GetNode ();· |
323 Ptr<Ipv4> ueIpv4 = ueNode->GetObject<Ipv4> (); | 370 Ptr<Ipv4> ueIpv4 = ueNode->GetObject<Ipv4> (); |
324 NS_ASSERT_MSG (ueIpv4 != 0, "UEs need to have IPv4 installed before EPS bearer
s can be activated"); | 371 Ptr<Ipv6> ueIpv6 = ueNode->GetObject<Ipv6> (); |
325 int32_t interface = ueIpv4->GetInterfaceForDevice (ueDevice); | 372 NS_ASSERT_MSG (ueIpv4 != 0 || ueIpv6 != 0, "UEs need to have IPv4/IPv6 install
ed before EPS bearers can be activated"); |
326 NS_ASSERT (interface >= 0); | 373 |
327 NS_ASSERT (ueIpv4->GetNAddresses (interface) == 1); | 374 if (ueIpv4) |
328 Ipv4Address ueAddr = ueIpv4->GetAddress (interface, 0).GetLocal (); | 375 { |
329 NS_LOG_LOGIC (" UE IP address: " << ueAddr); m_sgwPgwApp->SetUeAddress (imsi,
ueAddr); | 376 int32_t interface = ueIpv4->GetInterfaceForDevice (ueDevice); |
330 ·· | 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 } |
| 384 if (ueIpv6) |
| 385 { |
| 386 int32_t interface6 = ueIpv6->GetInterfaceForDevice (ueDevice); |
| 387 if (interface6 >= 0 && ueIpv6->GetNAddresses (interface6) == 2) |
| 388 { |
| 389 Ipv6Address ueAddr6 = ueIpv6->GetAddress (interface6, 1).GetAddress ()
; |
| 390 NS_LOG_LOGIC (" UE IPv6 address: " << ueAddr6); |
| 391 m_sgwPgwApp->SetUeAddress6 (imsi, ueAddr6); |
| 392 } |
| 393 } |
| 394 |
331 uint8_t bearerId = m_mme->AddBearer (imsi, tft, bearer); | 395 uint8_t bearerId = m_mme->AddBearer (imsi, tft, bearer); |
332 Ptr<LteUeNetDevice> ueLteDevice = ueDevice->GetObject<LteUeNetDevice> (); | 396 Ptr<LteUeNetDevice> ueLteDevice = ueDevice->GetObject<LteUeNetDevice> (); |
333 if (ueLteDevice) | 397 if (ueLteDevice) |
334 { | 398 { |
335 Simulator::ScheduleNow (&EpcUeNas::ActivateEpsBearer, ueLteDevice->GetNas
(), bearer, tft); | 399 Simulator::ScheduleNow (&EpcUeNas::ActivateEpsBearer, ueLteDevice->GetNas
(), bearer, tft); |
336 } | 400 } |
337 return bearerId; | 401 return bearerId; |
338 } | 402 } |
339 | 403 |
340 | 404 |
341 Ptr<Node> | 405 Ptr<Node> |
342 EmuEpcHelper::GetPgwNode () | 406 EmuEpcHelper::GetPgwNode () |
343 { | 407 { |
344 return m_sgwPgw; | 408 return m_sgwPgw; |
345 } | 409 } |
346 | 410 |
347 | 411 |
348 Ipv4InterfaceContainer· | 412 Ipv4InterfaceContainer· |
349 EmuEpcHelper::AssignUeIpv4Address (NetDeviceContainer ueDevices) | 413 EmuEpcHelper::AssignUeIpv4Address (NetDeviceContainer ueDevices) |
350 { | 414 { |
351 return m_ueAddressHelper.Assign (ueDevices); | 415 return m_uePgwAddressHelper.Assign (ueDevices); |
352 } | 416 } |
353 | 417 |
354 | 418 Ipv6InterfaceContainer· |
| 419 EmuEpcHelper::AssignUeIpv6Address (NetDeviceContainer ueDevices) |
| 420 { |
| 421 for (NetDeviceContainer::Iterator iter = ueDevices.Begin (); |
| 422 iter != ueDevices.End (); |
| 423 iter ++) |
| 424 { |
| 425 Ptr<Icmpv6L4Protocol> icmpv6 = (*iter)->GetNode ()->GetObject<Icmpv6L4Prot
ocol> (); |
| 426 icmpv6->SetAttribute ("DAD", BooleanValue (false)); |
| 427 } |
| 428 return m_uePgwAddressHelper6.Assign (ueDevices); |
| 429 } |
355 | 430 |
356 Ipv4Address | 431 Ipv4Address |
357 EmuEpcHelper::GetUeDefaultGatewayAddress () | 432 EmuEpcHelper::GetUeDefaultGatewayAddress () |
358 { | 433 { |
359 // return the address of the tun device | 434 // return the address of the tun device |
360 return m_sgwPgw->GetObject<Ipv4> ()->GetAddress (1, 0).GetLocal (); | 435 return m_sgwPgw->GetObject<Ipv4> ()->GetAddress (1, 0).GetLocal (); |
361 } | 436 } |
362 | 437 |
| 438 Ipv6Address |
| 439 EmuEpcHelper::GetUeDefaultGatewayAddress6 () |
| 440 { |
| 441 // return the address of the tun device 6 |
| 442 return m_sgwPgw->GetObject<Ipv6> ()->GetAddress (1, 1).GetAddress (); |
| 443 } |
363 | 444 |
364 } // namespace ns3 | 445 } // namespace ns3 |
LEFT | RIGHT |