Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Perl Misc > Program printing all possible combinations of TCP flags

Thread Tools

Program printing all possible combinations of TCP flags

Rainer Weikusat
Posts: n/a
Main function of this program is/was to generate a list of C string
literals used to populate an array which can be used to map the
numerical value of the flags field in a TCP header to a string
containing an uppercase letter (Fin, Syn, Rst, Psh, Ack, Urg) for each
set flag. Since it is kind-of cute an the algorithm is (IMHO) not
completely trivial/ obvious anymore, I thought I'd just post it here:

NB: This is fairly fast at the expense of possibly consuming huge
amounts of memory.


my @flags = qw(F S R P A U);

my @all;

push(@all, '');

for my $f (@flags) {
push(@all, map { $_.$f; } @all);

printf("\"%s\",\n", $_) for (@all);
Reply With Quote

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: Quetion about flags of socket.recv(bufsize, [flags]) Steve Holden Python 0 02-08-2009 04:09 PM
All possible letter combinations? Teme Rosi Ruby 3 12-16-2008 12:02 AM
iterator? way of generating all possible combinations? Python 16 05-31-2006 04:45 PM
all possible combinations rbt Python 36 07-28-2005 02:01 PM
How to make combinations of an array to produce all possible expressions? Erik Terpstra Ruby 9 05-17-2004 07:30 AM