PERFORCE change 145343 for review

Victor Hugo Bilouro bilouro at FreeBSD.org
Wed Jul 16 21:06:55 UTC 2008


http://perforce.freebsd.org/chv.cgi?CH=145343

Change 145343 by bilouro at bilouro_tcptest on 2008/07/16 21:06:09

	Added three new methods to act as fasteners
	(1)threewayhandshakenoopt -> this make 3way
	(2)closeconnection -> this make active close
	(3)passivecloseconnection -> this make passive close

Affected files ...

.. //depot/projects/soc2008/bilouro_tcptest/src/scripts/tests/tcptest.py#2 edit

Differences ...

==== //depot/projects/soc2008/bilouro_tcptest/src/scripts/tests/tcptest.py#2 (text+ko) ====

@@ -248,6 +248,84 @@
      
     return ~total & 0xffff
 
+
+def threewayhandshakenoopt(self, tcb, from_, to):    
+
+    # 
+    #--->Sending SYN
+    (ipsyn, tcpsyn) = createsyn(self, tcb, from_, to)
+    createwritepacket(self, tcb, ipsyn, tcpsyn, from_, to)
+                                                           
+    # 
+    #--->Receivinig SYN + ACK
+    (ipsynack, tcpsynack) = receive(self, tcb, from_, to) 
+                               
+    #Some blackmagic to use assertSequenceAcknowledgmentOK at SYN
+    tcb.tcpsequence[ to ] = tcpsynack.sequence  
+    assertSequenceAcknowledgmentOK(self, tcb, tcpsynack, from_, to)
+    assertSynPresent(self, tcpsynack)
+    tcb.tcpsequence[ to ] = tcpsynack.sequence + 1
+
+    #
+    #-->Sending ACK
+    (ipack, tcpack) = createip(self, tcb, from_, to)
+    createwritepacket(self, tcb, ipack, tcpack, from_, to)
+
+
+def closeconnection(self, tcb, from_, to):    
+
+    #
+    #--->Sending FIN
+    (ipfin, tcpfin) = createfin(self, tcb, from_, to)
+    createwritepacket(self, tcb, ipfin, tcpfin, from_, to)
+                                                           
+    #
+    #--->Receiving ACK from FIN sent
+    (ipfinack, tcpfinack) = receive(self, tcb, from_, to) 
+    assertSequenceAcknowledgmentOK(self, tcb, tcpfinack, from_, to)
+
+    #
+    #--->Receiving FIN
+    #test if FIN was sent in the same segment
+    if (tcpfinack.fin == None or tcpfinack.fin == 0):
+        (ipfinack, tcpfinack) = receive(self, tcb, from_, to)
+        assertSequenceAcknowledgmentOK(self, tcb, tcpfinack, from_, to)
+        
+    assertFin(self, tcpfinack)
+    tcb.tcpsequence[ to ] += 1
+             
+    #
+    #--->Sending ACK
+    (ipackfin, tcpackfin) = createip(self, tcb, from_, to)
+    createwritepacket(self, tcb, ipackfin, tcpackfin, from_, to)
+                
+
+
+def passivecloseconnection(self, tcb, from_, to):    
+
+    #
+    #--->Receiving FIN
+    (ipfinack, tcpfinack) = receive(self, tcb, from_, to)
+    assertSequenceAcknowledgmentOK(self, tcb, tcpfinack, from_, to)
+    assertFin(self, tcpfinack)
+    tcb.tcpsequence[ to ] += 1
+             
+    #
+    #--->Sending ACK
+    (ipackfin, tcpackfin) = createip(self, tcb, from_, to)
+    createwritepacket(self, tcb, ipackfin, tcpackfin, from_, to)
+                
+    #
+    #--->Sending FIN
+    (ipfin, tcpfin) = createfin(self, tcb, from_, to)
+    createwritepacket(self, tcb, ipfin, tcpfin, from_, to)
+                                                           
+    #
+    #--->Receiving ACK from FIN sent
+    (ipfinack, tcpfinack) = receive(self, tcb, from_, to) 
+    assertSequenceAcknowledgmentOK(self, tcb, tcpfinack, from_, to)
+
+
 class tcb:
     def __init__(self):
        self.ip = { }


More information about the p4-projects mailing list