1 /* Copyright (c) 2012, 2014. The SimGrid Team.
2 * All rights reserved. */
4 /* This program is free software; you can redistribute it and/or modify it
5 * under the terms of the license (GNU LGPL) which comes with this package. */
7 #include "simgrid/platf_generator.h"
8 #include "platf_generator_private.h"
10 #include "xbt/RngStream.h"
11 #include "surf/simgrid_dtd.h"
12 #include "surf_private.h"
15 XBT_LOG_NEW_DEFAULT_SUBCATEGORY(platf_generator, surf, "Platform Generator");
17 static xbt_graph_t platform_graph = NULL;
18 static xbt_dynar_t promoter_dynar = NULL;
19 static xbt_dynar_t labeler_dynar = NULL;
21 static RngStream rng_stream = NULL;
23 static unsigned long last_link_id = 0;
25 xbt_graph_t platf_graph_get(void) {
26 // We need some debug, so let's add this function
27 // WARNING : should be removed when it becomes useless
28 return platform_graph;
32 * \brief Set the seed of the platform generator RngStream
34 * This RngStream is used to generate all the random values needed to
35 * generate the platform
37 * \param seed A array of six integer; if NULL, the default seed will be used.
39 void platf_random_seed(unsigned long seed[6]) {
41 if(rng_stream == NULL) {
42 //stream not created yet, we do it now
43 rng_stream = RngStream_CreateStream(NULL);
46 RngStream_SetSeed(rng_stream, seed);
51 * \brief Initialize the platform generator
53 * This function create the graph and add node_count nodes to it
54 * \param node_count The number of nodes of the platform
56 void platf_graph_init(unsigned long node_count) {
58 platform_graph = xbt_graph_new_graph(FALSE, NULL);
59 if(rng_stream == NULL) {
60 rng_stream = RngStream_CreateStream(NULL);
63 for(i=0 ; i<node_count ; i++) {
64 context_node_t node_data = NULL;
65 node_data = xbt_new0(s_context_node_t, 1);
69 node_data->degree = 0;
70 node_data->kind = ROUTER;
71 node_data->connect_checked = FALSE;
72 xbt_graph_new_node(platform_graph, (void*) node_data);
80 * \brief Connect two nodes
81 * \param node1 The first node to connect
82 * \param node2 The second node to connect
84 void platf_node_connect(xbt_node_t node1, xbt_node_t node2) {
85 context_node_t node1_data;
86 context_node_t node2_data;
87 node1_data = (context_node_t) xbt_graph_node_get_data(node1);
88 node2_data = (context_node_t) xbt_graph_node_get_data(node2);
92 context_edge_t edge_data = NULL;
93 edge_data = xbt_new0(s_context_edge_t, 1);
94 edge_data->id = ++last_link_id;
95 edge_data->length = platf_node_distance(node1, node2);
96 edge_data->labeled = FALSE;
97 xbt_graph_new_edge(platform_graph, node1, node2, (void*)edge_data);
101 * \brief Compute the distance between two nodes
102 * \param node1 The first node
103 * \param node2 The second node
104 * \return The distance between node1 and node2
106 double platf_node_distance(xbt_node_t node1, xbt_node_t node2) {
107 context_node_t node1_data;
108 context_node_t node2_data;
112 node1_data = (context_node_t) xbt_graph_node_get_data(node1);
113 node2_data = (context_node_t) xbt_graph_node_get_data(node2);
114 delta_x = node1_data->x - node2_data->x;
115 delta_y = node1_data->y - node2_data->y;
116 distance = sqrt(delta_x*delta_x + delta_y*delta_y);
121 * \brief Initialize the platform, placing nodes uniformly on the unit square
122 * \param node_count The number of node
124 void platf_graph_uniform(unsigned long node_count) {
125 xbt_dynar_t dynar_nodes = NULL;
126 xbt_node_t graph_node = NULL;
127 context_node_t node_data = NULL;
129 platf_graph_init(node_count);
130 dynar_nodes = xbt_graph_get_nodes(platform_graph);
131 xbt_dynar_foreach(dynar_nodes, i, graph_node) {
132 node_data = (context_node_t) xbt_graph_node_get_data(graph_node);
133 node_data->x = RngStream_RandU01(rng_stream);
134 node_data->y = RngStream_RandU01(rng_stream);
139 * \brief Initialize the platform, placing nodes in little clusters on the unit square
140 * \param node_count The number of node
142 void platf_graph_heavytailed(unsigned long node_count) {
143 xbt_dynar_t dynar_nodes = NULL;
144 xbt_node_t graph_node = NULL;
145 context_node_t node_data = NULL;
147 platf_graph_init(node_count);
148 dynar_nodes = xbt_graph_get_nodes(platform_graph);
149 xbt_dynar_foreach(dynar_nodes, i, graph_node) {
150 node_data = (context_node_t) xbt_graph_node_get_data(graph_node);
151 node_data->x = random_pareto(0, 1, 1.0/*K*/, 10e9/*P*/, 1.0/*alpha*/);
152 node_data->y = random_pareto(0, 1, 1.0/*K*/, 10e9/*P*/, 1.0/*alpha*/);
157 * \brief Creates a simple topology where all nodes are connected to the first one in a star fashion
159 void platf_graph_interconnect_star(void) {
160 xbt_dynar_t dynar_nodes = NULL;
161 xbt_node_t graph_node = NULL;
162 xbt_node_t first_node = NULL;
165 dynar_nodes = xbt_graph_get_nodes(platform_graph);
166 xbt_dynar_foreach(dynar_nodes, i, graph_node) {
168 //Ok, we get the first node, let's keep it somewhere...
169 first_node = graph_node;
171 //All the other nodes are connected to the first one
172 platf_node_connect(graph_node, first_node);
178 * \brief Creates a simple topology where all nodes are connected in line
180 void platf_graph_interconnect_line(void) {
181 xbt_dynar_t dynar_nodes = NULL;
182 xbt_node_t graph_node = NULL;
183 xbt_node_t old_node = NULL;
186 dynar_nodes = xbt_graph_get_nodes(platform_graph);
187 xbt_dynar_foreach(dynar_nodes, i, graph_node) {
188 if(old_node != NULL) {
189 platf_node_connect(graph_node, old_node);
191 old_node = graph_node;
196 * \brief Create a simple topology where all nodes are connected along a ring
198 void platf_graph_interconnect_ring(void) {
199 xbt_dynar_t dynar_nodes = NULL;
200 xbt_node_t graph_node = NULL;
201 xbt_node_t old_node = NULL;
202 xbt_node_t first_node = NULL;
205 dynar_nodes = xbt_graph_get_nodes(platform_graph);
206 xbt_dynar_foreach(dynar_nodes, i, graph_node) {
208 // this is the first node, let's keep it somewhere
209 first_node = graph_node;
211 //connect each node to the previous one
212 platf_node_connect(graph_node, old_node);
214 old_node = graph_node;
216 //we still have to connect the first and the last node together
217 platf_node_connect(first_node, graph_node);
221 * \brief Create a simple topology where all nodes are connected to each other, in a clique manner
223 void platf_graph_interconnect_clique(void) {
224 xbt_dynar_t dynar_nodes = NULL;
225 xbt_node_t first_node = NULL;
226 xbt_node_t second_node = NULL;
229 dynar_nodes = xbt_graph_get_nodes(platform_graph);
230 xbt_dynar_foreach(dynar_nodes, i, first_node) {
231 xbt_dynar_foreach(dynar_nodes, j, second_node) {
234 platf_node_connect(first_node, second_node);
240 * \brief Creates a topology where the probability to connect two nodes is uniform (unrealistic, but simple)
241 * \param alpha Probability for two nodes to get connected
243 void platf_graph_interconnect_uniform(double alpha) {
244 xbt_dynar_t dynar_nodes = NULL;
245 xbt_node_t first_node = NULL;
246 xbt_node_t second_node = NULL;
249 dynar_nodes = xbt_graph_get_nodes(platform_graph);
250 xbt_dynar_foreach(dynar_nodes, i, first_node) {
251 xbt_dynar_foreach(dynar_nodes, j, second_node) {
254 if(RngStream_RandU01(rng_stream) < alpha) {
255 platf_node_connect(first_node, second_node);
262 * \brief Create a topology where the probability follows an exponential law
263 * \param alpha Number of edges increases with alpha
265 void platf_graph_interconnect_exponential(double alpha) {
266 xbt_dynar_t dynar_nodes = NULL;
267 xbt_node_t first_node = NULL;
268 xbt_node_t second_node = NULL;
270 double L = sqrt(2.0); /* L = c*sqrt(2); c=side of placement square */
271 dynar_nodes = xbt_graph_get_nodes(platform_graph);
272 xbt_dynar_foreach(dynar_nodes, i, first_node) {
273 xbt_dynar_foreach(dynar_nodes, j, second_node) {
276 double d = platf_node_distance(first_node, second_node);
277 if(RngStream_RandU01(rng_stream) < alpha*exp(-d/(L-d))) {
278 platf_node_connect(first_node, second_node);
285 * \brief Create a topology where the probability follows the model of Waxman
287 * see Waxman, Routing of Multipoint Connections, IEEE J. on Selected Areas in Comm., 1988
289 * \param alpha Number of edges increases with alpha
290 * \param beta Edge length heterogeneity increases with beta
292 void platf_graph_interconnect_waxman(double alpha, double beta) {
293 xbt_dynar_t dynar_nodes = NULL;
294 xbt_node_t first_node = NULL;
295 xbt_node_t second_node = NULL;
297 double L = sqrt(2.0); /* L = c*sqrt(2); c=side of placement square */
298 dynar_nodes = xbt_graph_get_nodes(platform_graph);
299 xbt_dynar_foreach(dynar_nodes, i, first_node) {
300 xbt_dynar_foreach(dynar_nodes, j, second_node) {
303 double d = platf_node_distance(first_node, second_node);
304 if(RngStream_RandU01(rng_stream) < alpha*exp(-d/(L*beta))) {
305 platf_node_connect(first_node, second_node);
312 * \brief Create a topology where the probability follows the model of Zegura
313 * see Zegura, Calvert, Donahoo, A quantitative comparison of graph-based models
314 * for Internet topology, IEEE/ACM Transactions on Networking, 1997.
316 * \param alpha Probability of connexion for short edges
317 * \param beta Probability of connexion for long edges
318 * \param r Limit between long and short edges (between 0 and sqrt(2) since nodes are placed on the unit square)
320 void platf_graph_interconnect_zegura(double alpha, double beta, double r) {
321 xbt_dynar_t dynar_nodes = NULL;
322 xbt_node_t first_node = NULL;
323 xbt_node_t second_node = NULL;
325 dynar_nodes = xbt_graph_get_nodes(platform_graph);
326 xbt_dynar_foreach(dynar_nodes, i, first_node) {
327 xbt_dynar_foreach(dynar_nodes, j, second_node) {
330 double d = platf_node_distance(first_node, second_node);
331 double proba = d < r ? alpha : beta;
332 if(RngStream_RandU01(rng_stream) < proba) {
333 platf_node_connect(first_node, second_node);
340 * \brief Create a topology constructed according to the Barabasi-Albert algorithm (follows power laws)
341 * see Barabasi and Albert, Emergence of scaling in random networks, Science 1999, num 59, p509Â-512.
343 void platf_graph_interconnect_barabasi(void) {
344 xbt_dynar_t dynar_nodes = NULL;
345 xbt_node_t first_node = NULL;
346 xbt_node_t second_node = NULL;
347 context_node_t node_data = NULL;
349 unsigned long sum = 0;
350 dynar_nodes = xbt_graph_get_nodes(platform_graph);
351 xbt_dynar_foreach(dynar_nodes, i, first_node) {
352 xbt_dynar_foreach(dynar_nodes, j, second_node) {
355 node_data = xbt_graph_node_get_data(second_node);
356 if(sum==0 || RngStream_RandU01(rng_stream) < ((double)(node_data->degree)/ (double)sum)) {
357 platf_node_connect(first_node, second_node);
365 * \brief Check if the produced graph is connected
367 * You should check if the produced graph is connected before doing anything
368 * on it. You probably don't want any isolated node or group of nodes...
370 * \return TRUE if the graph is connected, FALSE otherwise
372 int platf_graph_is_connected(void) {
373 xbt_dynar_t dynar_nodes = NULL;
374 xbt_dynar_t connected_nodes = NULL;
375 xbt_dynar_t outgoing_edges = NULL;
376 xbt_node_t graph_node = NULL;
377 context_node_t node_data = NULL;
378 xbt_edge_t outedge = NULL;
379 unsigned long iterator;
381 dynar_nodes = xbt_graph_get_nodes(platform_graph);
382 connected_nodes = xbt_dynar_new(sizeof(xbt_node_t), NULL);
384 //Let's just check if every nodes are connected to something
385 xbt_dynar_foreach(dynar_nodes, i, graph_node) {
386 node_data = xbt_graph_node_get_data(graph_node);
387 if(node_data->degree==0) {
392 //We still need a real check
393 //Initialize the connected node array with the first node
394 xbt_dynar_get_cpy(dynar_nodes, 0, &graph_node);
395 node_data = xbt_graph_node_get_data(graph_node);
396 node_data->connect_checked = TRUE;
397 xbt_dynar_push(connected_nodes, &graph_node);
401 xbt_dynar_get_cpy(connected_nodes, iterator, &graph_node);
402 node_data = xbt_graph_node_get_data(graph_node);
404 //add all the linked nodes to the connected node array
405 outgoing_edges = xbt_graph_node_get_outedges(graph_node);
406 xbt_dynar_foreach(outgoing_edges, i, outedge) {
407 xbt_node_t src = xbt_graph_edge_get_source(outedge);
408 xbt_node_t dst = xbt_graph_edge_get_target(outedge);
409 node_data = xbt_graph_node_get_data(src);
410 if(!node_data->connect_checked) {
411 xbt_dynar_push(connected_nodes, &src);
412 node_data->connect_checked = TRUE;
414 node_data = xbt_graph_node_get_data(dst);
415 if(!node_data->connect_checked) {
416 xbt_dynar_push(connected_nodes, &dst);
417 node_data->connect_checked = TRUE;
420 } while(++iterator < xbt_dynar_length(connected_nodes));
422 // The graph is connected if the connected node array has the same length
423 // as the graph node array
424 return xbt_dynar_length(connected_nodes) == xbt_dynar_length(dynar_nodes);
429 * \brief Remove the links in the created topology
431 * This is useful when the created topology is not connected, and you want
432 * to generate a new one.
434 void platf_graph_clear_links(void) {
435 xbt_dynar_t dynar_nodes = NULL;
436 xbt_dynar_t dynar_edges = NULL;
437 xbt_dynar_t dynar_edges_cpy = NULL;
438 xbt_node_t graph_node = NULL;
439 xbt_edge_t graph_edge = NULL;
440 context_node_t node_data = NULL;
443 //The graph edge dynar will be modified directly, so we work on a copy of it
444 dynar_edges = xbt_graph_get_edges(platform_graph);
445 dynar_edges_cpy = xbt_dynar_new(sizeof(xbt_edge_t), NULL);
446 xbt_dynar_foreach(dynar_edges, i, graph_edge) {
447 xbt_dynar_push_as(dynar_edges_cpy, xbt_edge_t, graph_edge);
449 //Delete edges from the graph
450 xbt_dynar_foreach(dynar_edges_cpy, i, graph_edge) {
451 xbt_graph_free_edge(platform_graph, graph_edge, xbt_free);
453 //remove the dynar copy
454 xbt_dynar_free(&dynar_edges_cpy);
456 //All the nodes will be of degree 0, unchecked from connectedness
457 dynar_nodes = xbt_graph_get_nodes(platform_graph);
458 xbt_dynar_foreach(dynar_nodes, i, graph_node) {
459 node_data = xbt_graph_node_get_data(graph_node);
460 node_data->degree = 0;
461 node_data->connect_checked = FALSE;
466 * \brief Promote a node to a host
468 * This function should be called in callbacks registered with the
469 * platf_graph_promoter function.
471 * \param node The node to promote
472 * \param parameters The parameters needed to build the host
474 void platf_graph_promote_to_host(context_node_t node, sg_platf_host_cbarg_t parameters) {
476 memcpy(&(node->host_parameters), parameters, sizeof(s_sg_platf_host_cbarg_t));
480 * \brief Promote a node to a cluster
482 * This function should be called in callbacks registered with the
483 * platf_graph_promoter function.
485 * \param node The node to promote
486 * \param parameters The parameters needed to build the cluster
488 void platf_graph_promote_to_cluster(context_node_t node, sg_platf_cluster_cbarg_t parameters) {
489 node->kind = CLUSTER;
490 memcpy(&(node->cluster_parameters), parameters, sizeof(s_sg_platf_cluster_cbarg_t));
494 * \brief Set the parameters of a network link.
496 * This function should be called in callbacks registered with the
497 * platf_graph_labeler function.
499 * \param edge The edge to modify
500 * \param parameters The parameters of the network link
502 void platf_graph_link_label(context_edge_t edge, sg_platf_link_cbarg_t parameters) {
503 memcpy(&(edge->link_parameters), parameters, sizeof(s_sg_platf_link_cbarg_t));
504 edge->labeled = TRUE;
508 * \brief Register a callback to promote nodes
510 * The best way to promote nodes into host or cluster is to write a function
511 * which takes one parameter, a #context_node_t, make every needed test on
512 * it, and call platf_graph_promote_to_host or platf_graph_promote_to_cluster
513 * if needed. Then, register the function with this one.
514 * You can register several callbacks: the first registered function will be
515 * called first. If the node have not been promoted yet, the second function
516 * will be called, and so on...
518 * \param promoter_callback The callback function
520 void platf_graph_promoter(platf_promoter_cb_t promoter_callback) {
521 if(promoter_dynar == NULL) {
522 promoter_dynar = xbt_dynar_new(sizeof(platf_promoter_cb_t), NULL);
524 xbt_dynar_push(promoter_dynar, &promoter_callback);
528 * \brief Register a callback to label links
530 * Like the node promotion, it is better, to set links, to write a function
531 * which take one parameter, a #context_edge_t, make every needed test on
532 * it, and call platf_graph_link_label if needed.
533 * You can register several callbacks: the first registered function will be
534 * called first. If the link have not been labeled yet, the second function
535 * will be called, and so on... All the links must have been labeled after
538 * \param labeler_callback The callback function
540 void platf_graph_labeler(platf_labeler_cb_t labeler_callback) {
541 if(labeler_dynar == NULL) {
542 labeler_dynar = xbt_dynar_new(sizeof(void*), NULL);
544 xbt_dynar_push(labeler_dynar, &labeler_callback);
548 * \brief Call the registered promoters on all nodes
550 * The promoters are called on all nodes, in the order of their registration
551 * If some nodes are not promoted, they will be routers
553 void platf_do_promote(void) {
554 platf_promoter_cb_t promoter_callback;
555 xbt_node_t graph_node = NULL;
556 xbt_dynar_t dynar_nodes = NULL;
557 context_node_t node = NULL;
559 dynar_nodes = xbt_graph_get_nodes(platform_graph);
560 xbt_dynar_foreach(dynar_nodes, i, graph_node) {
561 node = (context_node_t) xbt_graph_node_get_data(graph_node);
562 xbt_dynar_foreach(promoter_dynar, j, promoter_callback) {
563 if(node->kind != ROUTER)
565 promoter_callback(node);
571 * \brief Call the registered labelers on all links
573 void platf_do_label(void) {
574 platf_labeler_cb_t labeler_callback;
575 xbt_edge_t graph_edge = NULL;
576 xbt_dynar_t dynar_edges = NULL;
577 context_edge_t edge = NULL;
579 dynar_edges = xbt_graph_get_edges(platform_graph);
580 xbt_dynar_foreach(dynar_edges, i, graph_edge) {
581 edge = (context_edge_t) xbt_graph_edge_get_data(graph_edge);
582 xbt_dynar_foreach(labeler_dynar, j, labeler_callback) {
585 labeler_callback(edge);
588 XBT_ERROR("All links of the generated platform are not labeled.");
589 xbt_die("Please check your generation parameters.");
595 * \brief putting into SURF the generated platform
597 * This function should be called when the generation is over and the platform
598 * is ready to be put in place in SURF. All the init function, like MSG_init,
599 * must have been called before, or this function will not do anything.
600 * After that function, it should be possible to list all the available hosts
601 * with the provided functions.
603 void platf_generate(void) {
605 xbt_dynar_t nodes = NULL;
606 xbt_node_t graph_node = NULL;
607 context_node_t node_data = NULL;
608 xbt_dynar_t edges = NULL;
609 xbt_edge_t graph_edge = NULL;
610 context_edge_t edge_data = NULL;
613 unsigned int last_host = 0;
614 unsigned int last_router = 0;
615 unsigned int last_cluster = 0;
617 sg_platf_host_cbarg_t host_parameters;
618 sg_platf_cluster_cbarg_t cluster_parameters;
619 sg_platf_link_cbarg_t link_parameters;
620 s_sg_platf_router_cbarg_t router_parameters; /* This one is not a pointer! */
621 s_sg_platf_route_cbarg_t route_parameters; /* neither this one! */
623 router_parameters.coord = NULL;
624 route_parameters.symmetrical = FALSE;
625 route_parameters.src = NULL;
626 route_parameters.dst = NULL;
627 route_parameters.gw_dst = NULL;
628 route_parameters.gw_src = NULL;
629 route_parameters.link_list = NULL;
631 nodes = xbt_graph_get_nodes(platform_graph);
632 edges = xbt_graph_get_edges(platform_graph);
635 surf_parse_init_callbacks();
636 routing_register_callbacks();
638 s_sg_platf_AS_cbarg_t AS = SG_PLATF_AS_INITIALIZER;
639 AS.id = "random platform";
640 AS.routing = A_surfxml_AS_routing_Floyd;
641 sg_platf_new_AS_begin(&AS);
643 //Generate hosts, clusters and routers
644 xbt_dynar_foreach(nodes, i, graph_node) {
645 node_data = xbt_graph_node_get_data(graph_node);
646 switch(node_data->kind) {
648 host_parameters = &node_data->host_parameters;
650 if(host_parameters->id == NULL) {
651 host_parameters->id = bprintf("host-%d", last_host);
653 sg_platf_new_host(host_parameters);
656 cluster_parameters = &node_data->cluster_parameters;
658 if(cluster_parameters->prefix == NULL) {
659 cluster_parameters->prefix = "host-";
661 if(cluster_parameters->suffix == NULL) {
662 cluster_parameters->suffix = bprintf(".cluster-%d", last_cluster);
664 if(cluster_parameters->id == NULL) {
665 cluster_parameters->id = bprintf("cluster-%d", last_cluster);
667 sg_platf_new_cluster(cluster_parameters);
670 node_data->router_id = bprintf("router-%d", ++last_router);
671 router_parameters.id = node_data->router_id;
672 sg_platf_new_router(&router_parameters);
677 //Generate links and routes
678 xbt_dynar_foreach(edges, i, graph_edge) {
679 xbt_node_t src = xbt_graph_edge_get_source(graph_edge);
680 xbt_node_t dst = xbt_graph_edge_get_target(graph_edge);
681 context_node_t src_data = xbt_graph_node_get_data(src);
682 context_node_t dst_data = xbt_graph_node_get_data(dst);
683 edge_data = xbt_graph_edge_get_data(graph_edge);
684 const char* temp = NULL;
686 //Add a link to the platform
687 link_parameters = &edge_data->link_parameters;
688 if(link_parameters->id == NULL) {
689 link_parameters->id = bprintf("link-%ld", edge_data->id);
691 sg_platf_new_link(link_parameters);
693 //Add a route matching this link
694 switch(src_data->kind) {
696 route_parameters.src = src_data->router_id;
699 route_parameters.src = src_data->cluster_parameters.id;
702 route_parameters.src = src_data->host_parameters.id;
705 switch(dst_data->kind) {
707 route_parameters.dst = dst_data->router_id;
710 route_parameters.dst = dst_data->cluster_parameters.id;
713 route_parameters.dst = dst_data->host_parameters.id;
716 sg_platf_route_begin(&route_parameters);
717 sg_platf_route_add_link(link_parameters->id, &route_parameters);
718 sg_platf_route_end(&route_parameters);
720 //Create the symmertical route
721 temp = route_parameters.dst;
722 route_parameters.dst = route_parameters.src;
723 route_parameters.src = temp;
724 sg_platf_route_begin(&route_parameters);
725 sg_platf_route_add_link(link_parameters->id, &route_parameters);
726 sg_platf_route_end(&route_parameters);
729 sg_platf_new_AS_end();
733 /* Functions used to generate interesting random values */
735 double random_pareto(double min, double max, double K, double P, double ALPHA) {
736 double x = RngStream_RandU01(rng_stream);
737 double den = pow(1.0 - x + x*pow(K/P, ALPHA), 1.0/ALPHA);
738 double res = (1/den);
739 res += min - 1; // pareto is on [1, infinity) by default