Petter Sandvik Formal Modelling for Digital Media Distribution
Total Page:16
File Type:pdf, Size:1020Kb
Petter Sandvik Formal Modelling for Digital Media Distribution Turku Centre for Computer Science TUCS Dissertations No 206, November 2015 Formal Modelling for Digital Media Distribution Petter Sandvik To be presented, with the permission of the Faculty of Science and Engineering at Åbo Akademi University, for public criticism in Auditorium Gamma on November 13, 2015, at 12 noon. Åbo Akademi University Faculty of Science and Engineering Joukahainengatan 3-5 A, 20520 Åbo, Finland 2015 Supervisors Associate Professor Luigia Petre Faculty of Science and Engineering Åbo Akademi University Joukahainengatan 3-5 A, 20520 Åbo Finland Professor Kaisa Sere Faculty of Science and Engineering Åbo Akademi University Joukahainengatan 3-5 A, 20520 Åbo Finland Reviewers Professor Michael Butler Electronics and Computer Science Faculty of Physical Sciences and Engineering University of Southampton Highfield, Southampton SO17 1BJ United Kingdom Professor Gheorghe S, tefănescu Computer Science Department University of Bucharest 14 Academiei Str., Bucharest, RO-010014 Romania Opponent Professor Michael Butler Electronics and Computer Science Faculty of Physical Sciences and Engineering University of Southampton Highfield, Southampton SO17 1BJ United Kingdom ISBN 978-952-12-3294-7 ISSN 1239-1883 To tose who are no longr wit us, and to tose who wil be here afer we are gone i ii Abstract Human beings have always strived to preserve their memories and spread their ideas. In the beginning this was always done through human interpretations, such as telling stories and creating sculptures. Later, technological progress made it possible to create a recording of a phenomenon; first as an analogue recording onto a physical object, and later digitally, as a sequence of bits to be interpreted by a computer. By the end of the 20th century technological advances had made it feasible to distribute media content over a computer network instead of on physical objects, thus enabling the concept of digital media distribution. Many digital media distribution systems already exist, and their continued, and in many cases increasing, usage is an indicator for the high interest in their future enhancements and enriching. By looking at these digital media distribution systems, we have identified three main areas of possible improvement: network structure and coordination, transport of content over the network, and the encoding used for the content. In this thesis, our aim is to show that improvements in performance, efficiency and availability can be done in conjunction with improvements in software quality and reliability through the use of formal methods: mathematical approaches to reasoning about software so that we can prove its correctness, together with the desirable properties. We envision a complete media distribution system based on a distributed architecture, such as peer-to-peer networking, in which different parts of the system have been formally modelled and verified. Starting with the network itself, we show how it can be formally constructed and modularised in the Event-B formalism, such that we can separate the modelling of one node from the modelling of the network itself. We also show how the piece selection algorithm in the BitTorrent peer-to-peer transfer protocol can be adapted for on-demand media streaming, and how this can be modelled in Event-B. Furthermore, we show how modelling one peer in Event-B can give results similar to simulating an entire network of peers. Going further, we introduce a formal specification language for content transfer algorithms, and show that having such a language can make these algorithms easier to understand. We also show how generating Event-B code iii from this language can result in less complexity compared to creating the models from written specifications. We also consider the decoding part of a media distribution system by showing how video decoding can be done in parallel. This is based on formally defined dependencies between frames and blocks in a video sequence; we have shown that also this step can be performed in a way that is mathematically proven correct. Our modelling and proving in this thesis is, in its majority, tool-based. This provides a demonstration of the advance of formal methods as well as their increased reliability, and thus, advocates for their more wide-spread usage in the future. iv Sammanfattning Människor har alltid strävat efter att bevara sina minnen och sprida sina idéer. Till en början gjordes detta alltid genom mänskliga tolkningar, såsom historieberättande eller skapande av skulpturer. Senare gjorde tekniska framsteg det möjligt att göra inspelningar av fenomen; först som en analog inspelning på ett fysiskt föremål, och senare digitalt, som en sekvens bitar att tolkas av en dator. Vid senare halvan av 1990-talet hade tekniken gått så långt framåt att det var realistiskt att distribuera audiovisuell media över ett datornätverk istället för på fysiska föremål, och därmed skapades konceptet digital mediadistribution. Ett flertal digitala mediadistributionssystem existerar redan, och deras fortsatta, och i många fall ökande användning indikerar att det finns ett stort intresse för framtida vidareutveckling och utökning av dylika system. Genom att se på dessa digitala mediadistributionssystem har vi identifierat tre tänkbara områden för förbättring: nätverksstruktur och -koordination, överföring av data över nätverket, och kodningen som används för innehållet. I denna avhandling vill vi visa att förbättringar i prestanda, effektivitet och tillgänglighet kan göras i samförstånd med förbättringar i programvarans kvalitet och pålitlighet genom att använda formella metoder: matematiska tillvägagångssätt för att resonera om mjukvara på så sätt att vi kan bevisa dess korrekthet tillsammans med andra önskvärda egenskaper. Vi föreställer oss ett komplett mediadistributionssystem baserat på en distribuerad arkitektur, såsom peer-to-peer-nätverk, där olika delar av sys- temet har formellt modellerats och verifierats. Börjandes från själva nätverket visar vi hur det kan bli formellt konstruerat och modulariserat i Event-B- formalismen, så att vi kan separera modellerandet av en nod från modelleran- det av nätverket självt. Vi visar också hur den algoritm som används för att välja vilken del av innehållet som ska överföras till näst i BitTorrent- filöverföringsprotokollet kan anpassas för strömmande media, och hur detta kan modelleras i Event-B. Vidare visar vi hur modellerande av en nod i Event-B kan ge liknande resultat som att simulera ett helt nätverk av noder. Vi fortsätter genom att introducera ett formellt specifikationsspråk för dataöverföringsalgoritmer, och visar att genom att ha ett sådant språk kan dessa algoritmer bli enklare att förstå. Vi visar också hur vi kan minska v komplexiteten hos våra modeller genom att generera Event-B-kod från vårt formella specifikationsspråk istället för direkt från skrivna specifikationer. Vårt arbete berör också avkodningssidan av ett mediadistributionssystem genom att visa hur videoavkodning kan ske parallellt. Detta baserar sig på formellt definierade beroenden mellan ramar och block i en videosekvens; vi har visat att även detta steg kan utföras på ett sätt vars korrekthet har bevisats matematiskt. Modelleringen och bevisningen i denna avhandling är huvudsakligen verktygsbaserad. Detta demonstrerar hur formella metoder har framskridit och blivit mer pålitliga, vilket också talar för att deras användning kan få en vidare utbredning i framtiden. vi Acknowledgements First and foremost, I would like to thank my supervisor, Associate Prof. Luigia Petre, with whom I have had the fortune of working together on several different topics during the last few years. I am also very grateful to my other supervisor, the late Prof. Kaisa Sere, who was supportive of my ideas already when I was a master student, and encouraged me to continue towards a PhD. Many thanks also to my opponent, Prof. Michael Butler, for taking the time to thoroughly review my thesis and be the opponent at my defence. Likewise, I am very grateful to Prof. Gheorghe S, tefănescu for his review and constructive criticism of my thesis. I am lucky to have had many wonderful coworkers during my time as a PhD student. Among these are my closest coworkers currently or previously belonging to the Formal Methods and Networks group of the Distributed Systems Lab: Mats Neovius, Maryam Kamali, Mojgan Kamali, as well as Luigia Petre. I am also grateful to Marina Waldén who, among other things, helped me get started with formal modelling. Furthermore I would like to thank Marta Olszewska and Yuliya Prokhorova, both of whom I have been fortunate enough to have as office mates, as well as the other current and former members of the Distributed Systems Lab I have had the pleasure of working with: Pontus Boström, Jonatan Wiik, Fredrik Degerlund, Sergey Ostroumov, Linas Laibinis, Elena Troubitsyna, Anton Tarasyuk, Inna Pereverzeva, Johan Ersfolk, Andrew Edmunds, and Leonidas Tsiopoulos. For improving my time as a PhD student at Åbo Akademi and Turku Centre for Computer Science I am also thankful to the following people: Ion Petre, Bogdan Iancu, Cristian Gratie, Johannes Eriksson, Susanne Ramstedt, Nina Hultholm, Tove Österroos, Christel Engblom, and Tomi Suovuo. I would also like to thank my other co-authors and collaborators: Kristian Lumme and Erik Lumme; Mauno Rönkkö, Mikko Kolehmainen and Markus Stocker at University of Eastern Finland; and Seppo Horsmanheimo at VTT. For the financial support I have received during my time