How to monitor session is not existing between two IP address on specific port
I like to monitor the session between two IP address and it that session is break do specific task. Is it possible to monitor like this using tshark at command line??
Wireshark is not the tool for that purpose, but it may be useful to analyse how that particular session should look like when it is active, i.e. to determine the criteria based on which a purpose-made application would use to identify the break of the session.
Unless there is some permanent, albeit low, traffic in the monitored session, it may be impossible at all to determine the break. A TCP session may remain established for days with no packets being exchanged.
This may be possible if you used a script to monitor the output of tshark and then react to it. It depends what you are trying to do exactly and the conditions that have to be met. I think more information is required to give a complete answer.
@csereno, there is a deep trap in this idea. Neither tshark nor Wireshark can run continuously forever, as while dissecting packets, they build and keep a lot of state information related to sessions etc. which continuously grows until it occupies all the avalilable RAM sooner or later. You can run dumpcap forever, but it does not dissect packets.
@sindy, You are correct when running tshark's native commands. However, there are workarounds with scripting. I have been using tshark in a similar manner running for over 6 months now without filling file storage or RAM to pull LDAP information for an admin. That's why we would need more information in this case, and the solution would have to be scripted.
If by "scripting" you have in mind running several instances of tshark one after another with a short overlap between each pair of them, then yes. If you've been running a single instance of tshark for months, and moreover, handling a TCP-based protocol, my understanding of the world got just shaken to the roots :-)