public void SendPendingAcks() { if (deliverConfirmModule.IsPendingAcksExist()) { Queue <AckRange> acks = deliverConfirmModule.PopPendingAckRanges(); var acksIter = acks.GetEnumerator(); while (acksIter.MoveNext()) { RUDPPayload acksPayload = new RUDPPayload(RUDPPayload.PAYLOAD_TAG.ACK); Packet acksPacket = new Packet(Packet.HEADER.RUDP); acksPacket.Push(acksIter.Current.StartNum); acksPacket.Push(acksIter.Current.AckCount); acksPayload.Packet = acksPacket; this.SendAck(acksPacket); //Debug.Log(string.Format("Ack 보냄 StartNum : {0}, Count : {1}", acksIter.Current.StartNum, acksIter.Current.AckCount)); } } }
public void ConfirmModuleTest() { RUDPDeliverConfirmModule confirmModule = new RUDPDeliverConfirmModule(); confirmModule.Reset(ushort.MaxValue - 3); // 시퀀스 번호 최대값에 근접시키기(오버플로우 테스트 위해) // 시퀀스 번호가 낮을때 False Return RUDPPayload payload1 = new RUDPPayload(RUDPPayload.PAYLOAD_TAG.DELIVERY_NOFIFY, ushort.MaxValue - 4); payload1.Packet = emptyPacket; bool result = confirmModule.JudgeIncomePayload(payload1); Assert.IsTrue(result == false); // 시퀀스 번호가 같을때 True Return RUDPPayload payload2 = new RUDPPayload(RUDPPayload.PAYLOAD_TAG.DELIVERY_NOFIFY, ushort.MaxValue - 3); payload2.Packet = emptyPacket; bool result2 = confirmModule.JudgeIncomePayload(payload2); Assert.IsTrue(result2 == true); //시퀀스 번호가 높을때 (위에 테스트때문에 현재 ConfirmModule의 다음예상시퀀스는 ushort.MaxValue-2 임 RUDPPayload payload3 = new RUDPPayload(RUDPPayload.PAYLOAD_TAG.DELIVERY_NOFIFY, ushort.MaxValue - 1); payload3.Packet = emptyPacket; bool result3 = confirmModule.JudgeIncomePayload(payload3); Assert.IsTrue(result3 == true); //시퀀스 번호 오버플로우 구간일때(true 리턴해야함) RUDPPayload payload4 = new RUDPPayload(RUDPPayload.PAYLOAD_TAG.DELIVERY_NOFIFY, 200); RUDPPayload payload5 = new RUDPPayload(RUDPPayload.PAYLOAD_TAG.DELIVERY_NOFIFY, 201); RUDPPayload payload6 = new RUDPPayload(RUDPPayload.PAYLOAD_TAG.DELIVERY_NOFIFY, 202); RUDPPayload payload7 = new RUDPPayload(RUDPPayload.PAYLOAD_TAG.DELIVERY_NOFIFY, 203); payload4.Packet = emptyPacket; payload5.Packet = emptyPacket; payload6.Packet = emptyPacket; payload7.Packet = emptyPacket; bool result4 = confirmModule.JudgeIncomePayload(payload4); Assert.IsTrue(result4 == true); // 밑에 AckRange검사용 confirmModule.JudgeIncomePayload(payload5); confirmModule.JudgeIncomePayload(payload6); confirmModule.JudgeIncomePayload(payload7); //AckRange 가 잘 나오는지 검사 Queue <AckRange> acks = confirmModule.PopPendingAckRanges(); AckRange ack1 = acks.Dequeue(); Assert.IsTrue(ack1.StartNum == (ushort.MaxValue - 3) && ack1.AckCount == 1); AckRange ack2 = acks.Dequeue(); Assert.IsTrue(ack2.StartNum == (ushort.MaxValue - 1) && ack2.AckCount == 1); AckRange ack3 = acks.Dequeue(); Assert.IsTrue(ack3.StartNum == 200 && ack3.AckCount == 4); }