Lecture 1.1: Introduction. 2 Agenda 1 1 What is Firewall Types of Firewall 2 2 Firewall in linux kernel 3 3.

Slides:



Advertisements
Similar presentations
IUT– Network Security Course 1 Network Security Firewalls.
Advertisements

1 Topic 2 – Lesson 4 Packet Filtering Part I. 2 Basic Questions What is packet filtering? What is packet filtering? What elements are inside an IP header?
CCNA – Network Fundamentals
Intermediate TCP/IP TCP Operation.
Packet Injection 101 Vivek Ramachandran. What is packet injection ? Please go through the raw socket tutorial before going further. Simply put packet.
Lecture 1.2: Linux and networking Roei Ben-Harush 2015.
FIREWALLS. What is a Firewall? A firewall is hardware or software (or a combination of hardware and software) that monitors the transmission of packets.
FIREWALLS The function of a strong position is to make the forces holding it practically unassailable —On War, Carl Von Clausewitz On the day that you.
CSCI 530 Lab Firewalls. Overview Firewalls Capabilities Limitations What are we limiting with a firewall? General Network Security Strategies Packet Filtering.
Page: 1 Director 1.0 TECHNION Department of Computer Science The Computer Communication Lab (236340) Summer 2002 Submitted by: David Schwartz Idan Zak.
Design and Implementation of a Server Director Project for the LCCN Lab at the Technion.
FIREWALLS & NETWORK SECURITY with Intrusion Detection and VPNs, 2 nd ed. 6 Packet Filtering By Whitman, Mattord, & Austin© 2008 Course Technology.
WXES2106 Network Technology Semester /2005 Chapter 8 Intermediate TCP CCNA2: Module 10.
1 Netfilter in Linux Bing Qi Department of Computer Science and Engineering Auburn university.
TCP/IP Basics A review for firewall configuration.
Transport Layer TCP and UDP IS250 Spring 2010
Gursharan Singh Tatla Transport Layer 16-May
FIREWALL TECHNOLOGIES Tahani al jehani. Firewall benefits  A firewall functions as a choke point – all traffic in and out must pass through this single.
A Brief Taxonomy of Firewalls
1 Lab 3 Transport Layer T.A. Youngjoo Han. 2 Transport Layer  Providing logical communication b/w application processes running on different hosts 
Operating System Program 5 I/O System DMA Device Driver.
Packet Filtering. 2 Objectives Describe packets and packet filtering Explain the approaches to packet filtering Recommend specific filtering rules.
January 2009Prof. Reuven Aviv: Firewalls1 Firewalls.
Chapter 6: Packet Filtering
LWIP TCP/IP Stack 김백규.
FIREWALLS Vivek Srinivasan. Contents Introduction Need for firewalls Different types of firewalls Conclusion.
Packet Filtering Chapter 4. Learning Objectives Understand packets and packet filtering Understand approaches to packet filtering Set specific filtering.
1 The Internet and Networked Multimedia. 2 Layering  Internet protocols are designed to work in layers, with each layer building on the facilities provided.
Chapter 6-2 the TCP/IP Layers. The four layers of the TCP/IP model are listed in Table 6-2. The layers are The four layers of the TCP/IP model are listed.
Lecture 2: Linux devices Roei Ben-Harush Agenda 1 1 Linux Devices About next Assignment Roei Ben-Harush 2015 Reminder.
Fundamentals of Proxying. Proxy Server Fundamentals  Proxy simply means acting on someone other’s behalf  A Proxy acts on behalf of the client or user.
1 Firewalls Types of Firewalls Inspection Methods  Static Packet Inspection  Stateful Packet Inspection  NAT  Application Firewalls Firewall Architecture.
Security fundamentals Topic 10 Securing the network perimeter.
Firewalls A brief introduction to firewalls. What does a Firewall do? Firewalls are essential tools in managing and controlling network traffic Firewalls.
Firewalls. Overview of Firewalls As the name implies, a firewall acts to provide secured access between two networks A firewall may be implemented as.
Chapter 8.  Upon completion of this chapter, you should be able to:  Understand the purpose of a firewall  Name two types of firewalls  Identify common.
Lecture 3: Stateless Packet Filtering. 2 Agenda 1 1 Linux file system - networking sk_buff 2 2 Stateless packet filtering 3 3 About next assignment 4.
Lecture 9 Page 1 CS 236 Online Firewalls What is a firewall? A machine to protect a network from malicious external attacks Typically a machine that sits.
Polytechnic University Firewall and Trusted Systems Presented by, Lekshmi. V. S cos
Security fundamentals
Executive Director and Endowed Chair
Chapter 11 User Datagram Protocol
Introduction To TCP/IP Networking Mr. Zeeshan Ali, Asst. Professor
Port Scanning James Tate II
Introduction to TCP/IP networking
FIREWALL configuration in linux
TCP/IP Internetworking
Process-to-Process Delivery
TCP/IP Transmission Control Protocol / Internet Protocol
TCP/IP Internetworking
Introduction to Networking
* Essential Network Security Book Slides.
I. Basic Network Concepts
Process-to-Process Delivery:
Setting Up Firewall using Netfilter and Iptables
POOJA Programmer, CSE Department
Firewalls By conventional definition, a firewall is a partition made
دیواره ی آتش.
TRANSMISSION CONTROL PROTOCOL
Lecture 2: Overview of TCP/IP protocol
Lecture 3: Secure Network Architecture
Firewalls.
Firewalls Chapter 8.
Lecture9: Embedded Network Operating System: cisco IOS
Process-to-Process Delivery: UDP, TCP
Session 20 INST 346 Technologies, Infrastructure and Architecture
Transport Layer 9/22/2019.
Lecture9: Embedded Network Operating System: cisco IOS
Virtual Private Network
Firewalls.
Presentation transcript:

Lecture 1.1: Introduction

2 Agenda 1 1 What is Firewall Types of Firewall 2 2 Firewall in linux kernel 3 3

3 What is Firewall 1 1 Types of Firewall 2 2 Firewall in linux kernel 3 3

4 What is Firewall  Primary goal: protect an internal network (or host) from external attacks.  Inspects and controls network traffic  Controls the incoming and outgoing network traffic from a network (or host) based on a rule set.  A firewall establishes a barrier between a trusted, secure internal network and another network (e.g., the Internet) that is not assumed to be secure and trusted.  Can be hardware or software-based, depends on needs

5 Network topology  All network traffic should go though the firewall to be effective  We need to set up the network topology in such way that all incoming/outgoing traffic will go though the firewall.

6 Uses of firewall  Barrier between a trusted network to the world  Enforce protocol correctness.  Enforce policy of the network administrator.  Minimize chance of intrusion & attacks.  Can operate in different levels of the network stack. –First firewalls looked up to the TCP/IP level. –Today’s firewalls inspect all the way up to the application level.

7 Firewall’s capabilities and implementation goals  Implementation goals: –Should have minimum performance impact on the network –Easy to configure –Provide the user information (logging or monitor system)  Limitations: –Cannot inspect packets which bypass the firewall. –Internal threats usually don’t get inspected by the firewall –Virus-infected files and programs are transparent to the firewall

8 How does Firewall works 1 1 What is Firewall Types of Firewall 2 2 Firewall in linux kernel 3 3

9 Types of Firewall (chronological order)  Static packet filtering gateway –Stateless packet filtering/inspection  Circuit-level Gateway  Application-level/proxy gateway  Dynamic packet filtering gateway –Stateful inspection

10 But first, OSI and TCP/IP models  The OSI and Tcp/ip models

11 TCP/IP  We need to get two applications situated in remote hosts to communicate.  We have a standard model that divides the communication functionality to separated abstraction layers.  Each layer implementation is hidden from other layers implementation.  Each layer has a protocol family which governs the way information is passed by it.  We will be interested mostly in layers 3 and 4, and the data itself

12 Layer 3 (network layer)

13 Layer 4 (Transport layer)  On each host there is an application. Both applications need to pass data between them. –Need to make sure the data gets to the applications in the order it was send. –Needs to make sure the data gets to the correct destination.  We have a TCP protocol family to make sure it happens. –For every chunk of data received the sending host needs to be informed. –To start sending data, there got to be a connection. –When no more data needs to be send the connection must be closed.

14 Layer 4 (Transport layer) – establishing a connection.  To initiate a TCP connection, we have a 3-way handshake: –SYN + seq(X) –“Hello, I’m here. I chose X.” –SYN + seq(Y) + ACK + ack(X+1) –“I heard your X. here’s your X+1. I’m here too, I chose Y.” –ACK + ack(Y+1) –“I heard your Y, here’s your Y+1.”  Now a connection has been established.

15 Layer 4 (Transport layer) – passing data.  Now that we have a connection we can start sending data.  On each host every application has a port number.  When a packet arrives to the host it moves the data to the process that is associated with that port.  Server usually have a publicly known port numbers – – –SSH:22  Clients usually have higher numbers that changes between every client.

16 Layer 4 (Transport layer) – passing data (continues)  Each side sends data to the other side.  The data is chunked over segments.  The side that sends the packets wait for a conformation.  After it receives ACK it continues to send data  In any case of data getting lost, we can ask for retransmission.

17 Layer 4 (Transport layer) – terminating a connection.  To terminate a connection: –FIN (client) –“I want to end this conversation” –ACK + FIN(server) –“ok, just let me finish…I’m done” –ACK (client) –“bye bye”

18 A packet’s journey  The tcp/ip stack Logical transfer physical transfer

19 Stateless packet filtering Works by a static rule table Each packet is individual Works on the transport and network layers Checks only the interesting header fields and compare them with the rules, doesn't look in the packet’s data Each packet that is inspected waits for a verdict - accept or drop

20 IP header (network layer)  We need to see the source and destination ip addresses to determine if accept or deny the packet

21 TCP header (transport layer)  We want to know the source and destination ports, and the syn/ack flags to determine if accept or deny the packet

22 Stateless packet filtering  Rule for example –We’re not allowing incoming network designated to port 80. DirectionSrc address Dst address ProtocolSrc portDst portSyn/AckAction InAnyNetworkany 80Anydeny

23 Stateless inspection Pros Low performance impact Easy to configure Transparent to the client Cons Relies on static header fields, therefore easy to spoof and manipulate Doesn’t look in the data itself

24 Circuit-level Gateway Monitor TCP handshake between packets to determine if the session request is legitimate. Saves connections in dynamic connection tables Create 2 TCP connection, functions as MITM Works on the session layer

25 Circuit-level Gateway Pros Low performance impact conceal the network itself from the external computer Transparent to the client Cons Doesn’t filter individual packets, after legitimate session opening doesn’t check what’s coming Handle only TCP connections

26 Application-level/proxy gateway [Restricted] ONLY for designated groups and individuals Sits in the middle of the service and operate as a server (to the client) and as a client (to the server) Hence – a proxy server, filter and examine individual packets streams, depends on the service/application Works on the application layer

27 Application-level/proxy gateway Pros Inner hosts ip hiding Header destruction Protocol enforcement logging Cons High performance impact (data based filter, not only specific fields from headers) Not transparent to the client Only supported protocols can be used

28 Stateful inspection [Restricted] ONLY for designated groups and individuals Decide what to do with a packet based on: - Dynamic connection tables - Old connections - Information from the application layer Combination of all older methods Inspect the headers and the data

29 Stateful inspection Pros Good security coverage, deals with all levels and able to provide high level of defense No proxies – transparent to the client Cons Complicated and can hurt security and experience if not managed properly Most expansive method (requires most resources)

30 Types of Firewall 1 1 What is Firewall Types of Firewall 2 2 Firewall in linux kernel 3 3

31 Packet inspection in Linux kernel  As we discus, the firewall should have minimum performance impact. Therefore we need to implement it in the kernel, so it would have access to linux network structures to be able to see the packets.  Linux use structure for each protocol and layer.  We will be interested in the internet and transport layer (and of course the data itself) Data HTTP/ OK0x20Last-Modified: Mon, 07 Apr :16:25 GMT0x20Content-Type: image/jpeg0x20Cache-Control: max-age = x20magicmarker: 10x20Content-Length: 47060x20Accept-Ranges: bytes0x20Date: Mon, 07 Apr :35:46 GMT0x20X-Varnish: x20Age: Data HTTP/ OK0x20Last-Modified: Mon, 07 Apr :16:25 GMT0x20Content-Type: image/jpeg0x20Cache-Control: max-age = x20magicmarker: 10x20Content-Length: 47060x20Accept-Ranges: bytes0x20Date: Mon, 07 Apr :35:46 GMT0x20X-Varnish: x20Age: IP header TCP/UDP header

Lecture 1.2: Linux and Networking

33 Agenda 1 1 Linux kernel modules and networking Netfilter 2 2 About first Assignment Virtualization

34 Virtualization 1 1 Netfilter Linux kernel modules and networking About first Assignment 4 4

35 Virtual network  Virtual Machine software, like VMware or VirtualBox, provide a service which allow us to build not only virtual computers, but virtual networks too.

36 The Virtual NIC  Although we only have one NIC, we can simulate multiple NICs  vNICs send and receive data through the physical NIC  Data is written to register-variables, sent to the physical registers.  When an answer arrived the NIC interrupts, the virtualization layer inject the interrupt into the vNIC. Virtualization layer

37 Virtual Network in our Workshop inout

38 The VMs  There are three virtual machines we will work with: 1.FW: this is the firewall machine, which will sit in the middle of the topology. It runs Ubuntu with GUI, so you can do development inside the VM in out

39 The VMs  There are three virtual machines in the course site: 2-3. host1 and host2: testing machines which will communicate with each other though your firewall. Runs Ubuntu cli in out

40 Linux kernel modules and networking 1 1 Virtualization Linux kernel modules and networking 2 2 Netfilter 3 3 About first Assignment 4 4

41 What is a Kernel Module  An object file that contains code to extend the operating system’s kernel  Loaded at run time, after kernel is already up and running  Adds functionality: –Device drivers –New features

42 How kernel modules different from user- space programs  Cannot user regular libraries, like stdlib –Most of C library is implemented in the kernel –Besides, offers some nice utilities  Cannot use floating point math  Run in privileged mode, so security is critical –Don’t trust the user –Check all input sizes, formats, etc. –Check all exceptional conditions and potential errors –Don’t trust the user  More about it - Linux Kernel Development, pages 16-22Linux Kernel Development

43 Building the Module  The purpose – eliminate the need to re-compile the kernel every time you need to add/remove a specific feature.  A Makefile that adapts itself to current kernel.  Put the module in and out the kernel by command line – insmod to insert the module – rmmod to remove it  Initialization function that is called when the module enters the kernel.  Cleanup function that is called when the module is removed from the kernel.

44 Simple kernel module #include /* Needed by all modules */ #include /* Needed for KERN_INFO */ int init_module(void) { printk(KERN_INFO "Hello World!\n"); return 0; /* if non-0 return means init_module failed */ } void cleanup_module(void) { printk(KERN_INFO "Goodbye World!\n"); }

45 Explanation  init_module() is called when module is loaded  cleanup_module() is called when module is unloaded  Another option: Macros!

46 Simple module with macros #include /* Needed by all modules */ #include /* Needed for KERN_INFO and for the Macros */ static int __init my_module_init_function(void) { printk(KERN_INFO "Hello World!\n"); return 0; /* if non-0 return means init_module failed */ } static void __exit my_module_exit_function(void) { printk(KERN_INFO "Goodbye World!\n"); } module_init(my_module_init_function); module_exit(my_module_exit_function);

47 What are Macros and why  __init and __exit macros tells the kernel when we use those functions  This allows to free kernel memory that is used only at init –Kernel memory is scarce, and we need to free it whenever we can

48 How to compile a Linux module?  Suppose that our simple module called “module.c”  We need in this folder another file called “Makefile” (case sensitive).  This file contains instructions to the OS how to compile this module.

49 Simple Makefile obj-m += module.o all: make -C /lib/modules/$(shell uname -r)/build M=$(PWD) modules clean: make -C /lib/modules/$(shell uname -r)/build M=$(PWD) clean

50 How to compile a Linux module?  Then, the command “make” compiles the module.  The file “module.ko” is the executable file.

51 How to load a Linux module?  The command “ insmod.ko ” binds the module to the kernel. The “init” function is being execute.  The command “ rmmod ” removes the module from the kernel. The “cleanup” function is being execute.

52 Our Kernel Module – The Firewall!  What will we do with our kernel module? (spoilers ahead) –Register our own functions (AKA: hooks) with the netfilter API, to issue verdicts on packets going in/out/through our Linux box. –Register a char device, to communicate with the user space –Send commands to set module values. –Receive data from the firewall about the state of the system.  When our module will be removed, it will clean up all this mess, as if it was never there.

53 Linux networking  We need a way to see the packets  Packets has headers for each layer and data  Linux contains set of useful tools and structures to manage packets over the kernel

Each packet comes with headers, each for every layer. The layers we are interested in are the network layer and transport layer Packet Headers Data HTTP/ OK0x20Last-Modified: Mon, 07 Apr :16:25 GMT0x20Content-Type: image/jpeg0x20Cache-Control: max-age = x20magicmarker: 10x20Content-Length: 47060x20Accept-Ranges: bytes0x20Date: Mon, 07 Apr :35:46 GMT0x20X-Varnish: x20Age: 83980x20Via: 1.1 varnish0x20Connection: keep-alive0x20X-Cache: Data HTTP/ OK0x20Last-Modified: Mon, 07 Apr :16:25 GMT0x20Content-Type: image/jpeg0x20Cache-Control: max-age = x20magicmarker: 10x20Content-Length: 47060x20Accept-Ranges: bytes0x20Date: Mon, 07 Apr :35:46 GMT0x20X-Varnish: x20Age: 83980x20Via: 1.1 varnish0x20Connection: keep-alive0x20X-Cache: IP header TCP/UDP header

IP Header

IP Header, how Linux knows it struct iphdr { #if defined(__LITTLE_ENDIAN_BITFIELD) __u8 ihl:4, version:4; #elif defined (__BIG_ENDIAN_BITFIELD) __u8 version:4, ihl:4; #else #error "Please fix " #endif __u8 tos; __u16 tot_len; __u16 id; __u16 frag_off; __u8 ttl; __u8 protocol; __u16 check; __u32 saddr; __u32 daddr; /*The options start here. */ }; Declared in linux/ip.h To be on the safe side, don’t forget to use htonl, htons, ntohl, ntohs when processing the fields

Data HTTP/ OK0x20Last-Modified: Mon, 07 Apr :16:25 GMT0x20Content-Type: image/jpeg0x20Cache-Control: max-age = x20magicmarker: 10x20Content-Length: 47060x20Accept-Ranges: bytes0x20Date: Mon, 07 Apr :35:46 GMT0x20X-Varnish: x20Age: 83980x20Via: 1.1 varnish0x20Connection: keep-alive0x20X-Cache: Data HTTP/ OK0x20Last-Modified: Mon, 07 Apr :16:25 GMT0x20Content-Type: image/jpeg0x20Cache-Control: max-age = x20magicmarker: 10x20Content-Length: 47060x20Accept-Ranges: bytes0x20Date: Mon, 07 Apr :35:46 GMT0x20X-Varnish: x20Age: 83980x20Via: 1.1 varnish0x20Connection: keep-alive0x20X-Cache: IP header Each packet comes with headers, each for every layer. The layers we are interested in are the network layer and transport layer Packet Headers TCP/UDP header

Data HTTP/ OK0x20Last-Modified: Mon, 07 Apr :16:25 GMT0x20Content-Type: image/jpeg0x20Cache-Control: max-age = x20magicmarker: 10x20Content-Length: 47060x20Accept-Ranges: bytes0x20Date: Mon, 07 Apr :35:46 GMT0x20X-Varnish: x20Age: 83980x20Via: 1.1 varnish0x20Connection: keep-alive0x20X-Cache: Data HTTP/ OK0x20Last-Modified: Mon, 07 Apr :16:25 GMT0x20Content-Type: image/jpeg0x20Cache-Control: max-age = x20magicmarker: 10x20Content-Length: 47060x20Accept-Ranges: bytes0x20Date: Mon, 07 Apr :35:46 GMT0x20X-Varnish: x20Age: 83980x20Via: 1.1 varnish0x20Connection: keep-alive0x20X-Cache: IP header Each packet comes with headers, each for every layer. The layers we are interested in are the network layer and transport layer Packet Headers TCP/UDP header

TCP Header

TCP Header, how Linux knows it struct tcphdr { __u16 source; __u16 dest; __u32 seq; __u32 ack_seq; #if defined(__LITTLE_ENDIAN_BITFIELD) __u16 res1:4, doff:4, fin:1, syn:1, rst:1, psh:1, ack:1, urg:1, ece:1, cwr:1; #elif defined(__BIG_ENDIAN_BITFIELD) … #else #error "Adjust your defines" #endif __u16 window; __u16 check; __u16 urg_ptr; }; Defined in linux/tcp.h

UDP Header struct udphdr { __u16 source; __u16 dest; __u16 len; __u16 check; }; Defined in linux/udp.h

ICMP Header struct icmphdr { __u8 type; __u8 code; __sum16 checksum; union { struct { __be16 id; __be16 sequence; } echo; __be32 gateway; struct { __be16 __unused; __be16 mtu; } frag; } un; }; Defined in linux/icmp.h

Data HTTP/ OK0x20Last-Modified: Mon, 07 Apr :16:25 GMT0x20Content-Type: image/jpeg0x20Cache-Control: max-age = x20magicmarker: 10x20Content-Length: 47060x20Accept-Ranges: bytes0x20Date: Mon, 07 Apr :35:46 GMT0x20X-Varnish: x20Age: 83980x20Via: 1.1 varnish0x20Connection: keep-alive0x20X-Cache: Data HTTP/ OK0x20Last-Modified: Mon, 07 Apr :16:25 GMT0x20Content-Type: image/jpeg0x20Cache-Control: max-age = x20magicmarker: 10x20Content-Length: 47060x20Accept-Ranges: bytes0x20Date: Mon, 07 Apr :35:46 GMT0x20X-Varnish: x20Age: 83980x20Via: 1.1 varnish0x20Connection: keep-alive0x20X-Cache: sk_buff IP header: TCP/UDP header The Linux struct that holds a pointer to the packet and metadata about the packet Hold many fields for many purposes head, data, tail, end transport layer headers tcphdr, udphdr, icmphdr network layer headers iph, ipv6h The packet is copied directly to the RAM (DMA) and each part of the kernel that touches it, just gets a pointer

64 Agenda 1 1 Virtualization Linux kernel modules and networking 2 2 Netfilter 3 3 About first Assignment 4 4

65 Netfilter  Easy API to handle and examine packets from the internet –#include  Allow us to hook functions to the packet’s route on a specific (important) points though the kernel  There are 5 inspection points we can hook into, each for a different type of packets.

66 Netfilter hook points  Where packets come in, having passed the simple sanity checks they are passed to the netfilter framework's NF_IP_PRE_ROUTING hook.

67 Netfilter hook points  The routing code decides whether the packet is destined for another interface or a local process. If it's destined for the box itself, the netfilter framework is called again for the NF_IP_LOCAL_IN hook, before being passed to the process

68 Netfilter hook points  If it's destined to pass to another interface instead, the netfilter framework is called for the NF_IP_FORWARD hook

69 Netfilter hook points  The packet then passes a final netfilter hook, the NF_IP_POST_ROUTING hook, before the packet reaches the wire again.

70 Netfilter hook points  The NF_IP_LOCAL_OUT hook is called for packets that are created locally. –Routing code is called before this hook to figure out the IP address and after this hook to decide the route.

71  The hook function has a specific signature  It has specific input arguments that the kernel puts there – a sk_buff pointer to the sk_buff struct for the packet that has just passed through that specific point at the route –The hooknum (the place that the function was called from) –device_in and device_out, the network device sturct for the device that received the packet and for the device that should transmit the packet –A pointer to an “okay function” that will deal with the packet if all the hooks on that point will return ACCEPT struct nf_hook_ops { struct list_head list; /* User fills in from here down. */ nf_hookfn *hook; int pf; int hooknum; /* Hooks are ordered in ascending priority.*/ int priority; }; unsigned int hook_func_in( unsigned int hooknum, struct sk_buff *skb, const struct net_device *in, const struct net_device *out, int (*okfn)(struct sk_buff *)) The hook

72 Agenda 1 1 Virtualization Linux kernel modules and networking 2 2 Netfilter 3 3 About first Assignment 4 4

73 Assignment 1 – Building the virtual lab  In this assignment we will create the virtual lab  Use VirtualBox or VMware workstation. –Don’t use VMware player, it doesn’t support virtual networks  Pay attention for network configuration (make it persistent)  In the course site you’ll have 3 VMs (for VirtualBox): Host1and FW, so wont have to lose time installing Ubuntu machines. Most of the heavy coding will be performed on the FW VM.

74 Assignment 1  Make sure you don’t have kernel panics when you load the module – this would have heavy penalty on your grade  In this assignment, you decide the verdict for each packet base on it’s type, not content. Make use of that fact to make it easier on you. That said, you can use whatever method you want.  This code will be used in the next assignments. Make it fabulous.