Skip to content

Commit

Permalink
Changes to support ASH window TX_K=5
Browse files Browse the repository at this point in the history
Signed-off-by: Chris Jackson <[email protected]>
  • Loading branch information
cdjackson committed Nov 10, 2024
1 parent e6bc2ea commit f4952d2
Showing 1 changed file with 10 additions and 9 deletions.
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

0 comments on commit f4952d2

Please sign in to comment.