src/lte/model/epc-enb-application.cc
author Nicola Baldo <nbaldo@cttc.es>
Wed, 28 Nov 2012 11:37:28 +0100
changeset 9430 e8b87593ee5b
parent 9414 7b0db3dbf19b
child 9431 d157ce87b1c0
permissions -rw-r--r--
added MME with simulated S1AP and S11 interfaces
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
9430
e8b87593ee5b added MME with simulated S1AP and S11 interfaces
Nicola Baldo <nbaldo@cttc.es>
parents: 9414
diff changeset
    81
EpcEnbApplication::EpcEnbApplication (Ptr<Socket> lteSocket, Ptr<Socket> s1uSocket, Ipv4Address sgwAddress, 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),    
8386
419cbd9e357f S1-U now working also in uplink
Nicola Baldo <nbaldo@cttc.es>
parents: 8380
diff changeset
    84
    m_sgwAddress (sgwAddress),
9430
e8b87593ee5b added MME with simulated S1AP and S11 interfaces
Nicola Baldo <nbaldo@cttc.es>
parents: 9414
diff changeset
    85
    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
    86
    m_s1SapUser (0),
e8b87593ee5b added MME with simulated S1AP and S11 interfaces
Nicola Baldo <nbaldo@cttc.es>
parents: 9414
diff changeset
    87
    m_s1apSapMme (0),
e8b87593ee5b added MME with simulated S1AP and S11 interfaces
Nicola Baldo <nbaldo@cttc.es>
parents: 9414
diff changeset
    88
    m_cellId (cellId)
8357
7bb52f00c205 Refurbished GTP tunneling implementation + documentation
Jaume Nin
parents:
diff changeset
    89
{
8386
419cbd9e357f S1-U now working also in uplink
Nicola Baldo <nbaldo@cttc.es>
parents: 8380
diff changeset
    90
  NS_LOG_FUNCTION (this << lteSocket << s1uSocket << sgwAddress);
8380
f615b30c26e1 S1-U working in downlink
Nicola Baldo <nbaldo@cttc.es>
parents: 8378
diff changeset
    91
  m_s1uSocket->SetRecvCallback (MakeCallback (&EpcEnbApplication::RecvFromS1uSocket, this));
f615b30c26e1 S1-U working in downlink
Nicola Baldo <nbaldo@cttc.es>
parents: 8378
diff changeset
    92
  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
    93
  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
    94
  m_s1apSapEnb = new MemberEpcS1apSapEnb<EpcEnbApplication> (this);
8378
0d8107d1548b save changes before merge
Nicola Baldo <nbaldo@cttc.es>
parents: 8366
diff changeset
    95
}
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
EpcEnbApplication::~EpcEnbApplication (void)
0d8107d1548b save changes before merge
Nicola Baldo <nbaldo@cttc.es>
parents: 8366
diff changeset
    99
{
8380
f615b30c26e1 S1-U working in downlink
Nicola Baldo <nbaldo@cttc.es>
parents: 8378
diff changeset
   100
  NS_LOG_FUNCTION (this);
8378
0d8107d1548b save changes before merge
Nicola Baldo <nbaldo@cttc.es>
parents: 8366
diff changeset
   101
}
9337
ae7126b266ce revised LTE protocol stack for new RRC model
Nicola Baldo <nbaldo@cttc.es>
parents: 8462
diff changeset
   102
ae7126b266ce revised LTE protocol stack for new RRC model
Nicola Baldo <nbaldo@cttc.es>
parents: 8462
diff changeset
   103
8380
f615b30c26e1 S1-U working in downlink
Nicola Baldo <nbaldo@cttc.es>
parents: 8378
diff changeset
   104
void 
9337
ae7126b266ce revised LTE protocol stack for new RRC model
Nicola Baldo <nbaldo@cttc.es>
parents: 8462
diff changeset
   105
EpcEnbApplication::SetS1SapUser (EpcEnbS1SapUser * s)
ae7126b266ce revised LTE protocol stack for new RRC model
Nicola Baldo <nbaldo@cttc.es>
parents: 8462
diff changeset
   106
{
ae7126b266ce revised LTE protocol stack for new RRC model
Nicola Baldo <nbaldo@cttc.es>
parents: 8462
diff changeset
   107
  m_s1SapUser = s;
ae7126b266ce revised LTE protocol stack for new RRC model
Nicola Baldo <nbaldo@cttc.es>
parents: 8462
diff changeset
   108
}
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
EpcEnbS1SapProvider* 
ae7126b266ce revised LTE protocol stack for new RRC model
Nicola Baldo <nbaldo@cttc.es>
parents: 8462
diff changeset
   112
EpcEnbApplication::GetS1SapProvider ()
ae7126b266ce revised LTE protocol stack for new RRC model
Nicola Baldo <nbaldo@cttc.es>
parents: 8462
diff changeset
   113
{
ae7126b266ce revised LTE protocol stack for new RRC model
Nicola Baldo <nbaldo@cttc.es>
parents: 8462
diff changeset
   114
  return m_s1SapProvider;
ae7126b266ce revised LTE protocol stack for new RRC model
Nicola Baldo <nbaldo@cttc.es>
parents: 8462
diff changeset
   115
}
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
void 
9430
e8b87593ee5b added MME with simulated S1AP and S11 interfaces
Nicola Baldo <nbaldo@cttc.es>
parents: 9414
diff changeset
   118
EpcEnbApplication::SetS1apSapMme (EpcS1apSapMme * s)
e8b87593ee5b added MME with simulated S1AP and S11 interfaces
Nicola Baldo <nbaldo@cttc.es>
parents: 9414
diff changeset
   119
{
e8b87593ee5b added MME with simulated S1AP and S11 interfaces
Nicola Baldo <nbaldo@cttc.es>
parents: 9414
diff changeset
   120
  m_s1apSapMme = s;
e8b87593ee5b added MME with simulated S1AP and S11 interfaces
Nicola Baldo <nbaldo@cttc.es>
parents: 9414
diff changeset
   121
}
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
EpcS1apSapEnb* 
e8b87593ee5b added MME with simulated S1AP and S11 interfaces
Nicola Baldo <nbaldo@cttc.es>
parents: 9414
diff changeset
   125
EpcEnbApplication::GetS1apSapEnb ()
e8b87593ee5b added MME with simulated S1AP and S11 interfaces
Nicola Baldo <nbaldo@cttc.es>
parents: 9414
diff changeset
   126
{
e8b87593ee5b added MME with simulated S1AP and S11 interfaces
Nicola Baldo <nbaldo@cttc.es>
parents: 9414
diff changeset
   127
  return m_s1apSapEnb;
e8b87593ee5b added MME with simulated S1AP and S11 interfaces
Nicola Baldo <nbaldo@cttc.es>
parents: 9414
diff changeset
   128
}
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
void 
9337
ae7126b266ce revised LTE protocol stack for new RRC model
Nicola Baldo <nbaldo@cttc.es>
parents: 8462
diff changeset
   131
EpcEnbApplication::ErabSetupRequest (uint32_t teid, uint64_t imsi, EpsBearer bearer)
8380
f615b30c26e1 S1-U working in downlink
Nicola Baldo <nbaldo@cttc.es>
parents: 8378
diff changeset
   132
{
9337
ae7126b266ce revised LTE protocol stack for new RRC model
Nicola Baldo <nbaldo@cttc.es>
parents: 8462
diff changeset
   133
  NS_LOG_FUNCTION (this << teid << imsi);
ae7126b266ce revised LTE protocol stack for new RRC model
Nicola Baldo <nbaldo@cttc.es>
parents: 8462
diff changeset
   134
  // request the RRC to setup a radio bearer
ae7126b266ce revised LTE protocol stack for new RRC model
Nicola Baldo <nbaldo@cttc.es>
parents: 8462
diff changeset
   135
  struct EpcEnbS1SapUser::DataRadioBearerSetupRequestParameters params;
ae7126b266ce revised LTE protocol stack for new RRC model
Nicola Baldo <nbaldo@cttc.es>
parents: 8462
diff changeset
   136
  params.bearer = bearer;
9408
80fa1de0bef2 implemented UeManager::GetErabList ()
Nicola Baldo <nbaldo@cttc.es>
parents: 9406
diff changeset
   137
  params.gtpTeid = teid;
9345
8290ae6cab62 add/remove UEs and bearers upon handover
Nicola Baldo <nicola@baldo.biz>
parents: 9337
diff changeset
   138
  std::map<uint64_t, uint16_t>::iterator it = m_imsiRntiMap.find (imsi);
8290ae6cab62 add/remove UEs and bearers upon handover
Nicola Baldo <nicola@baldo.biz>
parents: 9337
diff changeset
   139
  NS_ASSERT_MSG (it != m_imsiRntiMap.end (), "unknown IMSI");
8290ae6cab62 add/remove UEs and bearers upon handover
Nicola Baldo <nicola@baldo.biz>
parents: 9337
diff changeset
   140
  params.rnti = it->second;
9337
ae7126b266ce revised LTE protocol stack for new RRC model
Nicola Baldo <nbaldo@cttc.es>
parents: 8462
diff changeset
   141
  m_s1SapUser->DataRadioBearerSetupRequest (params);
ae7126b266ce revised LTE protocol stack for new RRC model
Nicola Baldo <nbaldo@cttc.es>
parents: 8462
diff changeset
   142
}
ae7126b266ce revised LTE protocol stack for new RRC model
Nicola Baldo <nbaldo@cttc.es>
parents: 8462
diff changeset
   143
ae7126b266ce revised LTE protocol stack for new RRC model
Nicola Baldo <nbaldo@cttc.es>
parents: 8462
diff changeset
   144
void 
9345
8290ae6cab62 add/remove UEs and bearers upon handover
Nicola Baldo <nicola@baldo.biz>
parents: 9337
diff changeset
   145
EpcEnbApplication::DoS1BearerSetupRequest (EpcEnbS1SapProvider::S1BearerSetupRequestParameters params)
9337
ae7126b266ce revised LTE protocol stack for new RRC model
Nicola Baldo <nbaldo@cttc.es>
parents: 8462
diff changeset
   146
{
9406
7f0f9d8f8e20 new LTE RRC model
Nicola Baldo <nbaldo@cttc.es>
parents: 9345
diff changeset
   147
  NS_LOG_FUNCTION (this << params.rnti << params.bid);
7f0f9d8f8e20 new LTE RRC model
Nicola Baldo <nbaldo@cttc.es>
parents: 9345
diff changeset
   148
  EpsFlowId_t rbid (params.rnti, params.bid);
8380
f615b30c26e1 S1-U working in downlink
Nicola Baldo <nbaldo@cttc.es>
parents: 8378
diff changeset
   149
  // side effect: create entries if not exist
9408
80fa1de0bef2 implemented UeManager::GetErabList ()
Nicola Baldo <nbaldo@cttc.es>
parents: 9406
diff changeset
   150
  m_rbidTeidMap[rbid] = params.gtpTeid;
80fa1de0bef2 implemented UeManager::GetErabList ()
Nicola Baldo <nbaldo@cttc.es>
parents: 9406
diff changeset
   151
  m_teidRbidMap[params.gtpTeid] = rbid;
8380
f615b30c26e1 S1-U working in downlink
Nicola Baldo <nbaldo@cttc.es>
parents: 8378
diff changeset
   152
}
8378
0d8107d1548b save changes before merge
Nicola Baldo <nbaldo@cttc.es>
parents: 8366
diff changeset
   153
9345
8290ae6cab62 add/remove UEs and bearers upon handover
Nicola Baldo <nicola@baldo.biz>
parents: 9337
diff changeset
   154
8290ae6cab62 add/remove UEs and bearers upon handover
Nicola Baldo <nicola@baldo.biz>
parents: 9337
diff changeset
   155
void 
8290ae6cab62 add/remove UEs and bearers upon handover
Nicola Baldo <nicola@baldo.biz>
parents: 9337
diff changeset
   156
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
   157
{
8290ae6cab62 add/remove UEs and bearers upon handover
Nicola Baldo <nicola@baldo.biz>
parents: 9337
diff changeset
   158
  NS_LOG_FUNCTION (this);
8290ae6cab62 add/remove UEs and bearers upon handover
Nicola Baldo <nicola@baldo.biz>
parents: 9337
diff changeset
   159
  // side effect: create entry if not exist
8290ae6cab62 add/remove UEs and bearers upon handover
Nicola Baldo <nicola@baldo.biz>
parents: 9337
diff changeset
   160
  m_imsiRntiMap[imsi] = rnti;
9430
e8b87593ee5b added MME with simulated S1AP and S11 interfaces
Nicola Baldo <nbaldo@cttc.es>
parents: 9414
diff changeset
   161
  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
   162
}
e8b87593ee5b added MME with simulated S1AP and S11 interfaces
Nicola Baldo <nbaldo@cttc.es>
parents: 9414
diff changeset
   163
e8b87593ee5b added MME with simulated S1AP and S11 interfaces
Nicola Baldo <nbaldo@cttc.es>
parents: 9414
diff changeset
   164
e8b87593ee5b added MME with simulated S1AP and S11 interfaces
Nicola Baldo <nbaldo@cttc.es>
parents: 9414
diff changeset
   165
void 
e8b87593ee5b added MME with simulated S1AP and S11 interfaces
Nicola Baldo <nbaldo@cttc.es>
parents: 9414
diff changeset
   166
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
   167
{
e8b87593ee5b added MME with simulated S1AP and S11 interfaces
Nicola Baldo <nbaldo@cttc.es>
parents: 9414
diff changeset
   168
  NS_LOG_FUNCTION (this);
e8b87593ee5b added MME with simulated S1AP and S11 interfaces
Nicola Baldo <nbaldo@cttc.es>
parents: 9414
diff changeset
   169
  
e8b87593ee5b added MME with simulated S1AP and S11 interfaces
Nicola Baldo <nbaldo@cttc.es>
parents: 9414
diff changeset
   170
  for (std::list<EpcS1apSapEnb::ErabToBeSetupItem>::iterator it = erabToBeSetupList.begin ();
e8b87593ee5b added MME with simulated S1AP and S11 interfaces
Nicola Baldo <nbaldo@cttc.es>
parents: 9414
diff changeset
   171
       it != erabToBeSetupList.end ();
e8b87593ee5b added MME with simulated S1AP and S11 interfaces
Nicola Baldo <nbaldo@cttc.es>
parents: 9414
diff changeset
   172
       ++it)
e8b87593ee5b added MME with simulated S1AP and S11 interfaces
Nicola Baldo <nbaldo@cttc.es>
parents: 9414
diff changeset
   173
    {
e8b87593ee5b added MME with simulated S1AP and S11 interfaces
Nicola Baldo <nbaldo@cttc.es>
parents: 9414
diff changeset
   174
      ErabSetupRequest (it->sgwTeid, mmeUeS1Id, it->erabLevelQosParameters);
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
}
e8b87593ee5b added MME with simulated S1AP and S11 interfaces
Nicola Baldo <nbaldo@cttc.es>
parents: 9414
diff changeset
   177
e8b87593ee5b added MME with simulated S1AP and S11 interfaces
Nicola Baldo <nbaldo@cttc.es>
parents: 9414
diff changeset
   178
void 
e8b87593ee5b added MME with simulated S1AP and S11 interfaces
Nicola Baldo <nbaldo@cttc.es>
parents: 9414
diff changeset
   179
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
   180
{
e8b87593ee5b added MME with simulated S1AP and S11 interfaces
Nicola Baldo <nbaldo@cttc.es>
parents: 9414
diff changeset
   181
  NS_LOG_FUNCTION (this);
e8b87593ee5b added MME with simulated S1AP and S11 interfaces
Nicola Baldo <nbaldo@cttc.es>
parents: 9414
diff changeset
   182
  NS_FATAL_ERROR ("not implemented");
9345
8290ae6cab62 add/remove UEs and bearers upon handover
Nicola Baldo <nicola@baldo.biz>
parents: 9337
diff changeset
   183
}
8290ae6cab62 add/remove UEs and bearers upon handover
Nicola Baldo <nicola@baldo.biz>
parents: 9337
diff changeset
   184
8378
0d8107d1548b save changes before merge
Nicola Baldo <nbaldo@cttc.es>
parents: 8366
diff changeset
   185
void 
0d8107d1548b save changes before merge
Nicola Baldo <nbaldo@cttc.es>
parents: 8366
diff changeset
   186
EpcEnbApplication::RecvFromLteSocket (Ptr<Socket> socket)
0d8107d1548b save changes before merge
Nicola Baldo <nbaldo@cttc.es>
parents: 8366
diff changeset
   187
{
0d8107d1548b save changes before merge
Nicola Baldo <nbaldo@cttc.es>
parents: 8366
diff changeset
   188
  NS_LOG_FUNCTION (this);  
0d8107d1548b save changes before merge
Nicola Baldo <nbaldo@cttc.es>
parents: 8366
diff changeset
   189
  NS_ASSERT (socket == m_lteSocket);
0d8107d1548b save changes before merge
Nicola Baldo <nbaldo@cttc.es>
parents: 8366
diff changeset
   190
  Ptr<Packet> packet = socket->Recv ();
8386
419cbd9e357f S1-U now working also in uplink
Nicola Baldo <nbaldo@cttc.es>
parents: 8380
diff changeset
   191
419cbd9e357f S1-U now working also in uplink
Nicola Baldo <nbaldo@cttc.es>
parents: 8380
diff changeset
   192
  // 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
   193
  SocketAddressTag satag;
419cbd9e357f S1-U now working also in uplink
Nicola Baldo <nbaldo@cttc.es>
parents: 8380
diff changeset
   194
  packet->RemovePacketTag (satag);
419cbd9e357f S1-U now working also in uplink
Nicola Baldo <nbaldo@cttc.es>
parents: 8380
diff changeset
   195
9406
7f0f9d8f8e20 new LTE RRC model
Nicola Baldo <nbaldo@cttc.es>
parents: 9345
diff changeset
   196
  EpsBearerTag tag;
8380
f615b30c26e1 S1-U working in downlink
Nicola Baldo <nbaldo@cttc.es>
parents: 8378
diff changeset
   197
  bool found = packet->RemovePacketTag (tag);
f615b30c26e1 S1-U working in downlink
Nicola Baldo <nbaldo@cttc.es>
parents: 8378
diff changeset
   198
  NS_ASSERT (found);
9406
7f0f9d8f8e20 new LTE RRC model
Nicola Baldo <nbaldo@cttc.es>
parents: 9345
diff changeset
   199
  EpsFlowId_t flowId;
8380
f615b30c26e1 S1-U working in downlink
Nicola Baldo <nbaldo@cttc.es>
parents: 8378
diff changeset
   200
  flowId.m_rnti = tag.GetRnti ();
9406
7f0f9d8f8e20 new LTE RRC model
Nicola Baldo <nbaldo@cttc.es>
parents: 9345
diff changeset
   201
  flowId.m_bid = tag.GetBid ();
7f0f9d8f8e20 new LTE RRC model
Nicola Baldo <nbaldo@cttc.es>
parents: 9345
diff changeset
   202
  NS_LOG_LOGIC ("received packet with RNTI=" << flowId.m_rnti << ", BID=" << (uint16_t)  flowId.m_bid);
7f0f9d8f8e20 new LTE RRC model
Nicola Baldo <nbaldo@cttc.es>
parents: 9345
diff changeset
   203
  std::map<EpsFlowId_t, uint32_t>::iterator it = m_rbidTeidMap.find (flowId);
8380
f615b30c26e1 S1-U working in downlink
Nicola Baldo <nbaldo@cttc.es>
parents: 8378
diff changeset
   204
  NS_ASSERT (it != m_rbidTeidMap.end ());
f615b30c26e1 S1-U working in downlink
Nicola Baldo <nbaldo@cttc.es>
parents: 8378
diff changeset
   205
  uint32_t teid = it->second;
8378
0d8107d1548b save changes before merge
Nicola Baldo <nbaldo@cttc.es>
parents: 8366
diff changeset
   206
  SendToS1uSocket (packet, teid);
8357
7bb52f00c205 Refurbished GTP tunneling implementation + documentation
Jaume Nin
parents:
diff changeset
   207
}
7bb52f00c205 Refurbished GTP tunneling implementation + documentation
Jaume Nin
parents:
diff changeset
   208
8378
0d8107d1548b save changes before merge
Nicola Baldo <nbaldo@cttc.es>
parents: 8366
diff changeset
   209
void 
0d8107d1548b save changes before merge
Nicola Baldo <nbaldo@cttc.es>
parents: 8366
diff changeset
   210
EpcEnbApplication::RecvFromS1uSocket (Ptr<Socket> socket)
0d8107d1548b save changes before merge
Nicola Baldo <nbaldo@cttc.es>
parents: 8366
diff changeset
   211
{
8380
f615b30c26e1 S1-U working in downlink
Nicola Baldo <nbaldo@cttc.es>
parents: 8378
diff changeset
   212
  NS_LOG_FUNCTION (this << socket);  
8378
0d8107d1548b save changes before merge
Nicola Baldo <nbaldo@cttc.es>
parents: 8366
diff changeset
   213
  NS_ASSERT (socket == m_s1uSocket);
0d8107d1548b save changes before merge
Nicola Baldo <nbaldo@cttc.es>
parents: 8366
diff changeset
   214
  Ptr<Packet> packet = socket->Recv ();
0d8107d1548b save changes before merge
Nicola Baldo <nbaldo@cttc.es>
parents: 8366
diff changeset
   215
  GtpuHeader gtpu;
0d8107d1548b save changes before merge
Nicola Baldo <nbaldo@cttc.es>
parents: 8366
diff changeset
   216
  packet->RemoveHeader (gtpu);
0d8107d1548b save changes before merge
Nicola Baldo <nbaldo@cttc.es>
parents: 8366
diff changeset
   217
  uint32_t teid = gtpu.GetTeid ();
9406
7f0f9d8f8e20 new LTE RRC model
Nicola Baldo <nbaldo@cttc.es>
parents: 9345
diff changeset
   218
  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
   219
  NS_ASSERT (it != m_teidRbidMap.end ());
f615b30c26e1 S1-U working in downlink
Nicola Baldo <nbaldo@cttc.es>
parents: 8378
diff changeset
   220
f615b30c26e1 S1-U working in downlink
Nicola Baldo <nbaldo@cttc.es>
parents: 8378
diff changeset
   221
  // 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
   222
  SocketAddressTag tag;
f615b30c26e1 S1-U working in downlink
Nicola Baldo <nbaldo@cttc.es>
parents: 8378
diff changeset
   223
  packet->RemovePacketTag (tag);
f615b30c26e1 S1-U working in downlink
Nicola Baldo <nbaldo@cttc.es>
parents: 8378
diff changeset
   224
  
9406
7f0f9d8f8e20 new LTE RRC model
Nicola Baldo <nbaldo@cttc.es>
parents: 9345
diff changeset
   225
  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
   226
}
0d8107d1548b save changes before merge
Nicola Baldo <nbaldo@cttc.es>
parents: 8366
diff changeset
   227
0d8107d1548b save changes before merge
Nicola Baldo <nbaldo@cttc.es>
parents: 8366
diff changeset
   228
void 
9406
7f0f9d8f8e20 new LTE RRC model
Nicola Baldo <nbaldo@cttc.es>
parents: 9345
diff changeset
   229
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
   230
{
9406
7f0f9d8f8e20 new LTE RRC model
Nicola Baldo <nbaldo@cttc.es>
parents: 9345
diff changeset
   231
  NS_LOG_FUNCTION (this << packet << rnti << (uint16_t) bid);  
7f0f9d8f8e20 new LTE RRC model
Nicola Baldo <nbaldo@cttc.es>
parents: 9345
diff changeset
   232
  EpsBearerTag tag (rnti, bid);
8380
f615b30c26e1 S1-U working in downlink
Nicola Baldo <nbaldo@cttc.es>
parents: 8378
diff changeset
   233
  packet->AddPacketTag (tag);
f615b30c26e1 S1-U working in downlink
Nicola Baldo <nbaldo@cttc.es>
parents: 8378
diff changeset
   234
  int sentBytes = m_lteSocket->Send (packet);
f615b30c26e1 S1-U working in downlink
Nicola Baldo <nbaldo@cttc.es>
parents: 8378
diff changeset
   235
  NS_ASSERT (sentBytes > 0);
f615b30c26e1 S1-U working in downlink
Nicola Baldo <nbaldo@cttc.es>
parents: 8378
diff changeset
   236
}
f615b30c26e1 S1-U working in downlink
Nicola Baldo <nbaldo@cttc.es>
parents: 8378
diff changeset
   237
f615b30c26e1 S1-U working in downlink
Nicola Baldo <nbaldo@cttc.es>
parents: 8378
diff changeset
   238
f615b30c26e1 S1-U working in downlink
Nicola Baldo <nbaldo@cttc.es>
parents: 8378
diff changeset
   239
void 
8378
0d8107d1548b save changes before merge
Nicola Baldo <nbaldo@cttc.es>
parents: 8366
diff changeset
   240
EpcEnbApplication::SendToS1uSocket (Ptr<Packet> packet, uint32_t teid)
0d8107d1548b save changes before merge
Nicola Baldo <nbaldo@cttc.es>
parents: 8366
diff changeset
   241
{
8380
f615b30c26e1 S1-U working in downlink
Nicola Baldo <nbaldo@cttc.es>
parents: 8378
diff changeset
   242
  NS_LOG_FUNCTION (this << packet << teid);  
f615b30c26e1 S1-U working in downlink
Nicola Baldo <nbaldo@cttc.es>
parents: 8378
diff changeset
   243
  GtpuHeader gtpu;
8378
0d8107d1548b save changes before merge
Nicola Baldo <nbaldo@cttc.es>
parents: 8366
diff changeset
   244
  gtpu.SetTeid (teid);
0d8107d1548b save changes before merge
Nicola Baldo <nbaldo@cttc.es>
parents: 8366
diff changeset
   245
  // 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
   246
  // 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
   247
  gtpu.SetLength (packet->GetSize () + gtpu.GetSerializedSize () - 8);  
8378
0d8107d1548b save changes before merge
Nicola Baldo <nbaldo@cttc.es>
parents: 8366
diff changeset
   248
  packet->AddHeader (gtpu);
0d8107d1548b save changes before merge
Nicola Baldo <nbaldo@cttc.es>
parents: 8366
diff changeset
   249
  uint32_t flags = 0;
8386
419cbd9e357f S1-U now working also in uplink
Nicola Baldo <nbaldo@cttc.es>
parents: 8380
diff changeset
   250
  m_s1uSocket->SendTo (packet, flags, InetSocketAddress(m_sgwAddress, m_gtpuUdpPort));
8378
0d8107d1548b save changes before merge
Nicola Baldo <nbaldo@cttc.es>
parents: 8366
diff changeset
   251
}
0d8107d1548b save changes before merge
Nicola Baldo <nbaldo@cttc.es>
parents: 8366
diff changeset
   252
0d8107d1548b save changes before merge
Nicola Baldo <nbaldo@cttc.es>
parents: 8366
diff changeset
   253
8357
7bb52f00c205 Refurbished GTP tunneling implementation + documentation
Jaume Nin
parents:
diff changeset
   254
}; // namespace ns3