Refactor packet capacity calculation