src/lte/model/epc-enb-application.cc
author Nicola Baldo <nbaldo@cttc.es>
Mon, 04 Feb 2013 18:47:25 +0100
changeset 9653 382d27da8905
parent 9622 affdc8251c1c
child 10157 02e3d2d7d7e1
permissions -rw-r--r--
merged lena-dev with ns-3-dev
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
8357
7bb52f00c205 Refurbished GTP tunneling implementation + documentation
Jaume Nin
parents:
diff changeset
     1
/* -*-  Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
7bb52f00c205 Refurbished GTP tunneling implementation + documentation
Jaume Nin
parents:
diff changeset
     2
/*
7bb52f00c205 Refurbished GTP tunneling implementation + documentation
Jaume Nin
parents:
diff changeset
     3
 * Copyright (c) 2011 Centre Tecnologic de Telecomunicacions de Catalunya (CTTC)
7bb52f00c205 Refurbished GTP tunneling implementation + documentation
Jaume Nin
parents:
diff changeset
     4
 *
7bb52f00c205 Refurbished GTP tunneling implementation + documentation
Jaume Nin
parents:
diff changeset
     5
 * This program is free software; you can redistribute it and/or modify
7bb52f00c205 Refurbished GTP tunneling implementation + documentation
Jaume Nin
parents:
diff changeset
     6
 * it under the terms of the GNU General Public License version 2 as
7bb52f00c205 Refurbished GTP tunneling implementation + documentation
Jaume Nin
parents:
diff changeset
     7
 * published by the Free Software Foundation;
7bb52f00c205 Refurbished GTP tunneling implementation + documentation
Jaume Nin
parents:
diff changeset
     8
 *
7bb52f00c205 Refurbished GTP tunneling implementation + documentation
Jaume Nin
parents:
diff changeset
     9
 * This program is distributed in the hope that it will be useful,
7bb52f00c205 Refurbished GTP tunneling implementation + documentation
Jaume Nin
parents:
diff changeset
    10
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
7bb52f00c205 Refurbished GTP tunneling implementation + documentation
Jaume Nin
parents:
diff changeset
    11
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
7bb52f00c205 Refurbished GTP tunneling implementation + documentation
Jaume Nin
parents:
diff changeset
    12
 * GNU General Public License for more details.
7bb52f00c205 Refurbished GTP tunneling implementation + documentation
Jaume Nin
parents:
diff changeset
    13
 *
7bb52f00c205 Refurbished GTP tunneling implementation + documentation
Jaume Nin
parents:
diff changeset
    14
 * You should have received a copy of the GNU General Public License
7bb52f00c205 Refurbished GTP tunneling implementation + documentation
Jaume Nin
parents:
diff changeset
    15
 * along with this program; if not, write to the Free Software
7bb52f00c205 Refurbished GTP tunneling implementation + documentation
Jaume Nin
parents:
diff changeset
    16
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
7bb52f00c205 Refurbished GTP tunneling implementation + documentation
Jaume Nin
parents:
diff changeset
    17
 *
7bb52f00c205 Refurbished GTP tunneling implementation + documentation
Jaume Nin
parents:
diff changeset
    18
 * Author: Jaume Nin <jnin@cttc.cat>
8366
a3af0a5ed1e9 draft eNB and SGW/PGW applications
Nicola Baldo <nbaldo@cttc.es>
parents: 8357
diff changeset
    19
 *         Nicola Baldo <nbaldo@cttc.cat>
8357
7bb52f00c205 Refurbished GTP tunneling implementation + documentation
Jaume Nin
parents:
diff changeset
    20
 */
7bb52f00c205 Refurbished GTP tunneling implementation + documentation
Jaume Nin
parents:
diff changeset
    21
7bb52f00c205 Refurbished GTP tunneling implementation + documentation
Jaume Nin
parents:
diff changeset
    22
8366
a3af0a5ed1e9 draft eNB and SGW/PGW applications
Nicola Baldo <nbaldo@cttc.es>
parents: 8357
diff changeset
    23
#include "epc-enb-application.h"
8357
7bb52f00c205 Refurbished GTP tunneling implementation + documentation
Jaume Nin
parents:
diff changeset
    24
#include "ns3/log.h"
7bb52f00c205 Refurbished GTP tunneling implementation + documentation
Jaume Nin
parents:
diff changeset
    25
#include "ns3/mac48-address.h"
7bb52f00c205 Refurbished GTP tunneling implementation + documentation
Jaume Nin
parents:
diff changeset
    26
#include "ns3/ipv4.h"
7bb52f00c205 Refurbished GTP tunneling implementation + documentation
Jaume Nin
parents:
diff changeset
    27
#include "ns3/inet-socket-address.h"
8380
f615b30c26e1 S1-U working in downlink
Nicola Baldo <nbaldo@cttc.es>
parents: 8378
diff changeset
    28
#include "ns3/uinteger.h"
9337
ae7126b266ce revised LTE protocol stack for new RRC model
Nicola Baldo <nbaldo@cttc.es>
parents: 8462
diff changeset
    29
ae7126b266ce revised LTE protocol stack for new RRC model
Nicola Baldo <nbaldo@cttc.es>
parents: 8462
diff changeset
    30
#include "epc-gtpu-header.h"
9406
7f0f9d8f8e20 new LTE RRC model
Nicola Baldo <nbaldo@cttc.es>
parents: 9345
diff changeset
    31
#include "eps-bearer-tag.h"
9337
ae7126b266ce revised LTE protocol stack for new RRC model
Nicola Baldo <nbaldo@cttc.es>
parents: 8462
diff changeset
    32
8357
7bb52f00c205 Refurbished GTP tunneling implementation + documentation
Jaume Nin
parents:
diff changeset
    33
7bb52f00c205 Refurbished GTP tunneling implementation + documentation
Jaume Nin
parents:
diff changeset
    34
namespace ns3 {
7bb52f00c205 Refurbished GTP tunneling implementation + documentation
Jaume Nin
parents:
diff changeset
    35
8366
a3af0a5ed1e9 draft eNB and SGW/PGW applications
Nicola Baldo <nbaldo@cttc.es>
parents: 8357
diff changeset
    36
NS_LOG_COMPONENT_DEFINE ("EpcEnbApplication");
8357
7bb52f00c205 Refurbished GTP tunneling implementation + documentation
Jaume Nin
parents:
diff changeset
    37
7bb52f00c205 Refurbished GTP tunneling implementation + documentation
Jaume Nin
parents:
diff changeset
    38
9406
7f0f9d8f8e20 new LTE RRC model
Nicola Baldo <nbaldo@cttc.es>
parents: 9345
diff changeset
    39
EpcEnbApplication::EpsFlowId_t::EpsFlowId_t ()
7f0f9d8f8e20 new LTE RRC model
Nicola Baldo <nbaldo@cttc.es>
parents: 9345
diff changeset
    40
{
7f0f9d8f8e20 new LTE RRC model
Nicola Baldo <nbaldo@cttc.es>
parents: 9345
diff changeset
    41
}
7f0f9d8f8e20 new LTE RRC model
Nicola Baldo <nbaldo@cttc.es>
parents: 9345
diff changeset
    42
7f0f9d8f8e20 new LTE RRC model
Nicola Baldo <nbaldo@cttc.es>
parents: 9345
diff changeset
    43
EpcEnbApplication::EpsFlowId_t::EpsFlowId_t (const uint16_t a, const uint8_t b)
7f0f9d8f8e20 new LTE RRC model
Nicola Baldo <nbaldo@cttc.es>
parents: 9345
diff changeset
    44
  : m_rnti (a),
7f0f9d8f8e20 new LTE RRC model
Nicola Baldo <nbaldo@cttc.es>
parents: 9345
diff changeset
    45
    m_bid (b)
7f0f9d8f8e20 new LTE RRC model
Nicola Baldo <nbaldo@cttc.es>
parents: 9345
diff changeset
    46
{
7f0f9d8f8e20 new LTE RRC model
Nicola Baldo <nbaldo@cttc.es>
parents: 9345
diff changeset
    47
}
7f0f9d8f8e20 new LTE RRC model
Nicola Baldo <nbaldo@cttc.es>
parents: 9345
diff changeset
    48
7f0f9d8f8e20 new LTE RRC model
Nicola Baldo <nbaldo@cttc.es>
parents: 9345
diff changeset
    49
bool
7f0f9d8f8e20 new LTE RRC model
Nicola Baldo <nbaldo@cttc.es>
parents: 9345
diff changeset
    50
operator == (const EpcEnbApplication::EpsFlowId_t &a, const EpcEnbApplication::EpsFlowId_t &b)
7f0f9d8f8e20 new LTE RRC model
Nicola Baldo <nbaldo@cttc.es>
parents: 9345
diff changeset
    51
{
7f0f9d8f8e20 new LTE RRC model
Nicola Baldo <nbaldo@cttc.es>
parents: 9345
diff changeset
    52
  return ( (a.m_rnti == b.m_rnti) && (a.m_bid == b.m_bid) );
7f0f9d8f8e20 new LTE RRC model
Nicola Baldo <nbaldo@cttc.es>
parents: 9345
diff changeset
    53
}
7f0f9d8f8e20 new LTE RRC model
Nicola Baldo <nbaldo@cttc.es>
parents: 9345
diff changeset
    54
7f0f9d8f8e20 new LTE RRC model
Nicola Baldo <nbaldo@cttc.es>
parents: 9345
diff changeset
    55
bool
7f0f9d8f8e20 new LTE RRC model
Nicola Baldo <nbaldo@cttc.es>
parents: 9345
diff changeset
    56
operator < (const EpcEnbApplication::EpsFlowId_t& a, const EpcEnbApplication::EpsFlowId_t& b)
7f0f9d8f8e20 new LTE RRC model
Nicola Baldo <nbaldo@cttc.es>
parents: 9345
diff changeset
    57
{
7f0f9d8f8e20 new LTE RRC model
Nicola Baldo <nbaldo@cttc.es>
parents: 9345
diff changeset
    58
  return ( (a.m_rnti < b.m_rnti) || ( (a.m_rnti == b.m_rnti) && (a.m_bid < b.m_bid) ) );
7f0f9d8f8e20 new LTE RRC model
Nicola Baldo <nbaldo@cttc.es>
parents: 9345
diff changeset
    59
}
7f0f9d8f8e20 new LTE RRC model
Nicola Baldo <nbaldo@cttc.es>
parents: 9345
diff changeset
    60
7f0f9d8f8e20 new LTE RRC model
Nicola Baldo <nbaldo@cttc.es>
parents: 9345
diff changeset
    61
8357
7bb52f00c205 Refurbished GTP tunneling implementation + documentation
Jaume Nin
parents:
diff changeset
    62
TypeId
8366
a3af0a5ed1e9 draft eNB and SGW/PGW applications
Nicola Baldo <nbaldo@cttc.es>
parents: 8357
diff changeset
    63
EpcEnbApplication::GetTypeId (void)
8357
7bb52f00c205 Refurbished GTP tunneling implementation + documentation
Jaume Nin
parents:
diff changeset
    64
{
8366
a3af0a5ed1e9 draft eNB and SGW/PGW applications
Nicola Baldo <nbaldo@cttc.es>
parents: 8357
diff changeset
    65
  static TypeId tid = TypeId ("ns3::EpcEnbApplication")
8380
f615b30c26e1 S1-U working in downlink
Nicola Baldo <nbaldo@cttc.es>
parents: 8378
diff changeset
    66
    .SetParent<Object> ();
8357
7bb52f00c205 Refurbished GTP tunneling implementation + documentation
Jaume Nin
parents:
diff changeset
    67
  return tid;
7bb52f00c205 Refurbished GTP tunneling implementation + documentation
Jaume Nin
parents:
diff changeset
    68
}
7bb52f00c205 Refurbished GTP tunneling implementation + documentation
Jaume Nin
parents:
diff changeset
    69
9380
890e3ccc4bc5 fixed valgrind error in EpcEnbApplication
Nicola Baldo <nbaldo@cttc.es>
parents: 9345
diff changeset
    70
void
890e3ccc4bc5 fixed valgrind error in EpcEnbApplication
Nicola Baldo <nbaldo@cttc.es>
parents: 9345
diff changeset
    71
EpcEnbApplication::DoDispose (void)
890e3ccc4bc5 fixed valgrind error in EpcEnbApplication
Nicola Baldo <nbaldo@cttc.es>
parents: 9345
diff changeset
    72
{
890e3ccc4bc5 fixed valgrind error in EpcEnbApplication
Nicola Baldo <nbaldo@cttc.es>
parents: 9345
diff changeset
    73
  NS_LOG_FUNCTION (this);
890e3ccc4bc5 fixed valgrind error in EpcEnbApplication
Nicola Baldo <nbaldo@cttc.es>
parents: 9345
diff changeset
    74
  m_lteSocket = 0;
890e3ccc4bc5 fixed valgrind error in EpcEnbApplication
Nicola Baldo <nbaldo@cttc.es>
parents: 9345
diff changeset
    75
  m_s1uSocket = 0;
890e3ccc4bc5 fixed valgrind error in EpcEnbApplication
Nicola Baldo <nbaldo@cttc.es>
parents: 9345
diff changeset
    76
  delete m_s1SapProvider;
9430
e8b87593ee5b added MME with simulated S1AP and S11 interfaces
Nicola Baldo <nbaldo@cttc.es>
parents: 9414
diff changeset
    77
  delete m_s1apSapEnb;
9380
890e3ccc4bc5 fixed valgrind error in EpcEnbApplication
Nicola Baldo <nbaldo@cttc.es>
parents: 9345
diff changeset
    78
}
890e3ccc4bc5 fixed valgrind error in EpcEnbApplication
Nicola Baldo <nbaldo@cttc.es>
parents: 9345
diff changeset
    79
890e3ccc4bc5 fixed valgrind error in EpcEnbApplication
Nicola Baldo <nbaldo@cttc.es>
parents: 9345
diff changeset
    80
9439
5107601b7a75 added S1 path switch + S11 modify bearer for X2 handover
Nicola Baldo <nbaldo@cttc.es>
parents: 9431
diff changeset
    81
EpcEnbApplication::EpcEnbApplication (Ptr<Socket> lteSocket, Ptr<Socket> s1uSocket, Ipv4Address enbS1uAddress, Ipv4Address sgwS1uAddress, uint16_t cellId)
8380
f615b30c26e1 S1-U working in downlink
Nicola Baldo <nbaldo@cttc.es>
parents: 8378
diff changeset
    82
  : m_lteSocket (lteSocket),
f615b30c26e1 S1-U working in downlink
Nicola Baldo <nbaldo@cttc.es>
parents: 8378
diff changeset
    83
    m_s1uSocket (s1uSocket),    
9439
5107601b7a75 added S1 path switch + S11 modify bearer for X2 handover
Nicola Baldo <nbaldo@cttc.es>
parents: 9431
diff changeset
    84
    m_enbS1uAddress (enbS1uAddress),
5107601b7a75 added S1 path switch + S11 modify bearer for X2 handover
Nicola Baldo <nbaldo@cttc.es>
parents: 9431
diff changeset
    85
    m_sgwS1uAddress (sgwS1uAddress),
9430
e8b87593ee5b added MME with simulated S1AP and S11 interfaces
Nicola Baldo <nbaldo@cttc.es>
parents: 9414
diff changeset
    86
    m_gtpuUdpPort (2152), // fixed by the standard
e8b87593ee5b added MME with simulated S1AP and S11 interfaces
Nicola Baldo <nbaldo@cttc.es>
parents: 9414
diff changeset
    87
    m_s1SapUser (0),
e8b87593ee5b added MME with simulated S1AP and S11 interfaces
Nicola Baldo <nbaldo@cttc.es>
parents: 9414
diff changeset
    88
    m_s1apSapMme (0),
e8b87593ee5b added MME with simulated S1AP and S11 interfaces
Nicola Baldo <nbaldo@cttc.es>
parents: 9414
diff changeset
    89
    m_cellId (cellId)
8357
7bb52f00c205 Refurbished GTP tunneling implementation + documentation
Jaume Nin
parents:
diff changeset
    90
{
9439
5107601b7a75 added S1 path switch + S11 modify bearer for X2 handover
Nicola Baldo <nbaldo@cttc.es>
parents: 9431
diff changeset
    91
  NS_LOG_FUNCTION (this << lteSocket << s1uSocket << sgwS1uAddress);
8380
f615b30c26e1 S1-U working in downlink
Nicola Baldo <nbaldo@cttc.es>
parents: 8378
diff changeset
    92
  m_s1uSocket->SetRecvCallback (MakeCallback (&EpcEnbApplication::RecvFromS1uSocket, this));
f615b30c26e1 S1-U working in downlink
Nicola Baldo <nbaldo@cttc.es>
parents: 8378
diff changeset
    93
  m_lteSocket->SetRecvCallback (MakeCallback (&EpcEnbApplication::RecvFromLteSocket, this));
9337
ae7126b266ce revised LTE protocol stack for new RRC model
Nicola Baldo <nbaldo@cttc.es>
parents: 8462
diff changeset
    94
  m_s1SapProvider = new MemberEpcEnbS1SapProvider<EpcEnbApplication> (this);
9430
e8b87593ee5b added MME with simulated S1AP and S11 interfaces
Nicola Baldo <nbaldo@cttc.es>
parents: 9414
diff changeset
    95
  m_s1apSapEnb = new MemberEpcS1apSapEnb<EpcEnbApplication> (this);
8378
0d8107d1548b save changes before merge
Nicola Baldo <nbaldo@cttc.es>
parents: 8366
diff changeset
    96
}
0d8107d1548b save changes before merge
Nicola Baldo <nbaldo@cttc.es>
parents: 8366
diff changeset
    97
0d8107d1548b save changes before merge
Nicola Baldo <nbaldo@cttc.es>
parents: 8366
diff changeset
    98
0d8107d1548b save changes before merge
Nicola Baldo <nbaldo@cttc.es>
parents: 8366
diff changeset
    99
EpcEnbApplication::~EpcEnbApplication (void)
0d8107d1548b save changes before merge
Nicola Baldo <nbaldo@cttc.es>
parents: 8366
diff changeset
   100
{
8380
f615b30c26e1 S1-U working in downlink
Nicola Baldo <nbaldo@cttc.es>
parents: 8378
diff changeset
   101
  NS_LOG_FUNCTION (this);
8378
0d8107d1548b save changes before merge
Nicola Baldo <nbaldo@cttc.es>
parents: 8366
diff changeset
   102
}
9337
ae7126b266ce revised LTE protocol stack for new RRC model
Nicola Baldo <nbaldo@cttc.es>
parents: 8462
diff changeset
   103
ae7126b266ce revised LTE protocol stack for new RRC model
Nicola Baldo <nbaldo@cttc.es>
parents: 8462
diff changeset
   104
8380
f615b30c26e1 S1-U working in downlink
Nicola Baldo <nbaldo@cttc.es>
parents: 8378
diff changeset
   105
void 
9337
ae7126b266ce revised LTE protocol stack for new RRC model
Nicola Baldo <nbaldo@cttc.es>
parents: 8462
diff changeset
   106
EpcEnbApplication::SetS1SapUser (EpcEnbS1SapUser * s)
ae7126b266ce revised LTE protocol stack for new RRC model
Nicola Baldo <nbaldo@cttc.es>
parents: 8462
diff changeset
   107
{
ae7126b266ce revised LTE protocol stack for new RRC model
Nicola Baldo <nbaldo@cttc.es>
parents: 8462
diff changeset
   108
  m_s1SapUser = s;
ae7126b266ce revised LTE protocol stack for new RRC model
Nicola Baldo <nbaldo@cttc.es>
parents: 8462
diff changeset
   109
}
ae7126b266ce revised LTE protocol stack for new RRC model
Nicola Baldo <nbaldo@cttc.es>
parents: 8462
diff changeset
   110
ae7126b266ce revised LTE protocol stack for new RRC model
Nicola Baldo <nbaldo@cttc.es>
parents: 8462
diff changeset
   111
  
ae7126b266ce revised LTE protocol stack for new RRC model
Nicola Baldo <nbaldo@cttc.es>
parents: 8462
diff changeset
   112
EpcEnbS1SapProvider* 
ae7126b266ce revised LTE protocol stack for new RRC model
Nicola Baldo <nbaldo@cttc.es>
parents: 8462
diff changeset
   113
EpcEnbApplication::GetS1SapProvider ()
ae7126b266ce revised LTE protocol stack for new RRC model
Nicola Baldo <nbaldo@cttc.es>
parents: 8462
diff changeset
   114
{
ae7126b266ce revised LTE protocol stack for new RRC model
Nicola Baldo <nbaldo@cttc.es>
parents: 8462
diff changeset
   115
  return m_s1SapProvider;
ae7126b266ce revised LTE protocol stack for new RRC model
Nicola Baldo <nbaldo@cttc.es>
parents: 8462
diff changeset
   116
}
ae7126b266ce revised LTE protocol stack for new RRC model
Nicola Baldo <nbaldo@cttc.es>
parents: 8462
diff changeset
   117
ae7126b266ce revised LTE protocol stack for new RRC model
Nicola Baldo <nbaldo@cttc.es>
parents: 8462
diff changeset
   118
void 
9430
e8b87593ee5b added MME with simulated S1AP and S11 interfaces
Nicola Baldo <nbaldo@cttc.es>
parents: 9414
diff changeset
   119
EpcEnbApplication::SetS1apSapMme (EpcS1apSapMme * s)
e8b87593ee5b added MME with simulated S1AP and S11 interfaces
Nicola Baldo <nbaldo@cttc.es>
parents: 9414
diff changeset
   120
{
e8b87593ee5b added MME with simulated S1AP and S11 interfaces
Nicola Baldo <nbaldo@cttc.es>
parents: 9414
diff changeset
   121
  m_s1apSapMme = s;
e8b87593ee5b added MME with simulated S1AP and S11 interfaces
Nicola Baldo <nbaldo@cttc.es>
parents: 9414
diff changeset
   122
}
e8b87593ee5b added MME with simulated S1AP and S11 interfaces
Nicola Baldo <nbaldo@cttc.es>
parents: 9414
diff changeset
   123
e8b87593ee5b added MME with simulated S1AP and S11 interfaces
Nicola Baldo <nbaldo@cttc.es>
parents: 9414
diff changeset
   124
  
e8b87593ee5b added MME with simulated S1AP and S11 interfaces
Nicola Baldo <nbaldo@cttc.es>
parents: 9414
diff changeset
   125
EpcS1apSapEnb* 
e8b87593ee5b added MME with simulated S1AP and S11 interfaces
Nicola Baldo <nbaldo@cttc.es>
parents: 9414
diff changeset
   126
EpcEnbApplication::GetS1apSapEnb ()
e8b87593ee5b added MME with simulated S1AP and S11 interfaces
Nicola Baldo <nbaldo@cttc.es>
parents: 9414
diff changeset
   127
{
e8b87593ee5b added MME with simulated S1AP and S11 interfaces
Nicola Baldo <nbaldo@cttc.es>
parents: 9414
diff changeset
   128
  return m_s1apSapEnb;
e8b87593ee5b added MME with simulated S1AP and S11 interfaces
Nicola Baldo <nbaldo@cttc.es>
parents: 9414
diff changeset
   129
}
e8b87593ee5b added MME with simulated S1AP and S11 interfaces
Nicola Baldo <nbaldo@cttc.es>
parents: 9414
diff changeset
   130
e8b87593ee5b added MME with simulated S1AP and S11 interfaces
Nicola Baldo <nbaldo@cttc.es>
parents: 9414
diff changeset
   131
void 
9345
8290ae6cab62 add/remove UEs and bearers upon handover
Nicola Baldo <nicola@baldo.biz>
parents: 9337
diff changeset
   132
EpcEnbApplication::DoInitialUeMessage (uint64_t imsi, uint16_t rnti)
8290ae6cab62 add/remove UEs and bearers upon handover
Nicola Baldo <nicola@baldo.biz>
parents: 9337
diff changeset
   133
{
8290ae6cab62 add/remove UEs and bearers upon handover
Nicola Baldo <nicola@baldo.biz>
parents: 9337
diff changeset
   134
  NS_LOG_FUNCTION (this);
8290ae6cab62 add/remove UEs and bearers upon handover
Nicola Baldo <nicola@baldo.biz>
parents: 9337
diff changeset
   135
  // side effect: create entry if not exist
8290ae6cab62 add/remove UEs and bearers upon handover
Nicola Baldo <nicola@baldo.biz>
parents: 9337
diff changeset
   136
  m_imsiRntiMap[imsi] = rnti;
9430
e8b87593ee5b added MME with simulated S1AP and S11 interfaces
Nicola Baldo <nbaldo@cttc.es>
parents: 9414
diff changeset
   137
  m_s1apSapMme->InitialUeMessage (imsi, rnti, imsi, m_cellId);
e8b87593ee5b added MME with simulated S1AP and S11 interfaces
Nicola Baldo <nbaldo@cttc.es>
parents: 9414
diff changeset
   138
}
e8b87593ee5b added MME with simulated S1AP and S11 interfaces
Nicola Baldo <nbaldo@cttc.es>
parents: 9414
diff changeset
   139
9439
5107601b7a75 added S1 path switch + S11 modify bearer for X2 handover
Nicola Baldo <nbaldo@cttc.es>
parents: 9431
diff changeset
   140
void 
5107601b7a75 added S1 path switch + S11 modify bearer for X2 handover
Nicola Baldo <nbaldo@cttc.es>
parents: 9431
diff changeset
   141
EpcEnbApplication::DoPathSwitchRequest (EpcEnbS1SapProvider::PathSwitchRequestParameters params)
5107601b7a75 added S1 path switch + S11 modify bearer for X2 handover
Nicola Baldo <nbaldo@cttc.es>
parents: 9431
diff changeset
   142
{
5107601b7a75 added S1 path switch + S11 modify bearer for X2 handover
Nicola Baldo <nbaldo@cttc.es>
parents: 9431
diff changeset
   143
  NS_LOG_FUNCTION (this);
5107601b7a75 added S1 path switch + S11 modify bearer for X2 handover
Nicola Baldo <nbaldo@cttc.es>
parents: 9431
diff changeset
   144
  uint16_t enbUeS1Id = params.rnti;  
5107601b7a75 added S1 path switch + S11 modify bearer for X2 handover
Nicola Baldo <nbaldo@cttc.es>
parents: 9431
diff changeset
   145
  uint64_t mmeUeS1Id = params.mmeUeS1Id;
5107601b7a75 added S1 path switch + S11 modify bearer for X2 handover
Nicola Baldo <nbaldo@cttc.es>
parents: 9431
diff changeset
   146
  uint64_t imsi = mmeUeS1Id;
5107601b7a75 added S1 path switch + S11 modify bearer for X2 handover
Nicola Baldo <nbaldo@cttc.es>
parents: 9431
diff changeset
   147
  // side effect: create entry if not exist
5107601b7a75 added S1 path switch + S11 modify bearer for X2 handover
Nicola Baldo <nbaldo@cttc.es>
parents: 9431
diff changeset
   148
  m_imsiRntiMap[imsi] = params.rnti;
5107601b7a75 added S1 path switch + S11 modify bearer for X2 handover
Nicola Baldo <nbaldo@cttc.es>
parents: 9431
diff changeset
   149
5107601b7a75 added S1 path switch + S11 modify bearer for X2 handover
Nicola Baldo <nbaldo@cttc.es>
parents: 9431
diff changeset
   150
  uint16_t gci = params.cellId;
5107601b7a75 added S1 path switch + S11 modify bearer for X2 handover
Nicola Baldo <nbaldo@cttc.es>
parents: 9431
diff changeset
   151
  std::list<EpcS1apSapMme::ErabSwitchedInDownlinkItem> erabToBeSwitchedInDownlinkList;
5107601b7a75 added S1 path switch + S11 modify bearer for X2 handover
Nicola Baldo <nbaldo@cttc.es>
parents: 9431
diff changeset
   152
  for (std::list<EpcEnbS1SapProvider::BearerToBeSwitched>::iterator bit = params.bearersToBeSwitched.begin ();
5107601b7a75 added S1 path switch + S11 modify bearer for X2 handover
Nicola Baldo <nbaldo@cttc.es>
parents: 9431
diff changeset
   153
       bit != params.bearersToBeSwitched.end ();
5107601b7a75 added S1 path switch + S11 modify bearer for X2 handover
Nicola Baldo <nbaldo@cttc.es>
parents: 9431
diff changeset
   154
       ++bit)
5107601b7a75 added S1 path switch + S11 modify bearer for X2 handover
Nicola Baldo <nbaldo@cttc.es>
parents: 9431
diff changeset
   155
    {
5107601b7a75 added S1 path switch + S11 modify bearer for X2 handover
Nicola Baldo <nbaldo@cttc.es>
parents: 9431
diff changeset
   156
      EpsFlowId_t flowId;
5107601b7a75 added S1 path switch + S11 modify bearer for X2 handover
Nicola Baldo <nbaldo@cttc.es>
parents: 9431
diff changeset
   157
      flowId.m_rnti = params.rnti;
5107601b7a75 added S1 path switch + S11 modify bearer for X2 handover
Nicola Baldo <nbaldo@cttc.es>
parents: 9431
diff changeset
   158
      flowId.m_bid = bit->epsBearerId;
5107601b7a75 added S1 path switch + S11 modify bearer for X2 handover
Nicola Baldo <nbaldo@cttc.es>
parents: 9431
diff changeset
   159
      uint32_t teid = bit->teid;
5107601b7a75 added S1 path switch + S11 modify bearer for X2 handover
Nicola Baldo <nbaldo@cttc.es>
parents: 9431
diff changeset
   160
      
5107601b7a75 added S1 path switch + S11 modify bearer for X2 handover
Nicola Baldo <nbaldo@cttc.es>
parents: 9431
diff changeset
   161
      EpsFlowId_t rbid (params.rnti, bit->epsBearerId);
5107601b7a75 added S1 path switch + S11 modify bearer for X2 handover
Nicola Baldo <nbaldo@cttc.es>
parents: 9431
diff changeset
   162
      // side effect: create entries if not exist
9442
ea15d4676dff release UE context at EpcEnbApplication upon X2 UE CONTEXT RELEASE
Nicola Baldo <nbaldo@cttc.es>
parents: 9439
diff changeset
   163
      m_rbidTeidMap[params.rnti][bit->epsBearerId] = teid;
9439
5107601b7a75 added S1 path switch + S11 modify bearer for X2 handover
Nicola Baldo <nbaldo@cttc.es>
parents: 9431
diff changeset
   164
      m_teidRbidMap[teid] = rbid;
5107601b7a75 added S1 path switch + S11 modify bearer for X2 handover
Nicola Baldo <nbaldo@cttc.es>
parents: 9431
diff changeset
   165
5107601b7a75 added S1 path switch + S11 modify bearer for X2 handover
Nicola Baldo <nbaldo@cttc.es>
parents: 9431
diff changeset
   166
      EpcS1apSapMme::ErabSwitchedInDownlinkItem erab;
5107601b7a75 added S1 path switch + S11 modify bearer for X2 handover
Nicola Baldo <nbaldo@cttc.es>
parents: 9431
diff changeset
   167
      erab.erabId = bit->epsBearerId;
5107601b7a75 added S1 path switch + S11 modify bearer for X2 handover
Nicola Baldo <nbaldo@cttc.es>
parents: 9431
diff changeset
   168
      erab.enbTransportLayerAddress = m_enbS1uAddress;
5107601b7a75 added S1 path switch + S11 modify bearer for X2 handover
Nicola Baldo <nbaldo@cttc.es>
parents: 9431
diff changeset
   169
      erab.enbTeid = bit->teid;
5107601b7a75 added S1 path switch + S11 modify bearer for X2 handover
Nicola Baldo <nbaldo@cttc.es>
parents: 9431
diff changeset
   170
5107601b7a75 added S1 path switch + S11 modify bearer for X2 handover
Nicola Baldo <nbaldo@cttc.es>
parents: 9431
diff changeset
   171
      erabToBeSwitchedInDownlinkList.push_back (erab);
5107601b7a75 added S1 path switch + S11 modify bearer for X2 handover
Nicola Baldo <nbaldo@cttc.es>
parents: 9431
diff changeset
   172
    }
5107601b7a75 added S1 path switch + S11 modify bearer for X2 handover
Nicola Baldo <nbaldo@cttc.es>
parents: 9431
diff changeset
   173
  m_s1apSapMme->PathSwitchRequest (enbUeS1Id, mmeUeS1Id, gci, erabToBeSwitchedInDownlinkList);
5107601b7a75 added S1 path switch + S11 modify bearer for X2 handover
Nicola Baldo <nbaldo@cttc.es>
parents: 9431
diff changeset
   174
}
9430
e8b87593ee5b added MME with simulated S1AP and S11 interfaces
Nicola Baldo <nbaldo@cttc.es>
parents: 9414
diff changeset
   175
e8b87593ee5b added MME with simulated S1AP and S11 interfaces
Nicola Baldo <nbaldo@cttc.es>
parents: 9414
diff changeset
   176
void 
9442
ea15d4676dff release UE context at EpcEnbApplication upon X2 UE CONTEXT RELEASE
Nicola Baldo <nbaldo@cttc.es>
parents: 9439
diff changeset
   177
EpcEnbApplication::DoUeContextRelease (uint16_t rnti)
ea15d4676dff release UE context at EpcEnbApplication upon X2 UE CONTEXT RELEASE
Nicola Baldo <nbaldo@cttc.es>
parents: 9439
diff changeset
   178
{
ea15d4676dff release UE context at EpcEnbApplication upon X2 UE CONTEXT RELEASE
Nicola Baldo <nbaldo@cttc.es>
parents: 9439
diff changeset
   179
  NS_LOG_FUNCTION (this << rnti);
ea15d4676dff release UE context at EpcEnbApplication upon X2 UE CONTEXT RELEASE
Nicola Baldo <nbaldo@cttc.es>
parents: 9439
diff changeset
   180
  std::map<uint16_t, std::map<uint8_t, uint32_t> >::iterator rntiIt = m_rbidTeidMap.find (rnti);
9576
86424fb2ca42 allow removing UE Context when UE has no active EPS Bearer
Nicola Baldo <nbaldo@cttc.es>
parents: 9442
diff changeset
   181
  if (rntiIt != m_rbidTeidMap.end ())
9442
ea15d4676dff release UE context at EpcEnbApplication upon X2 UE CONTEXT RELEASE
Nicola Baldo <nbaldo@cttc.es>
parents: 9439
diff changeset
   182
    {
9576
86424fb2ca42 allow removing UE Context when UE has no active EPS Bearer
Nicola Baldo <nbaldo@cttc.es>
parents: 9442
diff changeset
   183
      for (std::map<uint8_t, uint32_t>::iterator bidIt = rntiIt->second.begin ();
86424fb2ca42 allow removing UE Context when UE has no active EPS Bearer
Nicola Baldo <nbaldo@cttc.es>
parents: 9442
diff changeset
   184
           bidIt != rntiIt->second.end ();
86424fb2ca42 allow removing UE Context when UE has no active EPS Bearer
Nicola Baldo <nbaldo@cttc.es>
parents: 9442
diff changeset
   185
           ++bidIt)
86424fb2ca42 allow removing UE Context when UE has no active EPS Bearer
Nicola Baldo <nbaldo@cttc.es>
parents: 9442
diff changeset
   186
        {
86424fb2ca42 allow removing UE Context when UE has no active EPS Bearer
Nicola Baldo <nbaldo@cttc.es>
parents: 9442
diff changeset
   187
          uint32_t teid = bidIt->second;
86424fb2ca42 allow removing UE Context when UE has no active EPS Bearer
Nicola Baldo <nbaldo@cttc.es>
parents: 9442
diff changeset
   188
          m_teidRbidMap.erase (teid);
86424fb2ca42 allow removing UE Context when UE has no active EPS Bearer
Nicola Baldo <nbaldo@cttc.es>
parents: 9442
diff changeset
   189
        }
86424fb2ca42 allow removing UE Context when UE has no active EPS Bearer
Nicola Baldo <nbaldo@cttc.es>
parents: 9442
diff changeset
   190
      m_rbidTeidMap.erase (rntiIt);
9442
ea15d4676dff release UE context at EpcEnbApplication upon X2 UE CONTEXT RELEASE
Nicola Baldo <nbaldo@cttc.es>
parents: 9439
diff changeset
   191
    }
ea15d4676dff release UE context at EpcEnbApplication upon X2 UE CONTEXT RELEASE
Nicola Baldo <nbaldo@cttc.es>
parents: 9439
diff changeset
   192
}
ea15d4676dff release UE context at EpcEnbApplication upon X2 UE CONTEXT RELEASE
Nicola Baldo <nbaldo@cttc.es>
parents: 9439
diff changeset
   193
ea15d4676dff release UE context at EpcEnbApplication upon X2 UE CONTEXT RELEASE
Nicola Baldo <nbaldo@cttc.es>
parents: 9439
diff changeset
   194
void 
9430
e8b87593ee5b added MME with simulated S1AP and S11 interfaces
Nicola Baldo <nbaldo@cttc.es>
parents: 9414
diff changeset
   195
EpcEnbApplication::DoInitialContextSetupRequest (uint64_t mmeUeS1Id, uint16_t enbUeS1Id, std::list<EpcS1apSapEnb::ErabToBeSetupItem> erabToBeSetupList)
e8b87593ee5b added MME with simulated S1AP and S11 interfaces
Nicola Baldo <nbaldo@cttc.es>
parents: 9414
diff changeset
   196
{
e8b87593ee5b added MME with simulated S1AP and S11 interfaces
Nicola Baldo <nbaldo@cttc.es>
parents: 9414
diff changeset
   197
  NS_LOG_FUNCTION (this);
e8b87593ee5b added MME with simulated S1AP and S11 interfaces
Nicola Baldo <nbaldo@cttc.es>
parents: 9414
diff changeset
   198
  
9431
d157ce87b1c0 removed obsolete S1BearerSetupRequest method from EpcEnbS1Sap
Nicola Baldo <nbaldo@cttc.es>
parents: 9430
diff changeset
   199
  for (std::list<EpcS1apSapEnb::ErabToBeSetupItem>::iterator erabIt = erabToBeSetupList.begin ();
d157ce87b1c0 removed obsolete S1BearerSetupRequest method from EpcEnbS1Sap
Nicola Baldo <nbaldo@cttc.es>
parents: 9430
diff changeset
   200
       erabIt != erabToBeSetupList.end ();
d157ce87b1c0 removed obsolete S1BearerSetupRequest method from EpcEnbS1Sap
Nicola Baldo <nbaldo@cttc.es>
parents: 9430
diff changeset
   201
       ++erabIt)
9430
e8b87593ee5b added MME with simulated S1AP and S11 interfaces
Nicola Baldo <nbaldo@cttc.es>
parents: 9414
diff changeset
   202
    {
9431
d157ce87b1c0 removed obsolete S1BearerSetupRequest method from EpcEnbS1Sap
Nicola Baldo <nbaldo@cttc.es>
parents: 9430
diff changeset
   203
      // request the RRC to setup a radio bearer
d157ce87b1c0 removed obsolete S1BearerSetupRequest method from EpcEnbS1Sap
Nicola Baldo <nbaldo@cttc.es>
parents: 9430
diff changeset
   204
d157ce87b1c0 removed obsolete S1BearerSetupRequest method from EpcEnbS1Sap
Nicola Baldo <nbaldo@cttc.es>
parents: 9430
diff changeset
   205
      uint64_t imsi = mmeUeS1Id;
d157ce87b1c0 removed obsolete S1BearerSetupRequest method from EpcEnbS1Sap
Nicola Baldo <nbaldo@cttc.es>
parents: 9430
diff changeset
   206
      std::map<uint64_t, uint16_t>::iterator imsiIt = m_imsiRntiMap.find (imsi);
d157ce87b1c0 removed obsolete S1BearerSetupRequest method from EpcEnbS1Sap
Nicola Baldo <nbaldo@cttc.es>
parents: 9430
diff changeset
   207
      NS_ASSERT_MSG (imsiIt != m_imsiRntiMap.end (), "unknown IMSI");
d157ce87b1c0 removed obsolete S1BearerSetupRequest method from EpcEnbS1Sap
Nicola Baldo <nbaldo@cttc.es>
parents: 9430
diff changeset
   208
      uint16_t rnti = imsiIt->second;
d157ce87b1c0 removed obsolete S1BearerSetupRequest method from EpcEnbS1Sap
Nicola Baldo <nbaldo@cttc.es>
parents: 9430
diff changeset
   209
      
d157ce87b1c0 removed obsolete S1BearerSetupRequest method from EpcEnbS1Sap
Nicola Baldo <nbaldo@cttc.es>
parents: 9430
diff changeset
   210
      struct EpcEnbS1SapUser::DataRadioBearerSetupRequestParameters params;
d157ce87b1c0 removed obsolete S1BearerSetupRequest method from EpcEnbS1Sap
Nicola Baldo <nbaldo@cttc.es>
parents: 9430
diff changeset
   211
      params.rnti = rnti;
d157ce87b1c0 removed obsolete S1BearerSetupRequest method from EpcEnbS1Sap
Nicola Baldo <nbaldo@cttc.es>
parents: 9430
diff changeset
   212
      params.bearer = erabIt->erabLevelQosParameters;
d157ce87b1c0 removed obsolete S1BearerSetupRequest method from EpcEnbS1Sap
Nicola Baldo <nbaldo@cttc.es>
parents: 9430
diff changeset
   213
      params.bearerId = erabIt->erabId;
d157ce87b1c0 removed obsolete S1BearerSetupRequest method from EpcEnbS1Sap
Nicola Baldo <nbaldo@cttc.es>
parents: 9430
diff changeset
   214
      params.gtpTeid = erabIt->sgwTeid;
d157ce87b1c0 removed obsolete S1BearerSetupRequest method from EpcEnbS1Sap
Nicola Baldo <nbaldo@cttc.es>
parents: 9430
diff changeset
   215
      m_s1SapUser->DataRadioBearerSetupRequest (params);
d157ce87b1c0 removed obsolete S1BearerSetupRequest method from EpcEnbS1Sap
Nicola Baldo <nbaldo@cttc.es>
parents: 9430
diff changeset
   216
d157ce87b1c0 removed obsolete S1BearerSetupRequest method from EpcEnbS1Sap
Nicola Baldo <nbaldo@cttc.es>
parents: 9430
diff changeset
   217
      EpsFlowId_t rbid (rnti, erabIt->erabId);
d157ce87b1c0 removed obsolete S1BearerSetupRequest method from EpcEnbS1Sap
Nicola Baldo <nbaldo@cttc.es>
parents: 9430
diff changeset
   218
      // side effect: create entries if not exist
9442
ea15d4676dff release UE context at EpcEnbApplication upon X2 UE CONTEXT RELEASE
Nicola Baldo <nbaldo@cttc.es>
parents: 9439
diff changeset
   219
      m_rbidTeidMap[rnti][erabIt->erabId] = params.gtpTeid;
9431
d157ce87b1c0 removed obsolete S1BearerSetupRequest method from EpcEnbS1Sap
Nicola Baldo <nbaldo@cttc.es>
parents: 9430
diff changeset
   220
      m_teidRbidMap[params.gtpTeid] = rbid;
d157ce87b1c0 removed obsolete S1BearerSetupRequest method from EpcEnbS1Sap
Nicola Baldo <nbaldo@cttc.es>
parents: 9430
diff changeset
   221
9430
e8b87593ee5b added MME with simulated S1AP and S11 interfaces
Nicola Baldo <nbaldo@cttc.es>
parents: 9414
diff changeset
   222
    }
e8b87593ee5b added MME with simulated S1AP and S11 interfaces
Nicola Baldo <nbaldo@cttc.es>
parents: 9414
diff changeset
   223
}
e8b87593ee5b added MME with simulated S1AP and S11 interfaces
Nicola Baldo <nbaldo@cttc.es>
parents: 9414
diff changeset
   224
e8b87593ee5b added MME with simulated S1AP and S11 interfaces
Nicola Baldo <nbaldo@cttc.es>
parents: 9414
diff changeset
   225
void 
e8b87593ee5b added MME with simulated S1AP and S11 interfaces
Nicola Baldo <nbaldo@cttc.es>
parents: 9414
diff changeset
   226
EpcEnbApplication::DoPathSwitchRequestAcknowledge (uint64_t enbUeS1Id, uint64_t mmeUeS1Id, uint16_t gci, std::list<EpcS1apSapEnb::ErabSwitchedInUplinkItem> erabToBeSwitchedInUplinkList)
e8b87593ee5b added MME with simulated S1AP and S11 interfaces
Nicola Baldo <nbaldo@cttc.es>
parents: 9414
diff changeset
   227
{
e8b87593ee5b added MME with simulated S1AP and S11 interfaces
Nicola Baldo <nbaldo@cttc.es>
parents: 9414
diff changeset
   228
  NS_LOG_FUNCTION (this);
9439
5107601b7a75 added S1 path switch + S11 modify bearer for X2 handover
Nicola Baldo <nbaldo@cttc.es>
parents: 9431
diff changeset
   229
5107601b7a75 added S1 path switch + S11 modify bearer for X2 handover
Nicola Baldo <nbaldo@cttc.es>
parents: 9431
diff changeset
   230
  uint64_t imsi = mmeUeS1Id;
5107601b7a75 added S1 path switch + S11 modify bearer for X2 handover
Nicola Baldo <nbaldo@cttc.es>
parents: 9431
diff changeset
   231
  std::map<uint64_t, uint16_t>::iterator imsiIt = m_imsiRntiMap.find (imsi);
5107601b7a75 added S1 path switch + S11 modify bearer for X2 handover
Nicola Baldo <nbaldo@cttc.es>
parents: 9431
diff changeset
   232
  NS_ASSERT_MSG (imsiIt != m_imsiRntiMap.end (), "unknown IMSI");
5107601b7a75 added S1 path switch + S11 modify bearer for X2 handover
Nicola Baldo <nbaldo@cttc.es>
parents: 9431
diff changeset
   233
  uint16_t rnti = imsiIt->second;
5107601b7a75 added S1 path switch + S11 modify bearer for X2 handover
Nicola Baldo <nbaldo@cttc.es>
parents: 9431
diff changeset
   234
  EpcEnbS1SapUser::PathSwitchRequestAcknowledgeParameters params;
5107601b7a75 added S1 path switch + S11 modify bearer for X2 handover
Nicola Baldo <nbaldo@cttc.es>
parents: 9431
diff changeset
   235
  params.rnti = rnti;
5107601b7a75 added S1 path switch + S11 modify bearer for X2 handover
Nicola Baldo <nbaldo@cttc.es>
parents: 9431
diff changeset
   236
  m_s1SapUser->PathSwitchRequestAcknowledge (params);
9345
8290ae6cab62 add/remove UEs and bearers upon handover
Nicola Baldo <nicola@baldo.biz>
parents: 9337
diff changeset
   237
}
8290ae6cab62 add/remove UEs and bearers upon handover
Nicola Baldo <nicola@baldo.biz>
parents: 9337
diff changeset
   238
8378
0d8107d1548b save changes before merge
Nicola Baldo <nbaldo@cttc.es>
parents: 8366
diff changeset
   239
void 
0d8107d1548b save changes before merge
Nicola Baldo <nbaldo@cttc.es>
parents: 8366
diff changeset
   240
EpcEnbApplication::RecvFromLteSocket (Ptr<Socket> socket)
0d8107d1548b save changes before merge
Nicola Baldo <nbaldo@cttc.es>
parents: 8366
diff changeset
   241
{
0d8107d1548b save changes before merge
Nicola Baldo <nbaldo@cttc.es>
parents: 8366
diff changeset
   242
  NS_LOG_FUNCTION (this);  
0d8107d1548b save changes before merge
Nicola Baldo <nbaldo@cttc.es>
parents: 8366
diff changeset
   243
  NS_ASSERT (socket == m_lteSocket);
0d8107d1548b save changes before merge
Nicola Baldo <nbaldo@cttc.es>
parents: 8366
diff changeset
   244
  Ptr<Packet> packet = socket->Recv ();
8386
419cbd9e357f S1-U now working also in uplink
Nicola Baldo <nbaldo@cttc.es>
parents: 8380
diff changeset
   245
419cbd9e357f S1-U now working also in uplink
Nicola Baldo <nbaldo@cttc.es>
parents: 8380
diff changeset
   246
  // workaround for bug 231 https://www.nsnam.org/bugzilla/show_bug.cgi?id=231
419cbd9e357f S1-U now working also in uplink
Nicola Baldo <nbaldo@cttc.es>
parents: 8380
diff changeset
   247
  SocketAddressTag satag;
419cbd9e357f S1-U now working also in uplink
Nicola Baldo <nbaldo@cttc.es>
parents: 8380
diff changeset
   248
  packet->RemovePacketTag (satag);
419cbd9e357f S1-U now working also in uplink
Nicola Baldo <nbaldo@cttc.es>
parents: 8380
diff changeset
   249
9406
7f0f9d8f8e20 new LTE RRC model
Nicola Baldo <nbaldo@cttc.es>
parents: 9345
diff changeset
   250
  EpsBearerTag tag;
8380
f615b30c26e1 S1-U working in downlink
Nicola Baldo <nbaldo@cttc.es>
parents: 8378
diff changeset
   251
  bool found = packet->RemovePacketTag (tag);
f615b30c26e1 S1-U working in downlink
Nicola Baldo <nbaldo@cttc.es>
parents: 8378
diff changeset
   252
  NS_ASSERT (found);
9442
ea15d4676dff release UE context at EpcEnbApplication upon X2 UE CONTEXT RELEASE
Nicola Baldo <nbaldo@cttc.es>
parents: 9439
diff changeset
   253
  uint16_t rnti = tag.GetRnti ();
ea15d4676dff release UE context at EpcEnbApplication upon X2 UE CONTEXT RELEASE
Nicola Baldo <nbaldo@cttc.es>
parents: 9439
diff changeset
   254
  uint8_t bid = tag.GetBid ();
ea15d4676dff release UE context at EpcEnbApplication upon X2 UE CONTEXT RELEASE
Nicola Baldo <nbaldo@cttc.es>
parents: 9439
diff changeset
   255
  NS_LOG_LOGIC ("received packet with RNTI=" << (uint32_t) rnti << ", BID=" << (uint32_t)  bid);
ea15d4676dff release UE context at EpcEnbApplication upon X2 UE CONTEXT RELEASE
Nicola Baldo <nbaldo@cttc.es>
parents: 9439
diff changeset
   256
  std::map<uint16_t, std::map<uint8_t, uint32_t> >::iterator rntiIt = m_rbidTeidMap.find (rnti);
9583
2ffd086b410c discard packets for which UE context is not found
Nicola Baldo <nbaldo@cttc.es>
parents: 9576
diff changeset
   257
  if (rntiIt == m_rbidTeidMap.end ())
2ffd086b410c discard packets for which UE context is not found
Nicola Baldo <nbaldo@cttc.es>
parents: 9576
diff changeset
   258
    {
2ffd086b410c discard packets for which UE context is not found
Nicola Baldo <nbaldo@cttc.es>
parents: 9576
diff changeset
   259
      NS_LOG_WARN ("UE context not found, discarding packet");
2ffd086b410c discard packets for which UE context is not found
Nicola Baldo <nbaldo@cttc.es>
parents: 9576
diff changeset
   260
    }
2ffd086b410c discard packets for which UE context is not found
Nicola Baldo <nbaldo@cttc.es>
parents: 9576
diff changeset
   261
  else
2ffd086b410c discard packets for which UE context is not found
Nicola Baldo <nbaldo@cttc.es>
parents: 9576
diff changeset
   262
    {
2ffd086b410c discard packets for which UE context is not found
Nicola Baldo <nbaldo@cttc.es>
parents: 9576
diff changeset
   263
      std::map<uint8_t, uint32_t>::iterator bidIt = rntiIt->second.find (bid);
2ffd086b410c discard packets for which UE context is not found
Nicola Baldo <nbaldo@cttc.es>
parents: 9576
diff changeset
   264
      NS_ASSERT (bidIt != rntiIt->second.end ());
2ffd086b410c discard packets for which UE context is not found
Nicola Baldo <nbaldo@cttc.es>
parents: 9576
diff changeset
   265
      uint32_t teid = bidIt->second;
2ffd086b410c discard packets for which UE context is not found
Nicola Baldo <nbaldo@cttc.es>
parents: 9576
diff changeset
   266
      SendToS1uSocket (packet, teid);
2ffd086b410c discard packets for which UE context is not found
Nicola Baldo <nbaldo@cttc.es>
parents: 9576
diff changeset
   267
    }
8357
7bb52f00c205 Refurbished GTP tunneling implementation + documentation
Jaume Nin
parents:
diff changeset
   268
}
7bb52f00c205 Refurbished GTP tunneling implementation + documentation
Jaume Nin
parents:
diff changeset
   269
8378
0d8107d1548b save changes before merge
Nicola Baldo <nbaldo@cttc.es>
parents: 8366
diff changeset
   270
void 
0d8107d1548b save changes before merge
Nicola Baldo <nbaldo@cttc.es>
parents: 8366
diff changeset
   271
EpcEnbApplication::RecvFromS1uSocket (Ptr<Socket> socket)
0d8107d1548b save changes before merge
Nicola Baldo <nbaldo@cttc.es>
parents: 8366
diff changeset
   272
{
8380
f615b30c26e1 S1-U working in downlink
Nicola Baldo <nbaldo@cttc.es>
parents: 8378
diff changeset
   273
  NS_LOG_FUNCTION (this << socket);  
8378
0d8107d1548b save changes before merge
Nicola Baldo <nbaldo@cttc.es>
parents: 8366
diff changeset
   274
  NS_ASSERT (socket == m_s1uSocket);
0d8107d1548b save changes before merge
Nicola Baldo <nbaldo@cttc.es>
parents: 8366
diff changeset
   275
  Ptr<Packet> packet = socket->Recv ();
0d8107d1548b save changes before merge
Nicola Baldo <nbaldo@cttc.es>
parents: 8366
diff changeset
   276
  GtpuHeader gtpu;
0d8107d1548b save changes before merge
Nicola Baldo <nbaldo@cttc.es>
parents: 8366
diff changeset
   277
  packet->RemoveHeader (gtpu);
0d8107d1548b save changes before merge
Nicola Baldo <nbaldo@cttc.es>
parents: 8366
diff changeset
   278
  uint32_t teid = gtpu.GetTeid ();
9406
7f0f9d8f8e20 new LTE RRC model
Nicola Baldo <nbaldo@cttc.es>
parents: 9345
diff changeset
   279
  std::map<uint32_t, EpsFlowId_t>::iterator it = m_teidRbidMap.find (teid);
8380
f615b30c26e1 S1-U working in downlink
Nicola Baldo <nbaldo@cttc.es>
parents: 8378
diff changeset
   280
  NS_ASSERT (it != m_teidRbidMap.end ());
f615b30c26e1 S1-U working in downlink
Nicola Baldo <nbaldo@cttc.es>
parents: 8378
diff changeset
   281
f615b30c26e1 S1-U working in downlink
Nicola Baldo <nbaldo@cttc.es>
parents: 8378
diff changeset
   282
  // workaround for bug 231 https://www.nsnam.org/bugzilla/show_bug.cgi?id=231
f615b30c26e1 S1-U working in downlink
Nicola Baldo <nbaldo@cttc.es>
parents: 8378
diff changeset
   283
  SocketAddressTag tag;
f615b30c26e1 S1-U working in downlink
Nicola Baldo <nbaldo@cttc.es>
parents: 8378
diff changeset
   284
  packet->RemovePacketTag (tag);
f615b30c26e1 S1-U working in downlink
Nicola Baldo <nbaldo@cttc.es>
parents: 8378
diff changeset
   285
  
9406
7f0f9d8f8e20 new LTE RRC model
Nicola Baldo <nbaldo@cttc.es>
parents: 9345
diff changeset
   286
  SendToLteSocket (packet, it->second.m_rnti, it->second.m_bid);
8378
0d8107d1548b save changes before merge
Nicola Baldo <nbaldo@cttc.es>
parents: 8366
diff changeset
   287
}
0d8107d1548b save changes before merge
Nicola Baldo <nbaldo@cttc.es>
parents: 8366
diff changeset
   288
0d8107d1548b save changes before merge
Nicola Baldo <nbaldo@cttc.es>
parents: 8366
diff changeset
   289
void 
9406
7f0f9d8f8e20 new LTE RRC model
Nicola Baldo <nbaldo@cttc.es>
parents: 9345
diff changeset
   290
EpcEnbApplication::SendToLteSocket (Ptr<Packet> packet, uint16_t rnti, uint8_t bid)
8380
f615b30c26e1 S1-U working in downlink
Nicola Baldo <nbaldo@cttc.es>
parents: 8378
diff changeset
   291
{
9622
affdc8251c1c added logging of packet size in EpcEnbApplication
Nicola Baldo <nbaldo@cttc.es>
parents: 9583
diff changeset
   292
  NS_LOG_FUNCTION (this << packet << rnti << (uint16_t) bid << packet->GetSize ());  
9406
7f0f9d8f8e20 new LTE RRC model
Nicola Baldo <nbaldo@cttc.es>
parents: 9345
diff changeset
   293
  EpsBearerTag tag (rnti, bid);
8380
f615b30c26e1 S1-U working in downlink
Nicola Baldo <nbaldo@cttc.es>
parents: 8378
diff changeset
   294
  packet->AddPacketTag (tag);
f615b30c26e1 S1-U working in downlink
Nicola Baldo <nbaldo@cttc.es>
parents: 8378
diff changeset
   295
  int sentBytes = m_lteSocket->Send (packet);
f615b30c26e1 S1-U working in downlink
Nicola Baldo <nbaldo@cttc.es>
parents: 8378
diff changeset
   296
  NS_ASSERT (sentBytes > 0);
f615b30c26e1 S1-U working in downlink
Nicola Baldo <nbaldo@cttc.es>
parents: 8378
diff changeset
   297
}
f615b30c26e1 S1-U working in downlink
Nicola Baldo <nbaldo@cttc.es>
parents: 8378
diff changeset
   298
f615b30c26e1 S1-U working in downlink
Nicola Baldo <nbaldo@cttc.es>
parents: 8378
diff changeset
   299
f615b30c26e1 S1-U working in downlink
Nicola Baldo <nbaldo@cttc.es>
parents: 8378
diff changeset
   300
void 
8378
0d8107d1548b save changes before merge
Nicola Baldo <nbaldo@cttc.es>
parents: 8366
diff changeset
   301
EpcEnbApplication::SendToS1uSocket (Ptr<Packet> packet, uint32_t teid)
0d8107d1548b save changes before merge
Nicola Baldo <nbaldo@cttc.es>
parents: 8366
diff changeset
   302
{
9622
affdc8251c1c added logging of packet size in EpcEnbApplication
Nicola Baldo <nbaldo@cttc.es>
parents: 9583
diff changeset
   303
  NS_LOG_FUNCTION (this << packet << teid <<  packet->GetSize ());  
8380
f615b30c26e1 S1-U working in downlink
Nicola Baldo <nbaldo@cttc.es>
parents: 8378
diff changeset
   304
  GtpuHeader gtpu;
8378
0d8107d1548b save changes before merge
Nicola Baldo <nbaldo@cttc.es>
parents: 8366
diff changeset
   305
  gtpu.SetTeid (teid);
0d8107d1548b save changes before merge
Nicola Baldo <nbaldo@cttc.es>
parents: 8366
diff changeset
   306
  // From 3GPP TS 29.281 v10.0.0 Section 5.1
0d8107d1548b save changes before merge
Nicola Baldo <nbaldo@cttc.es>
parents: 8366
diff changeset
   307
  // Length of the payload + the non obligatory GTP-U header
8380
f615b30c26e1 S1-U working in downlink
Nicola Baldo <nbaldo@cttc.es>
parents: 8378
diff changeset
   308
  gtpu.SetLength (packet->GetSize () + gtpu.GetSerializedSize () - 8);  
8378
0d8107d1548b save changes before merge
Nicola Baldo <nbaldo@cttc.es>
parents: 8366
diff changeset
   309
  packet->AddHeader (gtpu);
0d8107d1548b save changes before merge
Nicola Baldo <nbaldo@cttc.es>
parents: 8366
diff changeset
   310
  uint32_t flags = 0;
9439
5107601b7a75 added S1 path switch + S11 modify bearer for X2 handover
Nicola Baldo <nbaldo@cttc.es>
parents: 9431
diff changeset
   311
  m_s1uSocket->SendTo (packet, flags, InetSocketAddress(m_sgwS1uAddress, m_gtpuUdpPort));
8378
0d8107d1548b save changes before merge
Nicola Baldo <nbaldo@cttc.es>
parents: 8366
diff changeset
   312
}
0d8107d1548b save changes before merge
Nicola Baldo <nbaldo@cttc.es>
parents: 8366
diff changeset
   313
0d8107d1548b save changes before merge
Nicola Baldo <nbaldo@cttc.es>
parents: 8366
diff changeset
   314
8357
7bb52f00c205 Refurbished GTP tunneling implementation + documentation
Jaume Nin
parents:
diff changeset
   315
}; // namespace ns3