Heteroclinic.net logo

www.heteroclinic.net

Regular Expression for IPV4
Discussion of the Grammar
Checking servers' log is the basic task for system administrators. We always need to find the burried information. For example, the IPV4 addresses recorded in different log files.

First, we discuss the regular expression for ASCII strings represent number 0 to 255. To show it clearly, we didn't merge the identical entries.
Latex formula:

regexipv40to255.jpg

We draw the digram of the spanning tree for ASCII strings represent number 0 to 255.

regexipv40to255spantree.jpg



Second, we discuss the regular expression for an IP address V4 $P$for private network.

regexipv4p.jpg

But search strings matching pattern $P$ is not sufficient. For examples, 025.13.23.34, or 10.12.13.14.someisp.com, or 1.2.3.4.5.6.7 are not the information we are seeking. So the grammar is not context free. We need a wrapper pattern to validate a minimum context that the objective pattern is in. This wrapper pattern is dfined as $W$. Our assumption is that a valid string of ip address is delimited by a character that is not [0-9] or `.', or by begin of line `\verb|^| ' and end of line `\$'.

regexipv4w.jpg

Regular Expression for IPV4
Practice with egrep
W e give the example by using egrep.

The example file `atest.txt':

The results, we believe masks and broadcasts are valid ip addresses:

Some other log examples. The ip address may not be delimited by white spaces. iptables:

A log4j item

It is produced by the following Java lines.

If you find something wrong, please leave me a message by email.
Concurrency Basics:
V. Different Sleeping Values
Our updated version of program is

We set different sleeping value in the main function to observe how the program behave. We know set ll as 1000ms, ul as 3000ms.
First we set Sleep(800).

Second we set Sleep(2000).

Third we set Sleep(5000).

From the above experiments, we know all the child threads exit as the main function terminated. Our current implementation doesn't show each child thread status if we end our program in such a way. So we know why need the condition variables. The usage will be shown in the next section.
Concurrency Basics:
VI. Use Condition Variable
We modify the program accordingly.

Again we try to let the threads terminate prematurely by Sleep(800).

Now we can check the child threads' status.