Skip to main content

SwitchLog: A Logic Programming Language for Network Switches

  • Conference paper
  • First Online:
Practical Aspects of Declarative Languages (PADL 2023)

Abstract

The development of programmable switches such as the Intel Tofino has allowed network designers to implement a wide range of new in-network applications and network control logic. However, current switch programming languages, like P4, operate at a very low level of abstraction. This paper introduces SwitchLog, a new experimental logic programming language designed to lift the level of abstraction at which network programmers operate, while remaining amenable to efficient implementation on programmable switches. SwitchLog is inspired by previous distributed logic programming languages such as NDLog, in which programmers declare a series of facts, each located at a particular switch in the network. Logic programming rules that operate on facts at different locations implicitly generate network communication, and are updated incrementally, as packets pass through a switch. In order to ensure these updates can be implemented efficiently on switch hardware, SwitchLog imposes several restrictions on the way programmers can craft their rules. We demonstrate that SwitchLog can be used to express a variety of networking applications in a mere handful of lines of code.

This is a preview of subscription content, log in via an institution to check access.

Access this chapter

Chapter
USD 29.95
Price excludes VAT (USA)
  • Available as PDF
  • Read on any device
  • Instant download
  • Own it forever
eBook
USD 64.99
Price excludes VAT (USA)
  • Available as EPUB and PDF
  • Read on any device
  • Instant download
  • Own it forever
Softcover Book
USD 84.99
Price excludes VAT (USA)
  • Compact, lightweight edition
  • Dispatched in 3 to 5 business days
  • Free shipping worldwide - see info

Tax calculation will be finalised at checkout

Purchases are for personal use only

Institutional subscriptions

Notes

  1. 1.

    A similar program could be implemented in NDLog. It is not that SwitchLog is more efficient than NDLog necessarily, rather that SwitchLog is restricted so that only the efficient NDLog programs may be implemented.

References

  1. Differential datalog. VMWare (2019). https://github.com/vmware/differential-datalog

  2. Bosshart, P., et al.: P4: Programming protocol-independent packet processors. ACM SIGCOMM Comput. Commun. Rev. 44(3), 87–95 (2014)

    Article  Google Scholar 

  3. Eichholz, M., Campbell, E.H., Krebs, M., Foster, N., Mezini, M.: Dependently-typed data plane programming. In: Proceedings of the ACM Programming Languages 6(POPL) (2022). https://doi.org/10.1145/3498701

  4. Gao, J., et al.: Lyra: a cross-platform language and compiler for data plane programming on heterogeneous asics. In: Proceedings of the Annual Conference of the ACM Special Interest Group on Data Communication on the Applications, Technologies, Architectures, and Protocols for Computer Communication, p. 435–450. SIGCOMM’20, Association for Computing Machinery, New York, NY, USA (2020). https://doi.org/10.1145/3387514.3405879

  5. Gao, X., et al.: Switch code generation using program synthesis. In: Proceedings of the Annual Conference of the ACM Special Interest Group on Data Communication on the Applications, Technologies, Architectures, and Protocols for Computer Communication, pp. 44–61. SIGCOMM’20, Association for Computing Machinery, New York, NY, USA (2020). https://doi.org/10.1145/3387514.3405852

  6. Gupta, A., Harrison, R., Canini, M., Feamster, N., Rexford, J., Willinger, W.: Sonata: query-driven streaming network telemetry. In: Proceedings of the 2018 Conference of the ACM Special Interest Group on Data Communication, pp. 357–371. SIGCOMM’18, Association for Computing Machinery, New York, NY, USA (2018). https://doi.org/10.1145/3230543.3230555

  7. Harrison, R., Cai, Q., Gupta, A., Rexford, J.: Network-wide heavy hitter detection with commodity switches. In: Proceedings of the Symposium on SDN Research, pp. 1–7 (2018)

    Google Scholar 

  8. Hsu, K.F., Beckett, R., Chen, A., Rexford, J., Walker, D.: Contra: a programmable system for performance-aware routing. In: 17th USENIX Symposium on Networked Systems Design and Implementation (NSDI 20), pp. 701–721 (2020)

    Google Scholar 

  9. Laffranchini, P., Rodrigues, L.E.T., Canini, M., Krishnamurthy, B.: Measurements as first-class artifacts. In: 2019 IEEE Conference on Computer Communications, INFOCOM 2019, Paris, France, 29 April - 2 May 2019, pp. 415–423. IEEE (2019). https://doi.org/10.1109/INFOCOM.2019.8737383

  10. Loehr, D., Walker, D.: Safe, modular packet pipeline programming. In: Proceedings ACM Programming Languages 6(POPL) (2022). https://doi.org/10.1145/3498699

  11. Loo, B.T.: The design and implementation of declarative networks, p. 210 (2006). http://digicoll.lib.berkeley.edu/record/139082

  12. Loo, B.T., Hellerstein, J.M., Stoica, I., Ramakrishnan, R.: Declarative routing: extensible routing with declarative queries. ACM SIGCOMM Comput. Commun. Rev. 35(4), 289–300 (2005)

    Article  Google Scholar 

  13. Narayana, S., Arashloo, M.T., Rexford, J., Walker, D.: Compiling path queries. In: Proceedings of the 13th Usenix Conference on Networked Systems Design and Implementation, pp. 207–222. NSDI’16, USENIX Association, USA (2016)

    Google Scholar 

  14. Narayana, S., et al.: Language-directed hardware design for network performance monitoring. In: Proceedings of the Conference of the ACM Special Interest Group on Data Communication, pp. 85–98. SIGCOMM’17, Association for Computing Machinery, New York, NY, USA (2017). https://doi.org/10.1145/3098822.3098829

  15. Sivaraman, A., et al.: Packet transactions: high-level programming for line-rate switches. In: Proceedings of the 2016 ACM SIGCOMM Conference, pp. 15–28. SIGCOMM’16, Association for Computing Machinery, New York, NY, USA (2016). https://doi.org/10.1145/2934872.2934900

  16. Sonchack, J., Aviv, A.J., Keller, E., Smith, J.M.: Turboflow: information rich flow record generation on commodity switches. In: Proceedings of the 13th EuroSys Conference, pp. 1–16 (2018)

    Google Scholar 

  17. Sonchack, J., Loehr, D., Rexford, J., Walker, D.: Lucid: a language for control in the data plane. In: Proceedings of the 2021 ACM SIGCOMM 2021 Conference, pp. 731–747 (2021)

    Google Scholar 

  18. Sonchack, J., Michel, O., Aviv, A.J., Keller, E., Smith, J.M.: Scaling hardware accelerated network monitoring to concurrent and dynamic queries with \(\{\)* Flow\(\}\). In: 2018 USENIX Annual Technical Conference (USENIX ATC 18), pp. 823–835 (2018)

    Google Scholar 

  19. Soni, H., Rifai, M., Kumar, P., Doenges, R., Foster, N.: Composing dataplane programs with \(\mu \)p4. In: Proceedings of the Annual Conference of the ACM Special Interest Group on Data Communication on the Applications, Technologies, Architectures, and Protocols for Computer Communication, pp. 329–343. SIGCOMM’20, Association for Computing Machinery, New York, NY, USA (2020). https://doi.org/10.1145/3387514.3405872

  20. Wang, A., Basu, P., Loo, B.T., Sokolsky, O.: Declarative network verification. In: Gill, A., Swift, T. (eds.) PADL 2009. LNCS, vol. 5418, pp. 61–75. Springer, Heidelberg (2008). https://doi.org/10.1007/978-3-540-92995-6_5

    Chapter  Google Scholar 

Download references

Author information

Authors and Affiliations

Authors

Corresponding author

Correspondence to Vaibhav Mehta .

Editor information

Editors and Affiliations

Rights and permissions

Reprints and permissions

Copyright information

© 2023 The Author(s), under exclusive license to Springer Nature Switzerland AG

About this paper

Check for updates. Verify currency and authenticity via CrossMark

Cite this paper

Mehta, V., Loehr, D., Sonchack, J., Walker, D. (2023). SwitchLog: A Logic Programming Language for Network Switches. In: Hanus, M., Inclezan, D. (eds) Practical Aspects of Declarative Languages. PADL 2023. Lecture Notes in Computer Science, vol 13880. Springer, Cham. https://doi.org/10.1007/978-3-031-24841-2_12

Download citation

  • DOI: https://doi.org/10.1007/978-3-031-24841-2_12

  • Published:

  • Publisher Name: Springer, Cham

  • Print ISBN: 978-3-031-24840-5

  • Online ISBN: 978-3-031-24841-2

  • eBook Packages: Computer ScienceComputer Science (R0)

Publish with us

Policies and ethics