-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathaodvugd_nodes_pings_task.cpp
136 lines (116 loc) · 4.18 KB
/
aodvugd_nodes_pings_task.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
/************************************************************************
** This file is part of the network simulator Shawn. **
** Copyright (C) 2004-2007 by the SwarmNet (www.swarmnet.de) project **
** Shawn is free software; you can redistribute it and/or modify it **
** under the terms of the BSD License. Refer to the shawn-licence.txt **
** file in the root of the Shawn source tree for further details. **
************************************************************************/
#include "_legacyapps_enable_cmake.h"
#include "legacyapps/aodvugd/aodvugd_nodes_pings_task.h"
#ifdef ENABLE_AODVUGD
#include "sys/world.h"
#include "legacyapps/aodvugd/aodvugd_ping_app.h"
namespace aodvugd
{
NodesPingsTask::
NodesPingsTask()
{}
// ----------------------------------------------------------------------
NodesPingsTask::
~NodesPingsTask()
{}
// ----------------------------------------------------------------------
std::string
NodesPingsTask::
name( void )
const throw()
{
return "nodes_pings";
}
// ----------------------------------------------------------------------
std::string
NodesPingsTask::
description( void )
const throw()
{
return "Shawn AODV task: los nodos realizan pings entre ellos";
}
// ----------------------------------------------------------------------
void
NodesPingsTask::
run( shawn::SimulationController& sc )
throw( std::runtime_error )
{
require_world( sc );
std::cout<< "--------------------------Tiempo:" <<
sc.world().simulation_round()
<<std::endl;
shawn::Node* nodoSender;
const shawn::Node* nodoDestino;
nodoSender = sc.world_w().find_node_by_id_w ( 0 );
nodoDestino = sc.world().find_node_by_id ( 316 ); //8
std::string direccionDestino = nodoDestino->label();
//si o si hay que inicializar ahora los nodos.. asi mueve de la lista
//new_processors a processors
//nodoSender->init();
PingApp *pPingApp = nodoSender->get_processor_of_type_w <PingApp> ();
assert ( pPingApp != NULL );
double tiempoInicioPing = 6.00;
pPingApp-> programarPrimerPing ( direccionDestino , 1 /*maxPings*/ ,
true /*pingInfinito*/ , 50 /*timeoutPing*/ ,
64 /*ttl*/ , 116 ,
tiempoInicioPing ) ;
/* for( shawn::World::const_node_iterator
it = sc.world().begin_nodes();
it != sc.world().end_nodes();
++it )
{
count++;
}
INFO( logger(), "visited " << count << " nodes" );*/
}
//----------------------------------------------------------------------
//----------------------------------------------------------------------
//----------------------------------------------------------------------
NodesChangeNameTask::
NodesChangeNameTask()
{}
// ----------------------------------------------------------------------
NodesChangeNameTask::
~NodesChangeNameTask()
{}
// ----------------------------------------------------------------------
std::string
NodesChangeNameTask::
name( void )
const throw()
{
return "nodes_change_name";
}
// ----------------------------------------------------------------------
std::string
NodesChangeNameTask::
description( void )
const throw()
{
return "Shawn AODV task: se cambian los nombre de los nodos";
}
// ----------------------------------------------------------------------
void
NodesChangeNameTask::
run( shawn::SimulationController& sc )
throw( std::runtime_error )
{
require_world( sc );
for(shawn::World::node_iterator it = sc.world_w().begin_nodes_w(),
endit = sc.world_w().end_nodes_w();
it != endit ; ++it )
{
//cambiamos el label para que sean solo numeros
std::ostringstream nodoId;
nodoId<<"Nodo-"<< it->id();
it->set_label ( nodoId.str() );
}
}
}
#endif