/*---------------------------------------------------------------------------* Project: Horizon File: rdt_ResendQueue.h Copyright (C)2009-2012 Nintendo Co., Ltd. All rights reserved. These coded instructions, statements, and computer programs contain proprietary information of Nintendo of America Inc. and/or Nintendo Company Ltd., and are protected by Federal copyright law. They may not be disclosed to third parties or copied or duplicated in any form, in whole or in part, without the prior written consent of Nintendo. $Rev: 46347 $ *---------------------------------------------------------------------------*/ #include "stdafx.h" #ifndef NN_LIBRARIES_RDT_CTR_RDT_RESEND_QUEUE_H_ #define NN_LIBRARIES_RDT_CTR_RDT_RESEND_QUEUE_H_ #include "rdt_Deque.h" #include "rdt_Segment.h" #include "rdt_Utility.h" namespace nn { namespace rdt { namespace CTR { /* Please see man pages for details */ class ResendQueue{ public: /* Please see man pages for details */ ResendQueue(void); /* Please see man pages for details */ ~ResendQueue(void); /* Please see man pages for details */ bool Push(const Segment &seg); /* Please see man pages for details */ bool Front(Segment *pSeg) const; /* Please see man pages for details */ void Remove(u32 ack); /* Please see man pages for details */ void SetDefaultTimeout(MSEC_T msec) { m_defaultTimeout = msec; } /* Please see man pages for details */ bool IsResendRequired(void) const; /* Please see man pages for details */ u32 GetTotalDataSize(void) const; /* Please see man pages for details */ void Clear(void); /* Please see man pages for details */ void TryAgain(void); /* Please see man pages for details */ bool IsResendMode(void) const; /* Please see man pages for details */ bool IsFull(void) const { return m_queue.IsFull(); } /* Please see man pages for details */ void PrintDebugInfo(void) const; /* Please see man pages for details */ static void Test(void); private: /* Please see man pages for details */ ResendQueue (const ResendQueue&); /* Please see man pages for details */ ResendQueue& operator=(const ResendQueue&); // If the queue capacity is not larger than the window size notified from the receiving side, then the queue may be filled. // // If the RDT payload is 1400 bytes, then this is 16 * 1400 = 22400 bytes, and if the receive buffer (window size) on the receiving side is set to be larger than this, the sending side queue may become blocked. // // static const size_t DEPTH = 16; // TODO: Parameters must be adjusted for each platform. There is a major influence on the throughput. // Before, this value was 500. Then, it took 35 seconds to send and receive 256 KB of data. // static const MSEC_T DEFAULT_TIMEOUT = 100; static const MSEC_T DEFAULT_TIMEOUT = 50; // 150 to 180KB // Timeout value for segments containing SYN. // Preparations to work around the bug that causes the connection to be in a half-open state when resend is at a fast pace similar to data segments. // static const MSEC_T SYN_SEGMENT_TIMEOUT = 200; bool checkTimeStamp(void) const; struct SegmentWithTime { SegmentWithTime(void) : timeStamp(0), timeOut(0), resendMark(false) {} bool IsTimeOut(void) const { return (timeStamp + timeOut < GetCurrentTimeAsMillisecond()); } Segment segment; MSEC_T timeStamp; // Time of the send MSEC_T timeOut; // If the time specified here is exceeded, this becomes a resend target. bool resendMark; // Marking is done on elements in the instant of entering resend mode. u8 padding[7]; // Padding }; MSEC_T m_defaultTimeout; // Timeout (in milliseconds) Deque m_queue; // Resend queue bool m_bResendMode; // Resend mode flag u8 m_padding[7]; }; }}} // namespace nn::rdt::CTR #endif // end of NN_LIBRARIES_RDT_CTR_RDT_RESEND_QUEUE_H_