Reputation: 432
Is the parameter prn
in the sniff-function
ofScapy
an abbreviation for anything?
I know it is used to define a callback-function
for the sniffed packet, I just can't find the meaning of prn
.
I couldn't find an explanation for the abbreviation in the documentation.
Upvotes: 2
Views: 4349
Reputation: 11
I had the same question and took an hour to dig up the answer. I hope this helps!
sniff()
This is the function that captures packets from the network. By default, it listens on all network interfaces for incoming packets. prn=self._process_packet
prn stands for "print" or "process" and is a callback function that will be invoked for each captured packet.
The argument self._process_packet specifies that the function _process_packet (which is a method of the class in which this code resides) will be called for each packet. This function is expected to process the packet in some way — for example, analyzing or printing information about it.
store=0
The store parameter controls whether packets are stored in memory.
store=0 means do not store the packets in memory. Instead, they will be processed as they are captured, and then discarded. This is useful if you just need to inspect the packets in real-time and don't want to store them for later use, which helps to conserve memory.
If you set store=1, Scapy would store the packets in a list for later use, allowing you to access them after the sniffing operation ends.
Upvotes: 1
Reputation: 313
I found something interesting but I'm not sure if it's relevant or not.
PRN
is an abbreviation for the Latin term, "pro re nata" which loosely translates to "as needed." PRN is a term commonly used by healthcare employers and professionals to describe short-term, contract, part-time, or fill-in work by a nurse or allied health professional.
As prn
takes the call-back function name, it sounds logical to me but I don't believe they would go this far to name a parameter.
Upvotes: 3
Reputation: 6237
That's probably for "print", since the result of the callback (if it is not None
) is printed.
The first (historical) use of this callback was to print, for example, a .summary()
or a .display()
of each sniffed packet (see the tshark()
function).
Upvotes: 2