In the online packet scheduling problem with deadlines (PacketScheduling, for short), the goal is to schedule transmissions of packets that arrive over time in a network switch and need to be sent across a link. Each packet has a deadline, representing its urgency, and a non-negative weight, that represents its priority. Only one packet can be transmitted in any time slot, so, if the system is overloaded, some packets will inevitably miss their deadlines and be dropped. In this scenario, the natural objective is to compute a transmission schedule that maximizes the total weight of packets which are successfully transmitted. The problem is inherently online, with the scheduling decisions made without the knowledge of future packet arrivals. The central problem concerning PacketScheduling, that has been a subject of intensive study since 2001, is to determine the optimal competitive ratio of online algorithms, namely the worst-case ratio between the optimum total weight of a schedule (computed by an offline algorithm) and the weight of a schedule computed by a (deterministic) online algorithm.We solve this open problem by presenting a φ-competitive online algorithm for PacketScheduling (where φ ≈ 1.618 is the golden ratio), matching the previously established lower bound. arXiv:1807.07177v4 [cs.DS] 28 Jun 2019 Past work. The PacketScheduling problem was first introduced independently by Hajek [16] and Kesselman et al. [18], who both gave a proof that the greedy algorithm (that always schedules the heaviest packet) is 2-competitive. Hajek's paper also contained a proof of a lower bound of φ ≈ 1.618 on the competitive ratio. The same lower bound was later discovered independently by Andelman et al. [3,21] and also by Chin et al. [10] in a different, but equivalent setting. Improving over the greedy algorithm, Chrobak et al. [11,12] gave an online algorithm with competitive ratio 1.939. This was subsequently improved to 1.854 by Li et al. [20], and to 1.828 by Englert and Westermann [14], which, prior to the present paper, has been the best upper bound known.Algorithms with ratio φ have been developed for several restricted variants of PacketScheduling. Li et al. [19] (see also [17]) gave a φ-competitive algorithm for the case of agreeable deadlines, which consists of instances where the deadline ordering is the same as the ordering of release times. Another well-studied case is that of s-bounded instances, where each packet's deadline is within at most s steps from its release time. A φ-competitive algorithm for 2-bounded instances was given by Kesselman et al. [18]. This bound was later extended to 3-bounded instances by Chin et al. [9] and to 4-bounded instances by Böhm et al. [8]. The work of Bienkowski et al. [6] provides an upper bound of φ (in a somewhat more general setting) for the case where packet weights increase with respect to deadlines. (It should be noted that the lower bound of φ applies to instances that are 2-bounded, which implies agreeable-deadlines, and have increasing weights.) In s-uniform inst...