Merge branch 'develop' into develop-nr

This commit is contained in:
yilmazt
2019-05-17 17:11:31 +02:00
867 changed files with 123167 additions and 84023 deletions
+8 -14
View File
@@ -46,15 +46,10 @@ static void *link_manager_sender_thread(void *_manager)
LOG_D(MAC, "starting link manager sender thread\n");
while (manager->run) {
while (message_get(manager->send_queue, &data, &size, &priority) == 0) {
link_send_packet(manager->socket_link, data, size);
while ((size = message_get(manager->send_queue, &data, &priority)) > 0) {
link_send_packet(manager->socket_link, data, size, manager->peer_addr, manager->peer_port);
free(data);
}
// if (message_get(manager->send_queue, &data, &size, &priority))
// goto error;
//if (link_send_packet(manager->socket_link, data, size))
// goto error;
//free(data);
}
LOG_D(MAC, "link manager sender thread quits\n");
@@ -124,9 +119,6 @@ link_manager_t *create_link_manager(
pthread_attr_setschedpolicy(&attr, SCHED_RR);
//#endif
if (pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED))
goto error;
if (pthread_create(&t, &attr, link_manager_sender_thread, ret))
goto error;
ret->sender = t;
@@ -151,9 +143,11 @@ error:
void destroy_link_manager(link_manager_t *manager)
{
LOG_D(MAC, "destroying link manager\n");
manager->run = 0;
/* todo: force threads to stop (using a dummy message?) */
message_get_unlock(manager->send_queue);
pthread_join(manager->sender, NULL);
/* cancel aborts the read performed in the receiver, then cancels the thread */
pthread_cancel(manager->receiver);
}
#ifdef SERVER_TEST
@@ -186,7 +180,7 @@ int main(void)
data = strdup("hello"); if (data == NULL) goto error;
if (message_put(send_queue, data, 6, 100)) goto error;
if (message_get(receive_queue, &data, &size, &priority)) goto error;
if ((size = message_get(receive_queue, &data, &priority)) <= 0) goto error;
printf("received message:\n");
printf(" data: %s\n", (char *)data);
printf(" size: %d\n", size);
@@ -230,7 +224,7 @@ int main(void)
manager = create_link_manager(send_queue, receive_queue, link);
if (manager == NULL) goto error;
if (message_get(receive_queue, &data, &size, &priority)) goto error;
if ((size = message_get(receive_queue, &data, &priority)) <= 0) goto error;
printf("received message:\n");
printf(" data: %s\n", (char *)data);
printf(" size: %d\n", size);
+5 -2
View File
@@ -31,8 +31,8 @@
#ifndef LINK_MANAGER_H
#define LINK_MANAGER_H
//#include "message_queue.h"
#include "ringbuffer_queue.h"
#include "message_queue.h"
//#include "ringbuffer_queue.h"
#include "socket_link.h"
#include <pthread.h>
@@ -45,6 +45,8 @@ typedef struct {
message_queue_t *send_queue;
message_queue_t *receive_queue;
socket_link_t *socket_link;
const char *peer_addr; /* for UDP server remote IP */
int peer_port; /* for UDP server remote address */
pthread_t sender;
pthread_t receiver;
volatile int run;
@@ -54,6 +56,7 @@ link_manager_t *create_link_manager(
message_queue_t *send_queue,
message_queue_t *receive_queue,
socket_link_t *link);
void destroy_link_manager(link_manager_t *);
#ifdef __cplusplus
+28 -9
View File
@@ -56,6 +56,10 @@ message_queue_t *new_message_queue(void)
if (pthread_cond_init(ret->cond, NULL))
goto error;
ret->head = NULL;
ret->tail = NULL;
ret->exit = 0;
return ret;
error:
@@ -72,6 +76,8 @@ error:
int message_put(message_queue_t *queue, void *data, int size, int priority)
{
message_t *m = NULL;
if (size <= 0)
goto error;
m = calloc(1, sizeof(message_t));
if (m == NULL)
@@ -106,12 +112,12 @@ int message_put(message_queue_t *queue, void *data, int size, int priority)
return 0;
error:
free(m);
if (m) free(m);
LOG_E(MAC, "%s: an error occured\n", __FUNCTION__);
return -1;
}
int message_get(message_queue_t *queue, void **data, int *size, int *priority)
int message_get(message_queue_t *queue, void **data, int *priority)
{
message_t *m;
@@ -119,10 +125,15 @@ int message_get(message_queue_t *queue, void **data, int *size, int *priority)
goto error;
while (queue->count == 0) {
if (pthread_cond_wait(queue->cond, queue->mutex)) {
int rc = pthread_cond_wait(queue->cond, queue->mutex);
if (rc != 0) {
pthread_mutex_unlock(queue->mutex);
goto error;
}
if (queue->exit) {
pthread_mutex_unlock(queue->mutex);
return 0;
}
}
m = queue->head;
@@ -136,17 +147,24 @@ int message_get(message_queue_t *queue, void **data, int *size, int *priority)
goto error;
*data = m->data;
*size = m->size;
const int size = m->size;
*priority = m->priority;
free(m);
return 0;
return size;
error:
LOG_E(MAC, "%s: an error occured\n", __FUNCTION__);
return -1;
}
void message_get_unlock(message_queue_t *queue)
{
pthread_mutex_lock(queue->mutex);
queue->exit = 1;
pthread_mutex_unlock(queue->mutex);
pthread_cond_signal(queue->cond);
}
/* when calling this function, the queue must not be used anymore (we don't lock it) */
/* we suppose that the data pointer in messages was allocated by malloc/calloc/realloc */
void destroy_message_queue(message_queue_t *queue)
@@ -181,10 +199,10 @@ int main(void)
if (message_put(q, "hello", 6, 0)) goto error;
if (message_put(q, "world", 6, 1)) goto error;
if (message_get(q, &data, &size, &priority)) goto error;
if ((size = message_get(q, &data, &priority)) <= 0) goto error;
printf("message:\n data: '%s'\n size: %d\n priority: %d\n",
(char *)data, size, priority);
if (message_get(q, &data, &size, &priority)) goto error;
if ((size = message_get(q, &data, &priority)) <= 0) goto error;
printf("message:\n data: '%s'\n size: %d\n priority: %d\n",
(char *)data, size, priority);
@@ -193,10 +211,11 @@ int main(void)
sprintf(s, "hello");
if (message_put(q, s, 6, 0)) goto error;
destroy_message_queue(q);
free(s);
return 0;
error:
free(s);
printf("error\n");
return 1;
}
+4 -1
View File
@@ -41,6 +41,7 @@ typedef struct message_t {
void *data;
int size;
int priority;
struct message_t *next;
} message_t;
@@ -50,11 +51,13 @@ typedef struct {
volatile int count;
pthread_mutex_t *mutex;
pthread_cond_t *cond;
int exit;
} message_queue_t;
message_queue_t *new_message_queue(void);
int message_put(message_queue_t *queue, void *data, int size, int priority);
int message_get(message_queue_t *queue, void **data, int *size, int *priority);
int message_get(message_queue_t *queue, void **data, int *priority);
void message_get_unlock(message_queue_t *queue);
void destroy_message_queue(message_queue_t *queue);
#ifdef __cplusplus
+11 -4
View File
@@ -67,6 +67,9 @@ int message_put(message_queue_t *queue, void *data, int size, int priority) {
message_t *overwritten_msg;
message_t *m = NULL;
if (size <= 0)
goto error;
LFDS700_MISC_MAKE_VALID_ON_CURRENT_LOGICAL_CORE_INITS_COMPLETED_BEFORE_NOW_ON_ANY_OTHER_LOGICAL_CORE;
lfds700_misc_prng_init(&ls);
@@ -94,12 +97,11 @@ int message_put(message_queue_t *queue, void *data, int size, int priority) {
return 0;
error:
free(m);
LOG_E(MAC, "%s: an error occured\n", __FUNCTION__);
return -1;
}
int message_get(message_queue_t *queue, void **data, int *size, int *priority) {
int message_get(message_queue_t *queue, void **data, int *priority) {
message_t *m;
struct lfds700_misc_prng_state ls;
@@ -111,10 +113,15 @@ int message_get(message_queue_t *queue, void **data, int *size, int *priority) {
}
*data = m->data;
*size = m->size;
const int size = m->size;
*priority = m->priority;
free(m);
return 0;
return size;
}
void message_get_unlock(message_queue_t *queue) {
/* don't do anything, this function exists to unlock a message_queue but is
* not needed in the case of the ringbuffer_queue */
}
void destroy_message_queue(message_queue_t *queue) {
+2 -1
View File
@@ -47,7 +47,8 @@ typedef struct {
message_queue_t * new_message_queue(int size);
int message_put(message_queue_t *queue, void *data, int size, int priority);
int message_get(message_queue_t *queue, void **data, int *size, int *priority);
int message_get(message_queue_t *queue, void **data, int *priority);
void message_get_unlock(message_queue_t *queue);
void destroy_message_queue(message_queue_t *queue);
#endif /* RINGBUFFER_QUEUE_H */
+331 -40
View File
@@ -51,6 +51,7 @@ socket_link_t *new_link_server(int port)
socklen_t addrlen;
int socket_server = -1;
int no_delay;
ret = calloc(1, sizeof(socket_link_t));
if (ret == NULL) {
@@ -59,22 +60,26 @@ socket_link_t *new_link_server(int port)
}
ret->socket_fd = -1;
LOG_D(MAC, "create a new link server socket at port %d\n", port);
//printf("MAC create a new link server socket at port %d\n", port);
socket_server = socket(AF_INET, SOCK_STREAM, 0);
if (socket_server == -1) {
LOG_E(MAC, "%s:%d: socket: %s\n", __FILE__, __LINE__, strerror(errno));
goto error;
}
ret->type = SOCK_STREAM;
reuse = 1;
if (setsockopt(socket_server, SOL_SOCKET, SO_REUSEADDR, &reuse, sizeof(reuse)) == -1) {
LOG_E(MAC, "%s:%d: setsockopt: %s\n", __FILE__, __LINE__, strerror(errno));
goto error;
}
no_delay = 1;
if (setsockopt(socket_server, IPPROTO_TCP, TCP_NODELAY, &no_delay, sizeof(no_delay)) == -1) {
LOG_E(MAC, "%s:%d: setsockopt: %s\n", __FILE__, __LINE__, strerror(errno));
goto error;
}
@@ -99,20 +104,19 @@ socket_link_t *new_link_server(int port)
goto error;
}
close(socket_server);
LOG_D(MAC, "connection from %s:%d\n", inet_ntoa(addr.sin_addr), ntohs(addr.sin_port));
//printf("MAC connection from %s:%d\n", inet_ntoa(addr.sin_addr), ntohs(addr.sin_port));
return ret;
error:
close(socket_server);
if (ret != NULL) close(ret->socket_fd);
free(ret);
LOG_E(MAC, "ERROR in new_link_server (see above), returning NULL\n");
return NULL;
}
socket_link_t *new_link_client(char *server, int port)
socket_link_t *new_link_client(const char *server, int port)
{
socket_link_t *ret = NULL;
struct sockaddr_in addr;
@@ -132,6 +136,7 @@ socket_link_t *new_link_client(char *server, int port)
LOG_E(MAC, "%s:%d: socket: %s\n", __FILE__, __LINE__, strerror(errno));
goto error;
}
ret->type = SOCK_STREAM;
no_delay = 1;
if (setsockopt(ret->socket_fd, SOL_TCP, TCP_NODELAY, &no_delay, sizeof(no_delay)) == -1) {
@@ -160,6 +165,263 @@ error:
return NULL;
}
socket_link_t *new_link_udp_server(const char *bind_addr, int bind_port)
{
socket_link_t *ret = NULL;
struct sockaddr_in si_me;
int socket_server = -1;
ret = calloc(1, sizeof(socket_link_t));
if (ret == NULL) {
LOG_D(PROTO_AGENT, "%s:%d: out of memory\n", __FILE__, __LINE__);
goto error;
}
ret->socket_fd = -1;
//printf("PROTO_AGENT: create a new udp link server socket at port %d\n", port);
//create a UDP socket
if ((socket_server=socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP)) == -1) {
goto error;
}
ret->type = SOCK_DGRAM;
// zero out the structure
memset((char *) &si_me, 0, sizeof(si_me));
si_me.sin_family = AF_INET;
si_me.sin_port = htons(bind_port);
if (bind_addr) {
if (!inet_aton(bind_addr, &si_me.sin_addr))
goto error;
} else {
si_me.sin_addr.s_addr = INADDR_ANY;
}
//bind socket to port
if( bind(socket_server , (struct sockaddr*)&si_me, sizeof(si_me) ) == -1) {
fprintf(stderr, "could not bind to address %s: %s\n", bind_addr, strerror(errno));
goto error;
}
ret->socket_fd = socket_server;
return ret;
error:
if (socket_server != -1) close(socket_server);
if (ret != NULL) close(ret->socket_fd);
free(ret);
//printf("\n\n\nERROR PROTO_AGENT: ERROR in new_link_udp_server (see above), returning NULL\n");
return NULL;
}
socket_link_t *new_link_udp_client(const char *server, int port){
socket_link_t *ret = NULL;
ret = calloc(1, sizeof(socket_link_t));
if (ret == NULL) {
LOG_E(MAC, "%s:%d: out of memory\n", __FILE__, __LINE__);
goto error;
}
ret->socket_fd = -1;
struct sockaddr_in si_other;
int s;
socklen_t slen;
if ( (s=socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP)) == -1){
goto error;
}
ret->type = SOCK_DGRAM;
memset((char *) &si_other, 0, sizeof(si_other));
si_other.sin_family = AF_INET;
si_other.sin_port = 0; //htons(port);
if (inet_aton(server, &si_other.sin_addr) == 0){
fprintf(stderr, "inet_aton() failed\n");
goto error;
}
connect(s, (struct sockaddr *)&si_other, sizeof(si_other));
getsockname(s, (struct sockaddr *)&si_other, &slen);
ret->socket_fd = s;
return ret;
error:
if (ret != NULL) {
close(ret->socket_fd);
free(ret);
}
LOG_E(MAC, "ERROR in new_link_udp_client (see above), returning NULL\n");
return NULL;
}
socket_link_t *new_link_sctp_server(int port)
{
socket_link_t *ret = NULL;
int listenSock = -1, temp;
struct sockaddr_in servaddr;
listenSock = socket (AF_INET, SOCK_STREAM, IPPROTO_SCTP);
if(listenSock == -1)
{
perror("socket()");
exit(1);
}
bzero ((void *) &servaddr, sizeof (servaddr));
servaddr.sin_family = AF_INET;
servaddr.sin_addr.s_addr = INADDR_ANY;
servaddr.sin_port = htons(port);
temp = bind (listenSock, (struct sockaddr *) &servaddr, sizeof (servaddr));
if(temp == -1 )
{
perror("bind()");
close(listenSock);
exit(1);
}
temp = listen (listenSock, 5);
if(temp == -1 )
{
perror("listen()");
close(listenSock);
exit(1);
}
ret = calloc(1, sizeof(socket_link_t));
if (ret == NULL) {
LOG_D(PROTO_AGENT, "%s:%d: out of memory\n", __FILE__, __LINE__);
goto error;
}
ret->socket_fd = -1;
ret->socket_fd = accept (listenSock, NULL, NULL);
ret->type = SOCK_STREAM;
return ret;
error:
if (listenSock != -1) close(listenSock);
if (ret != NULL) close(ret->socket_fd);
free(ret);
LOG_E(MAC,"ERROR in new_link_sctp_server (see above), returning NULL\n");
return NULL;
}
socket_link_t *new_link_sctp_client(const char *server, int port)
{
socket_link_t *ret = NULL;
ret = calloc(1, sizeof(socket_link_t));
if (ret == NULL) {
LOG_D(PROTO_AGENT, "%s:%d: out of memory\n", __FILE__, __LINE__);
goto error;
}
ret->socket_fd = -1;
int temp;
struct sockaddr_in servaddr;
ret->socket_fd = socket (AF_INET, SOCK_STREAM, IPPROTO_SCTP);
if (ret->socket_fd == -1)
{
perror("socket()");
exit(1);
}
ret->type = SOCK_STREAM;
bzero ((void *) &servaddr, sizeof (servaddr));
servaddr.sin_family = AF_INET;
servaddr.sin_port = htons (port);
if (inet_aton(server, &servaddr.sin_addr) == 0) {
LOG_E(MAC,"invalid IP address '%s', use a.b.c.d notation\n", server);
goto error;
}
temp = connect (ret->socket_fd, (struct sockaddr *) &servaddr, sizeof (servaddr));
if (temp == -1)
{
perror("connect()");
close(ret->socket_fd);
exit(1);
}
return ret;
error:
if (ret != NULL) close(ret->socket_fd);
free(ret);
LOG_E(MAC, "ERROR in new_link_sctp_client (see above), returning NULL\n");
return NULL;
}
static int socket_udp_send(int socket_fd, void *buf, int size, const char *peer_addr, int port)
{
struct sockaddr_in si_other;
int slen = sizeof(si_other);
int l;
int my_socket;
LOG_D(PROTO_AGENT,"UDP send\n");
my_socket = socket_fd;
memset((char *) &si_other, 0, sizeof(si_other));
si_other.sin_family = AF_INET;
si_other.sin_port = htons(port);
if (inet_aton(peer_addr , &si_other.sin_addr) == 0)
{
fprintf(stderr, "inet_aton() failed\n");
exit(1);
}
l = sendto(my_socket, buf, size, 0, (struct sockaddr *) &si_other, slen);
if (l == -1) goto error;
return l;
error:
LOG_E(MAC,"socket_udp_send: ERROR: %s\n", strerror(errno));
return -1;
}
static int socket_udp_receive(int socket_fd, void *buf, int size)
{
LOG_D(PROTO_AGENT,"UDP RECEIVE\n");
struct sockaddr_in client;
socklen_t slen;
int l;
l = recvfrom(socket_fd, buf, size, 0, (struct sockaddr *) &client, &slen);
//getsockname(socket_fd, (struct sockaddr *)&client, &slen);
if (l == -1) goto error;
if (l == 0) goto socket_closed;
return l;
error:
LOG_E(MAC, "socket_udp_receive: ERROR: %s\n", strerror(errno));
return -1;
socket_closed:
LOG_E(MAC, "socket_udp_receive: socket closed\n");
return -1;
}
/*
* return -1 on error and 0 if the sending was fine
*/
@@ -213,63 +475,92 @@ socket_closed:
/*
* return -1 on error and 0 if the sending was fine
*/
int link_send_packet(socket_link_t *link, void *data, int size)
int link_send_packet(socket_link_t *link, void *data, int size, const char *peer_addr, int peer_port)
{
char sizebuf[4];
int32_t s = size;
switch (link->type) {
case SOCK_STREAM:
/* send the size first, maximum is 2^31 bytes */
sizebuf[0] = (s >> 24) & 255;
sizebuf[1] = (s >> 16) & 255;
sizebuf[2] = (s >> 8) & 255;
sizebuf[3] = s & 255;
if (socket_send(link->socket_fd, sizebuf, 4) == -1)
return -1;
/* send the size first, maximum is 2^31 bytes */
sizebuf[0] = (s >> 24) & 255;
sizebuf[1] = (s >> 16) & 255;
sizebuf[2] = (s >> 8) & 255;
sizebuf[3] = s & 255;
link->bytes_sent += 4;
if (socket_send(link->socket_fd, sizebuf, 4) == -1)
goto error;
link->bytes_sent += 4;
if (socket_send(link->socket_fd, data, size) == -1)
goto error;
if (socket_send(link->socket_fd, data, size) == -1)
return -1;
break;
case SOCK_DGRAM:
/* UDP is connectionless -> only send the data */
if (socket_udp_send(link->socket_fd, data, size, peer_addr, peer_port) == -1)
return -1;
break;
default:
LOG_E(MAC, "unknown socket type %d\n", link->type);
return -1;
}
link->bytes_sent += size;
link->packets_sent++;
return 0;
error:
return -1;
}
/*
* return -1 on error and 0 if the sending was fine
*/
int link_receive_packet(socket_link_t *link, void **ret_data, int *ret_size)
{
unsigned char sizebuf[4];
int32_t size;
int32_t size = 0;
void *data = NULL;
/* received the size first, maximum is 2^31 bytes */
if (socket_receive(link->socket_fd, sizebuf, 4) == -1)
goto error;
switch (link->type) {
case SOCK_STREAM:
if (socket_receive(link->socket_fd, sizebuf, 4) == -1)
goto error;
size = (sizebuf[0] << 24) |
(sizebuf[1] << 16) |
(sizebuf[2] << 8) |
sizebuf[3];
size = (sizebuf[0] << 24) |
(sizebuf[1] << 16) |
(sizebuf[2] << 8) |
sizebuf[3];
link->bytes_received += 4;
link->bytes_received += 4;
data = malloc(size);
if (data == NULL) {
LOG_E(MAC, "%s:%d: out of memory\n", __FILE__, __LINE__);
data = malloc(size);
if (data == NULL) {
LOG_E(MAC, "%s:%d: out of memory\n", __FILE__, __LINE__);
goto error;
}
if (socket_receive(link->socket_fd, data, size) == -1)
goto error;
break;
case SOCK_DGRAM:
/* we get a single packet (no size, UDP could lose it). Therefore, prepare
* for the maximum UDP packet size */
size = 65535;
data = malloc(size);
if (data == NULL) {
LOG_E(MAC, "%s:%d: out of memory\n", __FILE__, __LINE__);
goto error;
}
size = socket_udp_receive(link->socket_fd, data, size);
if (size < 0)
goto error;
break;
default:
LOG_E(MAC, "unknown socket type %d\n", link->type);
goto error;
}
if (socket_receive(link->socket_fd, data, size) == -1)
goto error;
link->bytes_received += size;
link->packets_received++;
@@ -313,8 +604,8 @@ int main(void)
*/
sleep(1);
printf("... done\n");
if (link_send_packet(l, "hello\n", 6+1) ||
link_send_packet(l, "world\n", 6+1)) return 1;
if (link_send_packet(l, "hello\n", 6+1, NULL, 0) ||
link_send_packet(l, "world\n", 6+1, NULL, 0)) return 1;
if (link_receive_packet(l, &data, &size)) return 1; printf("%s", (char *)data); free(data);
if (link_receive_packet(l, &data, &size)) return 1; printf("%s", (char *)data); free(data);
printf("stats:\n");
@@ -342,8 +633,8 @@ int main(void)
printf("link is up\n");
if (link_receive_packet(l, &data, &size)) return 1; printf("%s", (char *)data); free(data);
if (link_receive_packet(l, &data, &size)) return 1; printf("%s", (char *)data); free(data);
if (link_send_packet(l, "bye\n", 4+1) ||
link_send_packet(l, "server\n", 7+1)) return 1;
if (link_send_packet(l, "bye\n", 4+1, NULL, 0) ||
link_send_packet(l, "server\n", 7+1, NULL, 0)) return 1;
printf("stats:\n");
printf(" sent packets %"PRIu64"\n", l->packets_sent);
printf(" sent bytes %"PRIu64"\n", l->bytes_sent);
+10 -2
View File
@@ -37,8 +37,10 @@
extern "C" {
#endif
typedef struct {
int socket_fd;
int type;
uint64_t bytes_sent;
uint64_t packets_sent;
uint64_t bytes_received;
@@ -46,11 +48,17 @@ typedef struct {
} socket_link_t;
socket_link_t *new_link_server(int port);
socket_link_t *new_link_client(char *server, int port);
int link_send_packet(socket_link_t *link, void *data, int size);
socket_link_t *new_link_client(const char *server, int port);
/* setting bind_addr to NULL binds server to INADDR_ANY */
socket_link_t *new_link_udp_server(const char *bind_addr, int bind_port);
socket_link_t *new_link_udp_client(const char *server, int port);
socket_link_t *new_link_sctp_server(int port);
socket_link_t *new_link_sctp_client(const char *server, int port);
int link_send_packet(socket_link_t *link, void *data, int size, const char *peer_addr, int port);
int link_receive_packet(socket_link_t *link, void **data, int *size);
int close_link(socket_link_t *link);
#ifdef __cplusplus
}
#endif
-67
View File
@@ -1,67 +0,0 @@
/*
* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under
* the OAI Public License, Version 1.1 (the "License"); you may not use this file
* except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.openairinterface.org/?page_id=698
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*-------------------------------------------------------------------------------
* For more information about the OpenAirInterface (OAI) Software Alliance:
* contact@openairinterface.org
*/
#include "defs.h"
#include "linux/module.h"
#ifdef BIGPHYSAREA
#ifdef ARCH_64
char *bigphys_ptr,*bigphys_current;
#else //ARCH_64
unsigned int bigphys_ptr,bigphys_current;
#endif //ARCH_64
// return pointer to memory in big physical area aligned to 16 bytes
void* bigphys_malloc(int n)
{
int n2 = n + ((16-(n%16))%16);
#ifdef ARCH_64
char *bigphys_old;
#else
unsigned int bigphys_old;
#endif
printk("[BIGPHYSAREA] Calling bigphys_malloc for %d (%d) bytes\n",n,n2);
#ifdef ARCH_64
printk("[BIGPHYSAREA] Allocated Memory @ %p\n",bigphys_current);
#endif
bigphys_old = bigphys_current;
bigphys_current += n2;
#ifdef ARCH_64
printk("[BIGPHYSAREA] Allocated Memory top now @ %p\n",bigphys_current);
return ((void *)(bigphys_old));
#else //ARCH_64
//printk("[BIGPHYSAREA] Allocated Memory %d\n",bigphys_current-bigphys_ptr);
return ((void *)(bigphys_old));
#endif //ARCH_64
}
EXPORT_SYMBOL(bigphys_malloc);
#endif
-22
View File
@@ -1,22 +0,0 @@
/*
* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under
* the OAI Public License, Version 1.1 (the "License"); you may not use this file
* except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.openairinterface.org/?page_id=698
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*-------------------------------------------------------------------------------
* For more information about the OpenAirInterface (OAI) Software Alliance:
* contact@openairinterface.org
*/
void* bigphys_malloc(int);
+29 -78
View File
@@ -35,25 +35,19 @@
//#include <mpi.h>
void job_list_init (Job_List_t * listP)
{
void job_list_init (Job_List_t *listP) {
listP->tail = NULL;
listP->head = NULL;
listP->nb_elements = 0;
}
void event_list_init (Event_List_t * listP)
{
void event_list_init (Event_List_t *listP) {
listP->tail = NULL;
listP->head = NULL;
listP->nb_elements = 0;
}
void pkt_list_init (Packet_OTG_List_t * listP)
{
void pkt_list_init (Packet_OTG_List_t *listP) {
listP->tail = NULL;
listP->head = NULL;
listP->nb_elements = 0;
@@ -61,8 +55,7 @@ void pkt_list_init (Packet_OTG_List_t * listP)
//-----------------------------------------------------------------------------
void job_list_free (Job_List_t * listP)
{
void job_list_free (Job_List_t *listP) {
Job_elt_t *le;
while ((le = job_list_remove_head (listP))) {
@@ -70,8 +63,7 @@ void job_list_free (Job_List_t * listP)
}
}
void event_list_free (Event_List_t * listP)
{
void event_list_free (Event_List_t *listP) {
Event_elt_t *le;
while ((le = event_list_remove_head (listP))) {
@@ -79,8 +71,7 @@ void event_list_free (Event_List_t * listP)
}
}
void pkt_list_free (Packet_OTG_List_t * listP)
{
void pkt_list_free (Packet_OTG_List_t *listP) {
Packet_otg_elt_t *le;
while ((le = pkt_list_remove_head (listP))) {
@@ -90,18 +81,15 @@ void pkt_list_free (Packet_OTG_List_t * listP)
//-----------------------------------------------------------------------------
Job_elt_t * job_list_get_head (Job_List_t * listP)
{
Job_elt_t *job_list_get_head (Job_List_t *listP) {
return listP->head;
}
Event_elt_t * event_list_get_head (Event_List_t * listP)
{
Event_elt_t *event_list_get_head (Event_List_t *listP) {
return listP->head;
}
Packet_otg_elt_t * pkt_list_get_head (Packet_OTG_List_t * listP)
{
Packet_otg_elt_t *pkt_list_get_head (Packet_OTG_List_t *listP) {
return listP->head;
}
@@ -112,9 +100,7 @@ Packet_otg_elt_t * pkt_list_get_head (Packet_OTG_List_t * listP)
* @param pointer on targeted list
* @return pointer on removed Job_elt_t
*/
Job_elt_t * job_list_remove_head (Job_List_t * listP)
{
Job_elt_t *job_list_remove_head (Job_List_t *listP) {
// access optimisation
Job_elt_t *head;
head = listP->head;
@@ -137,9 +123,7 @@ Job_elt_t * job_list_remove_head (Job_List_t * listP)
return head;
}
Event_elt_t * event_list_remove_head (Event_List_t * listP)
{
Event_elt_t *event_list_remove_head (Event_List_t *listP) {
// access optimisation
Event_elt_t *head;
head = listP->head;
@@ -162,9 +146,7 @@ Event_elt_t * event_list_remove_head (Event_List_t * listP)
return head;
}
Packet_otg_elt_t * pkt_list_remove_head (Packet_OTG_List_t * listP)
{
Packet_otg_elt_t *pkt_list_remove_head (Packet_OTG_List_t *listP) {
// access optimisation
Packet_otg_elt_t *head;
head = listP->head;
@@ -189,9 +171,7 @@ Packet_otg_elt_t * pkt_list_remove_head (Packet_OTG_List_t * listP)
//-----------------------------------------------------------------------------
Job_elt_t * job_list_remove_element (Job_elt_t * elementP, Job_List_t * listP)
{
Job_elt_t *job_list_remove_element (Job_elt_t *elementP, Job_List_t *listP) {
// access optimisation;
Job_elt_t *head;
@@ -233,9 +213,7 @@ Job_elt_t * job_list_remove_element (Job_elt_t * elementP, Job_List_t * listP)
return elementP;
}
Event_elt_t * event_list_remove_element (Event_elt_t * elementP, Event_List_t * listP)
{
Event_elt_t *event_list_remove_element (Event_elt_t *elementP, Event_List_t *listP) {
// access optimisation;
Event_elt_t *head;
@@ -277,9 +255,7 @@ Event_elt_t * event_list_remove_element (Event_elt_t * elementP, Event_List_t *
return elementP;
}
Packet_otg_elt_t * pkt_list_remove_element (Packet_otg_elt_t * elementP, Packet_OTG_List_t * listP)
{
Packet_otg_elt_t *pkt_list_remove_element (Packet_otg_elt_t *elementP, Packet_OTG_List_t *listP) {
// access optimisation;
Packet_otg_elt_t *head;
@@ -328,9 +304,7 @@ Packet_otg_elt_t * pkt_list_remove_element (Packet_otg_elt_t * elementP, Packet_
* @return pointer on removed Job_elt_t
*/
void job_list_add_head (Job_elt_t * elementP, Job_List_t * listP)
{
void job_list_add_head (Job_elt_t *elementP, Job_List_t *listP) {
// access optimisation;
Job_elt_t *head;
@@ -349,9 +323,7 @@ void job_list_add_head (Job_elt_t * elementP, Job_List_t * listP)
}
}
void event_list_add_head (Event_elt_t * elementP, Event_List_t * listP)
{
void event_list_add_head (Event_elt_t *elementP, Event_List_t *listP) {
// access optimisation;
Event_elt_t *head;
@@ -370,9 +342,7 @@ void event_list_add_head (Event_elt_t * elementP, Event_List_t * listP)
}
}
void pkt_list_add_head (Packet_otg_elt_t * elementP, Packet_OTG_List_t * listP)
{
void pkt_list_add_head (Packet_otg_elt_t *elementP, Packet_OTG_List_t *listP) {
// access optimisation;
Packet_otg_elt_t *head;
@@ -391,14 +361,12 @@ void pkt_list_add_head (Packet_otg_elt_t * elementP, Packet_OTG_List_t * listP)
}
}
void event_list_add_element (Event_elt_t * elementP, Event_elt_t * previous, Event_List_t * listP)
{
void event_list_add_element (Event_elt_t *elementP, Event_elt_t *previous, Event_List_t *listP) {
// access optimisation;
Event_elt_t *next;
elementP->next = NULL;
if (elementP != NULL && previous != NULL) {
elementP->next = NULL;
next = previous->next;
listP->nb_elements = listP->nb_elements + 1;
@@ -420,8 +388,7 @@ void event_list_add_element (Event_elt_t * elementP, Event_elt_t * previous, Eve
* @param pointer on targeted list
* @return pointer on removed Job_elt_t
*/
void job_list_add_tail_eurecom (Job_elt_t * elementP, Job_List_t * listP)
{
void job_list_add_tail_eurecom (Job_elt_t *elementP, Job_List_t *listP) {
Job_elt_t *tail;
if (elementP != NULL) {
@@ -443,8 +410,7 @@ void job_list_add_tail_eurecom (Job_elt_t * elementP, Job_List_t * listP)
}
}
void event_list_add_tail_eurecom (Event_elt_t * elementP, Event_List_t * listP)
{
void event_list_add_tail_eurecom (Event_elt_t *elementP, Event_List_t *listP) {
Event_elt_t *tail;
if (elementP != NULL) {
@@ -466,8 +432,7 @@ void event_list_add_tail_eurecom (Event_elt_t * elementP, Event_List_t * listP)
}
}
void pkt_list_add_tail_eurecom (Packet_otg_elt_t * elementP, Packet_OTG_List_t * listP)
{
void pkt_list_add_tail_eurecom (Packet_otg_elt_t *elementP, Packet_OTG_List_t *listP) {
Packet_otg_elt_t *tail;
if (elementP != NULL) {
@@ -490,14 +455,11 @@ void pkt_list_add_tail_eurecom (Packet_otg_elt_t * elementP, Packet_OTG_List_t *
}
//-----------------------------------------------------------------------------
void job_list_add_list (Job_List_t * sublistP, Job_List_t * listP)
{
void job_list_add_list (Job_List_t *sublistP, Job_List_t *listP) {
if (sublistP) {
if (sublistP->head) {
// access optimisation
Job_elt_t *tail;
tail = listP->tail;
// almost one element
@@ -517,14 +479,11 @@ void job_list_add_list (Job_List_t * sublistP, Job_List_t * listP)
}
}
void event_list_add_list (Event_List_t * sublistP, Event_List_t * listP)
{
void event_list_add_list (Event_List_t *sublistP, Event_List_t *listP) {
if (sublistP) {
if (sublistP->head) {
// access optimisation
Event_elt_t *tail;
tail = listP->tail;
// almost one element
@@ -544,14 +503,11 @@ void event_list_add_list (Event_List_t * sublistP, Event_List_t * listP)
}
}
void pkt_list_add_list (Packet_OTG_List_t * sublistP, Packet_OTG_List_t * listP)
{
void pkt_list_add_list (Packet_OTG_List_t *sublistP, Packet_OTG_List_t *listP) {
if (sublistP) {
if (sublistP->head) {
// access optimisation
Packet_otg_elt_t *tail;
tail = listP->tail;
// almost one element
@@ -572,11 +528,8 @@ void pkt_list_add_list (Packet_OTG_List_t * sublistP, Packet_OTG_List_t * listP)
}
//-----------------------------------------------------------------------------
void job_list_display (Job_List_t * listP)
{
void job_list_display (Job_List_t *listP) {
//Correct the output once the content of struct Job is fixed
/*Job_elt_t *cursor;
unsigned short nb_elements = 0;
@@ -605,8 +558,7 @@ void job_list_display (Job_List_t * listP)
}*/
}
void event_list_display (Event_List_t * listP)
{
void event_list_display (Event_List_t *listP) {
Event_elt_t *cursor;
unsigned short nb_elements = 0;
@@ -630,8 +582,7 @@ void event_list_display (Event_List_t * listP)
}
}
void pkt_list_display (Packet_OTG_List_t * listP)
{
void pkt_list_display (Packet_OTG_List_t *listP) {
Packet_otg_elt_t *cursor;
unsigned short nb_elements = 0;
@@ -31,8 +31,6 @@ void lfds700_ringbuffer_cleanup( struct lfds700_ringbuffer_state *rs,
/****************************************************************************/
//#pragma warning( disable : 4100 )
static void lfds700_ringbuffer_internal_queue_element_cleanup_callback( struct lfds700_queue_state *qs, struct lfds700_queue_element *qe, enum lfds700_misc_flag dummy_element_flag )
{
struct lfds700_ringbuffer_element
@@ -57,9 +55,6 @@ static void lfds700_ringbuffer_internal_queue_element_cleanup_callback( struct l
//#pragma warning( default : 4100 )
/****************************************************************************/
//#pragma warning( disable : 4100 )
+3 -3
View File
@@ -112,9 +112,9 @@ typedef struct {
size_t atomSize;
size_t increment;
} varArray_t;
static inline varArray_t * initVarArray(size_t increment, size_t atomSize) {
varArray_t * tmp=malloc(sizeof(varArray_t)+increment*atomSize);
varArray_t * tmp=(varArray_t *)malloc(sizeof(varArray_t)+increment*atomSize);
tmp->size=0;
tmp->atomSize=atomSize;
tmp->mallocedSize=increment;
@@ -129,7 +129,7 @@ static inline void * dataArray(varArray_t * input) {
static inline void appendVarArray(varArray_t * input, void* data) {
if (input->size>=input->mallocedSize) {
input->mallocedSize+=input->increment;
input=realloc(input,sizeof(varArray_t)+input->mallocedSize*input->atomSize);
input=(varArray_t *)realloc(input,sizeof(varArray_t)+input->mallocedSize*input->atomSize);
}
memcpy((uint8_t*)(input+1)+input->atomSize*input->size++, data, input->atomSize);
}
File diff suppressed because it is too large Load Diff
+20 -30
View File
@@ -41,9 +41,7 @@ unsigned int s0[MAX_NUM_COMPS], s1[MAX_NUM_COMPS], s2[MAX_NUM_COMPS], b[MAX_NUM_
inline unsigned int taus(unsigned int comp)
{
inline unsigned int taus(unsigned int comp) {
b[comp] = (((s0[comp] << 13) ^ s0[comp]) >> 19);
s0[comp] = (((s0[comp] & 0xFFFFFFFE) << 12)^ b[comp]);
b[comp] = (((s1[comp] << 2) ^ s1[comp]) >> 25);
@@ -54,42 +52,36 @@ inline unsigned int taus(unsigned int comp)
return r[comp];
}
void set_taus_seed(unsigned int seed_type)
{
void set_taus_seed(unsigned int seed_type) {
unsigned int i; // i index of component
for (i=MIN_NUM_COMPS; i < MAX_NUM_COMPS ; i ++) {
switch (seed_type) {
case 0: // use rand func
if (i == 0) srand(time(NULL));
case 0: // use rand func
if (i == 0) srand(time(NULL));
s0[i] = ((unsigned int)rand());
s1[i] = ((unsigned int)rand());
s2[i] = ((unsigned int)rand());
printf("Initial seeds use rand: s0[%d] = 0x%x, s1[%d] = 0x%x, s2[%d] = 0x%x\n", i, s0[i], i, s1[i], i, s2[i]);
break;
s0[i] = ((unsigned int)rand());
s1[i] = ((unsigned int)rand());
s2[i] = ((unsigned int)rand());
printf("Initial seeds use rand: s0[%u] = 0x%x, s1[%u] = 0x%x, s2[%u] = 0x%x\n", i, s0[i], i, s1[i], i, s2[i]);
break;
case 1: // use rand with seed
if (i == 0) srand(0x1e23d851);
case 1: // use rand with seed
if (i == 0) srand(0x1e23d851);
s0[i] = ((unsigned int)rand());
s1[i] = ((unsigned int)rand());
s2[i] = ((unsigned int)rand());
printf("Initial seeds use rand with seed : s0[%d] = 0x%x, s1[%d] = 0x%x, s2[%d] = 0x%x\n", i, s0[i], i, s1[i], i, s2[i]);
break;
default:
break;
s0[i] = ((unsigned int)rand());
s1[i] = ((unsigned int)rand());
s2[i] = ((unsigned int)rand());
printf("Initial seeds use rand with seed : s0[%u] = 0x%x, s1[%u] = 0x%x, s2[%u] = 0x%x\n", i, s0[i], i, s1[i], i, s2[i]);
break;
default:
break;
}
}
}
int get_rand (unsigned int comp)
{
int get_rand (unsigned int comp) {
if ((comp > MIN_NUM_COMPS) && (comp < MAX_NUM_COMPS))
return r[comp];
else {
@@ -98,9 +90,7 @@ int get_rand (unsigned int comp)
}
}
unsigned int dtaus(unsigned int comp, unsigned int a, unsigned b)
{
unsigned int dtaus(unsigned int comp, unsigned int a, unsigned b) {
return (int) (((double)taus(comp)/(double)0xffffffff)* (double)(b-a) + (double)a);
}
/*
+2
View File
@@ -130,6 +130,8 @@ void check_free_mem_block (mem_block_t * leP);
# define MEM_MNGT_MB12_BLOCK_SIZE MEM_MNGT_MB0_BLOCK_SIZE*4096
// 262144
# define MEM_MNGT_MB12_NB_BLOCKS 32 * MEM_SCALE
//# define MEM_MNGT_MB12_NB_BLOCKS 4096 * MEM_SCALE
# define MEM_MNGT_POOL_ID12 12
-108
View File
@@ -1,108 +0,0 @@
MEM_DIR = $(OPENAIR2_TOP)/UTIL/MEM
LIST_DIR = $(OPENAIR2_TOP)/UTIL/LISTS
FIFO_DIR = $(OPENAIR2_TOP)/UTIL/FIFO
MATH_DIR = $(OPENAIR2_TOP)/UTIL/MATH
TIMER_DIR = $(OPENAIR2_TOP)/UTIL/TIMER
LOG_DIR=$(OPENAIR2_TOP)/UTIL/LOG
OCG_DIR=$(OPENAIR2_TOP)/UTIL/OCG
OPT_DIR=$(OPENAIR2_TOP)/UTIL/OPT
OMG_DIR=$(OPENAIR2_TOP)/UTIL/OMG
OTG_DIR=$(OPENAIR2_TOP)/UTIL/OTG
CLI_DIR=$(OPENAIR2_TOP)/UTIL/CLI
OMV_DIR=$(OPENAIR2_TOP)/UTIL/OMV
LFDS_DIR=$(OPENAIR2_TOP)/UTIL/LFDS/liblfds6.1.1/liblfds611
OSA_DIR=$(OPENAIR2_TOP)/UTIL/OSA
LIST_OBJ = $(LIST_DIR)/list.o
FIFO_OBJ = $(FIFO_DIR)/pad_list.o
LIST_OBJ += $(LIST_DIR)/list2.o
TIMER_OBJ += $(TIMER_DIR)/umts_timer.o
MEM_OBJ += $(MEM_DIR)/mem_block.o
LOG_OBJS = $(LOG_DIR)/log.o
LOG_OBJS += $(LOG_DIR)/vcd_signal_dumper.o
OCG_OBJS = $(OCG_DIR)/OCG.o
OCG_OBJS += $(OCG_DIR)/OCG_create_dir.o
OCG_OBJS += $(OCG_DIR)/OCG_detect_file.o
OCG_OBJS += $(OCG_DIR)/OCG_generate_report.o
OCG_OBJS += $(OCG_DIR)/OCG_parse_filename.o
OCG_OBJS += $(OCG_DIR)/OCG_parse_XML.o
OCG_OBJS += $(OCG_DIR)/OCG_save_XML.o
ifdef SECU
OSA_OBJS = $(OSA_DIR)/osa_key_deriver.o
OSA_OBJS += $(OSA_DIR)/osa_stream_eia.o
OSA_OBJS += $(OSA_DIR)/osa_stream_eea.o
OSA_OBJS += $(OSA_DIR)/osa_snow3g.o
OSA_OBJS += $(OSA_DIR)/osa_rijndael.o
endif
OPT_OBJS = $(OPT_DIR)/probe.o
OMG_OBJS = $(OMG_DIR)/omg.o
OMG_OBJS += $(OMG_DIR)/common.o
OMG_OBJS += $(OMG_DIR)/job.o
OMG_OBJS += $(OMG_DIR)/static.o
OMG_OBJS += $(OMG_DIR)/rwp.o
OMG_OBJS += $(OMG_DIR)/rwalk.o
#OMG_OBJS += $(OMG_DIR)/omg_hashtable.o
OMG_OBJS += $(OMG_DIR)/mobility_parser.o
OMG_OBJS += $(OMG_DIR)/trace.o
OMG_OBJS += $(OMG_DIR)/sumo.o
OMG_OBJS += $(OMG_DIR)/id_manager.o
OMG_OBJS += $(OMG_DIR)/client_traci_OMG.o
OMG_OBJS += $(OMG_DIR)/storage_traci_OMG.o
OMG_OBJS += $(OMG_DIR)/socket_traci_OMG.o
OMG_OBJS += $(OMG_DIR)/steadystaterwp.o
OMG_OBJS += $(OMG_DIR)/grid.o
OMG_OBJS += $(OMG_DIR)/trace_hashtable.o
OTG_OBJS = $(OTG_DIR)/otg_tx.o
OTG_OBJS += $(OTG_DIR)/otg.o
OTG_OBJS += $(OTG_DIR)/otg_rx.o
OTG_OBJS += $(OTG_DIR)/otg_kpi.o
OTG_OBJS += $(OTG_DIR)/otg_form.o
OTG_OBJS += $(OTG_DIR)/otg_models.o
MATH_OBJS = $(MATH_DIR)/oml.o
CLI_OBJ = $(CLI_DIR)/cli_server.o
CLI_OBJ += $(CLI_DIR)/cli.o
CLI_OBJ += $(CLI_DIR)/cli_cmd.o
UTIL_OBJ = \
$(OSA_OBJS) \
$(FIFO_OBJ) \
$(LIST_OBJ) \
$(TIMER_OBJ) \
$(MEM_OBJ) \
$(LOG_OBJS) \
$(OCG_OBJS) \
$(MATH_OBJS) \
$(OTG_OBJS) \
$(CLI_OBJ) \
$(OMG_OBJS) \
$(OPT_OBJS)
UTIL_incl = \
-I$(OPENAIR2_TOP)/UTIL \
-I$(OSA_DIR) \
-I$(LFDS_DIR)/inc \
-I$(MEM_DIR) \
-I$(LIST_DIR) \
-I$(FIFO_DIR) \
-I$(OCG_DIR) \
-I$(LOG_DIR) \
-I$(MATH_DIR) \
-I$(TIMER_DIR) \
-I$(OMG_DIR) \
-I$(OTG_DIR) \
-I$(CLI_DIR) \
-I$(OPT_DIR) \
-I$(OMV_DIR)
+7 -13
View File
@@ -39,10 +39,8 @@
#include "PHY/defs_common.h"
#include "PHY/impl_defs_top.h"
#include "platform_types.h"
#if defined(ENABLE_USE_MME)
# include "s1ap_eNB.h"
#endif
#ifdef __cplusplus
extern "C"
@@ -135,8 +133,7 @@ The following diagram is based on graphviz (http://www.graphviz.org/), you need
* \enddot
*/
enum
{
enum {
STATE_START_OCG, /*!< \brief initiate OCG */
STATE_GET_OPT, /*!< \brief get options of OCG command */
STATE_DETECT_FILE, /*!< \brief detect the configuration file in folder USER_XML_FOLDER */
@@ -571,7 +568,7 @@ typedef struct {
} Layer;
typedef struct {
char * level;
char *level;
char *verbosity;
int interval;
} Log_Emu;
@@ -598,8 +595,8 @@ typedef struct {
Log_Emu log_emu;
Packet_Trace packet_trace;
Seed seed;
char * curve;
char * background_stats;
char *curve;
char *background_stats;
// CLI tags are in Info
//char g_log_level[20];
} Emulation_Config;
@@ -677,7 +674,7 @@ typedef struct {
unsigned char cba_group_active;
unsigned char cba_backoff;
unsigned char handover_active;
char * otg_traffic;
char *otg_traffic;
unsigned char otg_bg_traffic_enabled;
unsigned char omg_model_rn;
unsigned char omg_model_enb;
@@ -705,7 +702,7 @@ typedef struct {
node_function_t node_function[MAX_NUM_CCs];
node_timing_t node_timing[MAX_NUM_CCs];
unsigned char frame_type[MAX_NUM_CCs]; //! LTE frame type (TDD=1, FDD=0). \note this should be converted to \ref lte_frame_type_t (header file reorganization needed)
char * frame_type_name[MAX_NUM_CCs];
char *frame_type_name[MAX_NUM_CCs];
unsigned char tdd_config[MAX_NUM_CCs];
unsigned char tdd_config_S[MAX_NUM_CCs];
unsigned char extended_prefix_flag[MAX_NUM_CCs];
@@ -713,10 +710,7 @@ typedef struct {
unsigned char transmission_mode[MAX_NUM_CCs];
int max_predefined_traffic_config_index;
int max_customized_traffic_config_index;
#if defined(ENABLE_USE_MME)
s1ap_eNB_config_t s1ap_config;
#endif
/* Per-Slot ISR
* Interval between two ISR = 500usec
+2 -30
View File
@@ -39,84 +39,60 @@
#include "OCG_config_mobi.h"
/*----------------------------------------------------------------------------*/
int config_mobi(char mobigen_filename[FILENAME_LENGTH_MAX], char filename[FILENAME_LENGTH_MAX])
{
int config_mobi(char mobigen_filename[FILENAME_LENGTH_MAX], char filename[FILENAME_LENGTH_MAX]) {
// for the xml writer, refer to http://xmlsoft.org/html/libxml-xmlwriter.html
char dir_to_mobigen_file[FILENAME_LENGTH_MAX + DIR_LENGTH_MAX] = "";
char dir_to_mobigen_file[FILENAME_LENGTH_MAX + DIR_LENGTH_MAX];
char mobi_file[FILENAME_LENGTH_MAX + DIR_LENGTH_MAX] = "";
xmlTextWriterPtr writer;
strcpy(dir_to_mobigen_file, DIR_TO_MOBIGEN);
strcat(dir_to_mobigen_file, mobigen_filename);
/* Create a new XmlWriter for uri, with no compression. */
writer = xmlNewTextWriterFilename(dir_to_mobigen_file, 0);
// set the output format of the XML file
xmlTextWriterSetIndent(writer, 1);
xmlTextWriterSetIndentString(writer, " ");
/* Start the document with the xml default for the version,
* encoding ISO 8859-1 and the default for the standalone
* declaration. */
xmlTextWriterStartDocument(writer, NULL, NULL, NULL);
/* Start an element named "EXAMPLE". Since this is the first
* element, this will be the root element of the document. */
xmlTextWriterStartElement(writer, "universe");
/* Write an element named "X_ORDER_ID" as child of HEADER. */
xmlTextWriterWriteFormatElement(writer, "dimx", "%lf", oai_emulation.topo_config.area.x);
/* Write an element named "X_ORDER_ID" as child of HEADER. */
xmlTextWriterWriteFormatElement(writer, "dimy", "%lf", oai_emulation.topo_config.area.y);
xmlTextWriterWriteFormatElement(writer, "seed", "%d", 1);
xmlTextWriterStartElement(writer, "extension");
xmlTextWriterWriteAttribute(writer, "class", "de.uni_stuttgart.informatik.canu.mobisim.simulations.TimeSimulation");
xmlTextWriterWriteFormatAttribute(writer, "param", "%lf", oai_emulation.emu_config.emu_time);
xmlTextWriterEndElement(writer);
xmlTextWriterStartElement(writer, "extension");
xmlTextWriterWriteAttribute(writer, "class", "de.uni_stuttgart.informatik.canu.spatialmodel.core.SpatialModel");
xmlTextWriterWriteFormatAttribute(writer, "max_x", "%lf", oai_emulation.topo_config.area.x);
xmlTextWriterWriteFormatAttribute(writer, "max_y", "%lf", oai_emulation.topo_config.area.y);
xmlTextWriterWriteAttribute(writer, "min_x", "0");
xmlTextWriterWriteAttribute(writer, "min_y", "0");
xmlTextWriterWriteFormatElement(writer, "dump_boundary_points", "%s", "false");
xmlTextWriterWriteFormatElement(writer, "separated_flow", "%s", "false");
xmlTextWriterWriteFormatElement(writer, "max_traffic_lights", "%d", 500);
xmlTextWriterEndElement(writer);
xmlTextWriterStartElement(writer, "extension");
xmlTextWriterWriteAttribute(writer, "class", "de.uni_stuttgart.informatik.canu.mobisim.extensions.ReportNodeMobility");
strcpy(mobi_file, MOBI_XML_FOLDER);
strcat(mobi_file, filename);
xmlTextWriterWriteAttribute(writer, "output", mobi_file);
xmlTextWriterWriteFormatElement(writer, "step", "%d", 1);
xmlTextWriterEndElement(writer);
xmlTextWriterStartElement(writer, "nodegroup");
xmlTextWriterWriteAttribute(writer, "car2x", "false");
xmlTextWriterWriteAttribute(writer, "id", "");
xmlTextWriterWriteAttribute(writer, "n", "50");
xmlTextWriterWriteAttribute(writer, "type", "car");
xmlTextWriterStartElement(writer, "position");
xmlTextWriterWriteAttribute(writer, "random", "true");
xmlTextWriterWriteFormatElement(writer, "z", "%s", "0.0");
xmlTextWriterEndElement(writer);
xmlTextWriterStartElement(writer, "extension");
xmlTextWriterWriteAttribute(writer, "class", "de.uni_stuttgart.informatik.canu.mobisim.mobilitymodels.RandomWaypointWalk");
@@ -134,12 +110,8 @@ int config_mobi(char mobigen_filename[FILENAME_LENGTH_MAX], char filename[FILENA
// Close the element named HEADER.
xmlTextWriterEndElement(writer);
xmlTextWriterEndDocument(writer);
xmlFreeTextWriter(writer);
return MODULE_OK;
}
+12 -22
View File
@@ -42,39 +42,29 @@
/*----------------------------------------------------------------------------*/
int generate_report(char dst_dir[DIR_LENGTH_MAX], char filename[FILENAME_LENGTH_MAX])
{
int generate_report(char dst_dir[DIR_LENGTH_MAX], char filename[FILENAME_LENGTH_MAX]) {
// for the xml writer, refer to http://xmlsoft.org/html/libxml-xmlwriter.html
char dst_file[FILENAME_LENGTH_MAX + DIR_LENGTH_MAX] = "";
strncat(dst_file, dst_dir, FILENAME_LENGTH_MAX + DIR_LENGTH_MAX - strlen(dst_file) - 1);
strncat(dst_file, filename, FILENAME_LENGTH_MAX + DIR_LENGTH_MAX - strlen(dst_file) - 1);
char dst_file[FILENAME_LENGTH_MAX + DIR_LENGTH_MAX];
strncpy(dst_file, dst_dir, FILENAME_LENGTH_MAX + DIR_LENGTH_MAX - strlen(filename) - 1);
strcat(dst_file, filename);
xmlTextWriterPtr writer;
writer = xmlNewTextWriterFilename(dst_file, 0);
// set the output format of the XML file
xmlTextWriterSetIndent(writer, 1);
xmlTextWriterSetIndentString(writer,(unsigned char*) " ");
xmlTextWriterSetIndentString(writer,(unsigned char *) " ");
xmlTextWriterStartDocument(writer, NULL, NULL, NULL);
/* Write an element named "X_ORDER_ID" as child of HEADER. */
xmlTextWriterWriteFormatElement(writer,(unsigned char*) "COMMENT ", " in this output file, %d means NOT_PROCESSED; %d means NO_FILE; %d means ERROR; %d means OK ", MODULE_NOT_PROCESSED,
xmlTextWriterWriteFormatElement(writer,(unsigned char *) "COMMENT ", " in this output file, %d means NOT_PROCESSED; %d means NO_FILE; %d means ERROR; %d means OK ", MODULE_NOT_PROCESSED,
NO_FILE, MODULE_ERROR, MODULE_OK);
xmlTextWriterWriteFormatElement(writer,(unsigned char*) "OCG_GET_OPT ", " %d ", get_opt_OK);
xmlTextWriterWriteFormatElement(writer,(unsigned char*) "OCG_DETECT_FILE ", " %d ", detect_file_OK);
xmlTextWriterWriteFormatElement(writer,(unsigned char*) "OCG_PARSE_FILENAME", " %d ", parse_filename_OK);
xmlTextWriterWriteFormatElement(writer,(unsigned char*) "OCG_CREATE_DIR ", " %d ", create_dir_OK);
xmlTextWriterWriteFormatElement(writer,(unsigned char*) "OCG_PARSE_XML ", " %d ", parse_XML_OK);
xmlTextWriterWriteFormatElement(writer,(unsigned char*) "OCG_SAVE_XML ", " %d ", save_XML_OK);
xmlTextWriterWriteFormatElement(writer,(unsigned char *) "OCG_GET_OPT ", " %d ", get_opt_OK);
xmlTextWriterWriteFormatElement(writer,(unsigned char *) "OCG_DETECT_FILE ", " %d ", detect_file_OK);
xmlTextWriterWriteFormatElement(writer,(unsigned char *) "OCG_PARSE_FILENAME", " %d ", parse_filename_OK);
xmlTextWriterWriteFormatElement(writer,(unsigned char *) "OCG_CREATE_DIR ", " %d ", create_dir_OK);
xmlTextWriterWriteFormatElement(writer,(unsigned char *) "OCG_PARSE_XML ", " %d ", parse_XML_OK);
xmlTextWriterWriteFormatElement(writer,(unsigned char *) "OCG_SAVE_XML ", " %d ", save_XML_OK);
// xmlTextWriterWriteFormatElement(writer, "OCG_CALL_EMU ", " %d ", call_emu_OK);
xmlTextWriterEndDocument(writer);
xmlFreeTextWriter(writer);
LOG_I(OCG, "A report of OCG is generated in directory \"%s\"\n\n", dst_dir);
return MODULE_OK;
}
Executable → Regular
View File
+488 -537
View File
File diff suppressed because it is too large Load Diff
+18 -30
View File
@@ -43,8 +43,7 @@
* @returns hash_table_element_t object when success
* @returns NULL when no memory
*/
hash_table_element_t * hash_table_element_new(void)
{
hash_table_element_t *hash_table_element_new(void) {
//INFO("creating a new hash table element");
return calloc(1, hash_table_element_s);
}
@@ -54,8 +53,7 @@ hash_table_element_t * hash_table_element_new(void)
* @param table table from which element has to be deleted
* @param element hash table element to be deleted
*/
void hash_table_element_delete(omg_hash_table_t * table, hash_table_element_t * element)
{
void hash_table_element_delete(omg_hash_table_t *table, hash_table_element_t *element) {
//INFO("Deleting an hash table element");
if (table->mode == MODE_COPY) {
free(element->value);
@@ -74,8 +72,7 @@ void hash_table_element_delete(omg_hash_table_t * table, hash_table_element_t *
* @returns omg_hash_table_t object which references the hash table
* @returns NULL when no memory
*/
omg_hash_table_t * hash_table_new(hash_table_mode_t mode)
{
omg_hash_table_t *hash_table_new(hash_table_mode_t mode) {
//INFO("Creating a new hash table");
omg_hash_table_t *table = calloc(1, SIZEOF_HASH_TABLE);
@@ -102,14 +99,13 @@ omg_hash_table_t * hash_table_new(hash_table_mode_t mode)
* Function to delete the hash table
* @param table hash table to be deleted
*/
void hash_table_delete(omg_hash_table_t * table)
{
void hash_table_delete(omg_hash_table_t *table) {
//INFO("Deleating a hash table");
size_t i=0;
for (; i<HASH_LEN; i++) {
while (table->store_house[i]) {
hash_table_element_t * temp = table->store_house[i];
hash_table_element_t *temp = table->store_house[i];
table->store_house[i] = table->store_house[i]->next;
hash_table_element_delete(table, temp);
}
@@ -129,8 +125,7 @@ void hash_table_delete(omg_hash_table_t * table)
* @returns 0 on sucess
* @returns -1 when no memory
*/
int hash_table_add(omg_hash_table_t * table, void * key, size_t key_len, void * value, size_t value_len)
{
int hash_table_add(omg_hash_table_t *table, void *key, size_t key_len, void *value, size_t value_len) {
if ((table->key_count / table->key_num) >= table->key_ratio) {
//LOG("Ratio(%d) reached the set limit %d\nExpanding hash_table", (table->key_count / table->key_num), table->key_ratio);
hash_table_resize(table, table->key_num*2);
@@ -138,7 +133,7 @@ int hash_table_add(omg_hash_table_t * table, void * key, size_t key_len, void *
}
size_t hash = HASH(key, key_len);
hash_table_element_t * element = hash_table_element_new();
hash_table_element_t *element = hash_table_element_new();
if (!element) {
//INFO("Cannot allocate memory for element");
@@ -197,7 +192,7 @@ int hash_table_add(omg_hash_table_t * table, void * key, size_t key_len, void *
table->key_count++;
} else {
//LOG("Conflicts adding element at %d", (int)hash);
hash_table_element_t * temp = table->store_house[hash];
hash_table_element_t *temp = table->store_house[hash];
while(temp->next) {
while(temp->next && temp->next->key_len!=key_len) {
@@ -234,8 +229,7 @@ int hash_table_add(omg_hash_table_t * table, void * key, size_t key_len, void *
* @returns 0 on sucess
* @returns -1 when key is not found
*/
int hash_table_remove(omg_hash_table_t * table, void * key, size_t key_len)
{
int hash_table_remove(omg_hash_table_t *table, void *key, size_t key_len) {
//INFO("Deleting a key-value pair from the hash table");
if ((table->key_num/ table->key_count) >= table->key_ratio) {
//LOG("Ratio(%d) reached the set limit %d\nContracting hash_table", (table->key_num / table->key_count), table->key_ratio);
@@ -290,8 +284,7 @@ int hash_table_remove(omg_hash_table_t * table, void * key, size_t key_len)
* @returns NULL when key is not found in the hash table
* @returns void* pointer to the value in the table
*/
void * hash_table_lookup(omg_hash_table_t * table, void * key, size_t key_len)
{
void *hash_table_lookup(omg_hash_table_t *table, void *key, size_t key_len) {
size_t hash = HASH(key, key_len);
//LOG("Looking up a key-value pair for hash -> %d", (int)hash);
@@ -328,8 +321,7 @@ void * hash_table_lookup(omg_hash_table_t * table, void * key, size_t key_len)
* @returns 0 when key is not found
* @returns 1 when key is found
*/
int hash_table_has_key(omg_hash_table_t * table, void * key, size_t key_len)
{
int hash_table_has_key(omg_hash_table_t *table, void *key, size_t key_len) {
size_t hash = HASH(key, key_len);
//LOG("Searching for key with hash -> %d", (int)hash);
@@ -365,11 +357,10 @@ int hash_table_has_key(omg_hash_table_t * table, void * key, size_t key_len)
* @param keys a void** pointer where keys are filled in (memory allocated internally and must be freed)
* @return total number of keys filled in keys
*/
size_t hash_table_get_keys(omg_hash_table_t * table, void ** keys)
{
size_t hash_table_get_keys(omg_hash_table_t *table, void **keys) {
size_t i = 0;
size_t count = 0;
keys = calloc(table->key_count, sizeof(void *));
keys = calloc(table->key_count, sizeof(void *)*HASH_LEN);
for(i=0; i<HASH_LEN; i++) {
if (table->store_house[i]) {
@@ -403,8 +394,7 @@ size_t hash_table_get_keys(omg_hash_table_t * table, void ** keys)
* @returns 1 when no memory
* @returns count of elements
*/
size_t hash_table_get_elements(omg_hash_table_t * table, hash_table_element_t *** elements)
{
size_t hash_table_get_elements(omg_hash_table_t *table, hash_table_element_t *** elements) {
size_t i = 0;
size_t count = 0;
(*elements) = (hash_table_element_t **) calloc(table->key_count, sizeof(hash_table_element_t *));
@@ -446,8 +436,7 @@ size_t hash_table_get_elements(omg_hash_table_t * table, hash_table_element_t **
* @param max_key max value of the hash to be returned by the function
* @returns hash value belonging to [0, max_key)
*/
uint16_t hash_table_do_hash(void * key, size_t key_len, uint16_t max_key)
{
uint16_t hash_table_do_hash(void *key, size_t key_len, uint16_t max_key) {
uint16_t *ptr = (uint16_t *) key;
uint16_t hash = 0xbabe; // WHY NOT
size_t i = 0;
@@ -469,10 +458,9 @@ uint16_t hash_table_do_hash(void * key, size_t key_len, uint16_t max_key)
* @returns -2 when no emmory for new store house
* @returns 0 when sucess
*/
int hash_table_resize(omg_hash_table_t *table, size_t len)
{
int hash_table_resize(omg_hash_table_t *table, size_t len) {
//LOG("resizing hash table from %d to %d", table->key_num, len);
hash_table_element_t ** elements;
hash_table_element_t **elements;
size_t count;
// FIXME traversing the elements twice, change it some time soon
count = hash_table_get_elements(table, &elements);
@@ -483,7 +471,7 @@ int hash_table_resize(omg_hash_table_t *table, size_t len)
}
// keep the current store house in case we dont get more memory
hash_table_element_t ** temp = table->store_house;
hash_table_element_t **temp = table->store_house;
table->store_house = calloc(len, sizeof(hash_table_element_t *));
if (!table->store_house) {
+43 -21
View File
@@ -33,25 +33,23 @@ This header file must be included */
#define OPT_H_
#ifndef sys_include
#define sys_include
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <netdb.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include <unistd.h>
#include <time.h>
#define sys_include
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <netdb.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include <unistd.h>
#include <time.h>
#endif
#ifndef project_include
#define project_include
#include "common/utils/LOG/log_if.h"
// #include "UTIL/LOG/log_extern.h"
//#include "PHY/defs.h"
//#include "PHY/extern.h"
#define project_include
#include "common/utils/LOG/log_if.h"
#include "PHY/defs_RU.h"
#endif
#define PACKET_MAC_LTE_DEFAULT_UDP_PORT (9999)
@@ -64,6 +62,32 @@ typedef guint8 gboolean;
#include "packet-mac-lte.h"
#include "mac_pcap.h"
/* OPT parameters definitions */
#define OPT_CONFIGPREFIX "opt"
#define CONFIG_HLP_TYPEMON "Type of L2 monitoring messages: none,pcap,wireshark \n"
#define CONFIG_HLP_L2MONIP "ip address for wireshark messages \n"
#define CONFIG_HLP_L2MONPATH "file path for pcap messages on localhost \n"
/*-----------------------------------------------------------------------------------------------------------------------------------------------------------------------*/
/* command line parameters for LOG utility */
/* optname helpstr paramflags XXXptr defXXXval type numelt */
/*-----------------------------------------------------------------------------------------------------------------------------------------------------------------------*/
#define OPT_PARAMS_DESC { \
{"type" , CONFIG_HLP_TYPEMON, 0, strptr:&in_type, defstrval:"none", TYPE_STRING, 0}, \
{"ip" , CONFIG_HLP_L2MONIP, 0, strptr:&in_ip, defstrval:"127.0.0.1", TYPE_STRING, 0}, \
{"path" , CONFIG_HLP_L2MONPATH, 0, strptr:&in_path, defstrval:"/tmp/oai_opt.pcap", TYPE_STRING, 0}, \
}
#define OPTTYPE_IDX 0
/* check function for opt parameters */
#define OPTTYPE_OKSTRINGS {"none","pcap","wireshark"}
#define OPTTYPE_VALUES {OPT_NONE,OPT_PCAP,OPT_WIRESHARK}
#define OPTPARAMS_CHECK_DESC { \
{ .s3a= { config_checkstr_assign_integer, OPTTYPE_OKSTRINGS,OPTTYPE_VALUES ,3}} ,\
{ .s5= {NULL }} , \
{ .s5= {NULL }} , \
}
#ifdef OCP_FRAMEWORK
#include <enums.h>
#else
@@ -81,9 +105,7 @@ typedef enum radio_type_e {
RADIO_TYPE_MAX
} radio_type_t;
extern trace_mode_t opt_type;
extern char in_ip[40];
extern char in_path[FILENAME_MAX];
/**
* function def
@@ -93,7 +115,7 @@ void trace_pdu(int direction, uint8_t *pdu_buffer, unsigned int pdu_buffer_size,
int ueid, int rntiType, int rnti, uint16_t sysFrame, uint8_t subframe,
int oob_event, int oob_event_value);
int init_opt(char *path, char *ip);
int init_opt(void);
void terminate_opt(void);
+143 -159
View File
@@ -90,7 +90,7 @@ what about the implementation
#include <pthread.h>
#include <stdint.h>
#include "common/config/config_userapi.h"
#include "opt.h"
int opt_enabled=0;
@@ -98,8 +98,8 @@ int opt_enabled=0;
//static unsigned char g_PDUBuffer[1600];
//static unsigned int g_PDUOffset;
char in_ip[40];
char in_path[FILENAME_MAX];
static char *in_ip;
static char *in_path;
FILE *file_fd = NULL;
pcap_hdr_t file_header = {
0xa1b2c3d4, /* magic number */
@@ -133,17 +133,15 @@ static void SendFrame(guint8 radioType, guint8 direction, guint8 rntiType,
static int MAC_LTE_PCAP_WritePDU(MAC_Context_Info_t *context,
const unsigned char *PDU, unsigned int length);
static void *opt_listener_thread(void *arg)
{
static void *opt_listener_thread(void *arg) {
ssize_t ret;
struct sockaddr_in from_address;
socklen_t socklen = sizeof(from_address);
memset(&from_address, 0, sizeof(from_address));
while(1) {
/* Simply drop packets */
ret = recvfrom(opt_listener.sd, NULL, 0, 0, (struct sockaddr*)&from_address,
ret = recvfrom(opt_listener.sd, NULL, 0, 0, (struct sockaddr *)&from_address,
&socklen);
if (ret == 0) {
@@ -165,17 +163,13 @@ static void *opt_listener_thread(void *arg)
}
static
int opt_create_listener_socket(char *ip_address, uint16_t port)
{
int opt_create_listener_socket(char *ip_address, uint16_t port) {
/* Create an UDP socket and listen on it.
* Silently discard PDU received.
*/
int sd = -1;
int ret = -1;
memset(&opt_listener, 0, sizeof(opt_listener_t));
sd = socket(AF_INET, SOCK_DGRAM, 0);
if (sd < 0) {
@@ -190,8 +184,7 @@ int opt_create_listener_socket(char *ip_address, uint16_t port)
/* Listening only on provided IP address */
opt_listener.address.sin_addr.s_addr = inet_addr(ip_address);
opt_listener.address.sin_port = htons(port);
ret = bind(opt_listener.sd, (struct sockaddr*) &opt_listener.address, sizeof(opt_listener.address));
ret = bind(opt_listener.sd, (struct sockaddr *) &opt_listener.address, sizeof(opt_listener.address));
if (ret != 0) {
LOG_E(OPT, "Failed to bind socket to (%s:%u): %s\n",
@@ -231,49 +224,39 @@ static void SendFrame(guint8 radioType, guint8 direction, guint8 rntiType,
guint16 rnti, guint16 ueid, guint16 sfnSf,
guint8 isPredefinedData, guint8 retx, guint8 crcStatus,
guint8 oob_event, guint8 oob_event_value,
uint8_t *pdu_buffer, unsigned int pdu_buffer_size)
{
uint8_t *pdu_buffer, unsigned int pdu_buffer_size) {
unsigned char frameBuffer[9000];
unsigned int frameOffset;
ssize_t bytesSent;
frameOffset = 0;
uint16_t tmp16;
memcpy(frameBuffer+frameOffset, MAC_LTE_START_STRING,
strlen(MAC_LTE_START_STRING));
frameOffset += strlen(MAC_LTE_START_STRING);
/******************************************************************************/
/* Now write out fixed fields (the mandatory elements of struct mac_lte_info) */
frameBuffer[frameOffset++] = radioType;
frameBuffer[frameOffset++] = direction;
frameBuffer[frameOffset++] = rntiType;
/*************************************/
/* Now optional fields */
/* RNTI */
frameBuffer[frameOffset++] = MAC_LTE_RNTI_TAG;
tmp16 = htons(rnti);
memcpy(frameBuffer+frameOffset, &tmp16, 2);
frameOffset += 2;
/* UEId */
frameBuffer[frameOffset++] = MAC_LTE_UEID_TAG;
tmp16 = htons(ueid);
memcpy(frameBuffer+frameOffset, &tmp16, 2);
frameOffset += 2;
/* Subframe number */
frameBuffer[frameOffset++] = MAC_LTE_FRAME_SUBFRAME_TAG;
tmp16 = htons(sfnSf); // frame counter : this will give an expert info as wireshark expects SF and not F
memcpy(frameBuffer+frameOffset, &tmp16, 2);
frameOffset += 2;
frameBuffer[frameOffset++] = MAC_LTE_CRC_STATUS_TAG;
frameBuffer[frameOffset++] = crcStatus;
#ifdef WIRESHARK_DEV
frameOffset += 2;
tmp16 = htons(sfnSf); // subframe
@@ -293,55 +276,55 @@ static void SendFrame(guint8 radioType, guint8 direction, guint8 rntiType,
frameBuffer[frameOffset++] = retx;
}
//#ifdef WIRESHARK_DEV
//#ifdef WIRESHARK_DEV
/* Relating to out-of-band events */
/* N.B. dissector will only look to these fields if length is 0... */
if (pdu_buffer_size==0) {
switch (oob_event) {
case ltemac_send_preamble :
LOG_D(OPT,"ltemac_send_preamble event %02x."
//"%02x."
"%02x.%02x\n",
MAC_LTE_SEND_PREAMBLE_TAG,
//ltemac_send_preamble,
rnti,
oob_event_value);
//frameBuffer[frameOffset++]=0;
//frameBuffer[frameOffset++]=0;
//frameBuffer[frameOffset++]=0;
frameBuffer[frameOffset++] = MAC_LTE_SEND_PREAMBLE_TAG;
//frameBuffer[frameOffset++]=ltemac_send_preamble;
frameBuffer[frameOffset++]=rnti; // is the preamble
frameBuffer[frameOffset++]=oob_event_value;
break;
case ltemac_send_preamble :
LOG_D(OPT,"ltemac_send_preamble event %02x."
//"%02x."
"%02x.%02x\n",
MAC_LTE_SEND_PREAMBLE_TAG,
//ltemac_send_preamble,
rnti,
oob_event_value);
//frameBuffer[frameOffset++]=0;
//frameBuffer[frameOffset++]=0;
//frameBuffer[frameOffset++]=0;
frameBuffer[frameOffset++] = MAC_LTE_SEND_PREAMBLE_TAG;
//frameBuffer[frameOffset++]=ltemac_send_preamble;
frameBuffer[frameOffset++]=rnti; // is the preamble
frameBuffer[frameOffset++]=oob_event_value;
break;
case ltemac_send_sr:
frameBuffer[frameOffset++]=MAC_LTE_SR_TAG ;
frameOffset+=2;
frameBuffer[frameOffset++]=rnti;
frameOffset++;
frameBuffer[frameOffset++]=oob_event_value;
frameOffset++;
break;
case ltemac_send_sr:
frameBuffer[frameOffset++]=MAC_LTE_SR_TAG ;
frameOffset+=2;
frameBuffer[frameOffset++]=rnti;
frameOffset++;
frameBuffer[frameOffset++]=oob_event_value;
frameOffset++;
break;
case ltemac_sr_failure:
default:
LOG_W(OPT,"not implemeneted yet\n");
break;
case ltemac_sr_failure:
default:
LOG_W(OPT,"not implemeneted yet\n");
break;
}
}
//#endif
//#endif
/***************************************/
/* Now write the MAC PDU */
frameBuffer[frameOffset++] = MAC_LTE_PAYLOAD_TAG;
/* Append actual PDU */
//memcpy(frameBuffer+frameOffset, g_PDUBuffer, g_PDUOffset);
//frameOffset += g_PDUOffset;
if (pdu_buffer != NULL) {
memcpy(frameBuffer+frameOffset, (void*)pdu_buffer, pdu_buffer_size);
memcpy(frameBuffer+frameOffset, (void *)pdu_buffer, pdu_buffer_size);
frameOffset += pdu_buffer_size;
}
@@ -358,44 +341,36 @@ static void SendFrame(guint8 radioType, guint8 direction, guint8 rntiType,
/* Write an individual PDU (PCAP packet header + mac-context + mac-pdu) */
static int MAC_LTE_PCAP_WritePDU(MAC_Context_Info_t *context,
const uint8_t *PDU, unsigned int length)
{
const uint8_t *PDU, unsigned int length) {
pcaprec_hdr_t packet_header;
uint8_t context_header[256];
int offset = 0;
unsigned short tmp16;
/*****************************************************************/
/* Context information (same as written by UDP heuristic clients */
context_header[offset++] = context->radioType;
context_header[offset++] = context->direction;
context_header[offset++] = context->rntiType;
/* RNTI */
context_header[offset++] = MAC_LTE_RNTI_TAG;
tmp16 = htons(context->rnti);
memcpy(context_header+offset, &tmp16, 2);
offset += 2;
/* UEId */
context_header[offset++] = MAC_LTE_UEID_TAG;
tmp16 = htons(context->ueid);
memcpy(context_header+offset, &tmp16, 2);
offset += 2;
/* Subframe number */
context_header[offset++] = MAC_LTE_FRAME_SUBFRAME_TAG;
tmp16 = htons(context->subFrameNumber);
memcpy(context_header+offset, &tmp16, 2);
offset += 2;
/* CRC Status */
context_header[offset++] = MAC_LTE_CRC_STATUS_TAG;
context_header[offset++] = context->crcStatusOK;
/* Data tag immediately preceding PDU */
context_header[offset++] = MAC_LTE_PAYLOAD_TAG;
/****************************************************************/
/* PCAP Header */
/* TODO: Timestamp might want to be relative to a more sensible
@@ -404,13 +379,11 @@ static int MAC_LTE_PCAP_WritePDU(MAC_Context_Info_t *context,
packet_header.ts_usec = (context->subframesSinceCaptureStart % 1000) * 1000;
packet_header.incl_len = offset + length;
packet_header.orig_len = offset + length;
/***************************************************************/
/* Now write everything to the file */
fwrite(&packet_header, sizeof(pcaprec_hdr_t), 1, file_fd);
fwrite(context_header, 1, offset, file_fd);
fwrite(PDU, 1, length, file_fd);
return 1;
}
#include <common/ran_context.h>
@@ -419,117 +392,129 @@ extern RAN_CONTEXT_t RC;
/* Remote serveraddress (where Wireshark is running) */
void trace_pdu(int direction, uint8_t *pdu_buffer, unsigned int pdu_buffer_size,
int ueid, int rntiType, int rnti, uint16_t sysFrameNumber, uint8_t subFrameNumber, int oob_event,
int oob_event_value)
{
int oob_event_value) {
MAC_Context_Info_t pdu_context;
int radioType=FDD_RADIO;
if (RC.eNB[0][0]!=NULL)
radioType=RC.eNB[0][0]->frame_parms.frame_type== FDD ? FDD_RADIO:TDD_RADIO;
if (PHY_vars_UE_g[0][0] != NULL)
radioType=PHY_vars_UE_g[0][0]->frame_parms.frame_type== FDD ? FDD_RADIO:TDD_RADIO;
switch (opt_type) {
case OPT_WIRESHARK :
if (g_socksd == -1) {
return;
}
case OPT_WIRESHARK :
if (g_socksd == -1) {
return;
}
SendFrame( radioType,
(direction == DIRECTION_DOWNLINK) ? DIRECTION_DOWNLINK : DIRECTION_UPLINK,
rntiType, rnti, ueid, (sysFrameNumber<<4) + subFrameNumber,
1, 0, 1, //guint8 isPredefinedData, guint8 retx, guint8 crcStatus
oob_event,oob_event_value,
pdu_buffer, pdu_buffer_size);
break;
SendFrame( radioType,
(direction == DIRECTION_DOWNLINK) ? DIRECTION_DOWNLINK : DIRECTION_UPLINK,
rntiType, rnti, ueid, (sysFrameNumber<<4) + subFrameNumber,
1, 0, 1, //guint8 isPredefinedData, guint8 retx, guint8 crcStatus
oob_event,oob_event_value,
pdu_buffer, pdu_buffer_size);
break;
case OPT_PCAP:
if (file_fd == NULL) {
return;
}
case OPT_PCAP:
if (file_fd == NULL) {
return;
}
pdu_context.radioType = radioType;
pdu_context.direction = (direction == DIRECTION_DOWNLINK) ? DIRECTION_DOWNLINK
: DIRECTION_UPLINK;
pdu_context.rntiType = rntiType;
pdu_context.rnti = rnti;
pdu_context.ueid = ueid;
pdu_context.isRetx = 0;
pdu_context.crcStatusOK =1;
pdu_context.sysFrameNumber = sysFrameNumber;
pdu_context.subFrameNumber = subFrameNumber;
pdu_context.subframesSinceCaptureStart = subframesSinceCaptureStart++;
MAC_LTE_PCAP_WritePDU( &pdu_context, pdu_buffer, pdu_buffer_size);
break;
pdu_context.radioType = radioType;
pdu_context.direction = (direction == DIRECTION_DOWNLINK) ? DIRECTION_DOWNLINK
: DIRECTION_UPLINK;
pdu_context.rntiType = rntiType;
pdu_context.rnti = rnti;
pdu_context.ueid = ueid;
pdu_context.isRetx = 0;
pdu_context.crcStatusOK =1;
pdu_context.sysFrameNumber = sysFrameNumber;
pdu_context.subFrameNumber = subFrameNumber;
pdu_context.subframesSinceCaptureStart = subframesSinceCaptureStart++;
MAC_LTE_PCAP_WritePDU( &pdu_context, pdu_buffer, pdu_buffer_size);
break;
case OPT_TSHARK:
default:
break;
case OPT_TSHARK:
default:
break;
}
}
/*---------------------------------------------------*/
int init_opt(char *path, char *ip)
{
int init_opt(void) {
char *in_type=NULL;
paramdef_t opt_params[] = OPT_PARAMS_DESC ;
checkedparam_t opt_checkParams[] = OPTPARAMS_CHECK_DESC;
uint16_t in_port;
config_set_checkfunctions(opt_params, opt_checkParams,
sizeof(opt_params)/sizeof(paramdef_t));
config_get( opt_params,sizeof(opt_params)/sizeof(paramdef_t),OPT_CONFIGPREFIX);
subframesSinceCaptureStart = 0;
int tmptype = config_get_processedint( &(opt_params[OPTTYPE_IDX]));
if (path != NULL) {
strncpy( in_path, path, sizeof(in_path) );
in_path[sizeof(in_path) - 1] = 0; // terminate string
if (tmptype == OPT_NONE) {
opt_enabled=0;
LOG_I(OPT,"OPT disabled\n");
return 0;
} else if (tmptype == OPT_PCAP && strlen(in_path) > 0) {
opt_type = OPT_PCAP;
opt_enabled=1;
LOG_I(OPT,"Enabling OPT for PCAP with the following file %s \n",in_path);
} else if (tmptype == OPT_WIRESHARK && strlen(in_ip) > 0) {
opt_enabled=1;
opt_type = OPT_WIRESHARK;
LOG_I(OPT,"Enabling OPT for wireshark for local interface %s\n",in_ip);
} else {
strcpy( in_path, "/tmp/opt.pcap" );
}
if (ip != NULL) {
strncpy( in_ip, ip, sizeof(in_ip) );
in_ip[sizeof(in_ip) - 1] = 0; // terminate string
} else {
strcpy( in_ip, "127.0.0.1" );
LOG_E(OPT,"Invalid OPT configuration\n");
config_printhelp(opt_params,sizeof(opt_params)/sizeof(paramdef_t),OPT_CONFIGPREFIX);
}
in_port = PACKET_MAC_LTE_DEFAULT_UDP_PORT;
// trace_mode
switch (opt_type) {
case OPT_WIRESHARK:
case OPT_WIRESHARK:
/* Create local server socket only if using localhost address */
if (strcmp(in_ip, "127.0.0.1") == 0) {
opt_create_listener_socket(in_ip, in_port);
}
/* Create local server socket only if using localhost address */
if (strcmp(in_ip, "127.0.0.1") == 0) {
opt_create_listener_socket(in_ip, in_port);
}
g_socksd = socket(AF_INET, SOCK_DGRAM, 0);
g_socksd = socket(AF_INET, SOCK_DGRAM, 0);
if (g_socksd == -1) {
LOG_E(OPT, "Error trying to create socket (errno=%d)\n", errno);
LOG_E(OPT, "CREATING SOCKET FAILED\n");
return (-1);
}
if (g_socksd == -1) {
LOG_E(OPT, "Error trying to create socket (errno=%d)\n", errno);
LOG_E(OPT, "CREATING SOCKET FAILED\n");
return (-1);
}
/* Get remote IP address from the function argument */
g_serv_addr.sin_family = AF_INET;
g_serv_addr.sin_port = htons(in_port);
g_serv_addr.sin_addr.s_addr = inet_addr(in_ip);
break;
/* Get remote IP address from the function argument */
g_serv_addr.sin_family = AF_INET;
g_serv_addr.sin_port = htons(in_port);
g_serv_addr.sin_addr.s_addr = inet_addr(in_ip);
break;
case OPT_PCAP:
file_fd = fopen(in_path, "w");
case OPT_PCAP:
file_fd = fopen(in_path, "w");
if (file_fd == NULL) {
LOG_D(OPT, "Failed to open file \"%s\" for writing\n", in_path);
return (-1);
}
/* Write the file header */
fwrite(&file_header, sizeof(pcap_hdr_t), 1, file_fd);
break;
if (file_fd == NULL) {
LOG_D(OPT, "Failed to open file \"%s\" for writing\n", in_path);
return (-1);
}
case OPT_TSHARK:
LOG_W(OPT, "Tshark is currently not supported\n");
opt_type = OPT_NONE;
break;
/* Write the file header */
fwrite(&file_header, sizeof(pcap_hdr_t), 1, file_fd);
break;
default:
opt_type = OPT_NONE;
LOG_W(OPT, "supported Option\n");
break;
case OPT_TSHARK:
LOG_W(OPT, "Tshark is currently not supported\n");
opt_type = OPT_NONE;
break;
default:
opt_type = OPT_NONE;
LOG_W(OPT, "supported Option\n");
break;
}
if ( opt_type == OPT_WIRESHARK )
@@ -543,8 +528,7 @@ int init_opt(char *path, char *ip)
// memset(mac_info, 0, sizeof(mac_lte_info)+pdu_buffer_size + 8);
return (1);
}
void terminate_opt(void)
{
void terminate_opt(void) {
/* Close local socket */
// free(mac_info);
if (opt_type != OPT_NONE) {
@@ -552,18 +536,18 @@ void terminate_opt(void)
}
switch (opt_type) {
case OPT_WIRESHARK:
close(g_socksd);
g_socksd = -1;
break;
case OPT_WIRESHARK:
close(g_socksd);
g_socksd = -1;
break;
case OPT_PCAP:
fclose (file_fd);
file_fd = NULL;
break;
case OPT_PCAP:
fclose (file_fd);
file_fd = NULL;
break;
default:
break;
default:
break;
}
}
+23 -128
View File
@@ -53,9 +53,7 @@ int simu_time=0, duration=0, seed=0, simu_mode=0;
// init OTG with config parameters
void init_config_otg(char *protocol, char *ip_version)
{
void init_config_otg(char *protocol, char *ip_version) {
int i, j, k;
if (simu_time>0)
@@ -70,25 +68,19 @@ void init_config_otg(char *protocol, char *ip_version)
printf("duration %d, seeds %d \n", duration, g_otg->seed);
for (i=0; i<(NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX); i++) {
if (duration>0)
g_otg->duration[i]=duration;
else
g_otg->duration[i]=10000;
g_otg->dst_port[i]=DST_PORT;
g_otg->dst_ip[i]=(char*)malloc(100*sizeof(char*));
g_otg->dst_ip[i]=(char *)malloc(100*sizeof(char *));
g_otg->dst_ip[i]=DST_IP;
g_otg->dst_ip[i]=DST_IP;
//config ip version
if (ip_version !=NULL) {
if ((strcmp(ip_version,"IP4")==0) ||(strcmp(ip_version,"ip4")==0))
g_otg->ip_v[i]=IPV4;
@@ -97,7 +89,6 @@ void init_config_otg(char *protocol, char *ip_version)
} else
g_otg->ip_v[i]=IPV4;
//config transport protocol version
if (protocol!=NULL) {
if ((strcmp(protocol,"TCP")==0) ||(strcmp(protocol,"tcp")==0))
@@ -123,20 +114,13 @@ void init_config_otg(char *protocol, char *ip_version)
g_otg->size_std_dev[i][j][k]=PKTS_SIZE_STD_DEV;
g_otg->size_lambda[i][j][k]=PKTS_SIZE_LAMBDA;
}
}
}
}
int main_below_ip()
{
int main_below_ip() {
int i, j, k, l, rtt_owd ,rx_otg=0, simu_time=0, ctime=0, nb_round=0;
float p;
char *packet;
@@ -145,25 +129,17 @@ int main_below_ip()
printf(" max enb %d, max ue %d \n", NUMBER_OF_eNB_MAX, NUMBER_OF_UE_MAX);
do {
nb_round=nb_round+1;
// for (stime=0; stime < SIMU_TIME; stime++) // discrete event generation : tick, stime generate the ctime
for (i=0; i<(NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX); i++) {
for (j=0; j<(NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX); j++) {
for (k=0; k<MAX_NUM_TRAFFIC_STATE; k++) {
LOG_I(OTG,"OTG emulation src=%d, dst=%d, state=%d \n", i, j, k);
ctime=0; // set the ctime to 0
do {
if (simu_time> SIMU_TIME) {
otg_info->ctime=SIMU_TIME;
return(0);
}
@@ -172,21 +148,16 @@ int main_below_ip()
char *packet=NULL;
/*packet=packet_gen(i, j, k, ctime);*/ packet=packet_gen(i, j, ctime, &pkt_size);
if (packet!=NULL) {
if ((ceil(g_otg->duration[i]*uniform_rng()))==ctime) {
printf("DROP PACKET (i=%d,j=%d) seq num=%d\n",i, j, otg_info->seq_num[i][j]);
printf("DROP PACKET (i=%d,j=%d) seq num=%d\n",i, j, (int)otg_info->seq_num[i][j]);
} else {
printf("SEND PACKET (i=%d,j=%d) seq num=%d\n",i, j, otg_info->seq_num[i][j]);
printf("SEND PACKET (i=%d,j=%d) seq num=%d\n",i, j, (int)otg_info->seq_num[i][j]);
rtt_owd=ceil(uniform_rng()*8.56);
LOG_I(OTG,"one way delay= %d , (src=%d, dst=%d, state=%d)\n", rtt_owd, i, j, k);
ctime+=rtt_owd;
otg_info->rx_pkt_owd[i][j]=rtt_owd;
simu_time+=rtt_owd;
//rx_packet_out=check_packet(i, j, ctime, packet);
rx_packet_out=otg_rx_pkt(i,j, ctime, packet, pkt_size);
//if (rx_packet_out==NULL)
@@ -196,18 +167,15 @@ int main_below_ip()
// rx_packet_out=NULL;
free(packet);
// }
//}
//Do not increase the ctime and simu_time with the one way delay.
ctime-=rtt_owd;
simu_time-=rtt_owd;
LOG_I(OTG,"PKTS INFO:: (src=%d, dst=%d, state=%d),NB PKTS=%d ,sequence NB=%d, RTT (one way)ms= %d \n ",i, j, k, otg_info->tx_num_pkt[i][j], otg_info->seq_num[i][j], otg_info->rx_pkt_owd[i][j]);
LOG_I(OTG,"PKTS INFO:: (src=%d, dst=%d, state=%d),NB PKTS=%d ,sequence NB=%d, RTT (one way)ms= %d \n ",
i, j, k, (int)otg_info->tx_num_pkt[i][j], (int)otg_info->seq_num[i][j], (int)otg_info->rx_pkt_owd[i][j]);
}
} else
printf("Node (i=%d,j=%d) seq num=%d, ctime %d, prb %lf\n",i, j, otg_info->seq_num[i][j], ctime,(ceil(g_otg->duration[i]*uniform_rng())));
printf("Node (i=%d,j=%d) seq num=%d, ctime %d, prb %lf\n",i, j, (int)otg_info->seq_num[i][j], ctime,(ceil(g_otg->duration[i]*uniform_rng())));
LOG_I(OTG,"Time:: ctime=%d, duration=%d, simu_time=%d, max=%d, (src=%d, dst=%d, state=%d) \n", ctime, g_otg->duration[i],simu_time, SIMU_TIME, i, j,k);
ctime+=1;
@@ -215,27 +183,19 @@ int main_below_ip()
} while (ctime<=g_otg->duration[i]) ;
}
if (otg_info->tx_num_pkt[i][j]>otg_info->rx_num_pkt[i][j])
LOG_I(OTG,"STAT: (LOSS):: (src=%d, dst=%d) NB packet TX= %d, NB packet RX = %d, seq NUM=%d\n ",i, j, otg_info->tx_num_pkt[i][j], otg_info->rx_num_pkt[i][j],otg_info->seq_num[i][j] );
LOG_I(OTG,"STAT: (LOSS):: (src=%d, dst=%d) NB packet TX= %d, NB packet RX = %d, seq NUM=%d\n ",
i, j, (int)otg_info->tx_num_pkt[i][j], (int)otg_info->rx_num_pkt[i][j],(int)otg_info->seq_num[i][j] );
else
LOG_I(OTG,"STAT: :: (src=%d, dst=%d) NB packet TX= %d, NB packet RX= %d, seq NUM=%d \n ",i, j, otg_info->tx_num_pkt[i][j], otg_info->rx_num_pkt[i][j], otg_info->seq_num[i][j]);
LOG_I(OTG,"STAT: :: (src=%d, dst=%d) NB packet TX= %d, NB packet RX= %d, seq NUM=%d \n ",
i, j, (int)otg_info->tx_num_pkt[i][j], (int)otg_info->rx_num_pkt[i][j], (int)otg_info->seq_num[i][j]);
}
}
} while (simu_time<=SIMU_TIME);
}
int main_above_ip()
{
int main_above_ip() {
int i, j, k, simu_time=0, ctime=0, nb_round=0;
char *packet=NULL;
printf(" max enb %d, max ue %d \n", NUMBER_OF_eNB_MAX, NUMBER_OF_UE_MAX);
@@ -244,9 +204,7 @@ int main_above_ip()
nb_round=nb_round+1;
for (i=0; i<(NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX); i++) {
for (j=0; j<(NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX); j++) {
for (k=0; k<MAX_NUM_TRAFFIC_STATE; k++) {
LOG_I(OTG,"SOCKET:: OTG emulation src=%d, dst=%d, state=%d \n", i, j, k);
ctime=0;
@@ -255,57 +213,44 @@ int main_above_ip()
}
}
ctime+=1;
simu_time+=1;
} while (simu_time<=SIMU_TIME);
}
void config_traffic_type(char *traffic)
{
void config_traffic_type(char *traffic) {
Application application;
int i,j;
if (strcmp(traffic, "SCBR")==0)
application=SCBR;
else if (strcmp(traffic, "OPENARENA")==0)
application=OPENARENA;
else if (strcmp(traffic, "BICYCLE_RACE")==0)
application=BICYCLE_RACE;
else if (strcmp(traffic, "AUTO_PILOT")==0)
application=AUTO_PILOT;
else if (strcmp(traffic, "TEAM_FORTRESS")==0)
application=TEAM_FORTRESS;
else
application=NO_PREDEFINED_TRAFFIC;
printf("Config Application: %d \n", application);
for (i=0; i<(NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX); i++) {
for (j=0; j<(NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX); j++) {
g_otg->application_type[i][j] =application;
}
}
}
cunstom_config(simu_time, duration)
{
cunstom_config(simu_time, duration) {
int i;
//--config introduced Global simulation time for each node
@@ -321,37 +266,23 @@ cunstom_config(simu_time, duration)
int main (int argc, char **argv)
{
int main (int argc, char **argv) {
int i,j, tx;
char *protocol=NULL;
char *ip_version=NULL;
char *traffic=NULL;
init_all_otg();
otg_info->ctime=0;
LOG_I(OTG,"Emulation time %d \n ", otg_info->ctime);
g_otg->num_nodes=NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX;
LOG_I(OTG,"OTG emulation number of nodes= %d \n", g_otg->num_nodes);
for (i = 1; i <argc ; i ++) {
if ('-' == argv[i][0]) {
if(('h' == argv[i][1]) || ('H' == argv[i][1])) {
printf("Help OTG: \n./otg [-M [s (socket mode)] [b (Below IP)]] [-T (Simu Time)] [-d (duration per node)] [-s (seed)] [-P (protocol: TCP or UDP)] [-I (ip version: IP4 or IP6)] -A [(application: CBR, AUTO_PILOT, BICYCLE_RACE, OPENARENA, TEAM_FORTRESS)]\n");
return(0);
}
else if ('M' == argv[i][1]) {
} else if ('M' == argv[i][1]) {
if (strcmp("s",argv[i+1])==0) {
printf("Above IP: SOCKET MODE \n");
simu_mode=1;
@@ -359,89 +290,53 @@ int main (int argc, char **argv)
printf("Below IP: IPC/RPC MODE\n");
simu_mode=0;
}
}
else if ('T' == argv[i][1]) {
} else if ('T' == argv[i][1]) {
simu_time=atoi(argv[i+1]);
printf("simu_time=%d\n", simu_time);
}
else if ('d' == argv[i][1]) {
} else if ('d' == argv[i][1]) {
duration=atoi(argv[i+1]);
printf("duration node=%d\n", duration);
}
else if ('s' == argv[i][1]) {
} else if ('s' == argv[i][1]) {
seed=atoi(argv[i+1]);
printf("seed val =%d\n", seed);
}
else if ('P' == argv[i][1]) {
} else if ('P' == argv[i][1]) {
protocol=argv[i+1];
if ((strcmp(argv[i+1],"TCP")==0) || (strcmp(argv[i+1],"UDP")==0) || (strcmp(argv[i+1],"tcp")==0) || (strcmp(argv[i+1],"udp")==0)) {
protocol=argv[i+1];
printf("Protocol=%s\n", protocol);
}
}
else if ('I' == argv[i][1]) {
} else if ('I' == argv[i][1]) {
if ((strcmp(argv[i+1],"IP4")==0) || (strcmp(argv[i+1],"IP6")==0) || (strcmp(argv[i+1],"ip4")==0) || (strcmp(argv[i+1],"ip6")==0)) {
ip_version=argv[i+1];
printf("IP version=%s\n", ip_version);
}
}
else if ('A' == argv[i][1]) {
} else if ('A' == argv[i][1]) {
if ((strcmp(argv[i+1],"CBR")==0) || (strcmp(argv[i+1],"AUTO_PILOT")==0) || (strcmp(argv[i+1],"BICYCLE_RACE")==0) || (strcmp(argv[i+1],"OPENARENA")==0) || (strcmp(argv[i+1],"TEAM_FORTRESS")==0))
traffic=argv[i+1];
config_traffic_type(traffic);
}
}
}
if (traffic!=NULL)
init_predef_traffic();
else
init_config_otg(protocol, ip_version);
init_seeds(g_otg->seed);
cunstom_config(simu_time, duration);
if (simu_mode==0)
tx=main_below_ip();
else if (simu_mode==1)
tx=main_above_ip();
// Compute KPI after the end of the simu
kpi_gen();
free_otg();
return 0;
}
+12 -66
View File
@@ -38,31 +38,25 @@
extern unsigned char NB_eNB_INST;
extern unsigned char NB_UE_INST;
FD_otg * form_dl, *form_ul;
FD_otg *form_dl, *form_ul;
FL_FORM *fclock;
unsigned int clear_cmpt_ul=0;
unsigned int clear_cmpt_dl=0;
FD_otg *create_form_otg(void)
{
FD_otg *create_form_otg(void) {
FL_OBJECT *obj;
FD_otg *fdui = (FD_otg *) fl_calloc(1, sizeof(*fdui));
fdui->otg = fl_bgn_form(FL_NO_BOX, 550, 550);
obj = fl_add_box(FL_UP_BOX,0,0,900,700,"");
fdui->owd = fl_add_xyplot(FL_NORMAL_XYPLOT,50,30,450,190,"Delay(ms)");
fl_set_object_color(fdui->owd,FL_BLACK,FL_YELLOW);
fdui->throughput = fl_add_xyplot(FL_NORMAL_XYPLOT,50,300,450,190,"Throughput(Kbit/s)");
fl_set_object_color(fdui->throughput,FL_BLACK,FL_YELLOW);
obj = fl_add_button(FL_NORMAL_BUTTON,250,510,50,30,"Exit");
fl_set_object_callback(obj, exit_cb, 0);
fdui->loss_ratio=fl_add_text(FL_NORMAL_TEXT,5,510,220,20,"NB Loss pkts");
fdui->simu_time=fl_add_text(FL_NORMAL_TEXT,370,510,250,30,"Simulation Time");
fl_end_form();
fdui->otg->fdui = fdui;
return fdui;
@@ -70,18 +64,15 @@ FD_otg *create_form_otg(void)
//For more details about object parameters, refer to: http://xforms-toolkit.org/doc/xforms_25.html
void show_otg_form()
{
void show_otg_form() {
int eNB_id;
char title[255];
char *tArgv[] = { "OTG", "OTG" };
int tArgc = 2;
int major_owd = 6;
int minor_owd = 3;
int major_thr = 5;
int minor_thr = 2;
fl_initialize(&tArgc,tArgv,"OTG",0,0);
for (eNB_id = 0; eNB_id < NB_eNB_INST; eNB_id++) { //NB_eNB_INST
@@ -98,9 +89,6 @@ void show_otg_form()
fl_set_xyplot_ytics(form_dl->throughput,major_thr, minor_thr);
fl_set_xyplot_ybounds(form_dl->throughput,0,1000);
form_ul= create_form_otg ();
sprintf (title, "LTE UE->eNB (UL)");
fl_show_form (form_ul->otg, FL_PLACE_HOTSPOT, FL_FULLBORDER, title);
@@ -116,20 +104,15 @@ void show_otg_form()
//fl_set_xyplot_xgrid (form_ul->throughput, FL_GRID_MAJOR);
fl_set_xyplot_ytics(form_ul->throughput,major_thr, minor_thr);
fl_set_xyplot_ybounds(form_ul->throughput,0,1000);
}
//create_form_clock();
//fl_show_form(fclock, FL_PLACE_CENTER,FL_TRANSIENT,"clocks");
//fl_do_forms();
fl_check_forms();
}
void add_tab_metric(int src, int dst, float owd, float throughput, int ctime)
{
void add_tab_metric(int src, int dst, float owd, float throughput, int ctime) {
if (otg_forms_info->init_forms==0) {
show_otg_form();
otg_forms_info->init_forms=1;
@@ -158,9 +141,7 @@ void add_tab_metric(int src, int dst, float owd, float throughput, int ctime)
}
void plot_graphes_ul(int src, int dst, int ctime) //UE -->eNB
{
void plot_graphes_ul(int src, int dst, int ctime) { //UE -->eNB
int i, src_idx=1, curve_id=1;
char loss_rate[100];
char simu_time[100];
@@ -169,12 +150,8 @@ void plot_graphes_ul(int src, int dst, int ctime) //UE -->eNB
int y_key_position=75;
if (otg_forms_info->idx_ul[src][dst]==MAX_SAMPLES-1) {
fl_update_display(1); //the function flushes the X buffer so the drawing requests are on their way to the server
if (otg_forms_info->is_data_plot_ul == -1)
otg_forms_info->is_data_plot_ul=src;
@@ -184,17 +161,13 @@ void plot_graphes_ul(int src, int dst, int ctime) //UE -->eNB
sprintf(curve_label, "%d%s%d", src,"-->", dst);
fl_set_xyplot_key(form_ul->owd, 0, curve_label);
fl_set_xyplot_key_position(form_ul->owd, x_key_position,y_key_position, FL_ALIGN_BOTTOM_LEFT);
fl_set_xyplot_data (form_ul->throughput, otg_forms_info->data_ctime_ul[src][dst],
otg_forms_info->data_throughput_ul[src][dst], otg_forms_info->idx_ul[src][dst], "", "time", "kbit/s");
fl_set_xyplot_key(form_ul->throughput, 0, curve_label);
fl_set_xyplot_key_font(form_ul->throughput, FL_BOLD_STYLE, FL_HUGE_SIZE);
fl_set_xyplot_key_position(form_ul->throughput, x_key_position,y_key_position , FL_ALIGN_BOTTOM_LEFT);
otg_kpi_nb_loss_pkts();
sprintf(loss_rate, "%s%d","NB Loss pkts UL=", otg_info->total_loss_ul);
sprintf(loss_rate, "%s%u","NB Loss pkts UL=", otg_info->total_loss_ul);
fl_set_object_label(form_ul->loss_ratio, loss_rate);
sprintf(simu_time, "%s%d","Simulation Time(ms)=", ctime);
fl_set_object_label(form_ul->simu_time, simu_time);
@@ -204,20 +177,16 @@ void plot_graphes_ul(int src, int dst, int ctime) //UE -->eNB
sprintf(curve_label, "%d%s%d", otg_forms_info->is_data_plot_ul,"-->", dst);
fl_set_xyplot_key(form_ul->owd, 0, curve_label);
fl_set_xyplot_key_position(form_ul->owd, x_key_position,y_key_position, FL_ALIGN_BOTTOM_LEFT);
fl_set_xyplot_data (form_ul->throughput, otg_forms_info->data_ctime_ul[otg_forms_info->is_data_plot_ul][dst],
otg_forms_info->data_throughput_ul[otg_forms_info->is_data_plot_ul][dst], otg_forms_info->idx_ul[otg_forms_info->is_data_plot_ul][dst], "", "time", "kbit/s");
sprintf(curve_label, "%d%s%d", otg_forms_info->is_data_plot_ul,"-->", dst);
fl_set_xyplot_key(form_ul->throughput, 0, curve_label);
fl_set_xyplot_key_position(form_ul->throughput, x_key_position,y_key_position , FL_ALIGN_BOTTOM_LEFT);
otg_kpi_nb_loss_pkts();
sprintf(loss_rate, "%s%d","NB Loss pkts UL=",otg_info->total_loss_ul);
sprintf(loss_rate, "%s%u","NB Loss pkts UL=",otg_info->total_loss_ul);
fl_set_object_label(form_ul->loss_ratio, loss_rate);
sprintf(simu_time, "%s%d","Simulation Time(ms)=", ctime);
fl_set_object_label(form_ul->simu_time, simu_time);
}
for (src_idx=1; src_idx<=NB_UE_INST; src_idx++) {
@@ -229,9 +198,6 @@ void plot_graphes_ul(int src, int dst, int ctime) //UE -->eNB
sprintf(curve_label, "%d%s%d", src_idx,"-->", dst);
fl_set_xyplot_key(form_ul->owd, curve_id-1, curve_label);
fl_set_xyplot_key_position(form_ul->owd, x_key_position,y_key_position, FL_ALIGN_BOTTOM_LEFT);
fl_add_xyplot_overlay(form_ul->throughput,curve_id++,
otg_forms_info->data_ctime_ul[src_idx][dst],
otg_forms_info->data_throughput_ul[src_idx][dst],
@@ -242,7 +208,6 @@ void plot_graphes_ul(int src, int dst, int ctime) //UE -->eNB
}
}
for (i=0; i<otg_forms_info->idx_ul[src][dst]; i++) {
otg_forms_info->data_ctime_ul[src][dst][otg_forms_info->idx_ul[src][dst]]=i;
otg_forms_info->data_owd_ul[src][dst][i]= otg_forms_info->data_owd_ul[src][dst][i+1];
@@ -253,14 +218,11 @@ void plot_graphes_ul(int src, int dst, int ctime) //UE -->eNB
}
fl_check_forms();
}
void plot_graphes_dl(int src, int dst, int ctime) //eNB -->UE
{
void plot_graphes_dl(int src, int dst, int ctime) { //eNB -->UE
int i, dst_idx=1, curve_id=1;
char loss_rate[100];
char curve_label[100];
@@ -269,11 +231,8 @@ void plot_graphes_dl(int src, int dst, int ctime) //eNB -->UE
int y_key_position=75;
if (otg_forms_info->idx_dl[src][dst]==MAX_SAMPLES-1) {
fl_update_display(1); //the function flushes the X buffer so the drawing requests are on their way to the server
if (otg_forms_info->is_data_plot_dl == -1)
otg_forms_info->is_data_plot_dl=dst;
@@ -289,12 +248,10 @@ void plot_graphes_dl(int src, int dst, int ctime) //eNB -->UE
fl_set_xyplot_key(form_dl->throughput, 0, curve_label);
fl_set_xyplot_key_position(form_dl->throughput, x_key_position,y_key_position, FL_ALIGN_BOTTOM_LEFT);
otg_kpi_nb_loss_pkts();
sprintf(loss_rate, "%s%d","NB Loss pkts DL=",otg_info->total_loss_dl);
sprintf(loss_rate, "%s%u","NB Loss pkts DL=",otg_info->total_loss_dl);
fl_set_object_label(form_dl->loss_ratio, loss_rate);
sprintf(simu_time, "%s%d","Simulation Time(ms)=", ctime);
fl_set_object_label(form_dl->simu_time, simu_time);
} else {
fl_set_xyplot_data (form_dl->owd, otg_forms_info->data_ctime_dl[src][otg_forms_info->is_data_plot_dl],
otg_forms_info->data_owd_dl[src][otg_forms_info->is_data_plot_dl], otg_forms_info->idx_dl[src][otg_forms_info->is_data_plot_dl], "", "time", "ms");
@@ -306,9 +263,8 @@ void plot_graphes_dl(int src, int dst, int ctime) //eNB -->UE
sprintf(curve_label, "%d%s%d", src,"-->",otg_forms_info->is_data_plot_dl);
fl_set_xyplot_key(form_dl->throughput, 0, curve_label);
fl_set_xyplot_key_position(form_dl->throughput,x_key_position,y_key_position, FL_ALIGN_BOTTOM_LEFT);
otg_kpi_nb_loss_pkts();
sprintf(loss_rate, "%s%d","NB Loss pkts DL=",otg_info->total_loss_dl);
sprintf(loss_rate, "%s%u","NB Loss pkts DL=",otg_info->total_loss_dl);
fl_set_object_label(form_dl->loss_ratio, loss_rate);
sprintf(simu_time, "%s%d","Simulation Time(ms)=", ctime);
fl_set_object_label(form_dl->simu_time, simu_time);
@@ -323,7 +279,6 @@ void plot_graphes_dl(int src, int dst, int ctime) //eNB -->UE
sprintf(curve_label, "%d%s%d", src,"-->", dst_idx);
fl_set_xyplot_key(form_dl->owd, curve_id-1, curve_label);
fl_set_xyplot_key_position(form_dl->owd, x_key_position,y_key_position, FL_ALIGN_BOTTOM_LEFT);
fl_add_xyplot_overlay(form_dl->throughput,curve_id++,
otg_forms_info->data_ctime_dl[src][dst_idx],
otg_forms_info->data_throughput_dl[src][dst_idx],
@@ -331,8 +286,6 @@ void plot_graphes_dl(int src, int dst, int ctime) //eNB -->UE
sprintf(curve_label, "%d%s%d", src,"-->", dst_idx);
fl_set_xyplot_key(form_dl->throughput, curve_id-1, curve_label);
fl_set_xyplot_key_position(form_dl->throughput, x_key_position,y_key_position, FL_ALIGN_BOTTOM_LEFT);
}
}
@@ -346,7 +299,6 @@ void plot_graphes_dl(int src, int dst, int ctime) //eNB -->UE
}
fl_check_forms();
}
@@ -354,14 +306,12 @@ void plot_graphes_dl(int src, int dst, int ctime) //eNB -->UE
void exit_cb(FL_OBJECT *ob, long q)
{
void exit_cb(FL_OBJECT *ob, long q) {
fl_finish();
exit(0);
}
void create_form_clock(void)
{
void create_form_clock(void) {
FL_OBJECT *obj;
if (fclock)
@@ -369,22 +319,18 @@ void create_form_clock(void)
fclock = fl_bgn_form(FL_NO_BOX,500,350);
obj = fl_add_box(FL_UP_BOX,0,0,500,350,"");
obj = fl_add_clock(FL_DIGITAL_CLOCK,185,20,150,35,"");
fl_set_object_boxtype(obj,FL_ROUNDED_BOX);
fl_set_object_color(obj,FL_COL1,FL_BLACK);
fl_set_object_lsize(obj,FL_MEDIUM_SIZE);
fl_set_object_lstyle(obj,FL_BOLD_STYLE);
obj = fl_add_clock(FL_ANALOG_CLOCK,30,70,220,200,"");
fl_set_object_boxtype(obj,FL_UP_BOX);
obj = fl_add_clock(FL_ANALOG_CLOCK,260,70,220,200,"");
fl_set_object_boxtype(obj,FL_OVAL3D_UPBOX);
obj = fl_add_button(FL_NORMAL_BUTTON,375,300,110,35,"Exit");
fl_set_object_callback(obj, exit_cb, 0);
fl_end_form();
fl_scale_form(fclock, 0.7, 0.7);
}
+44 -109
View File
@@ -43,23 +43,22 @@ unsigned int start_log_jitter=0;
extern unsigned char NB_eNB_INST;
extern unsigned char NB_UE_INST;
void tx_throughput(int src, int dst, int application)
{
void tx_throughput(int src, int dst, int application) {
if (otg_info->tx_num_bytes[src][dst][application]>0) {
// otg_info->tx_throughput[src][dst][application]=((double)otg_info->tx_num_bytes[src][dst][application] *1000*8)/ (get_ctime()*1024); // unit Kbit/sec, if ctime in ms
if ((g_otg->flow_start[src][dst][application]+g_otg->flow_duration[src][dst][application]) < get_ctime() )
otg_info->tx_throughput[src][dst][application]=((double)otg_info->tx_num_bytes[src][dst][application] *1000*8)/ ((g_otg->flow_start[src][dst][application]+g_otg->flow_duration[src][dst][application])*1024); // unit Kbit/sec, if ctime in ms
otg_info->tx_throughput[src][dst][application]=((double)otg_info->tx_num_bytes[src][dst][application] *1000*8)/ ((g_otg->flow_start[src][dst][application]+g_otg->flow_duration[src][dst][application])
*1024); // unit Kbit/sec, if ctime in ms
else if (g_otg->flow_start[src][dst][application] < get_ctime() )
otg_info->tx_throughput[src][dst][application]=((double)otg_info->tx_num_bytes[src][dst][application] *1000*8)/ ((get_ctime() - g_otg->flow_start[src][dst][application])*1024);
else
else
LOG_W(OTG, "[src %d][dst %d][app %d] flow start time less than the simu time (start %d, duration %d, ctime %d)\n",
src, dst, application,
g_otg->flow_start[src][dst][application],
g_otg->flow_duration[src][dst][application],
get_ctime());
src, dst, application,
g_otg->flow_start[src][dst][application],
g_otg->flow_duration[src][dst][application],
get_ctime());
}
if (otg_info->tx_num_bytes_background[src][dst]>0)
otg_info->tx_throughput_background[src][dst]=((double)otg_info->tx_num_bytes_background[src][dst]*1000*8)/ (get_ctime()*1024); // unit Kbit/sec, if ctime in ms
@@ -71,26 +70,24 @@ void tx_throughput(int src, int dst, int application)
// LOG_I(OTG,"DUY, get_ctime() [i=%d,j=%d,k=%d] = %.d\n", src,dst,application,get_ctime());
LOG_I(OTG,"otg_multicast_info->tx_num_bytes[i=%d,j=%d,k=%d] = %.d\n", src,dst,application,otg_multicast_info->tx_num_bytes[src][dst][application]);
}
}
void rx_goodput(int src, int dst, int application)
{
void rx_goodput(int src, int dst, int application) {
if (otg_info->rx_num_bytes[src][dst][application]>0) {
// otg_info->rx_goodput[src][dst][application]=((double)otg_info->rx_num_bytes[src][dst][application]*1000*8)/(get_ctime()*1024); // unit kB/sec, if ctime in ms
if ((g_otg->flow_start[src][dst][application]+g_otg->flow_duration[src][dst][application]) < get_ctime() )
otg_info->rx_goodput[src][dst][application]=((double)otg_info->rx_num_bytes[src][dst][application] *1000*8)/ ((g_otg->flow_start[src][dst][application]+g_otg->flow_duration[src][dst][application])*1024); // unit Kbit/sec, if ctime in ms
if ((g_otg->flow_start[src][dst][application]+g_otg->flow_duration[src][dst][application]) < get_ctime() )
otg_info->rx_goodput[src][dst][application]=((double)otg_info->rx_num_bytes[src][dst][application] *1000*8)/ ((g_otg->flow_start[src][dst][application]+g_otg->flow_duration[src][dst][application])
*1024); // unit Kbit/sec, if ctime in ms
else if (g_otg->flow_start[src][dst][application] < get_ctime() )
otg_info->rx_goodput[src][dst][application]=((double)otg_info->rx_num_bytes[src][dst][application] *1000*8)/ ((get_ctime() - g_otg->flow_start[src][dst][application])*1024);
else
else
LOG_W(OTG, "[src %d][dst %d][app %d] flow start time less than the simu time (start %d, duration %d, ctime %d)\n",
src, dst, application,
g_otg->flow_start[src][dst][application],
g_otg->flow_duration[src][dst][application],
get_ctime());
src, dst, application,
g_otg->flow_start[src][dst][application],
g_otg->flow_duration[src][dst][application],
get_ctime());
}
if (otg_info->rx_num_bytes_background[src][dst]>0)
@@ -105,9 +102,7 @@ if ((g_otg->flow_start[src][dst][application]+g_otg->flow_duration[src][dst][app
void rx_loss_rate_pkts(int src, int dst, int application)
{
void rx_loss_rate_pkts(int src, int dst, int application) {
if (otg_info->rx_num_pkt[src][dst][application]<otg_info->tx_num_pkt[src][dst][application])
otg_info->rx_loss_rate[src][dst][application]= 1 - ((double)otg_info->rx_num_pkt[src][dst][application]/otg_info->tx_num_pkt[src][dst][application]);
else
@@ -127,26 +122,20 @@ void rx_loss_rate_pkts(int src, int dst, int application)
otg_multicast_info->rx_loss_rate[src][dst]= 1 - ((double)otg_multicast_info->rx_num_pkt[src][dst][application]/otg_multicast_info->tx_num_pkt[src][dst][0]);
else
otg_multicast_info->rx_loss_rate[src][dst]=0;
}
void rx_loss_rate_bytes(int src, int dst, int application)
{
void rx_loss_rate_bytes(int src, int dst, int application) {
if (otg_info->rx_num_pkt[src][dst][application]<otg_info->tx_num_pkt[src][dst][application])
otg_info->rx_loss_rate[src][dst][application]= 1 - ((double)otg_info->rx_num_bytes[src][dst][application]/otg_info->tx_num_bytes[src][dst][application]);
else
otg_info->rx_loss_rate[src][dst][application]=0;
LOG_I(OTG, "loss rate (src=%d, dst=%d, appli %d ):: = %lf(bytes) \n",src, dst, application, otg_info->rx_loss_rate[src][dst][application]);
}
void otg_kpi_nb_loss_pkts(void)
{
void otg_kpi_nb_loss_pkts(void) {
unsigned int i,j,k;
otg_info->total_loss_dl=0;
otg_info->total_loss_ul=0;
@@ -162,9 +151,7 @@ void otg_kpi_nb_loss_pkts(void)
}
}
void average_pkt_jitter(int src, int dst, int application)
{
void average_pkt_jitter(int src, int dst, int application) {
if (otg_info->rx_jitter_sample[src][dst][application] > 0 ) {
otg_info->rx_jitter_avg[src][dst][application]/= otg_info->rx_jitter_sample[src][dst][application];
otg_info->rx_jitter_avg_e2e[src][dst][application]/= otg_info->rx_jitter_sample[src][dst][application];
@@ -189,13 +176,10 @@ void average_pkt_jitter(int src, int dst, int application)
LOG_T(OTG,"average_jitter_dl %lf average_jitter_ul %lf \n",otg_info->average_jitter_dl_e2e,otg_info->average_jitter_ul_e2e);
}
}
void average_total_jitter(void)
{
void average_total_jitter(void) {
unsigned int i,j,k;
otg_info->average_jitter_dl=0;
otg_info->average_jitter_ul=0;
otg_info->average_jitter_dl_e2e=0;
@@ -207,7 +191,6 @@ void average_total_jitter(void)
if (i<NB_eNB_INST) {
otg_info->average_jitter_dl+=otg_info->rx_jitter_avg[i][j][k];
otg_info->average_jitter_dl_e2e+=otg_info->rx_jitter_avg_e2e[i][j][k];
} else {
otg_info->average_jitter_ul+=otg_info->rx_jitter_avg[i][j][k];
otg_info->average_jitter_ul_e2e+=otg_info->rx_jitter_avg_e2e[i][j][k];
@@ -221,10 +204,8 @@ void average_total_jitter(void)
// otg_info->average_jitter_ul/= (float)NB_UE_INST;
}
void kpi_gen()
{
void kpi_gen() {
int i, j,k;
int tx_total_bytes_dl=0;
int tx_total_pkts_dl=0;
int rx_total_bytes_dl=0;
@@ -233,13 +214,10 @@ void kpi_gen()
int tx_total_pkts_ul=0;
int rx_total_bytes_ul=0;
int rx_total_pkts_ul=0;
float min_owd_dl=0;
float max_owd_dl=0;
float min_owd_dl_e2e=0;
float max_owd_dl_e2e=0;
int tx_total_bytes_dl_background=0;
int tx_total_pkts_dl_background=0;
int rx_total_bytes_dl_background=0;
@@ -248,27 +226,18 @@ void kpi_gen()
int tx_total_pkts_ul_background=0;
int rx_total_bytes_ul_background=0;
int rx_total_pkts_ul_background=0;
float min_owd_ul=0;
float max_owd_ul=0;
float min_owd_ul_e2e=0;
float max_owd_ul_e2e=0;
int tx_total_bytes_dl_multicast=0;
int tx_total_pkts_dl_multicast=0;
int rx_total_bytes_dl_multicast=0;
int rx_total_pkts_dl_multicast=0;
int num_active_source=0;
int dl_ok=1,ul_ok=1;
char traffic_type[12];
char traffic[30];
#ifdef STANDALONE
FILE *file;
file = fopen("log_OTG.txt", "w");
@@ -281,11 +250,8 @@ void kpi_gen()
#endif
for (i=0; i<(NB_eNB_INST + NB_UE_INST); i++) {
for (j=0; j<(NB_eNB_INST + NB_UE_INST); j++) {
/*background stats*/
if (i<NB_eNB_INST) {
tx_total_bytes_dl_background+=otg_info->tx_num_bytes_background[i][j];
@@ -300,7 +266,6 @@ void kpi_gen()
}
for (k=0; k<MAX_NUM_APPLICATION; k++) {
tx_throughput(i,j,k);
rx_goodput(i,j,k);
rx_loss_rate_pkts(i,j,k);
@@ -319,7 +284,6 @@ void kpi_gen()
tx_total_pkts_dl_multicast+=otg_multicast_info->tx_num_pkt[i][j][k];
rx_total_bytes_dl_multicast+=otg_multicast_info->rx_num_bytes[i][j][k];
rx_total_pkts_dl_multicast+=otg_multicast_info->rx_num_pkt[i][j][k];
#ifdef STANDALONE
LOG_I(OTG,"No stats for multicast "); // do nothing
#else
@@ -329,21 +293,17 @@ void kpi_gen()
if (otg_multicast_info->tx_num_bytes[i][j][k]>0) {
LOG_I(OTG,"----------------------------------------------------------\n");
LOG_I(OTG,"Total Time (multicast) (ms)= %d \n", otg_info->ctime+1);
// LOG_I(OTG,"[%s] Multicast [eNB:%d -> UE:%d] \n",traffic_type, i, j);
LOG_I(OTG,"[MULTICAST] Total packets(TX)= %d \n", otg_multicast_info->tx_num_pkt[i][j][k]);
LOG_I(OTG,"[MULTICAST] Total bytes(TX)= %d \n", otg_multicast_info->tx_num_bytes[i][j][k]);
LOG_I(OTG,"[MULTICAST] Total packets(RX)= %d \n", otg_multicast_info->rx_num_pkt[i][j][k]);
LOG_I(OTG,"[MULTICAST] Total bytes(RX)= %d \n", otg_multicast_info->rx_num_bytes[i][j][k]);
LOG_I(OTG,"[MULTICAST] TX throughput = %.7f (Kbit/s) \n", otg_multicast_info->tx_throughput[i][j]);
LOG_I(OTG,"[MULTICAST] RX goodput = %.7f (Kbit/s) \n", otg_multicast_info->rx_goodput[i][j]);
// if (otg_multicast_info->rx_loss_rate[i][j]>0){
// LOG_I(OTG,"[MULTICAST] Loss rate = %lf \n", (otg_multicast_info->rx_loss_rate[i][j]));
// LOG_I(OTG,"[MULTICAST] NB Lost packets=%d \n", (otg_multicast_info->tx_num_pkt[i][j][k]-otg_multicast_info->rx_num_pkt[i][j][k]));
//}
// if ((g_otg->background_stats==1)&&(otg_info->tx_num_bytes_background[i][j]>0)){
LOG_F(OTG,"----------------------------------------------------------\n");
LOG_F(OTG,"Total Time (multicast) (ms)= %d \n", otg_info->ctime+1);
@@ -363,12 +323,9 @@ void kpi_gen()
}
#endif
}// end for multicast
if ((otg_info->tx_throughput[i][j][k]>0)||((otg_info->tx_throughput_background[i][j]>0) && (otg_info->tx_num_bytes[i][j][k]>0))) {
num_active_source+=1;
if (i<NB_eNB_INST) { // DL
@@ -392,7 +349,6 @@ void kpi_gen()
if ((max_owd_dl_e2e<otg_info->rx_owd_max_e2e[i][j][k]) || (max_owd_dl_e2e==0))
max_owd_dl_e2e=otg_info->rx_owd_max_e2e[i][j][k];
} else { // UL
tx_total_bytes_ul+=otg_info->tx_num_bytes[i][j][k];
tx_total_pkts_ul+=otg_info->tx_num_pkt[i][j][k];
@@ -414,7 +370,6 @@ void kpi_gen()
if ((max_owd_ul_e2e<otg_info->rx_owd_max_e2e[i][j][k]) || (max_owd_ul_e2e==0))
max_owd_ul_e2e=otg_info->rx_owd_max_e2e[i][j][k];
}
//LOG_D(OTG,"KPI: (src=%d, dst=%d, appli %d) NB packet TX= %d, NB packet RX= %d\n ",i, j, otg_info->tx_num_pkt[i][j][k], otg_info->rx_num_pkt[i][j][k]);
@@ -432,9 +387,7 @@ void kpi_gen()
traffic[sizeof(traffic) - 1] = 0; // terminate string
}
#ifdef STANDALONE
fprintf(file,"----------------------------------------------------------\n");
fprintf(file,"Total Time (ms)= %d \n", otg_info->ctime+1);
@@ -467,8 +420,6 @@ void kpi_gen()
}
}
*/
#else
LOG_I(OTG,"----------------------------------------------------------\n");
LOG_I(OTG,"Total Time (ms)= %d \n", otg_info->ctime+1);
@@ -555,15 +506,11 @@ void kpi_gen()
}
*/
#endif
}
// if ((otg_multicast_info->tx_throughput[i][j]>0) && (otg_info->tx_num_bytes[i][j][k]>0)) {
}// end loop of k
#ifdef STANDALONE
if ((g_otg->background_stats==1)&&(otg_info->tx_num_bytes_background[i][j]>0)) {
@@ -629,14 +576,10 @@ void kpi_gen()
}
#endif
}// end loop of j
}// end loop of i
// average_total_jitter();
#ifdef STANDALONE
fprintf (file,"**************** TOTAL DL RESULTS ******************\n");
fprintf(file,"Total Time= %d \n", otg_info->ctime+1);
@@ -723,7 +666,6 @@ void kpi_gen()
LOG_I(OTG,"[MULTICAST] RX throughput = %.7f(Kbit/s) \n", ((double)rx_total_bytes_dl_multicast*1000*8)/(otg_info->ctime*1024));
}
LOG_F(OTG,"**************** TOTAL DL RESULTS ******************\n");
LOG_F(OTG,"Total Time (ms)= %d \n", otg_info->ctime+1);
LOG_F(OTG,"[DATA] Total packets(TX)= %d \n", tx_total_pkts_dl);
@@ -762,8 +704,6 @@ void kpi_gen()
LOG_F(OTG,"[MULTICAST] RX throughput = %.7f(Kbit/s) \n", ((double)rx_total_bytes_dl_multicast*1000*8)/(otg_info->ctime*1024));
}
LOG_I(OTG,"**************** TOTAL UL RESULTS ******************\n");
LOG_I(OTG,"Total Time (ms)= %d \n", otg_info->ctime+1);
LOG_I(OTG,"[DATA] Total packets(TX)= %d \n", tx_total_pkts_ul);
@@ -795,7 +735,6 @@ void kpi_gen()
LOG_I(OTG,"[BACKGROUND] Total bytes(RX)= %d \n", rx_total_bytes_ul_background);
LOG_I(OTG,"[BACKGROUND] TX throughput = %.7f(Kbit/s) \n", ((double)tx_total_bytes_ul_background*1000*8)/(otg_info->ctime*1024));
LOG_I(OTG,"[BACKGROUND] RX throughput = %.7f(Kbit/s) \n", ((double)rx_total_bytes_ul_background*1000*8)/(otg_info->ctime*1024));
}
LOG_F(OTG,"**************** TOTAL UL RESULTS ******************\n");
@@ -825,7 +764,6 @@ void kpi_gen()
LOG_F(OTG,"[BACKGROUND] Total bytes(RX)= %d \n", rx_total_bytes_ul_background);
LOG_F(OTG,"[BACKGROUND] TX throughput = %.7f(Kbit/s) \n", ((double)tx_total_bytes_ul_background*1000*8)/(otg_info->ctime*1024));
LOG_F(OTG,"[BACKGROUND] RX throughput = %.7f(Kbit/s) \n", ((double)rx_total_bytes_ul_background*1000*8)/(otg_info->ctime*1024));
}
if ((dl_ok == 1 ) && (ul_ok ==1))
@@ -837,8 +775,7 @@ void kpi_gen()
}
void add_log_metric(int src, int dst, int ctime, double metric, unsigned int label)
{
void add_log_metric(int src, int dst, int ctime, double metric, unsigned int label) {
unsigned int i;
unsigned int j;
unsigned int node_actif=0;
@@ -846,28 +783,27 @@ void add_log_metric(int src, int dst, int ctime, double metric, unsigned int lab
//LOG_I(OTG,"[%d][%d] LOGG_ADDED ctime=%d, metric=%.2f \n", src, dst, ctime, metric);
switch (label) {
case OTG_LATENCY:
add_log_label(label, &start_log_latency);
break;
case OTG_LATENCY:
add_log_label(label, &start_log_latency);
break;
case OTG_LATENCY_BG:
add_log_label(label, &start_log_latency_bg);
break;
case OTG_LATENCY_BG:
add_log_label(label, &start_log_latency_bg);
break;
case OTG_GP:
add_log_label(label, &start_log_GP);
break;
case OTG_GP:
add_log_label(label, &start_log_GP);
break;
case OTG_GP_BG:
add_log_label(label, &start_log_GP_bg);
break;
case OTG_GP_BG:
add_log_label(label, &start_log_GP_bg);
break;
case OTG_JITTER:
add_log_label(label, &start_log_GP_bg);
break;
default:
LOG_E(OTG, "File label unknown %d \n", label);
case OTG_JITTER:
add_log_label(label, &start_log_GP_bg);
break;
default:
LOG_E(OTG, "File label unknown %u \n", label);
}
LOG_F(label,"%d ", ctime);
@@ -892,8 +828,7 @@ void add_log_metric(int src, int dst, int ctime, double metric, unsigned int lab
void add_log_label(unsigned int label, unsigned int * start_log_metric)
{
void add_log_label(unsigned int label, unsigned int *start_log_metric) {
unsigned int i;
unsigned int j;
unsigned int node_actif=0;
@@ -910,7 +845,7 @@ void add_log_label(unsigned int label, unsigned int * start_log_metric)
node_actif++;
if (node_actif>0)
LOG_F(label,"%d->%d ", i, j);
LOG_F(label,"%u->%u ", i, j);
}
}
+29 -61
View File
@@ -38,9 +38,9 @@
#include "otg_kpi.h"
#ifdef ENABLE_DB_STATS
#include <mysql.h>
#include <m_ctype.h>
#include <sql_common.h>
#include <mysql.h>
#include <m_ctype.h>
#include <sql_common.h>
#endif
extern unsigned char NB_eNB_INST;
@@ -54,12 +54,10 @@ extern unsigned char NB_UE_INST;
#define MIN(x,y) ((x)<(y)?(x):(y))
// Check if the packet is well received or not and extract data
int otg_rx_pkt(const int dst_instanceP, const int ctime, const char * const buffer_tx, const unsigned int size)
{
int otg_rx_pkt(const int dst_instanceP, const int ctime, const char *const buffer_tx, const unsigned int size) {
int bytes_read = 0;
otg_hdr_info_t * otg_hdr_info_rx;
otg_hdr_t * otg_hdr_rx;
otg_hdr_info_t *otg_hdr_info_rx;
otg_hdr_t *otg_hdr_rx;
int is_size_ok = 0;
unsigned int seq_num_rx;
unsigned int nb_loss_pkts;
@@ -70,26 +68,22 @@ int otg_rx_pkt(const int dst_instanceP, const int ctime, const char * const buff
if (buffer_tx!=NULL) {
otg_hdr_info_rx = (otg_hdr_info_t *) (&buffer_tx[bytes_read]);
bytes_read += sizeof (otg_hdr_info_t);
LOG_D(OTG,"otg_rx_pkt functions: destination %d, size %d, otg_hdr_info_rx->flag %.4x, otg_hdr_info_rx->size %d \n",
LOG_D(OTG,"otg_rx_pkt functions: destination %d, size %u, otg_hdr_info_rx->flag %.4x, otg_hdr_info_rx->size %u \n",
dst_instanceP,
size,
otg_hdr_info_rx->flag,
otg_hdr_info_rx->size);
if (((otg_hdr_info_rx->flag == 0xffff) ||
(otg_hdr_info_rx->flag == 0xbbbb) ||
(otg_hdr_info_rx->flag == 0x1000)) &&
(otg_hdr_info_rx->size == size )) { //data traffic
LOG_I(OTG,"MAX_RX_INFO %d %d \n",NB_eNB_INST, NB_UE_INST);
/*is_size_ok= 0;
if (( otg_hdr_info_rx->size ) == size ) {*/
is_size_ok= 1;
otg_hdr_rx = (otg_hdr_t *) (&buffer_tx[bytes_read]);
LOG_I(OTG,"[SRC %d][DST %d] [FLOW_idx %d][APP TYPE %d] RX INFO pkt at time %d: flag 0x %x, seq number %d, tx time %d, size (hdr %d, pdcp %d) \n",
LOG_I(OTG,"[SRC %u][DST %u] [FLOW_idx %u][APP TYPE %u] RX INFO pkt at time %d: flag 0x %x, seq number %u, tx time %u, size (hdr %u, pdcp %u) \n",
otg_hdr_rx->src_instance,
otg_hdr_rx->dst_instance,
otg_hdr_rx->flow_id,
@@ -99,14 +93,12 @@ int otg_rx_pkt(const int dst_instanceP, const int ctime, const char * const buff
otg_hdr_rx->seq_num,
otg_hdr_rx->time,
otg_hdr_info_rx->size, size);
bytes_read += sizeof (otg_hdr_t);
src_instance = otg_hdr_rx->src_instance;
dst_instance = otg_hdr_rx->dst_instance;
if (dst_instance != dst_instanceP) {
//#warning "LG: TODO think about multicast traffic"
//#warning "LG: TODO think about multicast traffic"
/* TODO: fix this LOG, a lot of missing parameters, replaced by a simple basic version */
/*LOG_W(OTG,"[SRC %d][DST %d] [FLOW_idx %d][APP TYPE %d] RX INFO pkt at time %d: flag 0x %x, seq number %d, tx time %d, size (hdr %d, pdcp %d) not for dest instance %u\n",
dst_instanceP);*/
@@ -114,7 +106,7 @@ int otg_rx_pkt(const int dst_instanceP, const int ctime, const char * const buff
}
if(otg_hdr_rx->traffic_type > MAX_NUM_APPLICATION) {
LOG_W(OTG,"RX packet: application type out of range %d for the pair of (src %d, dst %d) \n",
LOG_W(OTG,"RX packet: application type out of range %u for the pair of (src %u, dst %u) \n",
otg_hdr_rx->traffic_type, src_instance, dst_instance);
otg_hdr_rx->traffic_type=0;
}
@@ -135,7 +127,7 @@ int otg_rx_pkt(const int dst_instanceP, const int ctime, const char * const buff
// rx_check_loss(src_instance, dst_instance, otg_hdr_info_rx->flag, otg_hdr_rx->seq_num, &seq_num_rx, &nb_loss_pkts);
// otg_multicast_info->loss_rate[src_instance][dst_instance][otg_hdr_rx->traffic_type]=nb_loss_pkts;
//otg_multicast_info->rx_sn[src_instance][dst_instance][otg_hdr_rx->traffic_type]=seq_num_rx;
LOG_I(OTG,"received a multicast packet with size %d sn %d ran owd %d loss rate %d\n",
LOG_I(OTG,"received a multicast packet with size %u sn %u ran owd %u loss rate %u\n",
otg_hdr_info_rx->size, seq_num_rx, ctime- otg_hdr_rx->time, nb_loss_pkts);
//return 0;
} /** background traffic **/
@@ -148,10 +140,8 @@ int otg_rx_pkt(const int dst_instanceP, const int ctime, const char * const buff
nb_loss_pkts=otg_info->nb_loss_pkts_background_ul[src_instance][dst_instance];
}
LOG_D(OTG,"[%d][%d] AGGREGATION LEVEL (RX) %d \n", src_instance, dst_instance, otg_hdr_rx->aggregation_level);
LOG_D(OTG,"[%u][%u] AGGREGATION LEVEL (RX) %u \n", src_instance, dst_instance, otg_hdr_rx->aggregation_level);
otg_info->aggregation_level[src_instance][dst_instance]=otg_hdr_rx->aggregation_level;
/* Loss and out of sequence data management */
lost_packet= rx_check_loss(
src_instance,
@@ -161,11 +151,9 @@ int otg_rx_pkt(const int dst_instanceP, const int ctime, const char * const buff
&seq_num_rx,
&nb_loss_pkts);
if (otg_info->owd_const[src_instance][dst_instance][otg_hdr_rx->flow_id]==0)
owd_const_gen(src_instance,dst_instance,otg_hdr_rx->flow_id, otg_hdr_rx->traffic_type);
/******/
/*
float owd_const_capillary_v=owd_const_capillary()/2;
@@ -185,7 +173,7 @@ int otg_rx_pkt(const int dst_instanceP, const int ctime, const char * const buff
otg_info->radio_access_delay[src_instance][dst_instance]=(float) (ctime- otg_hdr_rx->time);
otg_multicast_info->radio_access_delay[src_instance][dst_instance]=(float) (ctime- otg_hdr_rx->time);
} else {
LOG_I(OTG,"received packet has tx time %d greater than the current time %d\n",otg_hdr_rx->time,ctime );
LOG_I(OTG,"received packet has tx time %u greater than the current time %d\n",otg_hdr_rx->time,ctime );
otg_info->radio_access_delay[src_instance][dst_instance] = 0;
otg_multicast_info->radio_access_delay[src_instance][dst_instance]=0;
}
@@ -196,8 +184,7 @@ int otg_rx_pkt(const int dst_instanceP, const int ctime, const char * const buff
otg_info->rx_pkt_owd_e2e[src_instance][dst_instance]=
otg_info->owd_const[src_instance][dst_instance][otg_hdr_rx->flow_id] + otg_info->radio_access_delay[src_instance][dst_instance];
otg_multicast_info->rx_pkt_owd[src_instance][dst_instance]=otg_multicast_info->radio_access_delay[src_instance][dst_instance];
LOG_D(OTG, "[src %d][dst %d] ctime %d tx time %d: OWD %lf E2E OWD %lf \n",
LOG_D(OTG, "[src %u][dst %u] ctime %d tx time %u: OWD %lf E2E OWD %lf \n",
src_instance,
dst_instance,
ctime,
@@ -217,7 +204,7 @@ int otg_rx_pkt(const int dst_instanceP, const int ctime, const char * const buff
otg_info->rx_pkt_jitter[src_instance][dst_instance]=
abs(otg_info->rx_pkt_owd_history[src_instance][dst_instance][0] - otg_info->rx_pkt_owd_history[src_instance][dst_instance][1]);
LOG_D(OTG,"The packet jitter for the pair (src %d, dst %d)) at %d is %lf (current %lf, previous %lf) \n",
LOG_D(OTG,"The packet jitter for the pair (src %u, dst %u)) at %d is %lf (current %lf, previous %lf) \n",
src_instance, dst_instance, ctime, otg_info->rx_pkt_jitter[src_instance][dst_instance],
otg_info->rx_pkt_owd_history[src_instance][dst_instance][0], otg_info->rx_pkt_owd_history[src_instance][dst_instance][1]);
// e2e
@@ -230,26 +217,24 @@ int otg_rx_pkt(const int dst_instanceP, const int ctime, const char * const buff
otg_info->rx_pkt_jitter_e2e[src_instance][dst_instance]=
abs(otg_info->rx_pkt_owd_history_e2e[src_instance][dst_instance][0] - otg_info->rx_pkt_owd_history_e2e[src_instance][dst_instance][1]);
LOG_D(OTG,"The packet jitter for the pair (src %d, dst %d)) at %d is %lf (current %lf, previous %lf) \n",
LOG_D(OTG,"The packet jitter for the pair (src %u, dst %u)) at %d is %lf (current %lf, previous %lf) \n",
src_instance,
dst_instance,
ctime,
otg_info->rx_pkt_jitter_e2e[src_instance][dst_instance],
otg_info->rx_pkt_owd_history_e2e[src_instance][dst_instance][0],
otg_info->rx_pkt_owd_history_e2e[src_instance][dst_instance][1]);
}
if (otg_hdr_info_rx->flag == 0x1000) {
LOG_I(OTG,"[SRC%d -> DST %d] Received a multicast packet at time %d with size %d, seq num %d, ran owd %d number loss packet %d\n",
LOG_I(OTG,"[SRC%u -> DST %u] Received a multicast packet at time %d with size %u, seq num %u, ran owd %u number loss packet %u\n",
src_instance,
dst_instance,
ctime,otg_hdr_info_rx->size,
otg_hdr_rx->seq_num,
ctime - otg_hdr_rx->time,
nb_loss_pkts);
LOG_I(OTG,"INFO LATENCY :: [SRC %d][DST %d] radio access %.2f (tx time %d, ctime %d), OWD:%d (ms):\n",
LOG_I(OTG,"INFO LATENCY :: [SRC %u][DST %u] radio access %.2f (tx time %u, ctime %d), OWD:%d (ms):\n",
src_instance,
dst_instance,
otg_multicast_info->radio_access_delay[src_instance][dst_instance],
@@ -286,8 +271,7 @@ int otg_rx_pkt(const int dst_instanceP, const int ctime, const char * const buff
otg_multicast_info->rx_total_bytes_dl+=otg_hdr_info_rx->size;
} else {
LOG_I(OTG,"[SRC %d][DST %d] Stats :: radio access latency %.2f (tx time %d, ctime %d) jitter %.2f, Estimated E2E OWD:%.2f (ms):\n",
LOG_I(OTG,"[SRC %u][DST %u] Stats :: radio access latency %.2f (tx time %u, ctime %d) jitter %.2f, Estimated E2E OWD:%.2f (ms):\n",
src_instance,
dst_instance,
otg_info->radio_access_delay[src_instance][dst_instance],
@@ -296,7 +280,6 @@ int otg_rx_pkt(const int dst_instanceP, const int ctime, const char * const buff
otg_info->rx_pkt_owd_e2e[src_instance][dst_instance]);
if (otg_hdr_info_rx->flag == 0xffff) {
if (otg_info->rx_owd_max[src_instance][dst_instance][otg_hdr_rx->traffic_type]==0) {
otg_info->rx_owd_max[src_instance][dst_instance][otg_hdr_rx->traffic_type]=otg_info->rx_pkt_owd[src_instance][dst_instance];
otg_info->rx_owd_min[src_instance][dst_instance][otg_hdr_rx->traffic_type]=otg_info->rx_pkt_owd[src_instance][dst_instance];
@@ -332,7 +315,6 @@ int otg_rx_pkt(const int dst_instanceP, const int ctime, const char * const buff
otg_info->rx_jitter_avg_e2e[src_instance][dst_instance][otg_hdr_rx->traffic_type] += otg_info->rx_pkt_jitter_e2e[src_instance][dst_instance];
otg_info->rx_jitter_sample[src_instance][dst_instance][otg_hdr_rx->traffic_type] +=1;
}
}
if (g_otg->curve==1) {
@@ -355,15 +337,12 @@ int otg_rx_pkt(const int dst_instanceP, const int ctime, const char * const buff
otg_info->rx_total_bytes_dl+=otg_hdr_info_rx->size;
else
otg_info->rx_total_bytes_ul+=otg_hdr_info_rx->size;
}
//LOG_I(OTG,"RX INFO :: RTT MIN(one way) ms: %.2f, RTT MAX(one way) ms: %.2f \n", otg_info->rx_owd_min[src][dst], otg_info->rx_owd_max[src][dst]);
/* xforms part: add metrics */
//printf("payload_size %d, header_size %d \n", otg_hdr_rx->pkts_size, otg_hdr_rx->hdr_type);
LOG_I(OTG,"[RX] OTG packet, PACKET SIZE [SRC %d][DST %d]: Flag (0x%x), Traffic %d, time(%d), Seq num (%d), Total size (%d)\n",
LOG_I(OTG,"[RX] OTG packet, PACKET SIZE [SRC %u][DST %u]: Flag (0x%x), Traffic %u, time(%d), Seq num (%u), Total size (%u)\n",
src_instance,
dst_instance,
otg_hdr_info_rx->flag,
@@ -372,7 +351,6 @@ int otg_rx_pkt(const int dst_instanceP, const int ctime, const char * const buff
otg_hdr_rx->seq_num, size);
/*LOG_I(OTG,"details::RX [SRC %d][DST %d]: Flag (0x%x), time(%d), Seq num (%d), Total size (%d), header(%d), payload (%d) \n", src, dst, otg_hdr_info_rx->flag, ctime, otg_hdr_rx->seq_num, size, strlen(packet_rx->header), strlen(packet_rx->payload));*/
if (otg_hdr_info_rx->flag == 0xffff) {
otg_info->rx_num_pkt[src_instance][dst_instance][otg_hdr_rx->traffic_type]+=1;
otg_info->rx_num_bytes[src_instance][dst_instance][otg_hdr_rx->traffic_type]+=otg_hdr_info_rx->size;
@@ -402,7 +380,6 @@ int otg_rx_pkt(const int dst_instanceP, const int ctime, const char * const buff
otg_hdr_rx->time,
((otg_hdr_info_rx->size*1000*8)/(otg_info->rx_pkt_owd[src_instance][dst_instance]*1024 )),
OTG_GP); /* compute the throughput in Kbit/s */
} else if (otg_hdr_info_rx->flag == 0x1000) {
otg_multicast_info->rx_num_pkt[src_instance][dst_instance][otg_hdr_rx->traffic_type]+=1;
otg_multicast_info->rx_num_bytes[src_instance][dst_instance][otg_hdr_rx->traffic_type]+=otg_hdr_info_rx->size;
@@ -446,18 +423,17 @@ int otg_rx_pkt(const int dst_instanceP, const int ctime, const char * const buff
if (is_size_ok == 0) {
otg_hdr_rx = (otg_hdr_t *) (&buffer_tx[bytes_read]);
LOG_W(OTG,"[SRC %d][DST %d] RX pkt: seq number %d size mis-matche (hdr %d, pdcp %d) \n",
LOG_W(OTG,"[SRC %u][DST %u] RX pkt: seq number %u size mis-matche (hdr %u, pdcp %u) \n",
src_instance, dst_instance, otg_hdr_rx->seq_num, otg_hdr_info_rx->size, size);
otg_info->nb_loss_pkts_otg[src_instance][dst_instance]++;
}
return(0);
} else {
LOG_W(OTG,"RX: Not an OTG pkt, forward to upper layer (flag %x, size %d, pdcp_size %d) FIX ME \n",
LOG_W(OTG,"RX: Not an OTG pkt, forward to upper layer (flag %x, size %u, pdcp_size %u) FIX ME \n",
otg_hdr_info_rx->flag, otg_hdr_info_rx->size, size);
return(1); //to be fixed on the real case to one
}
}
return(0);
@@ -471,10 +447,8 @@ int rx_check_loss(
const int dst,
const unsigned int flag,
const int seq_num,
unsigned int * const seq_num_rx,
unsigned int * const nb_loss_pkts)
{
unsigned int *const seq_num_rx,
unsigned int *const nb_loss_pkts) {
/* Loss and out of sequence data management, we have 3 case : */
/* (1) Receieved packet corresponds to the expected one, in terms of the sequence number*/
int lost_packet=0;
@@ -509,8 +483,7 @@ void owd_const_gen(
const int src,
const int dst,
const int flow_id,
const unsigned int flag)
{
const unsigned int flag) {
otg_info->owd_const[src][dst][flow_id]=(owd_const_mobile_core()+owd_const_IP_backbone()+owd_const_application())/2;
if ((flag==M2M)||(flag==M2M_TRAFFIC)||(flag==AUTO_PILOT_L)||(flag==AUTO_PILOT_M)||(flag==AUTO_PILOT_H)||(flag==VIRTUAL_GAME_L)||(flag==VIRTUAL_GAME_M)|| (flag==VIRTUAL_GAME_H)||(flag==VIRTUAL_GAME_F)
@@ -523,8 +496,7 @@ void owd_const_gen(
float owd_const_capillary(void)
{
float owd_const_capillary(void) {
/*return (uniform_dist(MIN_APPLICATION_PROCESSING_GATEWAY_DELAY, MAX_APPLICATION_PROCESSING_GATEWAY_DELAY) +
uniform_dist(MIN_FORMATING_TRANSFERRING_DELAY, MAX_FORMATING_TRANSFERRING_DELAY) +
uniform_dist(MIN_ACCESS_DELAY, MAX_ACCESS_DELAY) +
@@ -534,8 +506,7 @@ float owd_const_capillary(void)
}
float owd_const_mobile_core(void)
{
float owd_const_mobile_core(void) {
/*double delay;
// this is a delay model for a loaded GGSN according to
//"M. Laner, P. Svoboda and M. Rupp, Latency Analysis of 3G Network Components, EW'12, Poznan, Poland, 2012", table 2, page 6.
@@ -559,15 +530,12 @@ float owd_const_mobile_core(void)
return ((double)MIN_U_PLANE_CORE_IP_ACCESS_DELAY+ (double)MAX_U_PLANE_CORE_IP_ACCESS_DELAY + (double)MIN_FW_PROXY_DELAY + (double)MAX_FW_PROXY_DELAY)/2;
}
float owd_const_IP_backbone(void)
{
float owd_const_IP_backbone(void) {
/*return uniform_dist(MIN_NETWORK_ACCESS_DELAY,MAX_NETWORK_ACCESS_DELAY);*/
return ((double)MIN_NETWORK_ACCESS_DELAY+(double)MAX_NETWORK_ACCESS_DELAY)/2;
}
float owd_const_application(void)
{
float owd_const_application(void) {
/*return uniform_dist(MIN_APPLICATION_ACESS_DELAY, MAX_APPLICATION_ACESS_DELAY);*/
return ((double)MIN_APPLICATION_ACESS_DELAY+(double)MAX_APPLICATION_ACESS_DELAY)/2;
}
+35 -35
View File
@@ -305,10 +305,10 @@ unsigned char *packet_gen(
otg_info->tx_num_pkt[src_instance][dst_instance][otg_info->traffic_type[src_instance][dst_instance]]+=1;
if (size!=strlen(payload))
LOG_E(OTG,"[%d][%d] [0x %x] The expected packet size does not match the payload size : size %d, strlen %zu, seq_num %d packet: |%s|%s| \n",
LOG_E(OTG,"[%d][%d] [0x %x] The expected packet size does not match the payload size : size %u, strlen %zu, seq_num %u packet: |%s|%s| \n",
src_instance, dst_instance, flag, size, strlen(payload), seq_num, header, payload);
else
LOG_D(OTG,"[%d][%d] 0x %x][m2m Aggre %d][Flow %d][Type %d/%s] TX INFO pkt at time %d Size= [payload %d] [Total %zu] with seq num %d, state=%d : |%s|%s| \n",
LOG_D(OTG,"[%d][%d] 0x %x][m2m Aggre %u][Flow %u][Type %u/%s] TX INFO pkt at time %d Size= [payload %u] [Total %zu] with seq num %u, state=%u : |%s|%s| \n",
src_instance, dst_instance, flag,
otg_info->m2m_aggregation[src_instance][dst_instance],
otg_info->flow_id[src_instance][dst_instance],
@@ -316,7 +316,7 @@ unsigned char *packet_gen(
map_int_to_str(otg_app_type_names,otg_info->traffic_type[src_instance][dst_instance]),
ctime, size, header_size+strlen(payload), seq_num,state, header, payload);
LOG_D(OTG, "[%d]MY_SEQ %d \n", otg_info->traffic_type[src_instance][dst_instance], otg_info->seq_num[src_instance][dst_instance][otg_info->traffic_type[src_instance][dst_instance]] );
LOG_D(OTG, "[%u]MY_SEQ %d \n", otg_info->traffic_type[src_instance][dst_instance], otg_info->seq_num[src_instance][dst_instance][otg_info->traffic_type[src_instance][dst_instance]] );
} else {
if ((g_otg->aggregation_level[src_instance][dst_instance][application]*otg_info->size_background[src_instance][dst_instance])<=PAYLOAD_MAX)
otg_info->size_background[src_instance][dst_instance]=g_otg->aggregation_level[src_instance][dst_instance][application]*otg_info->size_background[src_instance][dst_instance];
@@ -335,7 +335,7 @@ unsigned char *packet_gen(
otg_info->seq_num_background[src_instance][dst_instance]+=1;
if (otg_info->size_background[src_instance][dst_instance]!=strlen(payload))
LOG_E(OTG,"[%d][%d] [0x %x] The expected packet size does not match the payload size : size %d, strlen %zu, seq num %d, packet |%s|%s| \n",
LOG_E(OTG,"[%d][%d] [0x %x] The expected packet size does not match the payload size : size %d, strlen %zu, seq num %u, packet |%s|%s| \n",
src_instance,
dst_instance,
flag,
@@ -345,7 +345,7 @@ unsigned char *packet_gen(
header,
payload);
else
LOG_D(OTG,"[%d][%d][0x %x][%d] TX INFO pkt at time %s size is %d with seq num %d, state=%d : |%s|%s| \n",
LOG_D(OTG,"[%d][%d][0x %x][%d] TX INFO pkt at time %s size is %d with seq num %u, state=%u : |%s|%s| \n",
src_instance,
dst_instance,
flag,
@@ -367,7 +367,7 @@ unsigned char *packet_gen(
otg_info->tx_total_bytes_ul+=buffer_size;
if (otg_info->traffic_type[src_instance][dst_instance] > MAX_NUM_APPLICATION) {
LOG_W(OTG,"application type out of range %d for the pair of (src %d, dst %d) \n",
LOG_W(OTG,"application type out of range %u for the pair of (src %d, dst %d) \n",
otg_info->traffic_type[src_instance][dst_instance], src_instance, dst_instance);
otg_info->traffic_type[src_instance][dst_instance]=0;
}
@@ -425,7 +425,7 @@ unsigned char *packet_gen_multicast(
g_otg_multicast->idt_max[src_instance][dst_instance][app]));
size = ceil(uniform_dist(g_otg_multicast->size_min[src_instance][dst_instance][app],
g_otg_multicast->size_max[src_instance][dst_instance][app]));
LOG_D(OTG, "ptime %d, ctime %d idt %d (min %d, max %d) size %d (min %d, max %d)\n",
LOG_D(OTG, "ptime %d, ctime %d idt %d (min %d, max %d) size %u (min %d, max %d)\n",
otg_multicast_info->ptime[src_instance][dst_instance][application],
ctime,
otg_multicast_info->idt[src_instance][dst_instance][app],
@@ -459,10 +459,10 @@ unsigned char *packet_gen_multicast(
otg_multicast_info->tx_num_bytes[src_instance][dst_instance][app]);
if (size!=strlen(payload))
LOG_E(OTG,"[src %d][dst %d] The expected packet size does not match the payload size : size %d, strlen %zu \n",
LOG_E(OTG,"[src %d][dst %d] The expected packet size does not match the payload size : size %u, strlen %zu \n",
src_instance, dst_instance, size, strlen(payload));
else {
LOG_I(OTG,"[src %d][dst %d]TX INFO pkt at time %d Size= [payload %d] [Total %zu] with seq num %d: |%s|%s| \n",
LOG_I(OTG,"[src %d][dst %d]TX INFO pkt at time %d Size= [payload %u] [Total %zu] with seq num %d: |%s|%s| \n",
src_instance,
dst_instance,
ctime,
@@ -557,7 +557,7 @@ int check_data_transmit(
// for (application=0; application<g_otg->application_idx[src_instance][dst_instance]; application++){
otg_info->gen_pkts=0;
LOG_T(OTG,"FLOW_INFO [src %d][dst %d] [IDX %d] [APPLICATION TYPE %d] MAX %d [M2M %d ]\n",
LOG_T(OTG,"FLOW_INFO [src %d][dst %d] [IDX %d] [APPLICATION TYPE %d] MAX %u [M2M %u ]\n",
src_instance, dst_instance, app,
g_otg->application_type[src_instance][dst_instance][app],
g_otg->application_idx[src_instance][dst_instance],
@@ -605,7 +605,7 @@ int check_data_transmit(
if (((state==PU_STATE)||(state==ED_STATE))|| (otg_info->idt[src_instance][dst_instance][app]==0)
|| (( (ctime-otg_info->ptime[src_instance][dst_instance][app]) >= otg_info->idt[src_instance][dst_instance][app] ) )) {
LOG_D(OTG,"[TX] OTG packet: Time To Transmit::OK (Source= %d, Destination= %d, Application %d, State= %d) , (IDT= %d ,ctime= %d, ptime= %d) \n",
LOG_D(OTG,"[TX] OTG packet: Time To Transmit::OK (Source= %d, Destination= %d, Application %d, State= %u) , (IDT= %d ,ctime= %d, ptime= %d) \n",
src_instance,
dst_instance ,
app,
@@ -654,7 +654,7 @@ int check_data_transmit(
if (g_otg->m2m[src_instance][dst_instance][app]==M2M)
otg_info->traffic_type[src_instance][dst_instance]=app;//g_otg->application_idx[src_instance][dst_instance];//M2M;
LOG_D(OTG,"[BACKGROUND=%d] Time To Transmit [SRC %d][DST %d][APPLI %d] \n", otg_info->traffic_type_background[src_instance][dst_instance], src_instance, dst_instance, app);
LOG_D(OTG,"[BACKGROUND=%u] Time To Transmit [SRC %d][DST %d][APPLI %d] \n", otg_info->traffic_type_background[src_instance][dst_instance], src_instance, dst_instance, app);
}
}
@@ -720,7 +720,7 @@ void header_size_gen(
if ((g_otg->application_type[src_instance][dst_instance][application]==VOIP_G711)||(g_otg->application_type[src_instance][dst_instance][application]==VOIP_G729))
size_header+=RTP_HEADER;
LOG_D(OTG,"Header size is %d [IP V=%d][PROTO=%d]\n", size_header, g_otg->ip_v[src_instance][dst_instance][application],g_otg->trans_proto[src_instance][dst_instance][application]);
LOG_D(OTG,"Header size is %u [IP V=%d][PROTO=%d]\n", size_header, g_otg->ip_v[src_instance][dst_instance][application],g_otg->trans_proto[src_instance][dst_instance][application]);
otg_info->header_size_app[src_instance][dst_instance][application]=size_header;
}
}
@@ -889,7 +889,7 @@ unsigned char * serialize_buffer(
otg_hdr_p->traffic_type=traffic_type;
byte_tx_count += sizeof(otg_hdr_t);
LOG_I(OTG,"traffic type %d\n",otg_hdr_p->traffic_type);
LOG_I(OTG,"traffic type %u\n",otg_hdr_p->traffic_type);
// copy the header first
memcpy(&tx_buffer[byte_tx_count], header, strlen(header));
byte_tx_count += strlen(header);
@@ -1953,7 +1953,7 @@ int header_size_gen_background(
otg_info->header_size_background[src_instance][dst_instance]=size_header;
}
LOG_D(OTG," [SRC %d][DST %d] BACKGROUND TRAFFIC:: size header %d \n", src_instance, dst_instance, otg_info->header_size_background[src_instance][dst_instance]);
LOG_D(OTG," [SRC %d][DST %d] BACKGROUND TRAFFIC:: size header %u \n", src_instance, dst_instance, otg_info->header_size_background[src_instance][dst_instance]);
return otg_info->header_size_background[src_instance][dst_instance];
}
@@ -1987,7 +1987,7 @@ void state_management(
if (ctime>otg_info->start_holding_time_off[src_instance][dst_instance][application]) {
otg_info->c_holding_time_off[src_instance][dst_instance][application]= ctime - otg_info->start_holding_time_off[src_instance][dst_instance][application];
LOG_D(OTG,"[%d][%d][Appli id %d][Agg Level=%d] STATE:: OFF Holding Time %d (%d, %d)\n", src_instance, dst_instance,application , g_otg->aggregation_level[src_instance][dst_instance][application],
LOG_D(OTG,"[%d][%d][Appli id %d][Agg Level=%u] STATE:: OFF Holding Time %u (%d, %u)\n", src_instance, dst_instance,application , g_otg->aggregation_level[src_instance][dst_instance][application],
otg_info->c_holding_time_off[src_instance][dst_instance][application], ctime, otg_info->start_holding_time_off[src_instance][dst_instance][application]);
}
@@ -1997,7 +1997,7 @@ void state_management(
+g_otg->prob_off_pe[src_instance][dst_instance][application])))
&& (otg_info->c_holding_time_off[src_instance][dst_instance][application]>=g_otg->holding_time_off_pu[src_instance][dst_instance][application])) {
otg_info->state[src_instance][dst_instance][application]=PU_STATE;
LOG_I(OTG,"[%d][%d][Appli id %d][Agg Level=%d] NEW STATE:: OFF-->PU %d (ctime %d, start %d )\n", src_instance, dst_instance,application,
LOG_I(OTG,"[%d][%d][Appli id %d][Agg Level=%u] NEW STATE:: OFF-->PU %u (ctime %d, start %u )\n", src_instance, dst_instance,application,
g_otg->aggregation_level[src_instance][dst_instance][application], otg_info->c_holding_time_off[src_instance][dst_instance][application], ctime,
otg_info->start_holding_time_off[src_instance][dst_instance][application]);
otg_info->state_transition_prob[src_instance][dst_instance][application]=uniform_dist(0,1);
@@ -2007,7 +2007,7 @@ void state_management(
&& (otg_info->state_transition_prob[src_instance][dst_instance][application]< 1-g_otg->prob_off_pe[src_instance][dst_instance][application]))
&& (otg_info->c_holding_time_off[src_instance][dst_instance][application]>=g_otg->holding_time_off_ed[src_instance][dst_instance][application])) {
otg_info->state[src_instance][dst_instance][application]=ED_STATE;
LOG_D(OTG,"[%d][%d][Appli id %d][Agg Level=%d] NEW STATE:: OFF-->ED \n", src_instance, dst_instance,application, g_otg->aggregation_level[src_instance][dst_instance][application]);
LOG_D(OTG,"[%d][%d][Appli id %d][Agg Level=%u] NEW STATE:: OFF-->ED \n", src_instance, dst_instance,application, g_otg->aggregation_level[src_instance][dst_instance][application]);
otg_info->state_transition_prob[src_instance][dst_instance][application]=uniform_dist(0,1);
}
@@ -2015,13 +2015,13 @@ void state_management(
&& (otg_info->state_transition_prob[src_instance][dst_instance][application]<=1))
&& (otg_info->c_holding_time_off[src_instance][dst_instance]>=g_otg->holding_time_off_pe[src_instance][dst_instance])) {
otg_info->state[src_instance][dst_instance][application]=PE_STATE;
LOG_I(OTG,"[%d][%d][Appli id %d][Agg Level=%d] NEW STATE:: OFF-->PE \n", src_instance, dst_instance,application, g_otg->aggregation_level[src_instance][dst_instance][application]);
LOG_I(OTG,"[%d][%d][Appli id %d][Agg Level=%u] NEW STATE:: OFF-->PE \n", src_instance, dst_instance,application, g_otg->aggregation_level[src_instance][dst_instance][application]);
otg_info->state_transition_prob[src_instance][dst_instance][application]=uniform_dist(0,1);
} else {
otg_info->c_holding_time_off[src_instance][dst_instance][application]= ctime - otg_info->start_holding_time_off[src_instance][dst_instance][application];
otg_info->state_transition_prob[src_instance][dst_instance][application]=uniform_dist(0,1);
LOG_D(OTG,"[%d][%d][Appli id %d][Agg Level=%d] STATE:: OFF\n", src_instance, dst_instance,application, g_otg->aggregation_level[src_instance][dst_instance][application]);
LOG_D(OTG,"[%d][%d][Appli id %d][Agg Level=%u] STATE:: OFF\n", src_instance, dst_instance,application, g_otg->aggregation_level[src_instance][dst_instance][application]);
}
break;
@@ -2033,20 +2033,20 @@ void state_management(
otg_info->state[src_instance][dst_instance][application]=OFF_STATE;
otg_info->start_holding_time_off[src_instance][dst_instance][application]=ctime;
otg_info->c_holding_time_off[src_instance][dst_instance][application]=0;
LOG_D(OTG,"[%d][%d][Appli id %d][Agg Level=%d] NEW STATE:: PU-->OFF \n", src_instance, dst_instance,application, g_otg->aggregation_level[src_instance][dst_instance][application]);
LOG_D(OTG,"[%d][%d][Appli id %d][Agg Level=%u] NEW STATE:: PU-->OFF \n", src_instance, dst_instance,application, g_otg->aggregation_level[src_instance][dst_instance][application]);
otg_info->state_transition_prob[src_instance][dst_instance][application]=uniform_dist(0,1);
} else if ((otg_info->state_transition_prob[src_instance][dst_instance][application]<=1-g_otg->prob_pu_pe[src_instance][dst_instance][application])
&& (otg_info->state_transition_prob[src_instance][dst_instance][application]>1-(g_otg->prob_pu_ed[src_instance][dst_instance][application]
+g_otg->prob_pu_pe[src_instance][dst_instance][application]))) {
//otg_info->state[src_instance][dst_instance]=ON_STATE;
otg_info->state[src_instance][dst_instance][application]=ED_STATE;
LOG_I(OTG,"[%d][%d][Appli id %d][Agg Level=%d] NEW STATE:: PU-->ED \n", src_instance, dst_instance,application, g_otg->aggregation_level[src_instance][dst_instance][application]);
LOG_I(OTG,"[%d][%d][Appli id %d][Agg Level=%u] NEW STATE:: PU-->ED \n", src_instance, dst_instance,application, g_otg->aggregation_level[src_instance][dst_instance][application]);
otg_info->state_transition_prob[src_instance][dst_instance][application]=uniform_dist(0,1);
} else { /*if (otg_info->state_transition_prob[src_instance][dst_instance]>=g_otg->prob_pu_ed)*/
//otg_info->state[src_instance][dst_instance]=ON_STATE;
otg_info->state[src_instance][dst_instance][application]=PE_STATE;
otg_info->start_holding_time_pe_off[src_instance][dst_instance][application]=ctime;
LOG_D(OTG,"[%d][%d][Appli id %d][Agg Level=%d] NEW STATE:: PU-->PE \n", src_instance, dst_instance,application, g_otg->aggregation_level[src_instance][dst_instance][application]);
LOG_D(OTG,"[%d][%d][Appli id %d][Agg Level=%u] NEW STATE:: PU-->PE \n", src_instance, dst_instance,application, g_otg->aggregation_level[src_instance][dst_instance][application]);
otg_info->state_transition_prob[src_instance][dst_instance][application]=uniform_dist(0,1);
}
@@ -2059,20 +2059,20 @@ void state_management(
otg_info->state[src_instance][dst_instance][application]=OFF_STATE;
otg_info->start_holding_time_off[src_instance][dst_instance][application]=ctime;
otg_info->c_holding_time_off[src_instance][dst_instance][application]=0;
LOG_D(OTG,"[%d][%d][Appli id %d][Agg Level=%d] NEW STATE:: ED-->OFF \n", src_instance, dst_instance,application, g_otg->aggregation_level[src_instance][dst_instance][application]);
LOG_D(OTG,"[%d][%d][Appli id %d][Agg Level=%u] NEW STATE:: ED-->OFF \n", src_instance, dst_instance,application, g_otg->aggregation_level[src_instance][dst_instance][application]);
otg_info->state_transition_prob[src_instance][dst_instance][application]=uniform_dist(0,1);
} else if ((otg_info->state_transition_prob[src_instance][dst_instance][application]>=1-(g_otg->prob_ed_pu[src_instance][dst_instance][application] +
g_otg->prob_ed_pe[src_instance][dst_instance][application] ))
&& (otg_info->state_transition_prob[src_instance][dst_instance][application]<1-g_otg->prob_ed_pe[src_instance][dst_instance][application])) {
//otg_info->state[src_instance][dst_instance]=ON_STATE;
otg_info->state[src_instance][dst_instance][application]=PE_STATE;
LOG_D(OTG,"[%d][%d][Appli id %d][Agg Level=%d] NEW STATE:: ED-->PU \n", src_instance, dst_instance,application, g_otg->aggregation_level[src_instance][dst_instance][application]);
LOG_D(OTG,"[%d][%d][Appli id %d][Agg Level=%u] NEW STATE:: ED-->PU \n", src_instance, dst_instance,application, g_otg->aggregation_level[src_instance][dst_instance][application]);
otg_info->state_transition_prob[src_instance][dst_instance][application]=uniform_dist(0,1);
} else { /*if ((otg_info->state_transition_prob[src_instance][dst_instance]>=1-g_otg->prob_ed_pe)&&(otg_info->state_transition_prob[src_instance][dst_instance]<=1)) */
//otg_info->state[src_instance][dst_instance]=ON_STATE;
otg_info->state[src_instance][dst_instance][application]=PE_STATE;
otg_info->start_holding_time_pe_off[src_instance][dst_instance][application]=ctime;
LOG_D(OTG,"[%d][%d][Appli id %d][Agg Level=%d] NEW STATE:: ED-->PE \n", src_instance, dst_instance,application, g_otg->aggregation_level[src_instance][dst_instance][application]);
LOG_D(OTG,"[%d][%d][Appli id %d][Agg Level=%u] NEW STATE:: ED-->PE \n", src_instance, dst_instance,application, g_otg->aggregation_level[src_instance][dst_instance][application]);
otg_info->state_transition_prob[src_instance][dst_instance][application]=uniform_dist(0,1);
}
@@ -2082,7 +2082,7 @@ void state_management(
if (g_otg->holding_time_pe_off[src_instance][dst_instance][application]<=otg_info->c_holding_time_pe_off[src_instance][dst_instance][application]) {
//otg_info->state[src_instance][dst_instance]=OFF_STATE;
otg_info->state[src_instance][dst_instance][application]=OFF_STATE;
LOG_D(OTG,"[%d][%d][Appli id %d][Agg Level=%d] NEW STATE:: PE->OFF\n", src_instance, dst_instance,application, g_otg->aggregation_level[src_instance][dst_instance][application]);
LOG_D(OTG,"[%d][%d][Appli id %d][Agg Level=%u] NEW STATE:: PE->OFF\n", src_instance, dst_instance,application, g_otg->aggregation_level[src_instance][dst_instance][application]);
otg_info->c_holding_time_pe_off[src_instance][dst_instance][application]=0;
otg_info->state_transition_prob[src_instance][dst_instance][application]=uniform_dist(0,1);
otg_info->start_holding_time_off[src_instance][dst_instance][application]=ctime;
@@ -2097,7 +2097,7 @@ void state_management(
break;
default:
LOG_W(OTG,"Unknown state(%d) \n", otg_info->state[src_instance][dst_instance][application]);
LOG_W(OTG,"Unknown state(%u) \n", otg_info->state[src_instance][dst_instance][application]);
otg_info->state[src_instance][dst_instance][application]= OFF_STATE; // switch to default state
break;
@@ -2145,13 +2145,13 @@ void voip_traffic(
if (ctime>otg_info->start_voip_silence[src_instance][dst_instance][application])
otg_info->c_holding_time_silence[src_instance][dst_instance][application]= ctime - otg_info->start_voip_silence[src_instance][dst_instance][application];
LOG_D(OTG,"[%d][%d][Appli id %d] VOIP STATE:: SILENCE %d (ctime=%d, start=%d)\n", src_instance, dst_instance,application,
LOG_D(OTG,"[%d][%d][Appli id %d] VOIP STATE:: SILENCE %u (ctime=%d, start=%u)\n", src_instance, dst_instance,application,
otg_info->c_holding_time_silence[src_instance][dst_instance][application], ctime, otg_info->start_voip_silence[src_instance][dst_instance][application]);
}
if (otg_info->c_holding_time_silence[src_instance][dst_instance][application]>=otg_info->silence_time[src_instance][dst_instance][application]) {
otg_info->voip_state[src_instance][dst_instance][application]=SIMPLE_TALK;
LOG_I(OTG,"[%d][%d][Appli id %d] NEW VOIP STATE :: SILENCE-->TALK %d (ctime=%d, start=%d )\n", src_instance, dst_instance,application ,
LOG_I(OTG,"[%d][%d][Appli id %d] NEW VOIP STATE :: SILENCE-->TALK %u (ctime=%d, start=%u )\n", src_instance, dst_instance,application ,
otg_info->c_holding_time_silence[src_instance][dst_instance][application], ctime, otg_info->start_voip_silence[src_instance][dst_instance][application]);
otg_info->start_voip_talk[src_instance][dst_instance][application]=ctime;
otg_info->c_holding_time_talk[src_instance][dst_instance][application]=0;
@@ -2160,7 +2160,7 @@ void voip_traffic(
if (ctime>otg_info->start_voip_silence[src_instance][dst_instance][application])
otg_info->c_holding_time_silence[src_instance][dst_instance][application]= ctime - otg_info->start_voip_silence[src_instance][dst_instance][application];
LOG_I(OTG,"[%d][%d][Appli id %d] STATE:: SILENCE [timer:%d] \n", src_instance, dst_instance,application, otg_info->c_holding_time_silence[src_instance][dst_instance][application]);
LOG_I(OTG,"[%d][%d][Appli id %d] STATE:: SILENCE [timer:%u] \n", src_instance, dst_instance,application, otg_info->c_holding_time_silence[src_instance][dst_instance][application]);
}
break;
@@ -2168,7 +2168,7 @@ void voip_traffic(
case SIMPLE_TALK:
if (otg_info->c_holding_time_talk[src_instance][dst_instance][application]>=otg_info->simple_talk_time[src_instance][dst_instance][application]) {
otg_info->voip_state[src_instance][dst_instance][application]=SILENCE;
LOG_I(OTG,"[%d][%d][Appli id %d] NEW VOIP STATE:: TALK-->SILENCE %d (ctime=%d, start=%d )\n", src_instance, dst_instance,application ,
LOG_I(OTG,"[%d][%d][Appli id %d] NEW VOIP STATE:: TALK-->SILENCE %u (ctime=%d, start=%u )\n", src_instance, dst_instance,application ,
otg_info->c_holding_time_talk[src_instance][dst_instance][application], ctime, otg_info->start_voip_talk[src_instance][dst_instance][application]);
otg_info->start_voip_silence[src_instance][dst_instance][application]=ctime;
otg_info->c_holding_time_silence[src_instance][dst_instance][application]=0;
@@ -2177,15 +2177,15 @@ void voip_traffic(
if (ctime>otg_info->start_voip_talk[src_instance][dst_instance][application])
otg_info->c_holding_time_talk[src_instance][dst_instance][application]= ctime - otg_info->start_voip_talk[src_instance][dst_instance][application];
LOG_I(OTG,"[%d][%d][Appli id %d] VOIP STATE:: TALK [timer:%d]\n", src_instance, dst_instance,application, otg_info->c_holding_time_talk[src_instance][dst_instance][application]);
LOG_I(OTG, "test_talk [ctime %d] [start talk %d] [%d] \n",ctime, otg_info->start_voip_talk[src_instance][dst_instance][application],
LOG_I(OTG,"[%d][%d][Appli id %d] VOIP STATE:: TALK [timer:%u]\n", src_instance, dst_instance,application, otg_info->c_holding_time_talk[src_instance][dst_instance][application]);
LOG_I(OTG, "test_talk [ctime %d] [start talk %u] [%u] \n",ctime, otg_info->start_voip_talk[src_instance][dst_instance][application],
otg_info->c_holding_time_talk[src_instance][dst_instance][application] );
}
break;
default:
LOG_W(OTG,"Unknown VOIP state(%d) \n", otg_info->voip_state[src_instance][dst_instance][application]);
LOG_W(OTG,"Unknown VOIP state(%u) \n", otg_info->voip_state[src_instance][dst_instance][application]);
otg_info->voip_state[src_instance][dst_instance][application]= SILENCE; // switch to default state
break;
+34 -112
View File
@@ -36,28 +36,28 @@
#ifdef WIN32 /* si vous êtes sous Windows */
#include <winsock2.h>
#include <winsock2.h>
#elif defined (linux) /* si vous êtes sous Linux */
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <unistd.h> /* close */
#include <netdb.h> /* gethostbyname */
#include <errno.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <unistd.h> /* close */
#include <netdb.h> /* gethostbyname */
#include <errno.h>
#define INVALID_SOCKET -1
#define SOCKET_ERROR -1
#define closesocket(s) close(s)
typedef int SOCKET;
typedef struct sockaddr_in SOCKADDR_IN;
typedef struct sockaddr SOCKADDR;
typedef struct in_addr IN_ADDR;
#define INVALID_SOCKET -1
#define SOCKET_ERROR -1
#define closesocket(s) close(s)
typedef int SOCKET;
typedef struct sockaddr_in SOCKADDR_IN;
typedef struct sockaddr SOCKADDR;
typedef struct in_addr IN_ADDR;
#else /* sinon vous êtes sur une plateforme non supportée */
#error not defined for this platform
#error not defined for this platform
#endif
@@ -67,11 +67,8 @@ control_hdr_t *control_hdr;
void socket_packet_send(int src, int dst, int state,int ctime)
{
void socket_packet_send(int src, int dst, int state,int ctime) {
init_control_header();
LOG_I(OTG,"SOCKET:: IP version %d, Transport Protocol %d \n", g_otg->ip_v[src], g_otg->trans_proto[src]);
if ((g_otg->ip_v[src]==1) && (g_otg->trans_proto[src]==2))
@@ -85,29 +82,20 @@ void socket_packet_send(int src, int dst, int state,int ctime)
if ((g_otg->ip_v[src]==2) && (g_otg->trans_proto[src]==1))
client_socket_udp_ip6(src, dst, state, ctime);
}
void client_socket_tcp_ip4(int src, int dst, int state, int ctime)
{
void client_socket_tcp_ip4(int src, int dst, int state, int ctime) {
#define PORT 7777
LOG_I(OTG,"SOCKET:: TCP-IP4 :: src= %d , dst= %d , state= %d \n", src, dst, state);
#if defined (WIN32)
WSADATA WSAData;
int erreur = WSAStartup(MAKEWORD(2,2), &WSAData);
#else
int erreur = 0;
#endif
SOCKET sock;
SOCKADDR_IN sin;
int sock_err;
@@ -118,94 +106,69 @@ void client_socket_tcp_ip4(int src, int dst, int state, int ctime)
if(!erreur) {
/* Create socket */
sock = socket(AF_INET, SOCK_STREAM, 0);
/* Configure the connection */
sin.sin_addr.s_addr = inet_addr(g_otg->dst_ip[src]);
sin.sin_family = AF_INET;
sin.sin_port = htons(PORT);
/* connection is ok */
printf("SOCKET:: TCP-IP4 :: \n");
if(connect(sock, (SOCKADDR*)&sin, sizeof(sin)) != SOCKET_ERROR) {
if(connect(sock, (SOCKADDR *)&sin, sizeof(sin)) != SOCKET_ERROR) {
LOG_I(OTG,"SOCKET:: TCP-IP4 :: Create socket %s with dst port %d\n", inet_ntoa(sin.sin_addr), htons(sin.sin_port));
ctime=0;
LOG_I(OTG,"SOCKET:: TCP-IP4 :: ctime=%d, duration=%d \n", ctime, g_otg->duration[src]);
init_control_header();
do {
//payload=NULL;
//payload=packet_gen_socket(src, dst, state, ctime);
//payload="CCCCC";
char *payload_rest;
payload_rest=packet_gen_socket(src, dst, state, ctime);
if (payload_rest!=NULL) {
payload_t *payload;
payload= malloc(sizeof(payload_t));
// Data serialization
char *tx_buffer;
tx_buffer= (char *)malloc(PAYLOAD_MAX);
payload->control_hdr=otg_info_hdr_gen(src, dst, TCP, IPV4);
payload->payload_rest=payload_rest;
memcpy(tx_buffer, payload->control_hdr, sizeof (control_hdr_t));
memcpy(tx_buffer+ sizeof (control_hdr_t), payload->payload_rest, strlen(payload_rest));
int total_size=sizeof(control_hdr_t) + strlen(payload_rest);
if((sock_err = send(sock, tx_buffer, total_size, 0)) != SOCKET_ERROR)
LOG_I(OTG,"SOCKET:: TCP-IP4 :: Payload to send size :: %d \n",sock_err);
else
LOG_I(OTG,"SOCKET:: TCP-IP4 :: Transmission Error\n");
free(payload);
free(tx_buffer);
}
ctime+=1;
} while (ctime<=g_otg->duration[src]) ;
}
/* connection is not possible..." */
else
LOG_I(OTG,"SOCKET:: TCP-IP4 :: connection is not possible to connect \n");
/* close the socket */
closesocket(sock);
}
}
void client_socket_udp_ip4(int src, int dst, int state,int ctime)
{
void client_socket_udp_ip4(int src, int dst, int state,int ctime) {
char *payload_rest;
signed int udp_send;
int sockfd, ok, addr_in_size;
u_short portnum = 12345;
struct sockaddr_in *to;
struct hostent *toinfo;
char *htoname = "127.0.0.1";
u_long toaddr;
LOG_I(OTG,"SOCKET:: UDP-IP4 :: src= %d , dst= %d , state= %d \n", src, dst, state);
to = (struct sockaddr_in *)malloc(sizeof(struct sockaddr_in));
@@ -226,7 +189,6 @@ void client_socket_udp_ip4(int src, int dst, int state,int ctime)
to->sin_port = portnum;
//
/*
@@ -238,8 +200,6 @@ void client_socket_udp_ip4(int src, int dst, int state,int ctime)
memset(control_hdr, 0, sizeof(control_hdr_t));
*/
//
if((sockfd = socket (PF_INET, SOCK_DGRAM, 0)) == -1) {
LOG_W(OTG,"SOCKET:: UDP-IP4 :: Error %d in socket: %s\n",errno,sys_errlist[errno]);
exit(errno);
@@ -249,21 +209,20 @@ void client_socket_udp_ip4(int src, int dst, int state,int ctime)
payload_rest=packet_gen_socket(src, dst, state, ctime);
if (payload_rest!=NULL) {
payload_t *payload;
payload= malloc(sizeof(payload_t));
// Data serialization
char *tx_buffer;
tx_buffer= (char *)malloc(PAYLOAD_MAX);
if (tx_buffer == NULL || payload == NULL) {
LOG_E(OTG,"Memory allocation failed\n");
return;
}
payload->control_hdr=otg_info_hdr_gen(src, dst, UDP, IPV4);
payload->payload_rest=payload_rest;
memcpy(tx_buffer, payload->control_hdr, sizeof (control_hdr_t));
memcpy(tx_buffer+ sizeof (control_hdr_t), payload->payload_rest, strlen(payload_rest));
int total_size=sizeof(control_hdr_t) + strlen(payload_rest);
udp_send=sendto(sockfd, tx_buffer,total_size ,0,(struct sockaddr *)to,addr_in_size);
LOG_I(OTG,"SOCKET:: UDP-IP4 :: Payload to send :: data sent:%d \n", udp_send);
// Update TX OTG info
@@ -271,69 +230,42 @@ void client_socket_udp_ip4(int src, int dst, int state,int ctime)
//otg_info->rx_num_bytes[src][dst]+= udp_send + (HDR_IP_v4 + HDR_UDP);
//
if (NULL != payload) {
payload=NULL;
free(payload);
}
if (NULL != tx_buffer) {
tx_buffer=NULL;
free(tx_buffer);
}
free(payload);
free(tx_buffer);
}
if(udp_send == -1) {
LOG_I(OTG,"SOCKET:: UDP-IP4 :: Transmission Error\n");
exit(errno);
}
else
} else
LOG_I(OTG,"SOCKET:: UDP-IP4 :: No data to transmit\n");
ctime+=1;
} while (ctime<=g_otg->duration[src]) ;
closesocket(sockfd);
}
void client_socket_tcp_ip6(int src, int dst, int state,int ctime)
{
void client_socket_tcp_ip6(int src, int dst, int state,int ctime) {
printf("client TCP IPv6\n");
}
void client_socket_udp_ip6(int src, int dst, int state,int ctime)
{
void client_socket_udp_ip6(int src, int dst, int state,int ctime) {
printf("client UDP IPv6\n");
}
char* packet_gen_socket(int src, int dst, int state, int ctime)
{
char *packet_gen_socket(int src, int dst, int state, int ctime) {
int size;
char *payload=NULL;
set_ctime(ctime);
LOG_I(OTG,"SOCKET :: num_nodes_tx:: %d , seed:: %d \n", g_otg->num_nodes, g_otg->seed);
LOG_I(OTG,"SOCKET :: NODE_INFO (Source= %d, Destination= %d,State= %d) ctime %d \n", src, dst, state, otg_info->ctime);
LOG_I(OTG,"SOCKET :: INFO_SIM (src=%d, dst=%d, state=%d) application=%d, idt dist =%d, pkts dist= %d\n", src, dst, state, g_otg->application_type[src][dst], g_otg->idt_dist[src][dst][state],
g_otg->size_dist[src][dst][state]);
LOG_I(OTG,"SOCKET :: Transmission info: idt=%d, simulation time=%d \n", otg_info->idt[src][dst], ctime);
// do not generate packet for this pair of src, dst : no app type and/or idt are defined
@@ -352,7 +284,6 @@ char* packet_gen_socket(int src, int dst, int state, int ctime)
//end pre-config
if ((otg_info->idt[src][dst]==(ctime-otg_info->ptime[src][dst][state])) || (otg_info->idt[src][dst]==0)) {
LOG_I(OTG,"SOCKET :: Time To Transmit (Source= %d, Destination= %d,State= %d) , (IDT= %d ,simu time= %d, previous packet time= %d) \n", src, dst, state ,otg_info->idt[src][dst], ctime,
otg_info->ptime[src][dst][state]);
otg_info->ptime[src][dst][state]=ctime;
@@ -362,8 +293,6 @@ char* packet_gen_socket(int src, int dst, int state, int ctime)
return 0; // do not generate the packet, and keep the idt
}
size=size_dist(src, dst, state);
LOG_I(OTG,"SOCKET :: Generate Packet for (Source= %d, Destination= %d,State= %d) , pkt size dist= %d, simu time= %d ,packet size=%d \n",
src, dst, state, g_otg->size_dist[src][dst][state], otg_info->ctime, size);
@@ -374,15 +303,12 @@ char* packet_gen_socket(int src, int dst, int state, int ctime)
size=(5* sizeof(int))+10;
payload=payload_pkts(size);
return(payload);
}
control_hdr_t *otg_info_hdr_gen(int src, int dst, int trans_proto, int ip_v)
{
control_hdr_t *otg_info_hdr_gen(int src, int dst, int trans_proto, int ip_v) {
control_hdr->src=src;
control_hdr->dst=dst;
control_hdr->trans_proto=trans_proto;
@@ -391,15 +317,11 @@ control_hdr_t *otg_info_hdr_gen(int src, int dst, int trans_proto, int ip_v)
LOG_I(OTG,"SOCKET :: control header src %d\n",control_hdr->dst);
LOG_I(OTG,"SOCKET :: control header src %d\n",control_hdr->trans_proto);
LOG_I(OTG,"SOCKET :: control header src %d\n",control_hdr->ip_v);
return control_hdr;
}
void init_control_header()
{
void init_control_header() {
//set otg header to 0
control_hdr = calloc(1, sizeof(control_hdr_t));
-175
View File
@@ -1,175 +0,0 @@
/*
* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under
* the OAI Public License, Version 1.1 (the "License"); you may not use this file
* except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.openairinterface.org/?page_id=698
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*-------------------------------------------------------------------------------
* For more information about the OpenAirInterface (OAI) Software Alliance:
* contact@openairinterface.org
*/
/***************************************************************************
umts_timer.c - description
-------------------
AUTHOR : Lionel GAUTHIER
COMPANY : EURECOM
EMAIL : Lionel.Gauthier@eurecom.fr
***************************************************************************/
//#include "rtos_header.h"
#include "platform_types.h"
#include "list.h"
#include "umts_timer_struct.h"
#include "mem_block.h"
#include "openair_defs.h"
//-----------------------------------------------------------------------------
void
umts_timer_check_time_out (list2_t * atimer_listP, uint32_t current_frame_tick_millisecondsP)
{
//-----------------------------------------------------------------------------
struct timer_unit *timer;
mem_block_t *mem_unit;
uint8_t time_out = 255;
mem_unit = atimer_listP->head;
// do it simple now.
while ((mem_unit) && (time_out)) {
timer = (struct timer_unit *) (mem_unit->data);
if ((current_frame_tick_millisecondsP - timer->frame_tick_start) >= timer->frame_time_out) {
mem_unit = list2_remove_head (atimer_listP);
(*(timer->proc)) (timer->protocol, timer->timer_id);
free_mem_block (mem_unit, __func__);
mem_unit = atimer_listP->head;
} else {
time_out = 0;
}
}
}
//-----------------------------------------------------------------------------
void
umts_timer_delete_timer (list2_t * atimer_listP, void *timer_idP)
{
//-----------------------------------------------------------------------------
mem_block_t *mem_unit;
mem_unit = atimer_listP->head;
while ((mem_unit)) {
if (((struct timer_unit *) (mem_unit->data))->timer_id == timer_idP) {
list2_remove_element (mem_unit, atimer_listP);
free_mem_block (mem_unit, __func__);
return;
}
mem_unit = mem_unit->next;
}
}
//-----------------------------------------------------------------------------
mem_block_t *
umts_add_timer_list_up (list2_t * atimer_listP, void (*procP) (void *, void *), void *protocolP, void *timer_idP, uint32_t frame_time_outP, uint32_t current_frame_tick_millisecondsP)
{
//-----------------------------------------------------------------------------
struct mem_block_t *mb;
struct timer_unit *timer;
mem_block_t *mem_unit;
int32_t remaining_time;
uint8_t inserted = 0;
mb = get_free_mem_block (sizeof (struct timer_unit), __func__);
if(mb==NULL) return NULL;
((struct timer_unit *) (mb->data))->proc = procP;
((struct timer_unit *) (mb->data))->protocol = protocolP;
((struct timer_unit *) (mb->data))->timer_id = timer_idP;
((struct timer_unit *) (mb->data))->frame_time_out = frame_time_outP;
((struct timer_unit *) (mb->data))->frame_tick_start = current_frame_tick_millisecondsP;
// insert the timer in list in ascending order
mem_unit = atimer_listP->head;
while ((mem_unit) && (!inserted)) {
timer = (struct timer_unit *) (mem_unit->data);
remaining_time = timer->frame_time_out - current_frame_tick_millisecondsP + timer->frame_tick_start;
// not timed out
if ((remaining_time > 0) && (frame_time_outP < remaining_time)) {
inserted = 255;
if (mem_unit == atimer_listP->head) {
#ifdef DEBUG_TIMER
msg ("[TIMER][CREATION] added timer_id %p at head time out %d current time %d proc %p \n", timer_idP, frame_time_outP, current_frame_tick_millisecondsP, *procP);
#endif
list2_add_head (mb, atimer_listP);
} else {
#ifdef DEBUG_TIMER
msg ("[TIMER][CREATION] inserted timer_id %p time out %d current time %d proc %p \n", timer_idP, frame_time_outP, current_frame_tick_millisecondsP, *procP);
#endif
mb->previous = mem_unit->previous;
mb->next = mem_unit;
mem_unit->previous->next = mb;
mem_unit->previous = mb;
}
} else {
mem_unit = mem_unit->next;
}
}
if (!inserted) {
#ifdef DEBUG_TIMER
msg ("[TIMER][CREATION] added timer_id %p at tail time out %d current time %d proc %p \n", timer_idP, frame_time_outP, current_frame_tick_millisecondsP, *procP);
#endif
list2_add_tail (mb, atimer_listP);
}
return mb;
}
//-----------------------------------------------------------------------------
void
umts_stop_all_timers (list2_t * atimer_listP)
{
//-----------------------------------------------------------------------------
list2_free (atimer_listP);
}
//-----------------------------------------------------------------------------
void
umts_stop_all_timers_except (list2_t * atimer_listP, void (*procP) (void *, void *))
{
//-----------------------------------------------------------------------------
struct timer_unit *timer;
mem_block_t *mem_unit;
mem_block_t *mem_unit_to_delete;
mem_unit = atimer_listP->head;
while ((mem_unit)) {
timer = (struct timer_unit *) (mem_unit->data);
if (timer->proc != procP) {
mem_unit_to_delete = mem_unit;
mem_unit = mem_unit->next;
list2_remove_element (mem_unit_to_delete, atimer_listP);
free_mem_block (mem_unit_to_delete, __func__);
} else {
mem_unit = mem_unit->next;
}
}
}
-56
View File
@@ -1,56 +0,0 @@
/*
* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under
* the OAI Public License, Version 1.1 (the "License"); you may not use this file
* except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.openairinterface.org/?page_id=698
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*-------------------------------------------------------------------------------
* For more information about the OpenAirInterface (OAI) Software Alliance:
* contact@openairinterface.org
*/
/***************************************************************************
umts_timer.h - description
-------------------
AUTHOR : Lionel GAUTHIER
COMPANY : EURECOM
EMAIL : Lionel.Gauthier@eurecom.fr
***************************************************************************/
#ifndef __UMTS_TIMER_H__
# define __UMTS_TIMER_H__
# include "platform_types.h"
# include "lists_proto_extern.h"
# include "mem_mngt_proto_extern.h"
# define UMTS_TIMER_NOT_STARTED 0x00
# define UMTS_TIMER_STARTED 0x01
# define UMTS_TIMER_TIMED_OUT 0x02
void umts_timer_check_time_out (list2_t * atimer_listP, uint32_t current_frame_tick_millisecondsP);
mem_block *umts_add_timer_list_up (list2_t * atimer_listP, void (*procP) (void *, void *), void *protocolP, void *timer_idP, uint32_t frame_time_outP, uint32_t current_frame_tick_millisecondsP);
struct timer_unit {
void (*proc) (void *, void *); // proc executed when time_out
void *protocol; // arg should be a pointer on a allocated protocol entity private struct including its variables
void *timer_id; // arg should be a value or a pointer identifying the timer
// Example: rlc_am_sdu_discard_time_out(rlc_am, sdu)
uint32_t frame_time_out;
uint32_t frame_tick_start;
};
#endif
@@ -1,44 +0,0 @@
/*
* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under
* the OAI Public License, Version 1.1 (the "License"); you may not use this file
* except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.openairinterface.org/?page_id=698
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*-------------------------------------------------------------------------------
* For more information about the OpenAirInterface (OAI) Software Alliance:
* contact@openairinterface.org
*/
/***************************************************************************
umts_timer_proto_extern.h - description
-------------------
AUTHOR : Lionel GAUTHIER
COMPANY : EURECOM
EMAIL : Lionel.Gauthier@eurecom.fr
***************************************************************************/
#ifndef __UMTS_TIMER_PROTO_EXTERN_H__
# define __UMTS_TIMER_PROTO_EXTERN_H__
# include "platform_types.h"
# include "list.h"
# include "mem_block.h"
extern void umts_timer_check_time_out (list2_t * atimer_listP, uint32_t current_frame_tick_millisecondsP);
extern void umts_timer_delete_timer (list2_t * atimer_listP, void *timer_idP);
extern mem_block_t *umts_add_timer_list_up (list2_t * atimer_listP, void (*procP) (void *, void *), void *protocolP, void *timer_idP, uint32_t frame_time_outP,
uint32_t current_frame_tick_millisecondsP);
extern void umts_stop_all_timers (list2_t * atimer_listP);
extern void umts_stop_all_timers_except (list2_t * atimer_listP, void (*procP) (void *, void *));
#endif
-46
View File
@@ -1,46 +0,0 @@
/*
* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under
* the OAI Public License, Version 1.1 (the "License"); you may not use this file
* except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.openairinterface.org/?page_id=698
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*-------------------------------------------------------------------------------
* For more information about the OpenAirInterface (OAI) Software Alliance:
* contact@openairinterface.org
*/
/***************************************************************************
umts_timer_struct.h - description
-------------------
AUTHOR : Lionel GAUTHIER
COMPANY : EURECOM
EMAIL : Lionel.Gauthier@eurecom.fr
***************************************************************************/
#ifndef __UMTS_TIMER_STRUCT_H__
# define __UMTS_TIMER_STRUCT_H__
# include "platform_types.h"
struct timer_unit {
void (*proc) (void *, void *); // proc executed when time_out
void *protocol; // arg should be a pointer on a allocated protocol entity private struct including its variables
void *timer_id; // arg should be a value or a pointer identifying the timer
// Example: rlc_am_sdu_discard_time_out(rlc_am, sdu)
uint32_t frame_time_out;
uint32_t frame_tick_start;
};
#endif