At work, I've been assigned to find the application dependency mapping of a legacy application. They're in the process of migrating to the cloud, so they need to have a clear understanding of the application's dependencies. I've looked up open-source projects but couldn't find any. So I decided to write my own program.
The initial idea was to monitor the network traffic and, if the dependent application is on the same server, find the process ID of the application listening on the port. But I ran into a problem: when the application sends the request, it's via an ephemeral port, so I'm not able to find the process ID using the port number. Which made me think, Is this even a valid approach?
How can I tackle this problem?