reduced duplicated code for ping and trace by adding a common session handler