The invention relates to the field of network flow collection and analysis, in particular to a full-stack
path tracking method and
system based on
network analysis and electronic device.The method comprises the steps that data packets are collected from key network nodes, and key indexes of the data packets are extracted through TCP analysis; constructing a session
record which takes a composite key as a
unique identifier and aggregates the key indexes; inputting identification information of a target session, and querying all related sessions of
bidirectional traffic of the target session in the session
record; dividing the queried sessions into a session set of a request path from the
client to the
server and a session set of a response path from the
server to the
client, and sorting the session sets of the request path and the response path by using a non-
insertion association
algorithm; and determining a final path according to a sorting result. According to the method, a communication path can be completely restored without implanting codes, and low-intrusion and high-reliability full-stack traffic tracking and visual analysis are realized.