User Manual, Developers Guide and API Documentation

BaseState.cpp

Go to the documentation of this file.
00001 /******************************************************************************
00002  * WNS (Wireless Network Simulator)                                           *
00003  * __________________________________________________________________________ *
00004  *                                                                            *
00005  * Copyright (C) 2004-2006                                                    *
00006  * Chair of Communication Networks (ComNets)                                  *
00007  * Kopernikusstr. 16, D-52074 Aachen, Germany                                 *
00008  * phone: ++49-241-80-27910 (phone), fax: ++49-241-80-22242                   *
00009  * email: wns@comnets.rwth-aachen.de                                          *
00010  * www: http://wns.comnets.rwth-aachen.de                                     *
00011  ******************************************************************************/
00012 
00013 #include <GLUE/arqfsm/stopandwait/BaseState.hpp>
00014 
00015 using namespace glue::arqfsm::stopandwait;
00016 using namespace wns::ldk;
00017 
00018 StateInterface*
00019 BaseState::onI(const CompoundPtr& compound, int sequenceNumber)
00020 {
00021     MESSAGE_BEGIN(NORMAL, vars().logger, m, getFUNName());
00022     m << " Received I frame "
00023       << " expected " << vars().NR
00024       << " received " << sequenceNumber;
00025     MESSAGE_END();
00026 
00027     if(sequenceNumber == vars().NR) {
00028         // this is the I frame we waited for.
00029         sendOnData(compound);
00030         vars().NR = (vars().NR + 1) % vars().modulo;
00031     }
00032 
00033     vars().ackCompound = createReply(compound);
00034 
00035     StopAndWaitCommand* ackCommand = dynamic_cast<StopAndWaitCommand*>(getFU()->activateCommand(vars().ackCompound->getCommandPool()));
00036     assure(ackCommand, "Command is not a StopAndWaitCommand.");
00037 
00038     ackCommand->peer.type = StopAndWaitCommand::ACK;
00039     ackCommand->peer.NS = vars().NR;
00040 
00041     if (isAccepting(vars().ackCompound))
00042     {
00043         sendSendData(vars().ackCompound);
00044         vars().ackCompound = CompoundPtr();
00045     }
00046 
00047     return this;
00048 } // onI
00049 
00050 
00051 

Generated on Sun May 27 03:31:58 2012 for openWNS by  doxygen 1.5.5