count number of packets and store in database