Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
84 changes: 68 additions & 16 deletions src/components/charts/BGPLineChart.vue
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import {
QIcon
} from 'quasar'
import ReactiveChart from './ReactiveChart.vue'
import { ref, onMounted, watch, onUnmounted } from 'vue'
import { ref, onMounted, watch, onUnmounted, computed } from 'vue'
import report from '@/plugins/report'
import '@/styles/chart.css'
import BGPVrpsTable from '../tables/BGPVrpsTable.vue'
Expand Down Expand Up @@ -106,7 +106,7 @@ const prevNextElement = ref(null)
let observer = null

const timestampToUTC = (timestamp) => {
return utcString(new Date(timestamp * 1000))
return utcString(new Date(Number(String(timestamp).padEnd(13, '0'))))
}

// Update the time range
Expand Down Expand Up @@ -325,6 +325,36 @@ const customIntersectionObserver = () => {
}
}

const rpkiStatusChartXRange = computed(() => {
if (announcementsPeersChartData.value.length) {
if ('x' in announcementsPeersChartData.value[0]) {
return [
announcementsPeersChartData.value[0].x[0],
announcementsPeersChartData.value[0].x[announcementsPeersChartData.value[0].x.length - 1]
]
}
}
return []
})

const handleRpkiPlotlyClick = (event) => {
const point = event.points[0]
if (!point) return

const xaxis = point.xaxis
const mouseX = event.event.clientX
const plotDiv = event.event.target.closest('.js-plotly-plot')
const rect = plotDiv.getBoundingClientRect()

// xaxis.p2d converts pixel position to data coordinate (ms)
const pixelX = mouseX - rect.left - xaxis._offset
const clickedMs = xaxis.p2d(pixelX)
const timestamp = Math.floor(new Date(clickedMs + 'Z').getTime() / 1000)

selectedMaxTimestamp.value = timestamp
updateSlider(timestamp, true)
}

//Remove the vertical line and update the selected timestamp
watch(
() => props.isLiveMode,
Expand Down Expand Up @@ -401,8 +431,10 @@ onMounted(() => {
</div>
<div class="text-center" v-if="rawMessages.length === 0">
<h1 v-if="!isLoadingBgplayData">No data available</h1>
<h3 v-if="dataSource === 'ris-live'">Try changing the input parameters or you can wait</h3>
<h6 v-if="dataSource === 'ris-live'">Note: Some prefixes become active after some time.</h6>
<h3 v-if="dataSource === 'ris-live'">Waiting for BGP updates.</h3>
<h6 v-if="dataSource === 'ris-live'">
This may take some time, depending on the selected prefix.
</h6>
</div>
<div v-else>
<div v-if="dataSource === 'ris-live'" class="q-mb-md">
Expand Down Expand Up @@ -460,7 +492,12 @@ onMounted(() => {
{{ usedMessagesCount + ' out of ' + rawMessages.length }} Processed Messages
</div>
<div v-else class="text-body2">
{{ usedMessagesCount - initialStateDataCount + ' out of ' + rawMessages.length }}
{{
usedMessagesCount -
initialStateDataCount +
' out of ' +
(rawMessages.length - initialStateDataCount)
}}
Processed Messages
</div>
</QBadge>
Expand Down Expand Up @@ -504,16 +541,26 @@ onMounted(() => {
: currentIndex === 0)
"
/>
<QBadge class="q-mr-md">
<div v-if="dataSource === 'ris-live'" class="text-body2">
{{ usedMessagesCount + '/' + rawMessages.length }}
<QIcon name="message" />
</div>
<div v-else class="text-body2">
{{ usedMessagesCount - initialStateDataCount + '/' + rawMessages.length }}
<QIcon name="message" />
</div>
</QBadge>
<div class="q-mr-md column items-center">
<QBadge class="q-mb-sm">
<div v-if="dataSource === 'ris-live'" class="text-body2">
{{ usedMessagesCount + '/' + rawMessages.length }}
<QIcon name="message" />
</div>
<div v-else class="text-body2">
{{
usedMessagesCount -
initialStateDataCount +
'/' +
(rawMessages.length - initialStateDataCount)
}}
<QIcon name="message" />
</div>
</QBadge>
<QBadge class="text-body2">
{{ timestampToUTC(selectedMaxTimestamp)?.slice(0, 16) }}
</QBadge>
</div>
<QBtn
round
color="indigo"
Expand Down Expand Up @@ -561,11 +608,16 @@ onMounted(() => {
title: {
text: 'Peers'
}
},
xaxis: {
type: 'date',
autorange: rpkiStatusChartXRange.length ? false : true,
range: rpkiStatusChartXRange
}
}"
:traces="rpkiStatusChartData"
:shapes="rpkiLayout.shapes"
@plotly-click="handlePlotlyClick"
@plotly-click="handleRpkiPlotlyClick"
@plotly-relayout="adjustQSliderWidth(true)"
:no-data="
isNoVrpData
Expand Down
12 changes: 9 additions & 3 deletions src/components/charts/BGPPathsChart.vue
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ const props = defineProps({
type: Number,
default: 5
},
selectedPeers: {
type: Array,
default: () => []
},
isLiveMode: {
type: Boolean
},
Expand Down Expand Up @@ -46,7 +50,9 @@ const generateGraphData = () => {
const linkSetCount = new Map()

//Only consider selected peers which are selected in the table
const peers = props.filteredMessages.slice(0, props.selectedPeersNumber).map((obj) => obj.peer)
const peers = props.selectedPeers.length
? props.selectedPeers.map((obj) => obj.peer)
: props.filteredMessages.slice(0, props.selectedPeersNumber).map((obj) => obj.peer)
const filteredSelectedMessages = props.filteredMessages.filter((message) =>
peers.includes(message.peer)
)
Expand Down Expand Up @@ -185,8 +191,8 @@ onMounted(() => {
<div class="text-center">
<h1>No data available</h1>
<template v-if="dataSource === 'ris-live'">
<h3>Try changing the input parameters or you can wait</h3>
<h6>Note: Some prefixes become active after some time.</h6>
<h3>Waiting for BGP updates.</h3>
<h6>This may take some time, depending on the selected prefix.</h6>
</template>
</div>
</div>
Expand Down
20 changes: 15 additions & 5 deletions src/components/tables/BGPMessagesTable.vue
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ const props = defineProps({
type: Number,
default: 5
},
selectedPeers: {
type: Array,
default: () => []
},
isLiveMode: {
type: Boolean
},
Expand All @@ -33,7 +37,9 @@ const { utcString } = report()
const emit = defineEmits(['enable-live-mode', 'update-selected-peers'])

const selectedPeersModel = ref(
props.filteredMessages.slice(0, props.selectedPeersNumber).map((obj) => ({ peer: obj.peer }))
props.selectedPeers.length
? props.selectedPeers
: props.filteredMessages.slice(0, props.selectedPeersNumber).map((obj) => ({ peer: obj.peer }))
)
const search = ref('')

Expand Down Expand Up @@ -106,13 +112,17 @@ watch(
)

watch([() => props.selectedPeersNumber, () => props.filteredMessages], () => {
selectedPeersModel.value = props.filteredMessages
.slice(0, props.selectedPeersNumber)
.map((obj) => ({ peer: obj.peer }))
if (props.selectedPeers.length) {
selectedPeersModel.value = props.selectedPeers
} else {
selectedPeersModel.value = props.filteredMessages
.slice(0, props.selectedPeersNumber)
.map((obj) => ({ peer: obj.peer }))
}
})

watch(selectedPeersModel, () => {
emit('update-selected-peers', selectedPeersModel.value.length)
emit('update-selected-peers', selectedPeersModel.value)
})

onMounted(() => {
Expand Down
34 changes: 24 additions & 10 deletions src/views/BGPMonitor.vue
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import {
QItemSection,
QSpinner
} from 'quasar'
import { onMounted, onUnmounted, ref, watch, inject } from 'vue'
import { onMounted, onUnmounted, ref, watch, inject, computed } from 'vue'
import { useRoute, useRouter } from 'vue-router'
import GenericCardController from '@/components/controllers/GenericCardController.vue'
import i18n from '@/i18n'
Expand Down Expand Up @@ -46,7 +46,8 @@ const rawMessages = ref([]) //Used to store all the messages from the websocket
const filteredMessages = ref([]) //Used to store unique peer messages uses "uniquePeerMessages = new Map()""
const uniquePeerMessages = new Map() //Used to store unique peer messages (For simplification)
const communityInfo = ref({})
const defaultSelectedPeerCount = ref(5) //Default number of peers to display in the sankey chart
const defaultSelectedPeerCount = ref(50) //Default number of peers to display in the sankey chart
const defaultSelectedPeers = ref([]) //Default number of peers to display in the sankey chart
const isLiveMode = ref(true)
const selectedMaxTimestamp = ref(0)
const usedMessagesCount = ref(0) //Just for displaying how many messages are being used
Expand Down Expand Up @@ -134,7 +135,8 @@ const resetData = () => {
rawMessages.value = []
filteredMessages.value = []
uniquePeerMessages.clear()
defaultSelectedPeerCount.value = 5
defaultSelectedPeerCount.value = 50
defaultSelectedPeers.value = []
isLiveMode.value = true
selectedMaxTimestamp.value = 0
usedMessagesCount.value = 0
Expand Down Expand Up @@ -325,7 +327,6 @@ const processResData = (data) => {
community: addCommunityAndDescriptions(event.community),
as_info: addASInfo(path),
type: type,
rpki_status: status,
timestamp: minTimestamp.value
})
})
Expand Down Expand Up @@ -356,7 +357,6 @@ const processResData = (data) => {
community: addCommunityAndDescriptions(event.attrs.community),
as_info: addASInfo(path),
type: type,
rpki_status: status,
timestamp: timestamp
})
})
Expand Down Expand Up @@ -547,10 +547,10 @@ const generateLineChartTrace = () => {
}

function addData(timestamp) {
const duration = timestamp - current_range_start - 1
const duration = (timestamp - current_range_start - 1) * 1000
rsTrace[current_status] ??= { y: [], x: [], base: [], peer_asn: [], origin_asn: [] }
rsTrace[current_status].y.push(peer)
rsTrace[current_status].x.push(timestampToUTC(duration))
rsTrace[current_status].x.push(duration)
rsTrace[current_status].base.push(timestampToUTC(current_range_start))
rsTrace[current_status].peer_asn.push(peer_asn)
rsTrace[current_status].origin_asn.push(current_origin)
Expand All @@ -565,8 +565,19 @@ const generateLineChartTrace = () => {
rpkiStatusTraces.value = rsTrace
}

const filteredMessagesWithRpki = computed(() => {
return filteredMessages.value.map((msg) => {
const originASN = msg.path.length ? msg.path[msg.path.length - 1] : null
const { status } = getRPKIStatus(originASN, selectedMaxTimestamp.value)
return {
...msg,
rpki_status: status
}
})
})

const timestampToUTC = (timestamp) => {
return utcString(new Date(timestamp * 1000))
return utcString(new Date(Number(String(timestamp).padEnd(13, '0'))))
}

// Apply community descriptions to the community data array
Expand Down Expand Up @@ -1055,7 +1066,8 @@ const getRPKIStatus = (asn, timestamp) => {
}

const updateSelectedPeers = (val) => {
defaultSelectedPeerCount.value = val
defaultSelectedPeerCount.value = val.length
defaultSelectedPeers.value = val
}

const applyStartTime = () => {
Expand Down Expand Up @@ -1353,6 +1365,7 @@ onUnmounted(() => {
<BGPPathsChart
:filtered-messages="filteredMessages"
:selected-peers-number="defaultSelectedPeerCount"
:selected-peers="defaultSelectedPeers"
:is-live-mode="isLiveMode"
:is-playing="isPlaying"
:is-loading-bgplay-data="isLoadingBgplayData"
Expand Down Expand Up @@ -1381,8 +1394,9 @@ onUnmounted(() => {
</template>
<BGPMessagesTable
:data-source="dataSource.value"
:filtered-messages="filteredMessages"
:filtered-messages="filteredMessagesWithRpki"
:selected-peers-number="defaultSelectedPeerCount"
:selected-peers="defaultSelectedPeers"
:is-live-mode="isLiveMode"
:is-playing="isPlaying"
:is-loading-bgplay-data="isLoadingBgplayData"
Expand Down
Loading