49 : TclClass(
"Module/UW/PosBasedRt/ROV")
71 std::cout <<
" UwPosBasedRtROV::maxTxRange value not valid, value set "
72 <<
" by default to 3000 m" << std::endl;
85 Tcl &tcl = Tcl::instance();
88 if (strcasecmp(argv[1],
"setMaxTxRange") == 0) {
89 if (atof(argv[2]) <= 0) {
90 std::cerr <<
" UwPosBasedRtROV(IP=" <<(int)
ipAddr
91 <<
")::invalid value for max transmission range, "
92 <<
"use a value >= 0";
98 if (strcasecmp(argv[1],
"addr") == 0) {
99 ipAddr =
static_cast<uint8_t
>(atoi(argv[2]));
101 std::cerr <<
"UwPosBasedRtROV::0 is not a valid IP address"
107 if (strcasecmp(argv[1],
"setROVPosition") == 0) {
110 std::cout << NOW <<
" UwPosBasedRtROV(IP=" <<(int)
ipAddr
111 <<
")::ROV position, x: " <<
ROV_pos->
getX() <<
", y: "
115 }
else if (argc == 4) {
116 if (strcasecmp(argv[1],
"addPosition_IPotherNodes") == 0) {
118 Position *p =
dynamic_cast<Position*
> (tcl.lookup(argv[2]));
119 uint8_t ip =
static_cast<uint8_t
>(atoi(argv[3]));
121 std::cerr <<
"UwPosBasedRtROV::0 is not a valid IP address"
125 std::cout << NOW <<
" UwPosBasedRtROV(IP=" <<(int)
ipAddr
126 <<
")::add node position, x:" << p->getX() <<
" y: "<< p->getY()
127 <<
" z: " << p->getZ() <<
" with IP " << (int)ip << std::endl;
128 pair_posIP provv = std::pair<Position,uint8_t>(*p,ip);
134 return Module::command(argc, argv);
142 std::cout << NOW <<
" UwPosBasedRtROV(IP=" <<(int)
ipAddr
143 <<
")::node IP addres not set, drop packet" << std::endl;
147 hdr_cmn *ch = HDR_CMN(p);
150 if (ch->direction() == hdr_cmn::UP) {
158 if (ch->next_hop() == 0) {
159 std::cout << NOW <<
" UwPosBasedRtROV(IP=" <<(int)
ipAddr
160 <<
")::next hop not found, drop packet" << std::endl;
164 std::cout << NOW <<
" UwPosBasedRtROV(IP=" <<(int)
ipAddr
165 <<
")::next hop: " << (
int)ch->next_hop() << std::endl;
176 if (ch->next_hop() == 0) {
177 std::cout << NOW <<
" UwPosBasedRtROV(IP=" <<(int)
ipAddr
178 <<
")::next hop not found, drop packet" << std::endl;
182 std::cout << NOW <<
" UwPosBasedRtROV(IP=" <<(int)
ipAddr
183 <<
")::next hop: " << (
int)ch->next_hop() << std::endl;
193 std::cout << NOW <<
" UwPosBasedRtROV(IP=" <<(int)
ipAddr
194 <<
")::initPkt, init header fields" << std::endl;
205 pbrh->timestamp() = NOW;
210 std::cout << NOW <<
" UwPosBasedRtROV(IP=" <<(int)
ipAddr
211 <<
")::initPkt, init header fields" << std::endl;
212 std::cout << NOW <<
" UwPosBasedRtROV(IP=" <<(int)
ipAddr
213 <<
")::Inserted information"
214 <<
", x waypoint: " << pbrh->x_waypoint()
215 <<
" ,y waypoint: " << pbrh->y_waypoint()
216 <<
" ,z waypoint: " << pbrh->z_waypoint()
217 <<
" ,x ROV: " << pbrh->x_ROV()
218 <<
" ,y ROV: " << pbrh->y_ROV()
219 <<
" ,z ROV: " << pbrh->z_ROV()
220 <<
" ,timestamp: " << pbrh->timestamp()
221 <<
" ,ROV speed: " << pbrh->ROV_speed() << std::endl;
230 std::cout << NOW <<
" UwPosBasedRtROV(IP=" <<(int)
ipAddr
231 <<
")::List of position not setted" << std::endl;
234 double minDist = 10000000;
236 uint8_t ipCloserNode;
237 for (std::list<pair_posIP>::iterator it=
list_posIP.begin();
240 if (tempDist < minDist) {
242 ipCloserNode = it->second;
247 std::cout << NOW <<
" UwPosBasedRtROV(IP=" <<(int)
ipAddr
248 <<
")::findNextHop,the closest node in the tx range "
249 <<
"has IP equal to " << (
int)ipCloserNode << std::endl;
260 double x1 = p1.getX();
261 double y1 = p1.getY();
262 double z1 = p1.getZ();
263 double x2 = p2.getX();
264 double y2 = p2.getY();
265 double z2 = p2.getZ();
267 return sqrt(pow(x2-x1,2) + pow(y2-y1,2) + pow(z2-z1,2));
274 std::cout << NOW <<
" UwPosBasedRtROV(IP=" <<(int)
ipAddr
275 <<
")::value for max transmission range not valid" << std::endl;
280 std::cout << NOW <<
" UwPosBasedRtROV(IP=" <<(int)
ipAddr
281 <<
")::max transmission range set to " <<
maxTxRange << std::endl;
virtual double getY()
Method that return the current projection of the node on the y-axis.
virtual double getX()
Method that return the current projection of the node on the x-axis.
double getSpeed() const
Method that return the actual speed.
virtual double getZdest() const
Method that return the z cooridnate of the destination point.
virtual double getYdest() const
Method that return the y cooridnate of the destination point.
virtual double getZ()
Method that return the current projection of the node on the z-axis.
virtual double getXdest() const
Method that return the x cooridnate of the destination point.
UwPosBasedRtROVModuleClass()
TclObject * create(int, const char *const *)
virtual void initPkt(Packet *p)
Initialize field of hdr_uwpos_based_rt
double maxTxRange
Maximum transmission range, in meters, for this node.
std::pair< Position, uint8_t > pair_posIP
UWSMPosition * ROV_pos
Pointer to ROV position.
virtual uint8_t findNextHop(const Packet *p)
Find next hop of a packet passed as input.
virtual double nodesDistance(Position &p1, Position &p2)
Compute absoulute distance between 2 nodes.
virtual int command(int, const char *const *)
TCL command interpreter.
virtual void setMaxTxRange(double newRange)
Set maximum transmission range.
int debug_
Flag to enable or disable dirrefent levels of debug.
virtual ~UwPosBasedRtROV()
Destructor of UwPosBasedRtROV class.
UwPosBasedRtROV()
Constructor of UwPosBasedRtROV class.
std::list< pair_posIP > list_posIP
List with position of all the other nodes with its IP.
virtual void recv(Packet *p)
Performs the reception of packets from upper and lower layers.
hdr_uwip describes UWIP packets.
uint8_t & daddr()
Reference to the daddr_ variable.
hdr_uwpos_based_rt describes packets used by UWPOSBASEDRT.
#define HDR_UWPOS_BASED_RT(p)
packet_t PT_UWPOSITIONBASEDROUTING
UwPosBasedRtROVModuleClass class_module_uwposbasedrt_rov
Routing protocol for vehicles based on ROV position.
#define DROP_NEXT_HOP_NOT_FOUND