otg_tx.h 7.37 KB
Newer Older
1
/*******************************************************************************
nikaeinn's avatar
nikaeinn committed
2 3
    OpenAirInterface
    Copyright(c) 1999 - 2014 Eurecom
4

nikaeinn's avatar
nikaeinn committed
5 6 7 8
    OpenAirInterface is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.
9 10


nikaeinn's avatar
nikaeinn committed
11 12 13 14
    OpenAirInterface is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.
15

nikaeinn's avatar
nikaeinn committed
16 17 18 19
    You should have received a copy of the GNU General Public License
    along with OpenAirInterface.The full GNU General Public License is
    included in this distribution in the file called "COPYING". If not,
    see <http://www.gnu.org/licenses/>.
20 21

  Contact Information
nikaeinn's avatar
nikaeinn committed
22 23 24 25
  OpenAirInterface Admin: openair_admin@eurecom.fr
  OpenAirInterface Tech : openair_tech@eurecom.fr
  OpenAirInterface Dev  : openair4g-devel@eurecom.fr

ghaddab's avatar
ghaddab committed
26
  Address      : Eurecom, Campus SophiaTech, 450 Route des Chappes, CS 50193 - 06904 Biot Sophia Antipolis cedex, FRANCE
27 28 29 30

*******************************************************************************/

/*! \file otg_tx.h
31
* \brief Data structure and functions for OTG
32 33 34 35
* \author N. Nikaein and A. Hafsaoui
* \date 2011
* \version 1.0
* \company Eurecom
nikaeinn's avatar
nikaeinn committed
36
* \email: navid.nikaein@eurecom.fr
37 38 39 40 41
* \note
* \warning
*/

#ifndef __OTG_TX_H__
42
# define __OTG_TX_H__
43 44 45 46 47 48 49 50 51 52 53 54 55 56



#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <unistd.h>


#include "otg.h"
//#include "COMMON/platform_constants.h"


57
/*! \fn int time_dist(const int src, const int dst, const int state)
58 59
* \brief compute Inter Departure Time, in ms
* \param[in] Source, destination, state
60 61
* \param[out] Inter Departure Time
* \note
62 63
* @ingroup  _otg
*/
64 65 66 67 68
int time_dist(
  const int src_instance,
  const int dst_instance,
  const int application,
  const int state);
69

70
/*! \fn int size_dist(const int src, const int dst, const int state)
71
* \brief compute the payload size, in bytes
72 73
* \param[in] Source, node_dst, state
* \param[out] size of the payload, in bytes
74
* \note
75 76
* @ingroup  _otg
*/
77 78 79 80 81
int size_dist(
  const int src_instance,
  const int dst_instance,
  const int application,
  const int state);
82

83
/*! \fn char *random_string(const int size, const ALPHABET_GEN mode, const ALPHABET_TYPE data_type);
84
* \brief return a random string[size]
85
* \param[in] size  of the string to generate,
86 87 88
* \param[in] ALPHABET_GEN  : static or random string
* \param[in] ALPHABET_TYPE : numeric or letters + numeric
* \param[out] string of a random char
89
* \note
90 91
* @ingroup  _otg
*/
92
char * random_string(const int size, const ALPHABET_GEN mode, const ALPHABET_TYPE data_type);
93

94
/*! \fn int packet_gen(const int src, const int dst, const int state, const int ctime)
95
* \brief return int= 1 if the packet is generated: OTG header + header + payload, else 0
96 97
* \param[in] src source identity
* \param[in] dst destination id
98
* \param[in] application id that might generate the packet
99
* \param[out] final packet size
100
* \param[out] packet_t: the generated packet: otg_header + header + payload
101
* \note
102 103
* @ingroup  _otg
*/
104 105 106 107 108 109 110 111
unsigned char *packet_gen(
  const int src_instance,
  const int dst_instance,
  const int app,
  const int ctime,
  unsigned int * const pkt_size);

/*! \fn unsigned char * packet_gen_multicast(const int src, const int dst, const int ctime, unsigned int * const pkt_size)
winckel's avatar
winckel committed
112 113 114
* \brief return int= 1 if the packet is generated: OTG header + header + payload, else 0
* \param[in] src source identity
* \param[in] dst destination id
115
* \param[in] ctime
winckel's avatar
winckel committed
116 117 118 119
* \param[out] final packet size
* \note
* @ingroup  _otg
*/
120 121 122 123 124
unsigned char *packet_gen_multicast(
  const int src_instance,
  const int dst_instance,
  const int ctime,
  unsigned int * const pkt_size);
125

126
/*! \fn char *header_gen(const int  hdr_size);
127 128
* \brief generate IP (v4/v6) + transport header(TCP/UDP)
* \param[in] int : size
129
* \param[out] the payload corresponding to ip version and transport protocol
130
* \note
131 132
* @ingroup  _otg
*/
133
unsigned char *header_gen(const int hdr_size);
134

135
/*! \fn char *payload_pkts(const int payload_size);
136
* \brief generate the payload
137
* \param[in] int : payload size
138
* \param[out] char * payload
139
* \note
140 141
* @ingroup  _otg
*/
142
unsigned char *payload_pkts(const int payload_size);
143 144


145
/*! \fn
146
char * serialize_buffer(char* const header, char* const payload, const unsigned int buffer_size, const int flag, const int flow_id, const int ctime, const int seq_num, const int hdr_type, const int state)
147 148 149 150
* \brief serilize the packet and add otg control information
* \param[in] char* header pointer to the header
* \param[in] char* payload pointer to the payload
* \param[in] buffer_size size of the serilized tx buffer
151 152 153
* \param[in] flag for regular and background traffic
* \param[in] flow_id
* \param[in] ctime time of the transmission
154 155
* \param[in] seq_num sequence number of the packet used to calculate the loss rate
* \param[in] hdr_type indicatting the ip protocol version and transport protocol
156 157
* \param[in] state indicate in which state (PU, ED, PE) the packet is generated when generating M2M traffic
flow id, simulation time, , sequence number, header type (to know the transport/ip version in the RX)
158 159 160 161
* \param[out] tx_buffer the serilized packet
* @ingroup  _otg
*/

162 163 164 165 166 167 168 169 170 171 172 173 174 175
unsigned char * serialize_buffer(
  char* const header,
  char* const payload,
  const unsigned int buffer_size,
  const unsigned int traffic_type,
  const int flag,
  const int flow_id,
  const int ctime,
  const int seq_num,
  const int hdr_type,
  const int state,
  const unsigned int aggregation_level,
  const int src_instance,
  const int dst_instance);
176 177 178


/*! \fn int adjust_size(int size);
179 180
* \brief adjuste the generated packet size when size<min or size>max
* \param[in]  size
181
* \param[out] modified size in case
182
* \note
183 184 185 186 187 188
* @ingroup  _otg
*/
int adjust_size(int size);


/*! \fn int header_size_genint src();
189
* \brief return the header size corresponding to ip version and transport protocol
190
* \param[in]  the sender (src)
191 192
* \param[out] size of packet header
* \note
193 194
* @ingroup  _otg
*/
195
void header_size_gen(const int src, const int dst, const int application);
196

197
void init_predef_multicast_traffic(void);
198 199

/*! \fn void init_predef_traffic();
200 201 202 203
* \brief initialise OTG with predifined value for pre-configured traffic: cbr, openarena,etc.
* \param[in]
* \param[out]
* \note
204 205
* @ingroup  _otg
*/
206
void init_predef_traffic(const unsigned char nb_ue_local, const unsigned char nb_enb_local);
207

208
/*! \fn int background_gen(const int src, const int dst, const int ctime);
209
* \brief manage idt and packet size for the backgrounf traffic.
210 211 212
* \param[in] src
* \param[in] dst
* \param[in] ctime
213 214
* \param[out]
* \note
215 216
* @ingroup  _otg
*/
217
int background_gen(const int src, const int dst, const int ctime);
218

219
int header_size_gen_background(const int src, const int dst);
220

221
void state_management(const int src, const int dst,const int application, const int ctime);
222

223
void voip_traffic(const int src, const int dst, const int application, const int ctime);
224

225 226 227
int otg_hdr_size(
  const int src_instance,
  const int dst_instance);
228

229
void init_packet_gen(const int src_instance, const int dst_instance, const int ctime);
230

231
int check_data_transmit(const int src,const int dst, const int app, const int ctime);
232

233
unsigned int get_application_state(const int src, const int dst, const int application, const int ctime);
234

235
void check_ctime(const int ctime);
236 237

#endif