void FastTcpAgent::timeout(int tno) { if (tno == TCP_TIMER_RTX) { /* * IF DSACK and dynamic adjustment of numdupacks_, * check whether a smaller value of numdupacks_ * would have prevented this retransmit timeout. * If DSACK and detection of premature retransmit * timeouts, then save some info here. */ dupacks_ = 0; fastrecov_ = FALSE; timeout_ = TRUE; if (highest_ack_ > last_ack_) last_ack_ = highest_ack_; recover_ = maxseq_; scb_->ClearScoreBoard(); if (highest_ack_ == maxseq_ && !slow_start_restart_) { /* * TCP option: * If no outstanding data, then don't do anything. * * Note: in the USC implementation, * slow_start_restart_ == 0. * I don't know what the U. Arizona implementation * defaults to. */ return; }; last_cwnd_action_ = CWND_ACTION_TIMEOUT; reset_rtx_timer(0, 0); ++nrexmit_; slowdown(CLOSE_CWND_RESTART|CLOSE_SSTHRESH_HALF); cwnd_ = double(slowstart_); newcwnd_ = 0; send_much(0, TCP_REASON_TIMEOUT, maxburst_); } else { /* delayed-sent timer, with random overhead to avoid * phase effect. */ send_much(1, TCP_REASON_TIMEOUT, 3); } }
void FastTcpAgent::dupack_action() { int recovered = (highest_ack_ > recover_); if (recovered || (!bug_fix_ && !ecn_)) { goto sack_action; } if (ecn_ && last_cwnd_action_ == CWND_ACTION_ECN) { last_cwnd_action_ = CWND_ACTION_DUPACK; /* * What if there is a DUPACK action followed closely by ECN * followed closely by a DUPACK action? * The optimal thing to do would be to remember all * congestion actions from the most recent window * of data. Otherwise "bugfix" might not prevent * all unnecessary Fast Retransmits. */ reset_rtx_timer(1,0); /* * There are three possibilities: * (1) pipe_ = int(cwnd_) - numdupacks_; * (2) pipe_ = window() - numdupacks_; * (3) pipe_ = maxseq_ - highest_ack_ - numdupacks_; * equation (2) takes into account the receiver's * advertised window, and equation (3) takes into * account a data-limited sender. */ if (singledup_ && LimTransmitFix_) { pipe_ = maxseq_ - highest_ack_ - 1; } else { // numdupacks(cwnd_) packets have left the pipe pipe_ = maxseq_ - highest_ack_ - numdupacks(cwnd_); } fastrecov_ = TRUE; scb_->MarkRetran(highest_ack_+1); output(last_ack_ + 1, TCP_REASON_DUPACK); return; } if (bug_fix_) { /* * The line below, for "bug_fix_" true, avoids * problems with multiple fast retransmits in one * window of data. */ return; } sack_action: // we are now going into fast_recovery and will trace that event trace_event("FAST_RECOVERY"); recover_ = maxseq_; last_cwnd_action_ = CWND_ACTION_DUPACK; if (oldCode_) { pipe_ = int(cwnd_) - numdupacks(cwnd_); } else if (singledup_ && LimTransmitFix_) { pipe_ = maxseq_ - highest_ack_ - 1; } else { // numdupacks(cwnd_) packets have left the pipe pipe_ = maxseq_ - highest_ack_ - numdupacks(cwnd_); } slowdown(CLOSE_SSTHRESH_HALF|CLOSE_CWND_HALF); reset_rtx_timer(1,0); fastrecov_ = TRUE; scb_->MarkRetran(highest_ack_+1); output(last_ack_ + 1, TCP_REASON_DUPACK); // from top /* * If dynamically adjusting numdupacks_, record information * at this point. */ return; }
void main(){ //init pattern { asm("lda #$00"); //*(char*)(0x2006)=0; asm("sta $2006"); //*(char*)(0x2006)=0; asm("sta $2006"); //for(i=0;i<255;i++) asm("ldx #$00"); for1: //*(char*)(0x2007)=img1[i]; asm("lda %v,X",img1); asm("sta $2007"); asm("inx"); asm("cpx #$FF"); asm("bne %g",for1); //*(char*)(0x2007)=img1[255]; asm("lda %v,X",img1); asm("sta $2007"); //for(i=0;i<255;i++) asm("ldx #$00"); for2: //*(char*)(0x2007)=img2[i]; asm("lda %v,X",img2); asm("sta $2007"); asm("inx"); asm("cpx #$FF"); asm("bne %g",for2); //*(char*)(0x2007)=img1[255]; asm("lda %v,X",img2); asm("sta $2007"); } //clear SP { //*(char*)(0x2003)=0; //i<<2 asm("lda #$00"); asm("sta $2003"); //for(i=255;i>0;i--) asm("ldx #$FF"); for3: //*(char*)(0x2004)=0; asm("sta $2004"); asm("dex"); asm("bne %g",for3); //*(char*)(0x2004)=0; asm("sta $2004"); } //set background black { //*(char*)(0x2006)=0x20; asm("lda #$20");asm("sta $2006"); //*(char*)(0x2006)=0x20; asm("sta $2006"); //for(i=0;i<255;i++) asm("lda #$10"); asm("ldx #$FF"); for4: //*(char*)(0x2007)=0x10; asm("sta $2007"); asm("dex"); asm("bne %g",for4); //*(char*)(0x2007)=0x10; asm("sta $2007"); //for(i=0;i<255;i++) asm("ldx #$FF"); for5: //*(char*)(0x2007)=0x10; asm("sta $2007"); asm("dex"); asm("bne %g",for5); //*(char*)(0x2007)=0x10; asm("sta $2007"); //for(i=0;i<255;i++) asm("ldx #$FF"); for6: //*(char*)(0x2007)=0x10; asm("sta $2007"); asm("dex"); asm("bne %g",for6); //*(char*)(0x2007)=0x10; asm("sta $2007"); //for(i=0;i<128;i++) asm("ldx #$80"); for7: //*(char*)(0x2007)=0x10; asm("sta $2007"); asm("dex"); asm("bne %g",for7); } //set color { //*(char*)(0x2006)=0x3F; asm("lda #$3F");asm("sta $2006"); //*(char*)(0x2006)=0x00; asm("ldx #$00");asm("stx $2006"); //*(char*)(0x2007)=0x2C; asm("ldx #$2C");asm("stx $2007"); //*(char*)(0x2007)=0x30; asm("ldx #$30");asm("stx $2007"); //*(char*)(0x2007)=0x00; asm("ldx #$00");asm("stx $2007"); //*(char*)(0x2007)=0x3F; asm("sta $2007"); //*(char*)(0x2006)=0x3F; asm("sta $2006"); //*(char*)(0x2006)=0x11; asm("ldx #$11");asm("stx $2006"); //*(char*)(0x2007)=0x30; asm("ldx #$30");asm("stx $2007"); //*(char*)(0x2007)=0x22; asm("ldx #$22");asm("stx $2007"); //*(char*)(0x2007)=0x3F; asm("sta $2007"); } //show init title { //*(char*)(0x2006)=0x20; asm("lda #$20");asm("sta $2006"); //*(char*)(0x2006)=0xC5; asm("lda #$C5");asm("sta $2006"); //*(char*)(0x2007)=0x11; asm("ldx #$11");asm("stx $2007"); //*(char*)(0x2007)=0x12; asm("inx");asm("stx $2007"); //*(char*)(0x2007)=0x13; asm("inx");asm("stx $2007"); //*(char*)(0x2007)=0x14; asm("inx");asm("stx $2007"); //*(char*)(0x2007)=0x10; asm("lda #$10");asm("sta $2007"); //*(char*)(0x2007)=0x15; asm("inx");asm("stx $2007"); //*(char*)(0x2007)=0x10; asm("sta $2007"); //*(char*)(0x2007)=0x16; asm("inx");asm("stx $2007"); //*(char*)(0x2007)=0x17; asm("inx");asm("stx $2007"); //*(char*)(0x2007)=0x18; asm("inx");asm("stx $2007"); //*(char*)(0x2005) = 0; asm("stx $2005"); //*(char*)(0x2005) = 0; asm("stx $2005"); } //init ppu { //*(char*)(0x2000) = 0x80; //10 00 00 00 asm("lda #$80");asm("sta $2000"); //*(char*)(0x2001) = 0x18; //00 01 10 00 asm("lda #$18");asm("sta $2001"); //*(char*)(0x2005) = 0; asm("lda #$00");asm("sta $2005"); //*(char*)(0x2005) = 0; asm("sta $2005"); } //wait for key pressed (randomize) while1: rnd(); readJoystick(); asm("lda %b",key1); //if(key1)break; asm("bne %g",endwhile1); asm("jmp %g",while1); endwhile1: Clear(); //clear 4*4 nextShape { waitvblank(); asm("ldx #$00"); //*(char*)(0x2006)=0x20; asm("lda #$20");asm("sta $2006"); //*(char*)(0x2006)=0xAE; asm("lda #$AE");asm("sta $2006"); //*(char*)(0x2007)=0; asm("stx $2007"); //*(char*)(0x2007)=0; asm("stx $2007"); //*(char*)(0x2007)=0; asm("stx $2007"); //*(char*)(0x2007)=0; asm("stx $2007"); //*(char*)(0x2006)=0x20; asm("lda #$20");asm("sta $2006"); //*(char*)(0x2006)=0xCE; asm("lda #$CE");asm("sta $2006"); //*(char*)(0x2007)=0; asm("stx $2007"); //*(char*)(0x2007)=0; asm("stx $2007"); //*(char*)(0x2007)=0; asm("stx $2007"); //*(char*)(0x2007)=0; asm("stx $2007"); //*(char*)(0x2006)=0x20; asm("lda #$20");asm("sta $2006"); //*(char*)(0x2006)=0xEE; asm("lda #$EE");asm("sta $2006"); //*(char*)(0x2007)=0; asm("stx $2007"); //*(char*)(0x2007)=0; asm("stx $2007"); //*(char*)(0x2007)=0; asm("stx $2007"); //*(char*)(0x2007)=0; asm("stx $2007"); //*(char*)(0x2006)=0x21; asm("lda #$21");asm("sta $2006"); //*(char*)(0x2006)=0x0E; asm("lda #$0E");asm("sta $2006"); //*(char*)(0x2007)=0; asm("stx $2007"); //*(char*)(0x2007)=0; asm("stx $2007"); //*(char*)(0x2007)=0; asm("stx $2007"); //*(char*)(0x2007)=0; asm("stx $2007"); //*(char*)(0x2005) = 0; asm("stx $2005"); //*(char*)(0x2005) = 0; asm("stx $2005"); } NextShape(); NextShape(); //main cycle { //main_cnt = 50; asm("lda #$32"); asm("sta %b",main_cnt); while2: rnd(); waitvblank(); //one second count //if(main_cnt--==0) asm("dec %b",main_cnt); asm("bne %g",else1); //main_cnt=50; asm("lda #$32"); asm("sta %b",main_cnt); slowdown(); else1: readJoystick(); //key2 = key1 ^ lastkey; asm("lda %b",key1); asm("eor %b",lastkey); //key2 = key2 & key1; asm("and %b",key1); //if(key2!=0) asm("beq %g",else2); asm("sta %b",key2); //if(key2&0x01){movelr_n=1;movelr();}//button_RIGHT asm("and #$01"); asm("beq %g",elseKey1); asm("lda #$01"); asm("sta %b",movelr_n); movelr(); elseKey1: //if(key2&0x02){movelr_n=-1;movelr();}//button_LEFT asm("lda %b",key2); asm("and #$02"); asm("beq %g",elseKey2); asm("lda #$FF"); asm("sta %b",movelr_n); movelr(); elseKey2: //if(key2&0x04)down();//button_DOWN asm("lda %b",key2); asm("and #$04"); asm("beq %g",elseKey3); down(); elseKey3: //if(key2&0x08)slowdown();//button_UP asm("lda %b",key2); asm("and #$08"); asm("beq %g",elseKey4); slowdown(); elseKey4: //if(key2&0x10);//button_START //if(key2&0x20);//button_SELECT //if(key2&0x40){rotate_n=-1;rotate();}//button_B asm("lda %b",key2); asm("and #$40"); asm("beq %g",elseKey5); asm("lda #$FF"); asm("sta %b",rotate_n); rotate(); elseKey5: //if(key2&0x80){rotate_n=1;rotate();}//button_A asm("lda %b",key2); asm("and #$80"); asm("beq %g",elseKey6); asm("lda #$01"); asm("sta %b",rotate_n); rotate(); elseKey6: else2: //lastkey = key1; asm("lda %b",key1); asm("sta %b",lastkey); asm("jmp %g",while2); } }