Changeset 404754b


Ignore:
Timestamp:
Nov 6, 2009 12:47:21 PM (11 years ago)
Author:
zzz <zzz@…>
Branches:
master
Children:
7c36c0c
Parents:
413ab6d7
Message:

streaming lib packet capture first cut

Files:
1 added
10 edited

Legend:

Unmodified
Added
Removed
  • apps/streaming/java/src/net/i2p/client/streaming/Connection.java

    r413ab6d7 r404754b  
    7474   
    7575    private long _lifetimeBytesSent;
     76    /** TBD for tcpdump-compatible ack output */
     77    private long _lowestBytesAckedThrough;
    7678    private long _lifetimeBytesReceived;
    7779    private long _lifetimeDupMessageSent;
     
    743745    public long getCongestionWindowEnd() { return _congestionWindowEnd; }
    744746    public void setCongestionWindowEnd(long endMsg) { _congestionWindowEnd = endMsg; }
     747    /** @return the highest outbound packet we have recieved an ack for */
    745748    public long getHighestAckedThrough() { return _highestAckedThrough; }
     749    /** @deprecated unused */
    746750    public void setHighestAckedThrough(long msgNum) { _highestAckedThrough = msgNum; }
    747751   
  • apps/streaming/java/src/net/i2p/client/streaming/ConnectionHandler.java

    r413ab6d7 r404754b  
    176176            _manager.getPacketHandler().receivePacketDirect(packet, false);
    177177        } else {
     178            // log it here, just before we kill it - dest will be unknown
     179            ((PacketLocal)packet).logTCPDump(true);
     180
    178181            // goodbye
    179182            if (_log.shouldLog(Log.WARN))
  • apps/streaming/java/src/net/i2p/client/streaming/ConnectionManager.java

    r413ab6d7 r404754b  
    177177       
    178178        con.setReceiveStreamId(receiveId);
     179        // finally, we know enough that we can log the packet with the conn filled in
     180        ((PacketLocal)synPacket).setConnection(con);
     181        ((PacketLocal)synPacket).logTCPDump(true);
    179182        try {
    180183            con.getPacketHandler().receivePacket(synPacket, con);
  • apps/streaming/java/src/net/i2p/client/streaming/MessageHandler.java

    r413ab6d7 r404754b  
    4646        }
    4747        if (data == null) return;
    48         Packet packet = new Packet();
     48        //Packet packet = new Packet();
     49        // for tcpdump
     50        Packet packet = new PacketLocal(_context, null);
    4951        try {
    5052            packet.readPacket(data, 0, data.length);
  • apps/streaming/java/src/net/i2p/client/streaming/Packet.java

    r413ab6d7 r404754b  
    4343 * <li>{@link #FLAG_PROFILE_INTERACTIVE}: no option data</li>
    4444 * <li>{@link #FLAG_ECHO}: no option data</li>
    45  * <li>{@link #FLAG_NO_ACK}: no option data</li>
     45 * <li>{@link #FLAG_NO_ACK}: no option data - this appears to be unused, we always ack, even for the first packet</li>
    4646 * </ol>
    4747 *
  • apps/streaming/java/src/net/i2p/client/streaming/PacketHandler.java

    r413ab6d7 r404754b  
    108108            displayPacket(packet, "UNKN", null);
    109109        }
     110        // Don't log here, wait until we have the conn to make the dumps easier to follow
     111        //((PacketLocal)packet).logTCPDump(true);
    110112    }
    111113   
     
    128130   
    129131    private void receiveKnownCon(Connection con, Packet packet) {
     132        // is this ok here or does it need to be below each packetHandler().receivePacket() ?
     133        ((PacketLocal)packet).setConnection(con);
     134        ((PacketLocal)packet).logTCPDump(true);
    130135        if (packet.isFlagSet(Packet.FLAG_ECHO)) {
    131136            if (packet.getSendStreamId() > 0) {
     
    267272           
    268273            if (packet.isFlagSet(Packet.FLAG_SYNCHRONIZE)) {
     274                // logTCPDump() will be called in ConnectionManager.receiveConnection(),
     275                // which is called by ConnectionHandler.receiveNewSyn(),
     276                // after we have a new conn, which makes the logging better.
    269277                _manager.getConnectionHandler().receiveNewSyn(packet);
    270278            } else if (queueIfNoConn) {
     279                // don't call logTCPDump() here, wait for it to find a conn
     280
    271281                // We can get here on the 2nd+ packet if the 1st (SYN) packet
    272282                // is still on the _synQueue in the ConnectionHandler, and
     
    294304                _manager.getConnectionHandler().receiveNewSyn(packet);
    295305            } else {
     306                // log it here, just before we kill it - dest will be unknown
     307                ((PacketLocal)packet).logTCPDump(true);
    296308                // don't queue again (infinite loop!)
    297309                sendReset(packet);
  • apps/streaming/java/src/net/i2p/client/streaming/PacketLocal.java

    r413ab6d7 r404754b  
    11package net.i2p.client.streaming;
    22
     3import java.io.IOException;
    34import java.util.Set;
    45
     
    2930    private volatile boolean _retransmitted;
    3031    private SimpleTimer2.TimedEvent _resendEvent;
     32    private static final Object initLock = new Object();
     33    private static boolean _initialized;
     34    private static PcapWriter _pcapWriter;
    3135   
    3236    public PacketLocal(I2PAppContext ctx, Destination to) {
     
    4347        _nackCount = 0;
    4448        _retransmitted = false;
     49        synchronized(initLock) {
     50            if (!_initialized) {
     51                initPcap();
     52                _initialized = true;
     53            }
     54        }
    4555    }
    4656   
     
    140150    public long getLastSend() { return _lastSend; }
    141151    public Connection getConnection() { return _connection; }
     152    /** used to set the rcvd conn after the fact for incoming syn replies */
     153    public void setConnection(Connection con) { _connection = con; }
    142154
    143155    public void incrementNACKs() {
     
    243255    public boolean writeFailed() { return _cancelledOn > 0; }
    244256    public boolean writeSuccessful() { return _ackOn > 0 && _cancelledOn <= 0; }
     257
     258    static final String PCAP = "foo.pcap";
     259    private void initPcap() {
     260        try {
     261            _pcapWriter = new PcapWriter(_context, PCAP);
     262        } catch (IOException ioe) {
     263           System.err.println("pcap init ioe: " + ioe);
     264        }
     265    }
     266
     267    /** Generate a pcap/tcpdump-compatible format,
     268     *  so we can use standard debugging tools.
     269     */
     270    public void logTCPDump(boolean isInbound) {
     271        if (!_log.shouldLog(Log.INFO)) return;
     272        _log.info(toString());
     273        if (_pcapWriter != null) {
     274            try {
     275                _pcapWriter.write(this, isInbound);
     276            } catch (IOException ioe) {
     277               _log.warn("pcap write ioe: " + ioe);
     278            }
     279        }
     280    }
    245281}
  • apps/streaming/java/src/net/i2p/client/streaming/PacketQueue.java

    r413ab6d7 r404754b  
    151151            String suffix = (c != null ? "wsize " + c.getOptions().getWindowSize() + " rto " + c.getOptions().getRTO() : null);
    152152            _connectionManager.getPacketHandler().displayPacket(packet, "SEND", suffix);
     153            ((PacketLocal)packet).logTCPDump(false);
    153154        }
    154155       
  • core/java/src/net/i2p/client/I2PSessionMuxedImpl.java

    r413ab6d7 r404754b  
    272272                        msg.id, msg.size, msg.proto, msg.fromPort, msg.toPort);
    273273                } catch (Exception e) {
    274                     _log.error("Error notifying app of message availability");
     274                    _log.error("Error notifying app of message availability", e);
    275275                }
    276276            }
  • router/java/src/net/i2p/router/RouterVersion.java

    r413ab6d7 r404754b  
    2121    public final static long BUILD = 12;
    2222    /** for example "-test" */
    23     public final static String EXTRA = "";
     23    public final static String EXTRA = "-pcap";
    2424    public final static String FULL_VERSION = VERSION + "-" + BUILD + EXTRA;
    2525    public static void main(String args[]) {
Note: See TracChangeset for help on using the changeset viewer.