Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Protocol of a packet

I'm programming an offline packets decoding program in C under Windows 7 x86.

I wonder how it is possible to know packet protocol, either if it is UDP or TCP?

like image 692
Medardas Avatar asked Feb 22 '23 07:02

Medardas


1 Answers

You can know by checking the IP packet header, there is a Protocol field in the packet header that is used to indicate the type of the packet according to its value :

  • 1 is ICMP
  • 6 is TCP
  • 17 is UDP

and so on. More information on this is available on Wikipedia

Edit: Here's the list of all the possible values for that field.

P.S: I'm assuming IPv4 here, I don't know if things are the same with IPv6

like image 195
Nasreddine Avatar answered Feb 24 '23 21:02

Nasreddine