bool WiimotePipeServerWrapper::sendWiimoteData(WiimoteData *wiimoteData1,WiimoteData *wiimoteData2,int sequenceNumber,DWORD current_time) { if(m_CommandPipeServer->isWiimoteLoggingOn()) { //If is false it indicates that logging was currently off. In that scenario when m_CommandPipeServer->isWiimoteLoggingOn() changes to true //it indicates logging request just came in. So need to initialize //For this case return right away and do not send packet as this packet is not initialized by the client. //The clietnt did not know before sending this message that recording was restarted if(!m_WiimoteLoggingOn) { startLogging(wiimoteData1,wiimoteData2); return true; } else sendDataPacket(wiimoteData1,wiimoteData2,sequenceNumber,current_time,false); } else { if(m_WiimoteLoggingOn) { stopLogging(); return WIIMOTE_LOGGING_STOPPED; } } logWiimoteData(wiimoteData1,wiimoteData2,sequenceNumber,current_time); return false; }
void WiimotePipeServerWrapper::stopLogging() { m_WiimoteLoggingOn = false; sendDataPacket(NULL,NULL,NULL,NULL,true); closeLoggingFile(); }
/****************************************************************************** * retransmit * * Operation: * To perform retransmition of missing packet * * Input: * cwnd->size and cwnd->ssthresh * * Return: * no return ******************************************************************************/ void retransmit(TCPSession *session, Packet *packet){ uint32_t newFlightSize; sessionCWND->flightSize = session->offset - sessionCWND->offset; newFlightSize = roundOffValue(sessionCWND->flightSize); sessionCWND->ssthresh = max(newFlightSize/2, 2*SMSS); sessionCWND->lostPacket = sessionCWND->lostPacket+SMSS; sendDataPacket(packet,&sessionState->ptrBlock,sessionCWND->lostPacket); sessionCWND->size = sessionCWND->ssthresh + 3*SMSS; sessionCWND->recover = sessionCWND->size+sessionCWND->offset; }
/****************************************************************************** * send Packet * * Operation: * To perform send Packet * * Input: * TCPSession,Packet and availableSize * * Return: * no return ******************************************************************************/ void sendPacket(TCPSession *session, Packet *packet, uint32_t availableSize){ availableSize = session->offset + availableSize; sendDataPacket(packet,&sessionState->ptrBlock,availableSize); session->offset = session->offset + SMSS; }