0

I have a problem with timer in my code. I will show it on a code

from scapy.all import *
import time
interface = "eth0"
count = 0
packets = 0
packets = int(input())
seconds = int(input())

def admin_packet(packets):
    if count > packets:
        print("....")

def print_packet(packet):
    ip_layer = packet.getlayer(IP)
    print("New packets")
    global count
    global seconds
    count += 1
    print(count)
    for i in range(seconds):
        print(str(seconds - i) + "...")
        time.sleep(1)

The main problem is how to start a clock that will work regardless of the counting function. Because in this moment when I start program i will see new packet and then i must wait time which i gave in input before i see next packet. if anyone has any idea with this, I will be grateful.

Filip Młynarski
  • 3,534
  • 1
  • 10
  • 22

0 Answers0