Marcelo has asked for the wisdom of the Perl Monks concerning the following question:

How to set the DSCP field (or TOS) byte in IP packet headers from Perl? (Maybe setsockopt could be used for that?) Could you please provide an example? Thanks!

Replies are listed 'Best First'.
Re: DSCP/TOS byte marking?
by starbolin (Hermit) on Feb 25, 2005 at 03:21 UTC
    From CPAN:

    use Net::Packet::Frame; my $frame = Net::Packet::Frame->new(l3 => $ip, l4 => $tcp); $frame->send;

    or

    use NetPacket::Ethernet; $eth_pkt = NetPacket::Ethernet->encode(params...);

    CPAN documentation still reports this as unimplemented but functional versions are available.

      Thanks! I was reading the Net::Ping module, and it looks like something like
      # SOL_IP = 0, IP_TOS = 1 setsockopt(S, 0, 1, pack("I*", $tos));
      should work too...