Created
October 5, 2015 09:40
-
-
Save elvinio/6d6e2a947523f5a2d3c0 to your computer and use it in GitHub Desktop.
https://wiki.wireshark.org/Development/LibpcapFileFormat and http://www.cmegroup.com/confluence/display/EPICSANDBOX/MDP+3.0+-+Packet+and+Message+Headers
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python | |
from struct import * | |
with open('cap','rb') as f: | |
data = f.read(24) | |
globalHeader = unpack('IHHiIII',data) | |
print globalHeader | |
data = f.read(16) | |
while data != "": | |
packetHeader = unpack('IIII', data) | |
data = f.read(packetHeader[3]) | |
if data == "": | |
break | |
#Eth 14 bytes, IP 20 bytes, UDP 8 bytes | |
sbe = data[42:] | |
if len(sbe) > 16: | |
# Seq num, sending time | |
sbeHeader = unpack_from('IQ', sbe, 0) | |
# message size, block len, template id, schema id, version | |
sbeMsg = unpack_from('HHHHH', sbe, 12) | |
if sbeMsg[2] == 32: | |
# transact time, match event indic, MD Entries | |
sbeFix = unpack_from('QB', sbe, 22) | |
# px, size, sec id, rpt seq, numof order, price level, update action, entry type | |
# block length is 11 so add 10. | |
sbeMDEntries = unpack_from('qiiIiBBB', sbe, 32) | |
print sbeMsg, sbeFix, sbeMDEntries | |
data = f.read(16) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment