Skip to content

Commit

Permalink
add dscp field + side panel details
Browse files Browse the repository at this point in the history
  • Loading branch information
jpinsonneau committed Sep 22, 2023
1 parent 82c4ac9 commit a036c0e
Show file tree
Hide file tree
Showing 6 changed files with 90 additions and 18 deletions.
5 changes: 5 additions & 0 deletions web/locales/en/plugin__netobserv-plugin.json
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,9 @@
"Compare to total dropped": "Compare to total dropped",
"Export panel": "Export panel",
"n/a": "n/a",
"Type": "Type",
"Code": "Code",
"DSCP": "DSCP",
"reporting": "reporting",
"Ingress": "Ingress",
"Egress": "Egress",
Expand Down Expand Up @@ -455,6 +458,8 @@
"Specify the direction of the Flow observed at the Node observation point.": "Specify the direction of the Flow observed at the Node observation point.",
"Network interface": "Network interface",
"Specify a network interface.": "Specify a network interface.",
"DSCP value": "DSCP value",
"Specify a Differentiated Services Code Point value as integer number.": "Specify a Differentiated Services Code Point value as integer number.",
"Specify a single conversation hash Id.": "Specify a single conversation hash Id.",
"Packet drop TCP state": "Packet drop TCP state",
"Specify a single TCP state.": "Specify a single TCP state.",
Expand Down
2 changes: 2 additions & 0 deletions web/src/api/ipfix.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,8 @@ export interface Fields {
Bytes_AB?: number;
/** In conversation tracking, B to A bytes counter per conversation */
Bytes_BA?: number;
/** Differentiated Services Code Point Value */
Dscp?: number;
/** ICMP type */
IcmpType?: number;
/** ICMP code */
Expand Down
53 changes: 35 additions & 18 deletions web/src/components/netflow-record/record-field.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import {
import { DROP_CAUSES_NAMES, getDropCauseDescription, getDropCauseDocUrl } from '../../utils/pkt-drop';
import { formatDurationAboveMillisecond, formatDurationAboveNanosecond } from '../../utils/duration';
import { formatPort } from '../../utils/port';
import { getDSCPDocUrl, getDSCPServiceClassName } from '../../utils/dscp';
import { formatProtocol } from '../../utils/protocol';
import { Size } from '../dropdowns/table-display-dropdown';
import './record-field.css';
Expand Down Expand Up @@ -367,26 +368,42 @@ export const RecordField: React.FC<{
}
case ColumnsId.proto:
const text = value ? formatProtocol(value as number) : t('n/a');
let child: JSX.Element | undefined = undefined;
const children: JSX.Element[] = [];

if (detailed && flow.fields.IcmpType !== undefined) {
const type = getICMPType(flow.fields.Proto, flow.fields.IcmpType as ICMP_ALL_TYPES_VALUES);
const code = getICMPCode(
flow.fields.Proto,
flow.fields.IcmpType as ICMP_ALL_TYPES_VALUES,
flow.fields.IcmpCode as ICMP_ALL_CODES_VALUES
);
const docUrl = getICMPDocUrl(flow.fields.Proto);
child = type ? (
<>
{clickableContent(type.name, type.description || '', docUrl)}
{code ? clickableContent(code.name, code.description || '', docUrl) : <></>}
</>
) : (
clickableContent(`Type: ${flow.fields.IcmpType} Code: ${flow.fields.IcmpCode}`, '', docUrl)
);
if (detailed) {
if (flow.fields.IcmpType !== undefined) {
const type = getICMPType(flow.fields.Proto, flow.fields.IcmpType as ICMP_ALL_TYPES_VALUES);
const code = getICMPCode(
flow.fields.Proto,
flow.fields.IcmpType as ICMP_ALL_TYPES_VALUES,
flow.fields.IcmpCode as ICMP_ALL_CODES_VALUES
);
const docUrl = getICMPDocUrl(flow.fields.Proto);
if (type) {
children.push(clickableContent(type.name, type.description || '', docUrl));
if (code) {
children.push(clickableContent(code.name, code.description || '', docUrl));
}
} else {
children.push(
clickableContent(
`${t('Type')}: ${flow.fields.IcmpType} ${t('Code')}: ${flow.fields.IcmpCode}`,
'',
docUrl
)
);
}
}

if (flow.fields.Dscp !== undefined) {
const docUrl = getDSCPDocUrl();
const serviceClassName = getDSCPServiceClassName(flow.fields.Dscp);
children.push(clickableContent(`${t('DSCP')}: ${flow.fields.Dscp}}`, serviceClassName, docUrl));
}
}
return singleContainer(simpleTextWithTooltip(child ? `${text} ${t('reporting')}` : text, undefined, child));
return singleContainer(
simpleTextWithTooltip(children.length ? `${text} ${t('reporting')}` : text, undefined, <>{children}</>)
);
case ColumnsId.flowdir:
return singleContainer(
simpleTextWithTooltip(
Expand Down
1 change: 1 addition & 0 deletions web/src/model/filters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ export type FilterId =
| 'direction'
| 'interface'
| 'type'
| 'dscp'
| 'id'
| 'pkt_drop_state'
| 'pkt_drop_cause'
Expand Down
37 changes: 37 additions & 0 deletions web/src/utils/dscp.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
export const getDSCPDocUrl = () => {
return 'https://www.rfc-editor.org/rfc/rfc4594';
};

export const getDSCPServiceClassName = (dscp: number): string => {
switch (dscp) {
case 48:
return 'Network Control';
case 46:
return 'Telephony';
case 40:
return 'Multimedia Conferencing';
case 36:
case 32:
return 'Real-Time Interactive';
case 30:
case 28:
case 26:
return 'Multimedia Streaming';
case 24:
return 'Broadcast Video';
case 22:
case 20:
case 18:
return 'Low-Latency Data';
case 16:
return 'OAM';
case 14:
case 12:
case 10:
return 'Standard';
case 8:
return 'Low-Priority Data';
default:
return '';
}
};
10 changes: 10 additions & 0 deletions web/src/utils/filter-definitions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -456,6 +456,16 @@ export const getFilterDefinitions = (
hint: t('Specify a network interface.'),
encoder: simpleFiltersEncoder('Interface')
},
{
id: 'dscp',
name: t('DSCP value'),
category: FilterCategory.None,
component: FilterComponent.Number,
getOptions: noOption,
validate: rejectEmptyValue,
hint: t('Specify a Differentiated Services Code Point value as integer number.'),
encoder: simpleFiltersEncoder('Dscp')
},
{
id: 'id',
name: t('Conversation Id'),
Expand Down

0 comments on commit a036c0e

Please sign in to comment.