Refactoring packet communication into abstract messaging