diff --git a/tangostationcontrol/tangostationcontrol/devices/sdp/statistics_packet.py b/tangostationcontrol/tangostationcontrol/devices/sdp/statistics_packet.py
index c98ae9b5bdc604e8a55480cc5473e658b10cefa1..59c74e296c2eebdd677d448bdae523be8d149934 100644
--- a/tangostationcontrol/tangostationcontrol/devices/sdp/statistics_packet.py
+++ b/tangostationcontrol/tangostationcontrol/devices/sdp/statistics_packet.py
@@ -75,13 +75,13 @@ class StatisticsPacket(object):
                 "Invalid SDP statistics packet: packet marker (first byte) is {}, not one of 'SBX'.".format(
                     self.marker))
 
+    # format string for the header, see unpack below
+    header_format = ">cBL HHB BHL BBH HQ"
+    header_size = struct.calcsize(header_format)
+
     def unpack(self):
         """ Unpack the packet into properties of this object. """
 
-        # format string for the header, see unpack below
-        self.header_format = ">cBL HHB BHL BBH HQ"
-        self.header_size = struct.calcsize(self.header_format)
-
         # unpack fields
         try:
             (self.marker_raw,
@@ -335,11 +335,35 @@ def main(args=None, **kwargs):
     import sys
     import pprint
 
-    # read all of stdin, even though we only parse the first packet. we're too lazy to intelligently decide when
-    # the packet is complete and can stop reading.
-    data = sys.stdin.buffer.read()
-    packet = SSTPacket(data)
-
-    # print header & payload
-    pprint.pprint(packet.header())
-    pprint.pprint(packet.payload)
+    # packet counter
+    nr = 0
+
+    # byte offset in the stream
+    offset = 0
+
+    while True:
+        # read just the header
+        header = sys.stdin.buffer.read(StatisticsPacket.header_size)
+        if not header:
+            break
+
+        # read the payload
+        packet = StatisticsPacket(header)
+        payload_size = packet.expected_size() - len(header)
+        payload = sys.stdin.buffer.read(payload_size)
+
+        # construct the packet based on type
+        if packet.marker == 'S':
+            packet = SSTPacket(header + payload)
+        elif packet.marker == 'X':
+            packet = XSTPacket(header + payload)
+        elif packet.marker == 'B':
+            packet = BSTPacket(header + payload)
+
+        # print header
+        print(f"# Packet {nr} starting at offset {offset}")
+        pprint.pprint(packet.header())
+
+        # increment counters
+        nr += 1
+        offset += len(header) + len(payload)