47pthread_mutex_t
mutex_udp = PTHREAD_MUTEX_INITIALIZER;
56 std::cout <<
"[" <<
getEpoch() <<
"]::" << NOW
57 <<
"::UWAPPLICATION::OPEN_CONNECTION_UDP::SOCKET_"
62 <<
"::UWAPPLICATION::OPEN_CONNECTION_UDP::SOCKET_CREATION_"
68 if (setsockopt(
servSockDescr, SOL_SOCKET, SO_REUSEADDR, &sockoptval,
sizeof(
int)) == -1) {
70 std::cout <<
"[" <<
getEpoch() <<
"]::" << NOW
71 <<
"UWAPPLICATION::ERROR::REUSABLE_FAIL"
76 std::cout <<
"[" <<
getEpoch() <<
"]::" << NOW
77 <<
"::UWAPPLICATION::OPEN_CONNECTION_UDP::SOCKET_CREATED"
82 servAddr.sin_addr.s_addr = htonl(INADDR_ANY);
87 std::cout <<
"[" <<
getEpoch() <<
"]::" << NOW
88 <<
"::UWAPPLICATION::OPEN_CONNECTION_UDP::BINDING_FAILED_"
89 << strerror(errno) << endl;
92 <<
"::UWAPPLICATION::OPEN_CONNECTION_UDP::BINDING_FAILED_"
93 << strerror(errno) << endl;
99 std::cout <<
"[" <<
getEpoch() <<
"]::" << NOW
100 <<
"::UWAPPLICATION::OPEN_CONNECTION_UDP::CANNOT_CREATE_"
119 socklen_t clnLen =
sizeof(sockaddr_in);
132 (
struct sockaddr *) &(obj->
clnAddr),
135 std::cout <<
"[" << obj->
getEpoch() <<
"]::" << NOW
136 <<
"::UWAPPLICATION::READ_PROCESS_UDP::CONNECTION_"
141 <<
"::UWAPPLICATION::READ_PROCESS_UDP::CONNECTION_"
146 std::cout <<
"[" << obj->
getEpoch() <<
"]::" << NOW
147 <<
"::UWAPPLICATION::READ_PROCESS_TCP::NEW_CLIENT_IP_"
148 << inet_ntoa(obj->
clnAddr.sin_addr) << std::endl;
151 <<
"::UWAPPLICATION::READ_PROCESS_UDP::NEW_CLIENT_IP_"
152 << inet_ntoa(obj->
clnAddr.sin_addr) << std::endl;
153 int status = pthread_mutex_lock(&
mutex_udp);
156 std::cout <<
"[" << obj->
getEpoch() <<
"]::" << NOW
157 <<
"::UWAPPLICATION::PTHREAD_MUTEX_LOCK_FAILED "
160 if (recvMsgSize > 0) {
161 Packet *p = Packet::alloc();
162 hdr_cmn *ch = HDR_CMN(p);
165 ch->size() = recvMsgSize;
167 std::cout <<
"[" << obj->
getEpoch() <<
"]::" << NOW
168 <<
"::UWAPPLICATION::READ_PROCESS_UDP::NEW_PACKET_"
174 <<
"::UWAPPLICATION::READ_PROCESS_UDP::NEW_"
177 std::cout <<
"[" << obj->
getEpoch() <<
"]::" << NOW
178 <<
"::UWAPPLICATION::READ_PROCESS_UDP::PAYLOAD_"
180 for (
int i = 0; i < recvMsgSize; i++) {
182 cout << buffer_msg[i];
188 status = pthread_mutex_unlock(&
mutex_udp);
191 std::cout <<
"[" << obj->
getEpoch() <<
"]::" << NOW
192 <<
"::UWAPPLICATION::PTHREAD_MUTEX_UNLOCK_FAILED "
205 hdr_cmn *ch = HDR_CMN(ptmp);
212 ch->direction_ = hdr_cmn::DOWN;
213 ch->timestamp() = Scheduler::instance().clock();
229 std::cout <<
"[" <<
getEpoch() <<
"]::" << NOW
230 <<
"::UWAPPLICATION::INIT_PACKET_UDP::UID_" << ch->uid_
233 std::cout <<
"[" <<
getEpoch() <<
"]::" << NOW
234 <<
"::UWAPPLICATION::INIT_PACKET_UDP::DEST_"
235 << (int) uwiph->
daddr() << endl;
237 std::cout <<
"[" <<
getEpoch() <<
"]::" << NOW
238 <<
"::UWAPPLICATION::INIT_PACKET_UDP::SIZE_"
241 std::cout <<
"[" <<
getEpoch() <<
"]::" << NOW
242 <<
"::UWAPPLICATION::INIT_PACKET_UDP::SN_"
243 << (int) uwApph->
sn_ << endl;
245 std::cout <<
"[" <<
getEpoch() <<
"]::" << NOW
246 <<
"::UWAPPLICATION::INIT_PACKET_UDP::SEND_DOWN_PACKET"
251 <<
"::UWAPPLICATION::INIT_PACKET_UDP::UID_" << ch->uid_
255 <<
"::UWAPPLICATION::INIT_PACKET_UDP::DEST_"
256 << (int) uwiph->
daddr() << endl;
259 <<
"::UWAPPLICATION::INIT_PACKET_UDP::SIZE_"
263 <<
"::UWAPPLICATION::INIT_PACKET_UDP::SN_"
264 << (int) uwApph->
sn_ << endl;
267 <<
"::UWAPPLICATION::INIT_PACKET_UDP::SEND_DOWN_PACKET"
uwSendTimerAppl chkTimerPeriod
Timer that schedule the period between two successive generation of DATA packets.
int servSockDescr
socket descriptor for server
int rftt
Forward trip time.
int debug_
Used for debug purposes 1 debug activated 0 debug not activated.
std::queue< Packet * > queuePckReadUDP
Queue that store the DATA packets recevied from the client by the server using a UDP protocol.
virtual int openConnectionUDP()
When socket communication is used, this method establish a connection between client and server.
virtual void init_Packet_UDP()
Set all the field of DATA packet and take from the specific queue the payload of DATA packet that wil...
virtual void incrPktsPushQueue()
Increase the number of DATA packets stored in the Server queue.
int uidcnt
Identifier counter that identify uniquely the DATA packet generated.
unsigned long int getEpoch()
Calculate the epoch of the event.
struct sockaddr_in servAddr
Server address.
std::ofstream out_log
Variable that handle the file in which the protocol write the statistics.
int port_num
Number of the port in which the server provide the service.
struct sockaddr_in clnAddr
Client address.
uint8_t dst_addr
IP destination address.
virtual double getPeriod()
return period generation time
int txsn
Transmission sequence number of DATA packet.
Content header of TRIGGER packet.
int rftt_
Forward Trip Time of the packet.
char payload_msg[MAX_LENGTH_PAYLOAD]
Message payload.
uint16_t sn_
Serial number of the packet.
bool rftt_valid_
Flag used to set the validity of the fft field.
uint16_t & payload_size()
uint8_t priority_
Priority flag: 1 means high priority, 0 normal priority.
hdr_uwip describes UWIP packets.
uint8_t & daddr()
Reference to the daddr_ variable.
static hdr_uwip * access(const Packet *p)
hdr_uwudp describes UWUDP packets.
static struct hdr_uwudp * access(const Packet *p)
uint8_t & dport()
Reference to the dport_ variable.
pthread_mutex_t mutex_udp
void * read_process_UDP(void *arg)
packet_t PT_DATA_APPLICATION
Trigger packet type for UFetch protocol.
void * read_process_UDP(void *arg)