Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Changes to support ASH window TX_K=5 #1445

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -83,15 +83,15 @@ public class AshFrameHandler implements EzspProtocolHandler {
/**
* Maximum number of DATA frames we can transmit without an ACK
*/
private final int TX_WINDOW = 1;
private final int TX_WINDOW = 5;

private long sentTime;

private static final int ASH_CANCEL_BYTE = 0x1A;
private static final int ASH_FLAG_BYTE = 0x7E;
private static final int ASH_SUBSTITUTE_BYTE = 0x18;
private static final int ASH_XON_BYTE = 0x11;
private static final int ASH_OFF_BYTE = 0x13;
private static final int ASH_XOFF_BYTE = 0x13;
private static final int ASH_TIMEOUT = -1;

private static final int ASH_MAX_LENGTH = 220;
Expand Down Expand Up @@ -218,7 +218,7 @@ private int[] getPacket() throws IOException {
case ASH_XON_BYTE:
// XON: Resume transmissionUsed in XON/XOFF flow control. Always ignored if received by the NCP.
break;
case ASH_OFF_BYTE:
case ASH_XOFF_BYTE:
// XOFF: Stop transmissionUsed in XON/XOFF flow control. Always ignored if received by the NCP.
break;
case ASH_TIMEOUT:
Expand Down Expand Up @@ -300,7 +300,7 @@ public void run() {

AshFrameData dataPacket = (AshFrameData) packet;

// Check for out of sequence frame number
// Check for correct sequence frame number
if (packet.getFrmNum() == ackNum) {
// Clear rejection condition
rejectionCondition = false;
Expand Down Expand Up @@ -555,19 +555,20 @@ private synchronized void sendFrame(AshFrame ashFrame) {

private void sendRetry() {
logger.debug("ASH: Retry Sent Queue Length {}", sentQueue.size());
AshFrameData ashFrame = sentQueue.peek();
if (ashFrame == null) {
if (sentQueue.isEmpty()) {
logger.debug("ASH: Retry nothing to resend!");
return;
}

ashFrame.setReTx();
outputFrame(ashFrame);
for (AshFrameData ashFrame : sentQueue) {
ashFrame.setReTx();
outputFrame(ashFrame);
}
}

// Synchronize this method to ensure a packet gets sent as a block
private synchronized void outputFrame(AshFrame ashFrame) {
ashFrame.setAckNum(ackNum);
ashFrame.setAckNum((ackNum + sentQueue.size() - 1) & 0x07);
logger.debug("--> TX ASH frame: {}", ashFrame);

// Send the data
Expand Down
Loading