Exemplo n.º 1
0
/*************************************************************
 * 处理从tunnel收到的数据包
 * - 功能:根据包的类型,处理相应的OtherTunnelId的数据包,是还没有到
 * 该数据包,还是需要重传顺便对需要确认的数据包进行确认释放
 ************************************************************/
func (utNack *UT_NACK) processRecvPacket(p *udppacket.Packet) {
	utNack.LOG.Println("processRecvPacket")
	status := p.GetPacketType()
	utNack.LOG.Println("tunnelId", p.TunnelId, "packetType", status)
	/***** SEND *****/
	if status&udppacket.PACK_ACK == udppacket.PACK_ACK {
		utNack.LOG.Println("ack")
		utNack.ackPackets(p.OtherTunnelId)
	}

	/***** RECV *****/
	wrapper, ok := utNack.RecvMap[p.TunnelId]
	if ok {
		wrapper.status = WRAPPER_STATUS_RECVED
	} else {
		wrapper = new(PACKET_WRAPPER)
		wrapper.status = WRAPPER_STATUS_RECVED
	}

	utNack.RecvMap[p.TunnelId] = wrapper
	if p.TunnelId > utNack.maxRecvId {
		utNack.maxRecvId = p.TunnelId
	}
}