FileDocCategorySizeDatePackage
UDPNetworkManager.javaAPI DocAzureus 3.0.3.45727Wed Nov 29 17:07:24 GMT 2006com.aelitis.azureus.core.networkmanager.impl.udp

UDPNetworkManager

public class UDPNetworkManager extends Object

Fields Summary
public static final int
PROTOCOL_HEADER_SIZE
public static final boolean
MINIMISE_OVERHEADS
public static final int
MIN_INCOMING_INITIAL_PACKET_SIZE
public static final int
MAX_INCOMING_INITIAL_PACKET_SIZE
private static final int
MIN_MSS
private static final int
MAX_MSS
private static int
udp_mss_size
public static boolean
UDP_INCOMING_ENABLED
public static boolean
UDP_OUTGOING_ENABLED
private static UDPNetworkManager
singleton
private int
udp_listen_port
private int
udp_non_data_listen_port
private UDPConnectionManager
connection_manager
Constructors Summary
protected UDPNetworkManager()

	
	
	
	
		COConfigurationManager.addAndFireParameterListener( 
			   "UDP.Listen.Port", 
			   new ParameterListener() 
			   {
				   public void 
				   parameterChanged(String name) 
				   {
					   int port = COConfigurationManager.getIntParameter( name );
					   
					   if ( port == udp_listen_port ){
						   
						   return;
					   }
					   
					   if ( port < 0 || port > 65535 || port == 6880 ) {
						   
					        String msg = "Invalid incoming UDP listen port configured, " +port+ ". The port has been reset. Please check your config!";
					        
					        Debug.out( msg );
					        
					        Logger.log(new LogAlert(LogAlert.UNREPEATABLE, LogAlert.AT_ERROR, msg));
					        
					        udp_listen_port = RandomUtils.generateRandomNetworkListenPort();
					        
					        COConfigurationManager.setParameter( name, udp_listen_port );
					        
					    }else{
					
					    	udp_listen_port	= port;
					    }
				   }
			   });
	   
		COConfigurationManager.addAndFireParameterListener( 
				   "UDP.NonData.Listen.Port", 
				   new ParameterListener() 
				   {
					   public void 
					   parameterChanged(String name) 
					   {
						   int port = COConfigurationManager.getIntParameter( name );
						   
						   if ( port == udp_non_data_listen_port ){
							   
							   return;
						   }
						   
						   if ( port < 0 || port > 65535 || port == 6880 ) {
							   
						        String msg = "Invalid incoming UDP non-data listen port configured, " +port+ ". The port has been reset. Please check your config!";
						        
						        Debug.out( msg );
						        
						        Logger.log(new LogAlert(LogAlert.UNREPEATABLE, LogAlert.AT_ERROR, msg));
						        
						        udp_non_data_listen_port = RandomUtils.generateRandomNetworkListenPort();
						        
						        COConfigurationManager.setParameter( name, udp_non_data_listen_port );
						        
						    }else{
						
						    	udp_non_data_listen_port	= port;
						    }
					   }
				   });
		
		connection_manager = new UDPConnectionManager();
	
Methods Summary
public UDPConnectionManagergetConnectionManager()

		return( connection_manager );
	
public static com.aelitis.azureus.core.networkmanager.impl.udp.UDPNetworkManagergetSingleton()

	

	  
	
	
		return( singleton );
	
public intgetUDPListeningPortNumber()

		return( udp_listen_port );
	
public intgetUDPNonDataListeningPortNumber()

		return( udp_non_data_listen_port );
	
public static intgetUdpMssSize()

	
	
		COConfigurationManager.addAndFireParameterListener(
				"UDP.Listen.Port.Enable",
				new ParameterListener()
				{
					public void 
					parameterChanged(
						String name )
					{
						UDP_INCOMING_ENABLED = UDP_OUTGOING_ENABLED = COConfigurationManager.getBooleanParameter( name );
					}
				});
	  return udp_mss_size;  
public booleanisUDPListenerEnabled()

		return( UDP_INCOMING_ENABLED );
	
public booleanisUDPNonDataListenerEnabled()

		return( UDP_INCOMING_ENABLED );
	
public static voidrefreshRates(int min_rate)

		udp_mss_size = COConfigurationManager.getIntParameter( "network.udp.mtu.size" ) - PROTOCOL_HEADER_SIZE; 	        

	    if( udp_mss_size > min_rate )  udp_mss_size = min_rate - 1;
	    
	    if( udp_mss_size < MIN_MSS )  udp_mss_size = MIN_MSS; 
	    
	    if ( udp_mss_size > MAX_MSS ) udp_mss_size = MAX_MSS;