Synthia
Generic and flexible data structure generator
examples.apache.GenerateLog Class Reference

Detailed Description

Main program that generates the simulated log file interleaving multiple visitor instances.

Site map

The generation of the site map recycles the Barabási–Albert model from {@linkplain BarabasiAlbert another example}. A scale-free graph of a randomly selected number of nodes is first generated; the graph results in a few nodes with high degree (corresponding to "main" pages) and a majority of nodes with low degree. A StringPattern picker produces filenames for each node using randomly generated strings and appending the html extension to each of them. An example of such a map is shown below:

Example of site map

The site map is then turned into a MarkovChain, where each undirected edge between vertices A and B stands both for a link between A and B, and vice versa. Each outgoing edge of a given vertex is given the same probability.

Visitors

A visitor is a LogLinePicker that is fed with a picker for its IP address, another one providing page names, and a last one providing a timestamp.

The IP addresses for each visitor are pseudo-randomly generated using a StringPattern picker, with different probabilities associated to different regions. For the purpose of the simulation:

  • addresses of the form 11.x.x.x are considered to be in the USA and have a 1/2 probability of being generated
  • addresses of the form 10.x.x.x are considered to be in Canada and have a 1/3 probability of being generated
  • addresses in the range form 20.x.x.x-60.x.x.x are considered to be in Europe and have a 1/6 probability of being generated

The picker for page names is an instance of the Markov chain defined previously. It should be noted that the VisitorPicker gives a distinct copy of the chain to each visitor; hence, each visitor does its own independent random walk, but the site map they use is the same for all.

Finally, the picker for the timestamp is an instance of Tick, which randomly increments a timestamp counter every time it is called. Note that the same Tick instance is shared by all visitors, which ensures that the global timestamp increments on each page load, regardless of which visitor requested the page.

Generating the log

To simulate the action of multiple visitors in the site, it then suffices to pass the VisitorPicker to an instance of Knit, which takes care of creating new visitors and interleaving the progression of each of them. Each call to pick() selects one visitor, takes a transition, and outputs the log line resulting from the corresponding simulated page request.

A typical run of the program looks like this:

11.205.232.45 - - [26-Oct-1985 01:21:00 EDT 0] "GET J0.html HTTP/2" 200 1000
11.130.222.207 - - [26-Oct-1985 01:21:04 EDT 0] "GET Xv.html HTTP/2" 200 1000
11.130.222.207 - - [26-Oct-1985 01:21:09 EDT 0] "GET 9y.html HTTP/2" 200 1000
11.16.2.198 - - [26-Oct-1985 01:21:17 EDT 0] "GET Xv.html HTTP/2" 200 1000
11.130.222.207 - - [26-Oct-1985 01:21:27 EDT 0] "GET t0.html HTTP/2" 200 1000
45.86.208.44 - - [26-Oct-1985 01:21:29 EDT 0] "GET b7.html HTTP/2" 200 1000
10.112.251.183 - - [26-Oct-1985 01:21:34 EDT 0] "GET b7.html HTTP/2" 200 1000
11.130.222.207 - - [26-Oct-1985 01:21:40 EDT 0] "GET 9y.html HTTP/2" 200 1000
11.16.2.198 - - [26-Oct-1985 01:21:41 EDT 0] "GET 9y.html HTTP/2" 200 1000
45.86.208.44 - - [26-Oct-1985 01:21:45 EDT 0] "GET 9y.html HTTP/2" 200 1000
…

Exercises

  1. Modify the scenario so that each page is assigned a randomly selected size, instead of the constant "1000" that appears on each line. For a given page, make sure that the same size is always shown.
  2. Modify the Markov chain to add a sink state accessible from every state, and which will cause a visitor to "leave" the site (i.e. no longer produce any new page request).
  3. Modify the scenario so that some pages actually do not exist, and result in a return code of 404 instead of 200 (next to last element of each log line).

Definition at line 125 of file GenerateLog.java.

Static Public Member Functions

static void main (String[] args)
 

Member Function Documentation

◆ main()

static void examples.apache.GenerateLog.main ( String[]  args)
static

Definition at line 128 of file GenerateLog.java.


The documentation for this class was generated from the following file: