Change time value of a packet in a pcap file manually - networking

I have a question. I want to change the time value of a packet in a pcap. when we open a pcap in wireshark, we see a timestamp value in 2nd column after the packet serial numbers.
I want to change the time value of the packets. Though I am able to do the same but face a problem like below.
Let's say current time value showed for the packet in wireshark is 0.960727
I want to add 100000 to this time stamp.
Now the new stamp for the packet becomes 0.1060727 which ideally should be 1.060727.
If you open any pcap file in wireshark, you will never find a time value of more than 6 digits after decimal point.
But when I add this value I get 7 numbers after decimal point.
Could anhyone please let me know how can I make the time value to 1.060727 instead of 0.1060727 ?
Thank you for your suggestions here.
Regards,
Som

It's not completely clear to me what you're trying to do, but I'm going to take a guess that you are attempting to manually modify the timestamp of a single packet by editing the binary capture file. Assuming the file format is a .pcap file, then I suppose you're attempting to add 100000 microseconds to the timestamp of one particular packet?
Assuming this is the case, then you need to locate the packet header's ts_sec and ts_usec values and add 0x000186a0 microseconds to the current value of the ts_usec value, but if this value exceeds 0x000f423f (i.e., it's greater than or equal to 1 second), then you should add 0x00000001 to the ts_sec value and subtract 0x000f4240 from the newly computed ts_usec value.
One important thing to keep in mind is whether the .pcap file is written in big-endian or litte-endian format. This is determined by the so-called magic number (0xa1b2c3d4 implying big-endian and 0xd4c3d2a1 implying little-endian). Make sure you perform the addition/subtraction using the correct byte order of the ts_usec value and ts_sec value if appropriate, and make sure you write the bytes back to the ts_usec and ts_sec fields in the expected byte order of the file; otherwise your resulting timestamp will not be correct.
If this is not what you're attempting to do, then please clarify exactly what it is that you are attempting to do.

Related

Computer Networking - Bit stuffing

In bit stuffing why always add non information bits after consecutive 5 bits? Any reason behind that?
Here is some information from tutorialspoint:
Bit-Stuffing: A pattern of bits of arbitrary length is stuffed in the message to differentiate from the delimiter.
The flag field is some fixed sequence of binary values like 01111110. Now the payload can also have similar pattern, but the machine on the network can get confused and misinterpret that payload data as the flag field (indicating end of frame). So, to avoid the machine getting confused, some bits are stuffed into the payload (especially at points where payload data looks like the flag) so as to differentiate it from flag.

Siemens DICOM Individual Slice Time (Private_1019_1029)

I'm seeing that the individual slice time information from the Private_0019_1029 field of the DICOM header has negative values and sometime only positive values.
I assumed that these times are with respect to the Volume Acquisition time recorded in the header.
Going by that assumption, it would mean that the Acquisition time varies. But upon checking the difference between successive volume acquisition times, I see that it's equal to TR.
So I'm at a loss about what's happening.
I'm trying to look at the raw fMRI data without slice time correction; hence it's necessary to have the individual slice times.
Does the moco series do time shifting in addition to motion correction? (I don't believe it used to, but your experience may show otherwise).
This indicates how their slice timing is measured. Try the computations with the raw and the moco series and see if the times line up. That may give you your answer.
When dealing with private tag, you should really include the Private Vendor ID, in your case the value of tag (0019,0010).
You may also want to have a look at the output of:
gdcmdump --csa input.dcm
This will dump the SIEMENS CSA header directly from the DICOM attribute.

How to send multiple variables through Arduino serial port using ZigBee

I want to send five potentiometer values (bytes) through ZigBee using Arduino. I stored the potentiometer values in five different variables (bytes) and used
Serial.print(pot1);
Serial.print(pot2);
.
.
Serial.print(pot5);
The problem is that, when I am varying the potentiometer values, in the receiver section it is coming as 49, 55, 57, etc. (always changing), instead of some constant value from 0-255. (I am using Serial.read() function five times.)
How can I fix this problem?
q
Well, when you are varying the potentiometers it stands to reason that you will be reading varying values as the change is happening AND your program is reading and sending the changing values.
What I understand from your question is that you only want a ONE value sent after a change. I interpret this to mean that as you are changing the potentiometers, the values should not be sent, but in stead the final value should be sent.
What is the final value? Only you can decide, but one way to define it is: If the last value read one second ago is the same value read now, then send that value. The timing can be anything you decide, 1 second, 1/2 second etc.
I would like to help you with code, but you submitted very little code, and I am not sure I understood what you meant. Please clarify your requirements.

Locating data (like pressure etc) in a raw data stream

I am a newbie to Serial Port Analysis and I would appreciate some help on this. my specific question is...
If I have raw data from a serial port analyzer program, how will I locate measures like temperature, pressure, energy etc?
What should I look for in the raw data that will help me identify these units of measure?
What is the best way the extract relevant data from this raw data?
I would be very grateful if you can provide me any help with respect to this. I am unable to figure out how to do this.
Thanks a lot.
The best way that I know of to do this is to find the "reset" identifier, also called the "End of Stream" identifier or sequence. I am assuming that the data is a continuous flow not a one-time transmission.
If the data is continuously cycling, you need to find where the transmit begins (or ends) and then start metering your capture from there. Most devices will have an associated manual or documentation that give you the end sequence (or optionally the start sequence) and then the method by which they identifier their data.
For instance, the device may end a message by sending 4 all zero bytes in a row, then begin again by sending one byte that identifies the sensor, and another two bytes with the data, followed by the next sensor etc.
You would then watch the stream for 4 zero byte entries, and then start capturing 3 bytes at a time, one for the sensor and two for the data, until you saw 4 zero byte entries in a row again.

How to determine the length of an Ethernet II frame?

The Ethernet II frame format does not contain a length field, and I'd like to understand how the end of a frame can be detected without it.
Unfortunately, I have no idea of physics, but the following sounds reasonable to me: we assume that Layer 1 (Physical Layer) provides us with a way of transmitting raw bits in such a way that it is possible to distinguish between the situation where bits are being sent and the situation where nothing is sent (if digital data was coded into analog signals via phase modulation, this would be true, for example - but I don't know if this is really what's done). In this case, an ethernet card could simply wait until a certain time intervall occurs where no more bits are being transmitted, and then decide that the frame transmission has to be finished.
Is this really what's happening?
If yes: where can I find these things, and what are common values for the length of "certain time intervall"? Why does IEEE 802.3 have a length field?
If not: how is it done instead?
Thank you for your help!
Hanno
Your assumption is right. The length field inside the frame is not needed for layer1.
Layer1 uses other means to detect the end of a frame which vary depending on the type of physical layer.
with 10Base-T a frame is followed by a TP_IDL waveform. The lack of further Manchester coded data bits can be detected.
with 100Base-T a frame is ended with an End of Stream Delimiter bit pattern that may not occur in payload data (because of its 4B/5B encoding).
A rough description you can find e.g. here:
http://ww1.microchip.com/downloads/en/AppNotes/01120a.pdf "Ethernet Theory of Operation"

Resources