Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

TCP Retransmissions

Name: Anonymous 2009-01-04 23:05

Ordinarily, you're a terrible place to get code, /prog/, but I must yield.

I'm having trouble with AES encryption increasing on packet retransmissions, so I obviously must detect and discard retransmissions for encryption purposes. Since I'm using WinPcap, I figured that Ethereal would be a good place to go to see how it detects these events. I was wrong.

Example: http://pastebin.com/d165a8f15 [1]

I can't tell what the shit is going on with such ugly C code. Any of you have an enterprise-level solution to retransmission detection? Thanks for your time.

1: As accessed on 4 JAN 09 at 10 PM CST. It will evaporate within 24 hours.

Name: Anonymous 2009-01-04 23:11

It will evaporate within 24 hours.
So it's just a Torch with no Reiji Maigo.

Name: Anonymous 2009-01-04 23:25

HOLY SHIT A REAL QUESTION
GO DO YOUR OWN HOMEWORK FAG
READ SICP. PROBLEM SOLVED.

Name: Anonymous 2009-01-04 23:44

I can't tell what the shit is going on with such ugly C code.
it could be much worse. it could be python or lisp. those languages are completely write-only.

Name: Anonymous 2009-01-05 0:01

>>3
It's not homework.

>>4
Yes, it could be. However, this does not justify it being hideous in the first place.

Name: Anonymous 2009-01-05 0:03

>>5
it's actually very readable code. if you can't figure it out you're an idiot.

Name: Anonymous 2009-01-05 0:09

>>6
One word: The unforgivable use of goto. Thread over.

Name: Anonymous 2009-01-05 0:12

>>7
Only faggots and sailors worry about the use of the almighty goto, and you don't look like much of a sailor so that kind of narrows it down...

Name: FrozenVoid !FrOzEn2BUo 2009-01-05 8:19

Goto is very useful.
The point it when you can use conventional control structures you should use them and leave gotos to case when its required.
An algorithm with gotos replaced with equivalent structures will run slower(sometimes significantly,as goto skips parts of code which are run usually).

Name: Anonymous 2009-01-05 8:39

>>1
You just don't know how to read C:

#
        /* RETRANSMISSION/FAST RETRANSMISSION/OUT-OF-ORDER
#
         * If the segments contains data and if it does not advance
#
         * sequence number it must be either of these three.
#
         * Only test for this if we know what the seq number should be
#
         * (tcpd->fwd->nextseq)
#
         *
#
         * Note that a simple KeepAlive is not a retransmission
#
         */
#
        if( seglen>0
#
        &&  tcpd->fwd->nextseq
#
        &&  (LT_SEQ(seq, tcpd->fwd->nextseq)) ){
#
                guint32 t;
#
 
#
                if(tcpd->ta && (tcpd->ta->flags&TCP_A_KEEP_ALIVE) ){
#
                        goto finished_checking_retransmission_type;
#
                }
#
 
#
                /* If there were >=1 duplicate ACKs in the reverse direction
#
                 * (there might be duplicate acks missing from the trace)
#
                 * and if this sequence number matches those ACKs
#
                 * and if the packet occurs within 20ms of the last
#
                 * duplicate ack
#
                 * then this is a fast retransmission
#
                 */
#
                t=(pinfo->fd->abs_ts.secs-tcpd->rev->lastacktime.secs)*1000000000;
#
                t=t+(pinfo->fd->abs_ts.nsecs)-tcpd->rev->lastacktime.nsecs;
#
                if( tcpd->rev->dupacknum>=1
#
                &&  tcpd->rev->lastack==seq
#
                &&  t<20000000 ){
#
                        if(!tcpd->ta){
#
                                tcp_analyze_get_acked_struct(pinfo->fd->num, TRUE, tcpd);
#
                        }
#
                        tcpd->ta->flags|=TCP_A_FAST_RETRANSMISSION;
#
                        goto finished_checking_retransmission_type;
#
                }
#
 
#
                /* If the segment came <3ms since the segment with the highest
#
                 * seen sequence number, then it is an OUT-OF-ORDER segment.
#
                 *   (3ms is an arbitrary number)
#
                 */
#
                t=(pinfo->fd->abs_ts.secs-tcpd->fwd->nextseqtime.secs)*1000000000;
#
                t=t+(pinfo->fd->abs_ts.nsecs)-tcpd->fwd->nextseqtime.nsecs;
#
                if( t<3000000 ){
#
                        if(!tcpd->ta){
#
                                tcp_analyze_get_acked_struct(pinfo->fd->num, TRUE, tcpd);
#
                        }
#
                        tcpd->ta->flags|=TCP_A_OUT_OF_ORDER;
#
                        goto finished_checking_retransmission_type;
#
                }
#
 
#
                /* Then it has to be a generic retransmission */
#
                if(!tcpd->ta){
#
                        tcp_analyze_get_acked_struct(pinfo->fd->num, TRUE, tcpd);
#
                }
#
                tcpd->ta->flags|=TCP_A_RETRANSMISSION;
#
                nstime_delta(&tcpd->ta->rto_ts, &pinfo->fd->abs_ts, &tcpd->fwd->nextseqtime);
#
                tcpd->ta->rto_frame=tcpd->fwd->nextseqframe;
#
        }


You'll need to review all of the struct definitions and related functions to actually make any use of the code, but it provides a fairly concise example of the detection process.

Name: Anonymous 2009-01-05 16:28

>>9
An algorithm with gotos replaced with equivalent structures will run slower
Except for something called ``pipelining''. Sorry, bud.

Name: Anonymous 2009-01-05 16:47

>>9
When you can't use conventional control structures it's time to invent a new one, not to use gotos right there in the code.

Name: Anonymous 2009-01-05 17:42

>>12
You have been brainwashed.

freeyourmind

Name: Anonymous 2009-01-05 19:24

>>13
You don't think it would be better to solve the control problem once in a general way rather than pepper ad-hoc gotos around? Learn to abstract.

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List