from scapy.all import * pkt = IP(dst="google.com")/TCP(sport=1234, dport=80) send(pkt)
from scapy.all import * pkts = sniff(filter="tcp sport 1234", count=10)
from scapy.all import * sport = RandShort() pkt = IP(dst="google.com")/TCP(sport=sport, dport=80) send(pkt)This code uses the RandShort() function to generate a random 16-bit integer, which is then used as the source port for the TCP packet. The packet is sent to google.com with a destination port of 80. In all three examples, the package library being used is Scapy.