Display packet's detail using libpcap like Wireshark - wireshark

In the wireshark, it's able to display packet's details like ip.src, ip.port, info etc. When on click the packet, the packet's details are shown in the (middle) bottom part.
Is there anyway to show the details (known as pdml in tshark), i.e. the Frame, Ethernet, as shown in Wireshark by using libpcap? I understood that we are able to get source, destination address by using struct pcap_pkthdr, but I plan to build an application that resembles Wireshark and hence need to get details as displayed by Wireshark. Any expert here would like to share any websites or any source that I'm able to relate to? Thanks.

but I plan to build an application that resembles Wireshark and hence need to get details as displayed by Wireshark.
Then you will need to duplicate some or all of the work done by the Wireshark developers.
Ohloh's page on Wireshark says that Wireshark "has had 52,184 commits made by 119 contributors representing 2,849,177 lines of code" and that it "took an estimated 840 years of effort (COCOMO model) starting with its first commit in September, 1998 ending with its most recent commit about 13 hours ago". (That's more like "840 developer-years of effort"; it's not as if Gerald started working on it 840 years ago and did it all himself. :-))
Most of those lines of code are in the dissector core and the dissectors that use it.
If you don't care about using Wireshark's code (which means you are willing to have to give away the source code to your program to anybody who gets the program, and willing to let them give the source code away to anybody they want to), then you could try building your own program using the same Wireshark library that Wireshark and TShark use (that library is the one whose source is in the epan directory of the Wireshark source, and its subdirectories).
You wouldn't need all of them if you only have a small subset of protocols that you care about.
Libpcap will not help you; it is a library for capturing packets, writing them to capture files, and reading those capture files, and includes no code for analyzing the raw file data.

Related

What is the data contained in ROS topic velodyne_msgs/VelodynePacket Message?

I am doing a light weight program to monitor received beams for lidar. Preferably, I do not want to cache the entire UDP data packet or point cloud data due to the light weight nature.
The question is what is the data contained in ROS message velodyne_msgs/VelodynePacket. This message contains smaller data but I do not know if it is related.
By read the Ros Wiki on this topic but the link for velodynepackt did not provide useful info on the content.
Check the message definition to see what fields a message contains and their types. Message files will usually either have field names that are self explanatory or will have comments (## text) describing the fields. You can look at the message definitions either online or locally. To look at them locally use roscd to get to the package directory roscd <package_name>/msg and then using cat to see the contents of the message file. In your case, this would be:
roscd velodyne_msgs/msg
cat VelodynePacket.msg
cat VelodyneScan.msg
The relevant message files are available online from the page you linked to:
http://docs.ros.org/api/velodyne_msgs/html/msg/VelodyneScan.html
http://docs.ros.org/api/velodyne_msgs/html/msg/VelodynePacket.html
In regards to your specific question about creating a lightweight application, you have a few options.
Use the provided ROS message and subscribe to it. Most of the time if you don't have a ton of large data traveling around, you'll be okay and will be able to keep up with real time data. The majority of the time associated with ROS usually comes from the network transport, so if that's a problem, you'll need to not pass the data over ROS.
Put your code in a ROS Nodelet. This gives you the advantages of ROS data abstractions while eliminating the network data transfer that occurs between nodes. This is akin to using a pointer to the data field.
If you really don't want all the scan data, but still want to use ROS, you can write your own driver node. This will read from the LIDAR the data you want and discard the data you don't. You can do the raw data processing in that node (no ROS message required) or publish the data you care about and do the processing in another node.

Receiving data using aux cable on GNU RADIO

I am transmitting and receiving data using aux cable and GNU RADIO between two laptops.
I have implemented DQPSK using PSK mod block.
The problem is that while receiving I have to provide a delay, some integer value e.g 0,1,2 etc.
It is different every time.
Is there a way to dynamically check for the right delay value or any other workaround to this situation?
I have written 'start.' at the start of data being transmitted and 'end.' at the end.
I have to give a demo for this project and I dont want to manually change the delay at runtime.
I cannot find the .cc file of file sink in GNU RADIO, I can change the C++ code according my requirement but there is no such file.
Below is the screenshot of the grc file on the receive side.
Any help will be appreciated.
Since there's no way for the receiver to know when the transmitter started transmitting, it decodes stuff before there's actually anything to decode.
In essence, you need some kind of preamble or so to tell your receiver when to start – side effect of having something like that would be that you could correct some things (the two sound cards don't share the same oscillator, which leads to a symbol rate offset, and a center frequency offset).
You basically added that framing - your start. and end. strings.
I cannot find the .cc file of file sink in GNU RADIO, I can change the C++ code according my requirement but there is no such file.
It's in gr-blocks/lib; however, you shouldn't modify the file sink. Really,
I'd recommend you take the time to go through the guided tutorials, use gr_modtool to generate a general block which has a state machine that looks for the bits of your start string and drops everything before and including those, and then passes everything till it sees the stop string. That all can be done with a single state machine, and a bit of python or C++ code.

Can a wireshark capture include metadata advising users of the terms of its use?

We have a group of users who need to see the payloads of packets in wireshark captures. I'm looking for a way to remind them users that the data contained within may not represent the exact frames on the wire (because the capture will have been pre-processed by the time they get it to remove, e.g. security-sensitive IP addresses). A hook in the capture file that triggered a popup with a short message would be perfect. Is there anyway to do this, short of wrapping Wireshark with another binary (which would be trivially bypass-able anyway)?
I've searched in the wireshark lists but come up empty.
The only thing you could do would be to have the pre-processing program write out the file in pcapng format and add a comment to the initial Section Header Block giving that warning. That won't produce a popup - but, then, not all the capture file reading programs in the Wireshark suite are GUI programs that could produce a popup.

How to deal with package date from wireshark

Here's the thing.I come with a problem when I process the Internet packet Information in Wireshark.I need a tools can help me handle a large number of packets and take the packet information (I mean the data inside the packet which be show as hexadecimal and cut out the specific part) out from the Wireshark and can be order by specific order. Well,If it can generate a form I will very appreciate that. Thanks a lot.
I come with a problem when I process the Internet package Information in Wireshark
(In English, the term that's usually used is "packet", not "package"; I assume you're referring to network packets here.)
Are you processing them using Wireshark, or some other program?
I need a tools can help me handle a large number of packages and take the package information (I mean the data inside the package which be show as hexadecimal and cut out the specific part) out from the Wireshark and can be order by specific order.
Capture files written by Wireshark are either in pcap or pcap-ng format; libpcap/WinPcap can read pcap files, and libpcap 1.1.0 and later can read many pcap-ng files. A packet record in those files has a time stamp giving the date and time the packet was received (in UTC, represented as time since January 1, 1970, 00:00:00 UTC), the length of the packet as it appeared on the network, the amount of packet data that was saved (capture programs can be told to save no more than N bytes of packet data, with the user specifying the value of N), and the raw packet data in binary form.
You could use libpcap/WinPcap to read those files (although older versions of libpcap, and current versions of WinPcap, can't read pcap-ng files). The packets in a file aren't guaranteed to be sorted by the time stamp value, so you'd have to sort them yourself.
I don't know what you mean by "cut out the specific part"; if you want to extract particular parts of the packet's data, you'll either have to write your own code to understand that or find some tool that will help you do that - the TShark -T fields option might work here, as might Scapy.

Embedded image capture - need help getting started

I'm working on an embedded home surveillance system. I want to interface a couple of serial-enabled JPEG capture cameras, maybe a couple of door sensors, etc. Problem is, I can't for the life of me figure out how to interface a camera to a microcontroller. Stills, streaming video, it doesn't matter - I can't find any how-to documentation on this.
I understand serial communications, and most of the camera documentation I've found out there describes the protocol necessary to instruct the camera to send the datastream down to the uC for capture. What they don't show is what you're supposed to do with the data once you get it.
Here's an example.
They show a great little video, and the datasheet describes which bytes must be sent to the camera to retrieve the image. What I need is an example or tutorial of some sort that will explain what to do with the stream of bytes that make up the image itself. How do I arrange those bytes into an image and save it as a file?
I've looked all over the place for a tutorial of some sort, but have come up dry. I'm not sure which processor I'll use for this project just yet, but this question isn't really processor-dependent. All I need is the algorithm, maybe a peek at a library, if one exists. I'll take that process and adapt it to my hardware, I just can't seem to find a place to get started.
Have any of you done this?
I think the details are pretty clear in page 10 inside this document:
http://www.4dsystems.com.au/downloads/micro-CAM/Docs/uCAM-DS-rev4.pdf
First, one package is between 64 to 512 bytes - flexibly defined by the programmer. Image size is the actual JPEG image itself....nothing more or less....just pure JPEG image. So the equation to calculate the number of package based on image_size / package_size is given in page 10.
Next, is that (package_size - 6) is to be consistently used everywhere, because 6 bytes are used up for non-data purpose, so (package_size - 6) will be just the data - but u have to reassemble it yourself.
To assemble the data from the package, u have to strip the 4 byte header + 2 byte trailer and concatenate all these from all the package sequentially one after another.
Other facts:
a. "Set Package Size" command must be sent from host to CAM - before "SNAPSHOT" command, which capture the image from the camera into the CAM memory buffer.
b. Next is to send "SNAPSHOT" command to capture the image into memory buffer.
c. Last is to send "GET PICTURE" command (only one time, but data will come back multiple times - see diagram in page 15) to extract out all the images....and it will come back in the form of "package" as we have defined the size earlier in "set package size". Since u have calculate the formula u will know when to stop asking for the next package. And there is a verification byte - u have to used that to make sure data is correct.
I have not used this camera but looks like it works exactly the same is a camera (C328) I have used. Send an image resolution/colour command. When you want get an image send an image capture command. The camera responds by sending a binary file over the serial link.

Resources