parsing ip packets

Javier París <>
Wed May 3 18:47:11 CEST 2006


El Miércoles, 3 de Mayo de 2006 18:10, a escribió:
> Hello,
>
> I am new learning erlang ... are there examples of parsing a ip
> packet to determine what time ?

Parsing a (binary) ip packet would be something like..
 
<<4:4/integer,          % Ip Version
     Hd_Len:4/integer,      % Header Length
     Tos:8/integer,           % Tos 
     Len:16/big-integer,    % Packet Length
     Frg_Id:16/big-integer, % Fragment Id
     _:2/integer,           % Two first flags... bah
     Mf:1/integer,          % More Fragments flag
     Offset:13/big-integer, % Fragment Offset
     TTL:8/integer,           % TTL 
     Protocol:8/integer,    % Upper layer protocol
     Checksum:16/big-integer,      % Checksum
     Src_Ip:32/big-integer, % Where this pile of shit came from...
     Dst_Ip:32/big-integer, % Should check this against our Ip
     Options/binary>> = Ip_Header, % Options

This would be for a rfc791 Ip packet. That is, it is a bit outdated.
(For example, TOS isn't used anymore, and that field is used
for explicit congestion notification, among other things).

Regards.



More information about the erlang-questions mailing list