finally managed to add functions to detect TCP connection establishment and termination