001    /**
002     * Copyright (C) 2009-2013 Barchart, Inc. <http://www.barchart.com/>
003     *
004     * All rights reserved. Licensed under the OSI BSD License.
005     *
006     * http://www.opensource.org/licenses/bsd-license.php
007     */
008    package com.barchart.udt;
009    
010    import org.slf4j.Logger;
011    import org.slf4j.LoggerFactory;
012    
013    /**
014     * A wrapper around the base UDT congestion control class
015     * 
016     * @see <a href="http://udt.sourceforge.net/udt4/doc/ccc.htm">reference</a>
017     * @see <a href="http://udt.sourceforge.net/udt4/doc/t-cc.htm">tutorial</a>
018     * @see FactoryUDT
019     * @see FactoryInterfaceUDT
020     * 
021     * @author CCob
022     */
023    public class CCC {
024    
025            /** Force SocketUDT to load JNI if it hasn't already */
026            private static boolean initOk = SocketUDT.INIT_OK;
027    
028            /** Used internally by the JNI layer, points to JNICCC class */
029            private long nativeHandle;
030    
031            private int msINT;
032            private int pktINT;
033            private int usRTO;
034            private final Logger log = LoggerFactory.getLogger(CCC.class);
035    
036            private native void initNative();
037    
038            protected native void setACKTimer(final int msINT);
039    
040            protected native void setACKInterval(final int pktINT);
041    
042            protected native void setRTO(final int usRTO);
043    
044            protected native void setPacketSndPeriod(final double sndPeriod);
045    
046            protected native void setCWndSize(final double cWndSize);
047    
048            protected native MonitorUDT getPerfInfo();
049    
050            public CCC() {
051                    initNative();
052            }
053    
054            public void init() {
055                    log.info("CCC::init");
056            }
057    
058            public void close() {
059                    log.info("CCC::close");
060            }
061    
062            public void onACK(final int ack) {
063            }
064    
065            public void onLoss(final int[] lossList) {
066            }
067    
068            public void onTimeout() {
069            }
070    
071            // TODO: implement Java wrapper around CPacket
072            // public void onPktSent(const CPacket* pkt) {}
073            // public void onPktReceived(const CPacket* pkt) {}
074            // public void processCustomMsg(const CPacket& pkt) {}/
075            // void sendCustomMsg(CPacket& pkt) const;
076    }