Phase 2 - Network Layer

ACM Honored Class

Introduction

In this phase, you are going to implement the IP protocol and transmit data (so called datagrams) from node to node in the whole network.
IP protocol has identity number 0x0800 (for more detais see[3]) to distinguish from other protocols like ARP.This number is used to registe IP protocol in low level layer. Each node in the network also has its identity, i.e the IPv4 address, for example 192.168.1.1 .

A packet go through the network step by step. At each step, the router check the routing table and route the packet to the corresponding link until the router/node find itsself is the destination. Then the router/node passes the packet to the high level protocol.

Routing table can be set both staticly and dynamicly. Dynamic routing is not required in this phase.
Below is the header of the IP packet:
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|Version| IHL |Type of Service| Total Length |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Identification |Flags| Fragment Offset |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Time to Live | Protocol | Header Checksum |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Source Address |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
check your textbook or [1] for the meaning of the fields and how they are set.

Implementation Specification

IP layer utilizes low level protocol to provide service for high level protocol. The major functions required by our project is :
  1. Addressing: transmit datagrams toward their destinations.
  2. Fragmentation: use fields in the ip-packet header to fragment and reassemble datagrams when necessary.
  3. Checksum:check the ip-packet header using checksum or others methods.
  4. TTL: “Time to live” is important to prevent one packet run in the net forever.
IP layer doesn’t provide a reliable communication. No error check for data, no retransmissions and no flow control. Don't forget to recalculate the checksum when you modify any part of the header. You can ignore irrelevant fields in the header.

The interface for the IPProtocol is given in tenet.protocol.network.IPProtocol.
If you have any question, don't wait to ask.

Testing and Grading

Correctness comes the first. Besides, if you have any addition in you implementation , for example VPN ,multicast, write it in you report. Bonus has no limit.

Reference

  1. RFC791
  2. RFC790
  3. WIKI