Left: | ||
Right: |
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 Centre Tecnologic de Telecomunicacions de Catalunya (CTTC) | 3 * Copyright (c) 2011 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 |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
56 { | 56 { |
57 return ( (a.m_rnti < b.m_rnti) || ( (a.m_rnti == b.m_rnti) && (a.m_bid < b.m_b id) ) ); | 57 return ( (a.m_rnti < b.m_rnti) || ( (a.m_rnti == b.m_rnti) && (a.m_bid < b.m_b id) ) ); |
58 } | 58 } |
59 | 59 |
60 | 60 |
61 TypeId | 61 TypeId |
62 EpcEnbApplication::GetTypeId (void) | 62 EpcEnbApplication::GetTypeId (void) |
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_rxLteSocketP ktTrace), | |
70 "ns3::EpcEnbApplication::RxTracedCallback") | |
71 .AddTraceSource ("RxFromS1u", | |
72 "Receive data packets from S1-U Net Device", | |
73 MakeTraceSourceAccessor (&EpcEnbApplication::m_rxS1uSocketP ktTrace), | |
74 "ns3::EpcEnbApplication::RxTracedCallback") | |
75 ; | |
67 return tid; | 76 return tid; |
68 } | 77 } |
69 | 78 |
70 void | 79 void |
71 EpcEnbApplication::DoDispose (void) | 80 EpcEnbApplication::DoDispose (void) |
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 | 90 EpcEnbApplication::EpcEnbApplication (Ptr<Socket> lteSocket, Ptr<Socket> lteSock et6, Ptr<Socket> s1uSocket, Ipv4Address enbS1uAddress, Ipv4Address sgwS1uAddress , uint16_t cellId) |
81 EpcEnbApplication::EpcEnbApplication (Ptr<Socket> lteSocket, Ptr<Socket> s1uSock et, Ipv4Address enbS1uAddress, Ipv4Address sgwS1uAddress, uint16_t cellId) | |
82 : m_lteSocket (lteSocket), | 91 : m_lteSocket (lteSocket), |
92 m_lteSocket6 (lteSocket6), | |
83 m_s1uSocket (s1uSocket),···· | 93 m_s1uSocket (s1uSocket),···· |
84 m_enbS1uAddress (enbS1uAddress), | 94 m_enbS1uAddress (enbS1uAddress), |
85 m_sgwS1uAddress (sgwS1uAddress), | 95 m_sgwS1uAddress (sgwS1uAddress), |
86 m_gtpuUdpPort (2152), // fixed by the standard | 96 m_gtpuUdpPort (2152), // fixed by the standard |
87 m_s1SapUser (0), | 97 m_s1SapUser (0), |
88 m_s1apSapMme (0), | 98 m_s1apSapMme (0), |
89 m_cellId (cellId) | 99 m_cellId (cellId) |
90 { | 100 { |
91 NS_LOG_FUNCTION (this << lteSocket << s1uSocket << sgwS1uAddress); | 101 NS_LOG_FUNCTION (this << lteSocket << s1uSocket << sgwS1uAddress); |
92 m_s1uSocket->SetRecvCallback (MakeCallback (&EpcEnbApplication::RecvFromS1uSoc ket, this)); | 102 m_s1uSocket->SetRecvCallback (MakeCallback (&EpcEnbApplication::RecvFromS1uSoc ket, this)); |
93 m_lteSocket->SetRecvCallback (MakeCallback (&EpcEnbApplication::RecvFromLteSoc ket, this)); | 103 m_lteSocket->SetRecvCallback (MakeCallback (&EpcEnbApplication::RecvFromLteSoc ket, this)); |
104 m_lteSocket6->SetRecvCallback (MakeCallback (&EpcEnbApplication::RecvFromLteSo cket, this)); | |
94 m_s1SapProvider = new MemberEpcEnbS1SapProvider<EpcEnbApplication> (this); | 105 m_s1SapProvider = new MemberEpcEnbS1SapProvider<EpcEnbApplication> (this); |
95 m_s1apSapEnb = new MemberEpcS1apSapEnb<EpcEnbApplication> (this); | 106 m_s1apSapEnb = new MemberEpcS1apSapEnb<EpcEnbApplication> (this); |
96 } | 107 } |
97 | 108 |
98 | 109 |
99 EpcEnbApplication::~EpcEnbApplication (void) | 110 EpcEnbApplication::~EpcEnbApplication (void) |
100 { | 111 { |
101 NS_LOG_FUNCTION (this); | 112 NS_LOG_FUNCTION (this); |
102 } | 113 } |
103 | 114 |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
188 m_teidRbidMap.erase (teid); | 199 m_teidRbidMap.erase (teid); |
189 } | 200 } |
190 m_rbidTeidMap.erase (rntiIt); | 201 m_rbidTeidMap.erase (rntiIt); |
191 } | 202 } |
192 } | 203 } |
193 | 204 |
194 void· | 205 void· |
195 EpcEnbApplication::DoInitialContextSetupRequest (uint64_t mmeUeS1Id, uint16_t en bUeS1Id, std::list<EpcS1apSapEnb::ErabToBeSetupItem> erabToBeSetupList) | 206 EpcEnbApplication::DoInitialContextSetupRequest (uint64_t mmeUeS1Id, uint16_t en bUeS1Id, std::list<EpcS1apSapEnb::ErabToBeSetupItem> erabToBeSetupList) |
196 { | 207 { |
197 NS_LOG_FUNCTION (this); | 208 NS_LOG_FUNCTION (this); |
198 NS_UNUSED(enbUeS1Id); | 209 NS_UNUSED (enbUeS1Id); |
199 ·· | 210 ·· |
200 for (std::list<EpcS1apSapEnb::ErabToBeSetupItem>::iterator erabIt = erabToBeSe tupList.begin (); | 211 for (std::list<EpcS1apSapEnb::ErabToBeSetupItem>::iterator erabIt = erabToBeSe tupList.begin (); |
201 erabIt != erabToBeSetupList.end (); | 212 erabIt != erabToBeSetupList.end (); |
202 ++erabIt) | 213 ++erabIt) |
203 { | 214 { |
204 // request the RRC to setup a radio bearer | 215 // request the RRC to setup a radio bearer |
205 | 216 |
206 uint64_t imsi = mmeUeS1Id; | 217 uint64_t imsi = mmeUeS1Id; |
207 std::map<uint64_t, uint16_t>::iterator imsiIt = m_imsiRntiMap.find (imsi); | 218 std::map<uint64_t, uint16_t>::iterator imsiIt = m_imsiRntiMap.find (imsi); |
208 NS_ASSERT_MSG (imsiIt != m_imsiRntiMap.end (), "unknown IMSI"); | 219 NS_ASSERT_MSG (imsiIt != m_imsiRntiMap.end (), "unknown IMSI"); |
(...skipping 11 matching lines...) Expand all Loading... | |
220 m_rbidTeidMap[rnti][erabIt->erabId] = params.gtpTeid; | 231 m_rbidTeidMap[rnti][erabIt->erabId] = params.gtpTeid; |
221 m_teidRbidMap[params.gtpTeid] = rbid; | 232 m_teidRbidMap[params.gtpTeid] = rbid; |
222 | 233 |
223 } | 234 } |
224 } | 235 } |
225 | 236 |
226 void· | 237 void· |
227 EpcEnbApplication::DoPathSwitchRequestAcknowledge (uint64_t enbUeS1Id, uint64_t mmeUeS1Id, uint16_t gci, std::list<EpcS1apSapEnb::ErabSwitchedInUplinkItem> erab ToBeSwitchedInUplinkList) | 238 EpcEnbApplication::DoPathSwitchRequestAcknowledge (uint64_t enbUeS1Id, uint64_t mmeUeS1Id, uint16_t gci, std::list<EpcS1apSapEnb::ErabSwitchedInUplinkItem> erab ToBeSwitchedInUplinkList) |
228 { | 239 { |
229 NS_LOG_FUNCTION (this); | 240 NS_LOG_FUNCTION (this); |
230 NS_UNUSED(enbUeS1Id); | 241 NS_UNUSED (enbUeS1Id); |
231 NS_UNUSED(gci); | 242 NS_UNUSED (gci); |
232 | 243 |
233 uint64_t imsi = mmeUeS1Id; | 244 uint64_t imsi = mmeUeS1Id; |
234 std::map<uint64_t, uint16_t>::iterator imsiIt = m_imsiRntiMap.find (imsi); | 245 std::map<uint64_t, uint16_t>::iterator imsiIt = m_imsiRntiMap.find (imsi); |
235 NS_ASSERT_MSG (imsiIt != m_imsiRntiMap.end (), "unknown IMSI"); | 246 NS_ASSERT_MSG (imsiIt != m_imsiRntiMap.end (), "unknown IMSI"); |
236 uint16_t rnti = imsiIt->second; | 247 uint16_t rnti = imsiIt->second; |
237 EpcEnbS1SapUser::PathSwitchRequestAcknowledgeParameters params; | 248 EpcEnbS1SapUser::PathSwitchRequestAcknowledgeParameters params; |
238 params.rnti = rnti; | 249 params.rnti = rnti; |
239 m_s1SapUser->PathSwitchRequestAcknowledge (params); | 250 m_s1SapUser->PathSwitchRequestAcknowledge (params); |
240 } | 251 } |
241 | 252 |
242 void· | 253 void· |
243 EpcEnbApplication::RecvFromLteSocket (Ptr<Socket> socket) | 254 EpcEnbApplication::RecvFromLteSocket (Ptr<Socket> socket) |
244 { | 255 { |
245 NS_LOG_FUNCTION (this);·· | 256 NS_LOG_FUNCTION (this);·· |
246 NS_ASSERT (socket == m_lteSocket); | 257 if(m_lteSocket6) |
258 { | |
259 NS_ASSERT (socket == m_lteSocket || socket == m_lteSocket6); | |
260 } | |
261 else | |
262 { | |
263 NS_ASSERT (socket == m_lteSocket); | |
264 } | |
247 Ptr<Packet> packet = socket->Recv (); | 265 Ptr<Packet> packet = socket->Recv (); |
248 | 266 |
249 EpsBearerTag tag; | 267 EpsBearerTag tag; |
250 bool found = packet->RemovePacketTag (tag); | 268 bool found = packet->RemovePacketTag (tag); |
251 NS_ASSERT (found); | 269 NS_ASSERT (found); |
252 (void)found; // make compiler happy | 270 (void)found; // make compiler happy |
Biljana Bojović
2018/08/22 11:35:28
NS_ABBORT_UNLESS
| |
253 uint16_t rnti = tag.GetRnti (); | 271 uint16_t rnti = tag.GetRnti (); |
254 uint8_t bid = tag.GetBid (); | 272 uint8_t bid = tag.GetBid (); |
255 NS_LOG_LOGIC ("received packet with RNTI=" << (uint32_t) rnti << ", BID=" << ( uint32_t) bid); | 273 NS_LOG_LOGIC ("received packet with RNTI=" << (uint32_t) rnti << ", BID=" << ( uint32_t) bid); |
256 std::map<uint16_t, std::map<uint8_t, uint32_t> >::iterator rntiIt = m_rbidTeid Map.find (rnti); | 274 std::map<uint16_t, std::map<uint8_t, uint32_t> >::iterator rntiIt = m_rbidTeid Map.find (rnti); |
257 if (rntiIt == m_rbidTeidMap.end ()) | 275 if (rntiIt == m_rbidTeidMap.end ()) |
258 { | 276 { |
259 NS_LOG_WARN ("UE context not found, discarding packet"); | 277 NS_LOG_WARN ("UE context not found, discarding packet"); |
260 } | 278 } |
261 else | 279 else |
262 { | 280 { |
263 std::map<uint8_t, uint32_t>::iterator bidIt = rntiIt->second.find (bid); | 281 std::map<uint8_t, uint32_t>::iterator bidIt = rntiIt->second.find (bid); |
264 NS_ASSERT (bidIt != rntiIt->second.end ()); | 282 NS_ASSERT (bidIt != rntiIt->second.end ()); |
265 uint32_t teid = bidIt->second; | 283 uint32_t teid = bidIt->second; |
284 m_rxLteSocketPktTrace (packet->Copy ()); | |
266 SendToS1uSocket (packet, teid); | 285 SendToS1uSocket (packet, teid); |
267 } | 286 } |
268 } | 287 } |
269 | 288 |
270 void· | 289 void· |
271 EpcEnbApplication::RecvFromS1uSocket (Ptr<Socket> socket) | 290 EpcEnbApplication::RecvFromS1uSocket (Ptr<Socket> socket) |
272 { | 291 { |
273 NS_LOG_FUNCTION (this << socket);·· | 292 NS_LOG_FUNCTION (this << socket);·· |
274 NS_ASSERT (socket == m_s1uSocket); | 293 NS_ASSERT (socket == m_s1uSocket); |
275 Ptr<Packet> packet = socket->Recv (); | 294 Ptr<Packet> packet = socket->Recv (); |
276 GtpuHeader gtpu; | 295 GtpuHeader gtpu; |
277 packet->RemoveHeader (gtpu); | 296 packet->RemoveHeader (gtpu); |
278 uint32_t teid = gtpu.GetTeid (); | 297 uint32_t teid = gtpu.GetTeid (); |
279 std::map<uint32_t, EpsFlowId_t>::iterator it = m_teidRbidMap.find (teid); | 298 std::map<uint32_t, EpsFlowId_t>::iterator it = m_teidRbidMap.find (teid); |
280 NS_ASSERT (it != m_teidRbidMap.end ()); | 299 NS_ASSERT (it != m_teidRbidMap.end ()); |
281 | 300 |
301 m_rxS1uSocketPktTrace (packet->Copy ()); | |
282 SendToLteSocket (packet, it->second.m_rnti, it->second.m_bid); | 302 SendToLteSocket (packet, it->second.m_rnti, it->second.m_bid); |
283 } | 303 } |
284 | 304 |
285 void· | 305 void· |
286 EpcEnbApplication::SendToLteSocket (Ptr<Packet> packet, uint16_t rnti, uint8_t b id) | 306 EpcEnbApplication::SendToLteSocket (Ptr<Packet> packet, uint16_t rnti, uint8_t b id) |
287 { | 307 { |
288 NS_LOG_FUNCTION (this << packet << rnti << (uint16_t) bid << packet->GetSize ( ));·· | 308 NS_LOG_FUNCTION (this << packet << rnti << (uint16_t) bid << packet->GetSize ( ));·· |
289 EpsBearerTag tag (rnti, bid); | 309 EpsBearerTag tag (rnti, bid); |
290 packet->AddPacketTag (tag); | 310 packet->AddPacketTag (tag); |
291 int sentBytes = m_lteSocket->Send (packet); | 311 uint8_t ipType; |
312 | |
313 packet->CopyData (&ipType, 1); | |
314 ipType = (ipType>>4) & 0x0f; | |
315 | |
316 int sentBytes; | |
317 if (ipType == 0x04) | |
318 { | |
319 sentBytes = m_lteSocket->Send (packet); | |
320 } | |
321 else if (ipType == 0x06) | |
322 { | |
323 sentBytes = m_lteSocket6->Send (packet); | |
324 } | |
325 else | |
326 { | |
327 NS_ABORT_MSG ("EpcEnbApplication::SendToLteSocket - Unknown IP type..."); | |
328 } | |
329 | |
292 NS_ASSERT (sentBytes > 0); | 330 NS_ASSERT (sentBytes > 0); |
293 (void)sentBytes; // make compiler happy | 331 (void)sentBytes; // make compiler happy |
Biljana Bojović
2018/08/22 11:35:28
NS_ABBORT_UNLESS
| |
294 } | 332 } |
295 | 333 |
296 | 334 |
297 void· | 335 void· |
298 EpcEnbApplication::SendToS1uSocket (Ptr<Packet> packet, uint32_t teid) | 336 EpcEnbApplication::SendToS1uSocket (Ptr<Packet> packet, uint32_t teid) |
299 { | 337 { |
300 NS_LOG_FUNCTION (this << packet << teid << packet->GetSize ());·· | 338 NS_LOG_FUNCTION (this << packet << teid << packet->GetSize ());·· |
301 GtpuHeader gtpu; | 339 GtpuHeader gtpu; |
302 gtpu.SetTeid (teid); | 340 gtpu.SetTeid (teid); |
303 // From 3GPP TS 29.281 v10.0.0 Section 5.1 | 341 // From 3GPP TS 29.281 v10.0.0 Section 5.1 |
304 // Length of the payload + the non obligatory GTP-U header | 342 // Length of the payload + the non obligatory GTP-U header |
305 gtpu.SetLength (static_cast<uint16_t>(packet->GetSize () + gtpu.GetSerializedS ize () - 8));·· | 343 gtpu.SetLength (static_cast<uint16_t> (packet->GetSize () + gtpu.GetSerialized Size () - 8));·· |
306 packet->AddHeader (gtpu); | 344 packet->AddHeader (gtpu); |
307 uint32_t flags = 0; | 345 uint32_t flags = 0; |
308 m_s1uSocket->SendTo (packet, flags, InetSocketAddress (m_sgwS1uAddress, m_gtpu UdpPort)); | 346 m_s1uSocket->SendTo (packet, flags, InetSocketAddress (m_sgwS1uAddress, m_gtpu UdpPort)); |
309 } | 347 } |
310 | 348 |
311 void | 349 void |
312 EpcEnbApplication::DoReleaseIndication (uint64_t imsi, uint16_t rnti, uint8_t be arerId) | 350 EpcEnbApplication::DoReleaseIndication (uint64_t imsi, uint16_t rnti, uint8_t be arerId) |
313 { | 351 { |
314 NS_LOG_FUNCTION (this << bearerId ); | 352 NS_LOG_FUNCTION (this << bearerId ); |
315 std::list<EpcS1apSapMme::ErabToBeReleasedIndication> erabToBeReleaseIndication ; | 353 std::list<EpcS1apSapMme::ErabToBeReleasedIndication> erabToBeReleaseIndication ; |
316 EpcS1apSapMme::ErabToBeReleasedIndication erab; | 354 EpcS1apSapMme::ErabToBeReleasedIndication erab; |
317 erab.erabId = bearerId; | 355 erab.erabId = bearerId; |
318 erabToBeReleaseIndication.push_back (erab); | 356 erabToBeReleaseIndication.push_back (erab); |
319 //From 3GPP TS 23401-950 Section 5.4.4.2, enB sends EPS bearer Identity in Bea rer Release Indication message to MME | 357 //From 3GPP TS 23401-950 Section 5.4.4.2, enB sends EPS bearer Identity in Bea rer Release Indication message to MME |
320 m_s1apSapMme->ErabReleaseIndication (imsi, rnti, erabToBeReleaseIndication); | 358 m_s1apSapMme->ErabReleaseIndication (imsi, rnti, erabToBeReleaseIndication); |
321 } | 359 } |
360 | |
322 } // namespace ns3 | 361 } // namespace ns3 |
LEFT | RIGHT |