Example of pseudowire

Use this realistic example based on data received from an MPLS agent for a real-life example of a pseudowire data string.

Assume that the following pseudowire data string is retrieved from the agent.

Layer-2 VPN Statistics:
 Instance: vpls1

 Local interface: fe-1/3/0.0, Index: 71
 Multicast packets:                375747
 Multicast bytes  :              34780885
 Flooded packets  :                 96012
 Flooded bytes    :               9213657

 Local interface: vt-1/2/0.32768, Index: 72
 Remote PE: 10.1.230.4
 Multicast packets:                174307
 Multicast bytes  :              14449864
 Flooded packets  :                615013
 Flooded bytes    :              50990719

 Instance: vpls1

 Local interface: fe-1/3/0.0, Index: 71
 Multicast packets:                375747
 Multicast bytes  :              34780885
 Flooded packets  :                 96012
 Flooded bytes    :               9213657

 Local interface: vt-1/2/0.32768, Index: 72
 Remote PE: 10.1.230.4
 Multicast packets:                174307
 Multicast bytes  :              14449864
 Flooded packets  :                615013
 Flooded bytes    :              50990719

You can extract the data from this string by writing a stitcher which incorporates code with the MatchPattern() rule.

[1]text pattern=
   "Instance:[[:space:]]+([^[:space:]]+)[[:space:]]*[\n\r][[:space:]]
   *[\n\r][[:space:]]*Localinterface:[[:space:]]+([^,]+),[[:space:]]
   +Index:[[:space:]]+([[:digit:]]+)[[:space:]]*[\n\r][[:space:]]*
   Multicast packets[[:space:]]*:[[:space:]]+[[:digit:]]+[[:space:]]*
   [\n\r][[:space:]]*Multicast bytes[[:space:]]*:[[:space:]]+[[:digit:]]
   +[[:space:]]*[\n\r][[:space:]]*Flooded packets[[:space:]]*:[[:space:]]
   +[[:digit:]]+[[:space:]]*[\n\r][[:space:]]*Flooded bytes[[:space:]]*:
   [[:space:]]+[[:digit:]]+[[:space:]]*[\n\r][[:space:]]*[\n\r]
   [[:space:]]*Local interface:[[:space:]]+([^,]+),[[:space:]]+Index:
   [[:space:]]+([[:digit:]]+)[[:space:]]*[\n\r][[:space:]]*Remote PE:
   [[:space:]]+([^ \t\n\r]+)[[:space:]]*[\n\r].*";
[2]int count = MatchPattern( eval ( text,$target ), pattern);
[3]while(count > 0)
[4]        {
[5]            Print("Count ", count);
[6]            Print("Match ", REGEX0);
[7]            Print("SubMatch 1 ", REGEX1);
[8]            Print("SubMatch 2 ", REGEX2);
[9]            Print("SubMatch 3 ", REGEX3);
[10]           Print("SubMatch 4 ", REGEX4);
[11]           Print("SubMatch 5 ", REGEX5);
[12]           Print("SubMatch 6 ", REGEX6);
[13]
[14]           count = count - 1;
[15]       }

In line 2 of this example, $target is the pseudowire data string received from the MPLS stitcher.