Invitation dialog could be in two states

"Ringing"
or
accepted invitation.

Consider A invited B first.
----------------------------------------
[ using BYE ]
When A used BYE, got response 200 ok from B in both situations.
But SIP server dont show that A sended BYE.

PROBLEM : After this if B invites A, SIP server sends 486 busy( generated by server) once to B and then 180 ringing(generated by A) response.


[using CANCEL ]
SIP server showed CANCEL, ack for CANCEL and 487 Request Terminated.

PROBLEM : B did not got any request for cancellation.

I wan know what's correct method to cancel invitation in both situations ?