Skip to content

Commit

Permalink
Merge pull request #434 from h2o/toru/qlog-draft02
Browse files Browse the repository at this point in the history
QLog draft-02 support
  • Loading branch information
toru authored Feb 12, 2021
2 parents e6df839 + 62059ab commit a9498b4
Showing 1 changed file with 46 additions and 38 deletions.
84 changes: 46 additions & 38 deletions misc/qlog-adapter.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,16 @@
PACKET_LABELS = ["initial", "0rtt", "handshake", "1rtt"]

def handle_packet_lost(events, idx):
return [events[idx]["time"], "recovery", "packet_lost", {
"packet_type": PACKET_LABELS[events[idx]["packet-type"]],
"header": {
"packet_number": events[idx]["pn"]
return {
"time": events[idx]["time"],
"name": "recovery:packet_lost",
"data": {
"header": {
"packet_type": PACKET_LABELS[events[idx]["packet-type"]],
"packet_number": events[idx]["pn"]
}
}
}]
}

def handle_packet_received(events, idx):
frames = []
Expand All @@ -54,13 +58,17 @@ def handle_packet_received(events, idx):
if handler:
frames.append(handler(ev))

return [events[idx]["time"], "transport", "packet_received", {
"packet_type": PACKET_LABELS[events[idx]["packet-type"]],
"header": {
"packet_number": events[idx]["pn"]
},
"frames": frames
}]
return {
"time": events[idx]["time"],
"name": "transport:packet_received",
"data": {
"header": {
"packet_type": PACKET_LABELS[events[idx]["packet-type"]],
"packet_number": events[idx]["pn"]
},
"frames": frames
}
}

def handle_packet_sent(events, idx):
frames = []
Expand All @@ -71,13 +79,17 @@ def handle_packet_sent(events, idx):
frames.append(handler(events[i]))
i -= 1

return [events[idx]["time"], "transport", "packet_sent", {
"packet_type": PACKET_LABELS[events[idx]["packet-type"]],
"header": {
"packet_number": events[idx]["pn"]
},
"frames": frames
}]
return {
"time": events[idx]["time"],
"name": "transport:packet_sent",
"data": {
"header": {
"packet_type": PACKET_LABELS[events[idx]["packet-type"]],
"packet_number": events[idx]["pn"]
},
"frames": frames
}
}

def handle_ack_send(event):
return render_ack_frame([[event["largest-acked"]]])
Expand Down Expand Up @@ -333,28 +345,24 @@ def main():

(_, infile) = sys.argv
source_events = load_quicly_events(infile)
trace = {
"vantage_point": {
"type": "server"
},
"event_fields": [
"time",
"category",
"event",
"data"
],
"events": []
}
for i, event in enumerate(source_events):
handler = QLOG_EVENT_HANDLERS.get(event["type"])
if handler:
trace["events"].append(handler(source_events, i))

print(json.dumps({
"qlog_version": "draft-02-wip",
"qlog_format": "NDJSON",
"qlog_version": "draft-02",
"title": "h2o/quicly qlog",
"traces": [trace]
"trace": {
"vantage_point": {
"type": "server"
},
"common_fields": {
"protocol_type": "QUIC_HTTP3",
"time_format": "absolute"
}
}
}))
for i, event in enumerate(source_events):
handler = QLOG_EVENT_HANDLERS.get(event["type"])
if handler:
print(json.dumps(handler(source_events, i)))

if __name__ == "__main__":
main()

0 comments on commit a9498b4

Please sign in to comment.