Skip to content

ProfessionalLesson 11 of 14

Watching the network ​

You watch a network in three ways:

  • Counters on every port say how much traffic passes.
  • Flow records say who sent that traffic to whom.
  • Logs say what each device noticed about itself.

On top of all three, alerts turn what is measured into a message to a person, but only when that person has something to do.

Circuit doesn't watch anything itself. It writes the part of each device's config that lets the tools watch it. It also hands those tools the list of devices, with circuit sync librenms and circuit sync prometheus, so nobody types a new device in twice.

Counters: how much ​

Every router and switch keeps counters for each port, such as bytes in, bytes out, packets, and errors. A monitoring server reads them with Simple Network Management Protocol: how a monitoring server asks a device for its counters and settings. The device answers, and the server keeps the history.. The device runs a small SNMP The part of a device that answers SNMP requests about it.. The monitoring server, the manager, asks it for named values from a Management Information Base: the catalog of everything a device can be asked over SNMP, each value with its own name and number.. Asking again and again on a timer is called Asking a device for a value at a fixed interval, such as every five minutes..

The value for traffic is a port's byte counter, ifInOctets for bytes received. It only ever goes up, from when the device started, so one reading says nothing. Two readings do. The traffic between them is:

  1. The second reading minus the first, the bytes that passed.
  2. Times 8, the bits.
  3. Divided by the seconds between the two readings, the bits per second.
Try itWork out the traffic from two polls
Traffic on the port
Poll every
Counter
PollTimeifInOctets
First10:00:003,900,000,000
Second10:05:001,480,032,704

Work it out, then try a faster port, a longer poll, and the other counter.

The 32-bit counter, ifInOctets, counts up to 4,294,967,295 and then starts again from 0. When the second reading is smaller than the first, the counter has gone round. If it went round only once, adding 4,294,967,296 puts it right. But at 400 Mbit/s it goes round every 86 seconds. Between polls five minutes apart it goes round four times, and nothing in two readings says so. The graph shows a quiet 56 Mbit/s for a port carrying 400.

That is why the standard for these counters requires the 64-bit ones, ifHCInOctets, for byte counts on any port faster than 20 Mbit/s. A 64-bit counter would take thousands of years to go round at 900 Mbit/s. These counters need SNMP version 2c or 3. A device must never send one in answer to a version 1 request.

CheckA graph of a busy 10 Gbit/s port shows a calm 300 Mbit/s all day, read from ifInOctets every five minutes. What is most likely wrong?

Graphs from the counters ​

The tool that made this common was A program from the 1990s that reads traffic counters over SNMP and draws graphs of them on web pages., the Multi Router Traffic Grapher. It polls every five minutes by default, and draws a graph for the day, the week, the month, and the year.

Today two kinds of tool do the same job, with more around it:

  • LibreNMS monitors devices over SNMP, every five minutes by default. It draws traffic graphs, shows port status, and alerts when something goes down.
  • Prometheus collects numbers of every kind, once a minute by default, and a tool such as Grafana draws them as graphs. It reads network devices through its SNMP exporter.

The interval is the detail you get. A five-minute point is an average. A flood that lasts thirty seconds shows as a small bump, not as the full port it caused.

In Circuit ​

SNMP goes under monitoring. Give it a version 3 user, which signs and encrypts every message. Don't use a version 2c The shared password of SNMP versions 1 and 2c, sent in plain text with every request., which the standard calls insecure. Allow only the monitoring server:

ts
management: { allow: ["10.0.0.0/24"], ssh: {} },
monitoring: {
    snmp: {
        allow: ["10.0.0.20/32"],
        users: {
            monitor: {
                auth: "sha1",
                auth_password: secret("EDGE_01_SNMP_AUTH"),
                privacy: "aes128",
                privacy_password: secret("EDGE_01_SNMP_PRIVACY"),
            },
        },
        location: "Rack A1",
    },
},

This works on edge-01, the RouterOS router of the colocation example. With auth: "sha256", circuit validate stops and says why:

text
  error  edge-01: routeros cannot express monitoring.snmp.users.monitor.auth sha256: Circuit writes SHA1 only on RouterOS (SHA-2 comes with RouterOS 7.26, not tested yet)

Flow records: who sends what ​

A counter says that the transit port is full, but not who is filling it. For that, the router describes the traffic itself. A The packets of one conversation, such as one download: the same source and destination addresses, ports, and protocol. is a run of packets that share their addresses, ports, and protocol. A flow record says how many packets and bytes the flow had. The router sends its records to a A server that receives flow records or packet samples from devices, stores them, and answers questions such as who sent the most.. The collector can then answer "who sent the most to this address in the last five minutes?"

Three formats do this, each described in an Request for Comments: the numbered documents that publish internet standards and common practice.:

FormatFromWhat it sends
NetFlow 9Cisco, published as RFC 3954A record per flow, once the flow ends or has run long enough
IPFIXThe IETF standard, RFC 7011, built on NetFlow 9The same idea, as version 10
sFlowRFC 3176Not flows: one packet in N, picked at random, with its headers copied to the collector, and the port counters

A busy router can't afford to look at every packet, so it usually Looking at one packet in N, such as one in 1,000, and multiplying what was seen by N to estimate the whole.: it looks at one packet in N, and the collector multiplies by N. The big flows come out right, but a flow of a few packets may never be picked at all. Sampling is for "who is filling the port?", not for proving that one packet passed.

In Circuit ​

monitoring.flow_export takes the format, the collectors, the sampling rate, and the ports to watch. On the edge router, these are the two ports to the outside:

ts
// In monitoring: one packet in 1,000 on the two ports to the outside, as IPFIX records to the collector.
flow_export: { protocol: "ipfix", collectors: [{ address: "10.0.0.20" }], sampling: 1000, interfaces: ["25g-1", "25g-2"] },

The switch runs VRP, which exports sFlow and samples one packet in 4,096 at most:

ts
flow_export: { protocol: "sflow", collectors: [{ address: "10.0.0.20" }], sampling: 4096 },

Each platform exports only some formats. Platforms lists them, and circuit validate says so for any other choice. When you give no port, Circuit sends sFlow to 6343, IPFIX to 4739, and NetFlow 9 to 2055. Set port if your collector listens somewhere else.

Logs: what the device noticed ​

Devices also write messages about themselves, such as a port that went down, a BGP session that closed, or someone who failed to log in. They send them to a The standard way for devices to send log messages over the network to a server, which keeps them in one place. server, each with a severity from 0, emergency, to 7, debug. Keep the warnings and worse:

ts
// In monitoring
syslog: [{ address: "10.0.0.20", level: "warning" }],

This sends every message from warning up to the server, through error, critical, alert, and emergency.

Alert on what matters ​

A graph is only useful while someone looks at it. An A rule that sends a message to a person, by phone, chat, or pager, when something measured crosses a limit. watches for you. A An alert urgent enough to interrupt someone, at any hour, who is on call to answer it. is an alert urgent enough to wake the person on call.

Try itFind the incident, then set the alert
0G5G10G15G20G25Gthe port is full at 25G00:00 03:00 06:00 09:00 12:00 15:00 18:00 21:00

Move along the day, and mark the moment something went wrong.

Flow records at 10:00

ToProtocolFromTraffic
198.51.100.10Netflix server 1TCPmany2.2 Gbit/s
198.51.100.11Netflix server 2TCPmany1.4 Gbit/s
198.51.100.18Akamai server 1TCPmany1.0 Gbit/s
other addressesmixedmany0.6 Gbit/s

Estimated by the collector from one packet in 1,000.

Alert when inbound traffic is above

for

Pick a level. The drawing marks each page the rule would have sent today: a solid triangle for the flood, a hollow one for a false alarm.

Attacks on the network says what to do about a flood like this one.

The alert is where judgment comes in. Ordinary traffic crosses 8 Gbit/s every evening, and on a wobbly line it crosses several times, so an alert at 8 pages again and again for nothing. The Google book on running large systems puts the rules plainly. Every page must be something a person can act on, and must need a person's thinking to answer. Pages that come too often get skimmed, then ignored, and one day the real one is ignored too.

Good network alerts usually describe what customers feel, or are about to feel:

  • A port close to full, which is when traffic starts to queue and drop.
  • A BGP session to a transit or an exchange gone down.
  • A device that stops answering its polls.
  • Errors climbing on a port.

Everything else, such as a single failed login, belongs in a report or a dashboard, not on someone's phone at 3 in the morning.

CheckThe transit port is full. Which tells you which of your customers the traffic is going to?
CheckAn alert pages the on-call engineer every evening when inbound traffic passes 8 Gbit/s. Each time, the engineer looks and does nothing. What should change?

Further reading ​

  • RFC 2863, the interfaces group MIB: the port counters, and when 64-bit counters are required.
  • RFC 2578, SMIv2: how a Counter32 and a Counter64 wrap, and why one reading means nothing.
  • RFC 3410, an introduction to SNMPv3: agents and managers, the MIB, and why community strings are insecure.
  • RFC 3584, on SNMP versions side by side: why a 64-bit counter is never sent in answer to SNMP version 1.
  • MRTG and its reference: the classic traffic graphing tool, its five-minute interval, and its 64-bit counters.
  • LibreNMS 1 minute polling: its default of 300 seconds.
  • Prometheus configuration: its default scrape interval of one minute.
  • RFC 3954 on NetFlow 9, RFC 7011 on IPFIX, and RFC 3176 on sFlow.
  • RFC 5424, the syslog protocol: the eight severities.
  • Monitoring Distributed Systems, from the Google book on site reliability engineering: what deserves a page.

Discussion

Stuck, or found a mistake? Ask here. You sign in with GitHub.

Released under the Business Source License 1.1.