Commit f8de98ef authored by 's avatar
Browse files

Added support for individual ports in a DAG card


git-svn-id: file:///home/svn/mapi/trunk@754 8d5bb341-7cf1-0310-8cf6-ba355fef3186
parent dcd00625
INSTALLATION
0. Prerequisitives
You need libtool, readline-dev and rrdtool packages. Install them
using package management in your distribution of Linux (e.g., dselect
in Debian or yast in SuSe) or from sources.
I. Checkout MAPI and ABW application from SVN:
svn co --username public --password public \
......
......@@ -164,7 +164,9 @@ int main(int argc, char *argv[])
while (measurement->scope->subject[j] && j<MAX_SUBJECTS) {
if ((flow[flow_id]->rrd_filename[j]=
abw_rrd_create_filename(measurement->scope->subject[j]->hostname,
measurement->scope->subject[j]->interface, 0,
measurement->scope->subject[j]->interface,
(measurement->scope->subject[j]->port)>=0?
measurement->scope->subject[j]->port:0,
measurement->parameters_id,
measurement->protocols_array[i]))==NULL) {
fprintf(stderr, "%s: rrd_create_filename() failed\n",
......@@ -256,6 +258,17 @@ int main(int argc, char *argv[])
return -1;
}
/* Filter based on input port, we can use port number in the first
subject of the scope, because all subjects in a scope must have
the same port number */
if (measurement->scope->subject[0]->port >= 0) {
if ((flow[flow_id]->interface_fid=mapi_apply_function(flow[flow_id]->fd, "INTERFACE", measurement->scope->subject[0]->port))<0) {
fprintf(stderr, "%s: INTERFACE failed\n", __func__);
return -1;
}
}
/* Note that BPF_FILTER uses compiled header filter that
selects packets of the given protocol */
......
......@@ -10,7 +10,7 @@
[subject]
id=1
hostname=jra1-1.cesnet.cz
hostname=jra1-2.cesnet.cz
interface=/dev/dag0
port=0
label=GN2_CESNET
......@@ -19,7 +19,7 @@ direction=in
[subject]
id=2
hostname=jra1-1.cesnet.cz
hostname=jra1-2.cesnet.cz
interface=/dev/dag0
port=1
label=GN2_CESNET
......@@ -30,10 +30,9 @@ direction=out
# which should be monitored together. Each [subject] section MUST include id
# and subject_ids.
#
# Note that you cannot include in one [scope] subjects that some use MPLS and
# some not. This is because monitoring of MPLS links requires extending
# header filter applied by BPF_FILTER to a [scope]. Use one [scope] for
# MPLS links and one [scope] for non-MPLS links.
# You cannot include in one [scope] subjects that have different mpls or port
# fields, because these fields require to apply different BPF_FILTER or
# additional INTERFACE functions, respectively.
[scope]
id=1
......
......@@ -29,6 +29,7 @@ subject_t *new_subject(void) {
memset(p, 0, sizeof(subject_t));
p->port=-1;
p->mpls=0;
p->link_mbps=DEFAULT_LINK_MBPS;
p->out=0;
......
......@@ -29,6 +29,7 @@ typedef struct flow_struct {
int fd; /* flow file descriptor */
int interface_fid; /* fid for INTERFACE */
int bpf_filter_fid; /* fid for BPF_FILTER */
int track_function_fid; /* fid for a tracklib function */
int sample_fid; /* fid for SAMPLE */
......
......@@ -38,6 +38,7 @@ void usage() {
fprintf(stderr, " -d or --device <device> device on measurement station\n");
fprintf(stderr, " (e.g., /dev/combosix/0, /dev/dag0,\n");
fprintf(stderr, " default %s)\n", DEFAULT_INTERFACE);
fprintf(stderr, " --port <n> port on device, default is all ports together\n");
fprintf(stderr, " --mpls link uses MPLS\n");
fprintf(stderr, " -l or --link_mbps <mbps> link installed bandwidth (default %d)\n", DEFAULT_LINK_MBPS);
fprintf(stderr, "\nParameters options:\n");
......@@ -111,6 +112,14 @@ int read_command_line(int argc, char *argv[], configuration_t *configuration) {
direct_flow=1;
configuration->subject->interface=optarg;
break;
case LO_PORT:
/* check here, because -1 given here would look as correct default
value for check_conf() */
if (atoi(optarg)<0) {
fprintf(stderr, "%s: port number must be >= 0\n", __func__);
return -1;
}
configuration->subject->port=atoi(optarg);
case 'l':
case LO_LINK_MBPS:
direct_flow=1;
......@@ -293,6 +302,16 @@ int read_conf_file(configuration_t *configuration)
strcpy((*subject)->interface, param->value);
}
else if (!strcmp(param->name, "port")) {
/* check here, because -1 given here would look as correct default
value for check_conf() */
if (atoi(param->value) < 0) {
fprintf(stderr, "%s: port number must be >= 0\n", __func__);
return -1;
}
(*subject)->port=atoi(param->value);
}
else if (!strcmp(param->name, "link_mbps"))
(*subject)->link_mbps=atoi(param->value);
......@@ -638,6 +657,8 @@ int check_conf(configuration_t *configuration) {
}
for (i=0; i<subject_no; i++) {
int mpls, port;
subject=configuration->subject;
while (subject) {
if (subject->id == atoi(scope->subject_array[i])) {
......@@ -652,6 +673,21 @@ int check_conf(configuration_t *configuration) {
__func__, atoi(scope->subject_array[i]), scope->id);
return -1;
}
if (i==0) {
mpls=scope->subject[i]->mpls;
port=scope->subject[i]->port;
}
else {
if (mpls != scope->subject[i]->mpls) {
fprintf(stderr, "%s: mpls must be the same in all subjects in a scope\n", __func__);
return -1;
}
if (port != scope->subject[i]->port) {
fprintf(stderr, "%s: port must be the same in all subjects in a scope\n", __func__);
return -1;
}
}
}
scope->subject_no = subject_no;
......@@ -850,6 +886,7 @@ int print_conf(configuration_t *configuration) {
printf("id: %d\n", measurement->scope->subject[i]->id);
printf("hostname: %s\n", measurement->scope->subject[i]->hostname);
printf("interface: %s\n", measurement->scope->subject[i]->interface);
printf("port: %d\n", measurement->scope->subject[i]->port);
printf("mpls: %d\n", measurement->scope->subject[i]->mpls);
printf("link_mbps: %d\n", measurement->scope->subject[i]->link_mbps);
printf("label: %s\n", measurement->scope->subject[i]->label);
......
......@@ -20,7 +20,7 @@
/* Long option codes */
enum {
LO_HOSTNAME, LO_INTERFACE,
LO_HOSTNAME, LO_INTERFACE, LO_PORT,
LO_LINK_MBPS, LO_MPLS,
LO_SAU_MODE, LO_SAU_THRESHOLD, LO_PAYLOAD_STRING, LO_INTERVAL,
LO_PROTOCOLS,
......@@ -31,6 +31,7 @@ enum {
static const struct option long_options[] = {
{ "hostname", required_argument, 0, LO_HOSTNAME },
{ "interface", required_argument, 0, LO_INTERFACE },
{ "port", required_argument, 0, LO_PORT },
{ "mpls", no_argument, 0, LO_MPLS },
{ "link_mbps", required_argument, 0, LO_LINK_MBPS },
{ "sau_mode", required_argument, 0, LO_SAU_MODE },
......@@ -71,6 +72,7 @@ typedef struct subject_struct {
int id;
char *hostname;
char *interface;
int port;
int mpls;
int link_mbps;
char *label;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment