question: @ Override public boolean inputThrottled ( OFMessage ofm ) { if ( ofm . getType ( ) != OFType . PACKET_IN ) { return false ; } ctrSwitchPktin . updateCounterNoFlush ( ) ; messageCount ++ ; if ( messageCount % 1000 == 0 ) { long now = System . currentTimeMillis ( ) ; if ( now != lastMessageTime ) { currentRate = ( int ) ( 1000000 / ( now - lastMessageTime ) ) ; lastMessageTime = now ; } else { currentRate = Integer . MAX_VALUE ; } } if ( ! packetInThrottleEnabled ) { if ( currentRate <= packetInRateThresholdHigh ) { return false ; } enablePacketInThrottle ( ) ; } else if ( currentRate < packetInRateThresholdLow ) { disablePacketInThrottle ( ) ; return false ; } OFPacketIn pin = ( OFPacketIn ) ofm ; OFMatch match = new OFMatch ( ) ; match . loadFromPacket ( pin . getPacketData ( ) , pin . getInPort ( ) ) ; if ( ofMatchCache . update ( match ) ) { ctrSwitchPktinDrops . updateCounterNoFlush ( ) ; return true ; } messageCountUniqueOFMatch ++ ; if ( ( messageCountUniqueOFMatch % packetInRatePerMacThreshold ) == 1 ) { checkPerSourceMacRate ( pin ) ; } if ( ( messageCountUniqueOFMatch % packetInRatePerPortThreshold ) == 1 ) { checkPerPortRate ( pin ) ; } return false ; }
target:  Determine if this message should be dropped. We compute the current rate by taking a timestamp every 100 messages. Could change to a more complex scheme if more accuracy is needed. Enable throttling if the rate goes above packetInRateThresholdHigh Disable throttling when the rate drops below packetInRateThresholdLow While throttling is enabled, we do the following: - Remove duplicate packetIn's mapped to the same OFMatch - After filtering, if packetIn rate per host (mac) is above packetInRatePerMacThreshold, push a flow mod to block mac on port - After filtering, if packetIn rate per port is above packetInRatePerPortThreshold, push a flow mod to block port - Allow blocking flow mods have a hard timeout and expires automatically TODO: keep a history of all events related in input throttling