new set of cppcheck fixes

This commit is contained in:
frtabu
2019-02-12 10:12:07 +01:00
parent 63143b87a7
commit 824d2b478a
58 changed files with 13452 additions and 15300 deletions
+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;
+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 -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;
}
+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) {
+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;
}
+8 -62
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,15 +161,11 @@ 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);
fl_set_object_label(form_ul->loss_ratio, loss_rate);
@@ -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);
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;
@@ -291,10 +250,8 @@ void plot_graphes_dl(int src, int dst, int ctime) //eNB -->UE
otg_kpi_nb_loss_pkts();
sprintf(loss_rate, "%s%d","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,7 +263,6 @@ 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);
fl_set_object_label(form_dl->loss_ratio, loss_rate);
@@ -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);
}
+43 -108
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;
+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;
}
+29 -104
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,16 @@ 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);
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
@@ -277,63 +232,43 @@ void client_socket_udp_ip4(int src, int dst, int state,int ctime)
}
if (NULL != tx_buffer) {
tx_buffer=NULL;
free(tx_buffer);
tx_buffer=NULL;
}
}
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 +287,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 +296,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 +306,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 +320,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));