import java.io.IOException;
import java.net.InetAddress;
import java.net.DatagramPacket;

public class MyNQTCPSender extends NQTCPSender {

	/////////////////////////////////////////////////////////////////////////////////////////////////
	//
	// Add your own instance variables here. This should include some container for unacked packets,
	// and a variable for sequence numbers.
	//


	public MyNQTCPSender(InetAddress ip) throws IOException{
		super(ip);

		///////////////////////////////////////////
		//
		// Initialize instance variables here
		//
		
	}

	/**
	 * sendPacket: send (some of) the data in the array as a packet.
	 * Create and send a packet with the data described by the parameters.
	 * @param data The data array.
	 * @param start The starting index of the data to be sent.
	 * @param length The number of bytes of data to be sent.
	 */
	@Override
	public synchronized void sendPacket(byte[] data, int start, int length) {
		System.err.println("Sending data: |" + new String(data).substring(start, start+length) + "|");

	}

	/**
	 * receivePacket: called when an acknowledgement is received.
	 * This method should acknowledge any appropriate packets.
	 * @param ack The Datagram packet received as an acknowledgement. 
	 */
	@Override
	public synchronized void receivePacket(DatagramPacket ack){
        System.err.println("ACK Received");
	}

	/**
	 * timeout: resend unacknowledged packets and restart the timer.
	 */
	@Override
	public synchronized void timeout(){
        System.err.println("Timer timed out.");
	}


}
