why receiving duplicated frames using sockets in python? -


i make simple client/server code send/receive frames using sockets, @ reception, receive duplicated packets this

> num seq= 4751 num seq= 4751 num seq= 4752 num seq= 4752 num seq= 4753 > num seq= 4753 num seq= 4754 num seq= 4754 num seq= 4755 num seq= 4755 > num seq= 4756 num seq= 4756 num seq= 4757 num seq= 4757 num seq= 4758 > num seq= 4758 num seq= 4759 num seq= 4759 num seq= 4760 num seq= 4760 > num seq= 4761 num seq= 4761 num seq= 4762 num seq= 4762 num seq= 4763 > num seq= 4763 num seq= 4764 num seq= 4764 num seq= 4765 num seq= 4765 > num seq= 4766 num seq= 4766 num seq= 4767 num seq= 4767 num seq= 4768 > num seq= 4768 num seq= 4769 num seq= 4769 num seq= 4770 num seq= 4770 > num seq= 4771 num seq= 4771 num seq= 4772 num seq= 4772 num seq= 4773 > num seq= 4773 num seq= 4774 num seq= 4774 num seq= 4775 num seq= 4775 > num seq= 4776 num seq= 4776 num seq= 4777 num seq= 4777 num seq= 4778 

i couldn't understand why packets duplicated @ reception !!??

this client code:

from socket import * import binascii  #creation of raw socket s=socket(af_packet, sock_raw)  # bind socket interface s.bind(("eth0",0))  # ethernet header src="\x01\x01\x01\x01\x01\x01" dst="\x02\x02\x02\x02\x02\x02" ethertype="74"  #type or length  # generate infinite traffic   i=0       # frame number  while true :         payload=("0"*(100-len(str(i))))+str(i)         cr=binascii.crc32(dst+src+ethertype+payload)         res=''         j in range(4): # calculate crc             t=cr & 0xff             cr >>= 8             res='%02x%s' % (t, res)         s.send(dst+src+ethertype+payload+res)    # send frame         i+=1 

and server code is:

from scapy.all import *  def traiter(p) :      k=str(p) #transform frame string      print "num seq=",int(k[14:112]) # print sequence number  def main():  # intercept packet , send traiter      sniff(iface="lo", prn=lambda x: traiter(x))  if __name__ == "__main__":    sys.exit(main()) 

that's normal behaviour: if source , destination in same machine, when sniff on loopback interface, capture exiting , entering packets! packets not duplicated.


Comments

Popular posts from this blog

c# - How to get the current UAC mode -

postgresql - Lazarus + Postgres: incomplete startup packet -

javascript - Ajax jqXHR.status==0 fix error -