title: Fetch source address and port number of packet - Scapy script
body: <p>I am doing a sniffing of the network and trying to get ip address and port number on every tcp packet.</p>
  
  <p>I used scapy with python and could successfully sniff packets and in a callback function could even print the packet summary. But I would want to do more, like fetching only the IP address of the source and its port number. How can i accomplish it? Below is my code:</p>
  
  <pre><code>#!/usr/bin/evn python
  from scapy.all.import.*
  def print_summary(pkt):
      packet = pkt.summary()
      print packet
  sniff(filter="tcp",prn=packet_summary)
  </code></pre>
  
  <p>Please suggest a method to print only the source IP address of every packet.</p>
  
  <p>Thanks.</p>