An Iranian warship has sunk off the coast of Sri Lanka, with the Sri Lankan authorities saying on Wednesday they had rescued 32 people who were on board and recovered several bodies from the sea.