SlideShare a Scribd company logo
Custom IP Router
Vishal Vasudev
University of Southern California
Los Angeles, CA
vasudev@usc.edu
Varunika Gupta
University of Southern California
Los Angeles, CA
varunikg@usc.edu
Rahul Mishra
University of Southern California
Los Angeles, CA
rmishra@usc.edu
ABSTRACT
This paper demonstrates the steps involved in designing a custom
protocol with custom network, which will have custom defined
IP/TCP/UDP header and changes in the Ethernet structure.
Application protocol like ftp will be developed to run on this
custom network and throughput and performance will be
measured.
Keywords
Custom Network, Modified stack, libpcap, raw sockets,
ARP table, Routing Table
1. INTRODUCTION
Traditional TCP header of size varying from 20 bytes to 60
bytes (20 bytes mandatory plus 40 bytes for options) carry
lot of information such as Source port (16 bits) that
identifies the sending port and Destination port (16 bits)
that identifies the receiving port, Sequence number (32 bits)
that has a 2 role: If the SYN flag is set as 1 then this is the
initial sequence number. The sequence number of the actual
first byte of data and the ack number in the corresponding
ACK are then this sequence number plus 1. And If
the SYN flag is 0, then this is the accumulated sequence
number of the first byte of data of this segment for the
current session. Acknowledgment number (32 bits), if
the ACK flag is set then the value of this field is the next
sequence number that the receiver is expecting. This
acknowledges receipt of all prior bytes (if any). The first
ACK sent by each end acknowledges the other end's initial
sequence number itself, but no data. Data offset of 4 bits
that specifies the size of the TCP header in 32-bit words.
Thus giving the minimum size of 20 bytes and maximum of
60 bytes, allowing for up to 40 bytes of options in the
header. While in case of UDP the size of header is 8 bytes
and it consists of 4 fields source port number , destination
port number, length (of header + data) and checksum. The
IPv4 header at Network layer is of 20 bytes and contains
fields such as Version, IP, Header Length, Type of Service
(ToS),Size of
datagram ,Identification ,Flags ,Fragmentation Offset, Time
To Live ,Header Checksum ,Source Address, Destination
Address and Options. Processing each of these fields while
routing a packet adds lot of processing delay that’s why we
made a custom network protocol as described below to
make the packet transmission faster within our custom
network.
Our custom network will be subjected to some of the
real life tests that make the network provide reliable
connectivity to the end nodes.
2. OVERVIEW OF IMPLEMENTATION
The custom router was implemented to imitate real world
routers. This section gives details about how the
functionalities of the router were implemented in our code.
2.1 Custom Network Design
In order to capture packets and forward them within the
network, all nodes and routers need to be aware of the
layering mechanism being used. Hence we need to make all
the nodes aware of the underlying modified IP layer being
used. The topology for this lab consists of a three node
topology with 2 host and a router. We have two networks
one consisting of the sender node and the router and the
other consisting of the receiver node and the router. We
differentiate the networks based on their custom IP
addresses which is explained in the next section.
2.2 Custom Header Design
The custom header combines the essential features of the IP
and the transport layer to provide the basic yet reliable
features into one layer. The custom header consists of the
following fields:
Source and destination address:
We have chosen a 16 bit address for the source and
destination of the nodes on the interface. The first 2 bits are
to represent the network address or subnet that the node
belongs to and the other 14 bits are to represent the host ID.
This allows scalability to extend the number of nodes on
each network to 10,000 nodes since 2^14 is 16384 hosts.
Also, the 2 bits for network can support 4 different
networks since 2^2 is 4 networks.
Sequence Number:
This field is a 16 bit number which is used to keep track of
the packets sent from the file sender node. This allows the
receiver to keep track of the packets since packets can be
sent and received out of sequence. This is useful to
assemble the file at the receiver node and can be considered
as source of reliability in our custom network protocol as
the receiver can look into sequence number and later on at
application layer the application can ask for missing packet
with particular sequence number.
Source and Destination Port Number:
This field uses 8 bits each to represent destination and
source port. This is useful since the sending and the
receiving application will be able to determine the correct
packet based on the port number.
2.3 Elimination of IP Header fields
Some of the IP header fields have been eliminated in our
design to cater for the essential fields and improve the
performance of the network. Some of the fields removed
are:
Version: This has been eliminated since we are using a
small network and only using one version of IP, we do not
need this field.
Type Of Service (TOS): There is no priority mechanism in
place, hence this can be eliminated.
IP Header length: We have a predefined header length
which is known to all the nodes, hence this field is
eliminated.
Fragmentation Offset: This is a redundant field since we
are already setting our maximum frame size to 1200 bytes
at the application side. Hence this is also removed.
Header checksum: The DETER nodes setup does not
emulate any data corruption, hence we can be sure that
there will be no corruption of the packets and hence this
field is removed.
Identification: Since the MTU size is fixed we can
eliminate this field as well.
Protocol: We are wrapping our payload in a custom
header, we can also eliminate this field.
2.4 Implementation
We have used the custom header to implement the network.
Packets are sent over the network with the encapsulated
payload with the custom header over the payload. Using
libpcap library, packets are sniffed and injected.
The router code has been modified to accommodate the
custom header into the network. The file to be sent has been
mapped to improve the efficiency. This is done using the
mmap system call. The sender node will split the file into
packets which is calculated based on the file size and the
packet size that is decided by the node. The packet is then
encapsulated inside the custom header. The router then
received the packet and does a look up based on the first 2
bits. The packet is then injected to the appropriate interface.
The receiver on receiving this packet then de-encapsulates
it based on the offset and extracts the payload.
3. QUESTIONS AND ANSWERS
Q1. Constraints that NIC have placed?
A1. NIC acts as an interface between computer and network
cable. Its role is to prepare data from the computer for
network cable, send data to other computer and control the
data flow between two nodes (computer), receive incoming
data from cable and translate it into bytes form. Both
sending and receiving NIC exchange or negotiate on
following parameters –
1) Maximum size of chunk or group of data to be
sent.
2) Time interval between sending data.
3) Speed of data transmission
The default maximum transmission unit size is 1500 bytes
at Network layer for Ethernet carrier.
If the MTU of other network is less than the sent MTU size
then it needs to be fragmented and thus the overhead
processing time for managing the fragment offset and other
functions for fragmentation increases the processing time
and thus reduces throughput so generally NIC are
constraints the MTU size to 1500 bytes at network layer
and 1518 bytes at data link layer as the de facto MTU size
for Ethernet carrier is 1518 bytes at data link layer.
NIC also adds preamble and CRC bits.
Q2. Constraints of Network data.
Below shown is the traditional IPv4 header format.
The mandatory length of IPv4 header is 20 byes with 40
bytes for option field. The various fields in IPV4 header are
as shown below-
Fig 1 : IPV4 header format
In traditional OSI model kind of structure used currently by
internet for each packet sent from the sending node we add
a header to the data being sent right from the start i.e
application layer . Then in the presentation layer , then in
session layer . then in transport layer we add a header which
contains field e.q in case of UDP it contains source port and
destination port for process to process delivery and data
length field and checksum. Similarly in the network layer
we have IPv4 header as shown above. Many of the fields
used in these headers are redundant and in some scenarios
not at all useful. All of these things add a lot of overhead in
processing of each data at the router before it transmit it to
other interface. Thus this limits the throughput of router.
4. RESULTS AND ANALYSIS
We limit the number of nodes to 3 where the center node is
the router and the left node is the sender and the right node
being the receiver.
4.1 TEST SETUP
The configuration of our set up is like – nodeA connects to
router rtr with a 1 Mbps link and 5 ms delay and node b is
conncted to rtr with 1 Mbps link and 5 ms delay.
Packet Size in bytes Throughput in Kilo bits
per second
1400bytes 902 Kbps
1350 bytes 876 Kbps
1300 bytes 748 Kbps
1250 bytes 650 Kbps
1000 bytes 550 Kbps
700 bytes 412 Kbps
400 bytes 250 Kbps
400 500 600 700 800 900 1000 1100 1200 1300 1400
200
300
400
500
600
700
800
900
PacketS
ize In Kbps
ThroughputinKbps
Fig 2: Above plot shows Throughput vs Packet size for
sending a file of 10 MB from nodeA to nodeB.
ANALYSIS
Through the results we analyzed that throughput improves
tremendously by using the custom network protocol this
may be attributed to the fact that lot of processing delays to
lot of fields present in traditional UDP/IP header is
removed in custom protocol thus improvement came
through less processing time. Also from Fig2 we see the
throughput increases as we increase the packet size this is
due to the fact that the bigger the packet size lesser the
number of packets formed for sending same data and thus
lesser processing overhead for the header fields in the
packet. And when the packet size is less there is more
number of packets for same data and more processing time
as we have to process header of each packet sent.
HOW TO RUN PROGRAM
ReadMe instruction
Compile the code files attached using below commands .
1) Sender node
gcc -g sender_node.c -o sender -lpcap –lpthread
2) Router node
gcc -g router.c -o router -lpcap –lpthread
3) Receiver node
gcc -g receiver_node.c -o receiver -lpcap –lpthread
Create test.txt file on sender node run sudo ./sender on
sender node , sudo ./router on router
node and sudo ./receiver test5.txt . File will get copied to
receiver node .
5. CONCLUSION
Thus through this experiment we can conclude that using
our custom network protocol with limited number of
necessary fields in header (only 8 bytes) we can improve
the throughput performance of network. Also with variation
in packet size we observed that higher the packet size
higher is the throughput obtained.
.
6. REFERENCES
[1] Luis Martin Garcia, Programming with libpcap-
sniffing the network from our own application
[2] Tutorials on tcpdump.org
[3] Kefei Cheng; Yanglei Cui, Design and implementation
of network packets collection tools based on the
android platform. 2012 9th International Conference on
Fuzzy Systems and Knowledge Discovery (FSKD)

More Related Content

PPT
Ipv6up
PPT
Ipv4 ppt
PPTX
Internet Protocol Version 4
PPT
I pv4 format
PPTX
REMnux tutorial 4.1 - Datagrams, Fragmentation & Anomalies
PDF
IP Datagram Structure
PPT
internet protocols
PDF
Ipv4 tutorial
Ipv6up
Ipv4 ppt
Internet Protocol Version 4
I pv4 format
REMnux tutorial 4.1 - Datagrams, Fragmentation & Anomalies
IP Datagram Structure
internet protocols
Ipv4 tutorial

What's hot (20)

PPTX
Ipv4 header
PPTX
Network layer
PDF
Ipv4 packet structure
PDF
Data communication part2
PPT
Internet protocol
PDF
Network layer logical addressing
PPT
Exploration network chapter_5_modified
PDF
Neighbor Discovery Deep Dive – IPv6-Networking-Referat
PPTX
User datagram protocol (udp)
PPT
TCP/IP Basics
DOCX
Internet protocol
PPT
Training Day Slides
PPT
I pv4 and ipv6
PPTX
Internet Protocols
PPTX
IPv6 - Neighbour Discovery
PPT
Tcp ip
PDF
IPv6 Routing.pdf
PPTX
Transport layer
Ipv4 header
Network layer
Ipv4 packet structure
Data communication part2
Internet protocol
Network layer logical addressing
Exploration network chapter_5_modified
Neighbor Discovery Deep Dive – IPv6-Networking-Referat
User datagram protocol (udp)
TCP/IP Basics
Internet protocol
Training Day Slides
I pv4 and ipv6
Internet Protocols
IPv6 - Neighbour Discovery
Tcp ip
IPv6 Routing.pdf
Transport layer
Ad

Similar to Custom_IP_Network_Protocol_and_Router (20)

PPTX
Computer Network - Network Layer
PPT
Internet Protocol
DOCX
As the packet travels through the TCP.docx
PPTX
10 coms 525 tcpip - internet protocol - ip
PPTX
Introduction to IP
PPT
mohammad.ppt jahsjajajajajajwjjwjwjwjajajaja
PPT
Network Layer
DOCX
TCP/IP 3RD SEM.2012 AUG.ASSIGNMENT
PPTX
CN Unit 4.pptx related to ip network klk;k;hgkjkgkdk
PPT
PDF
The Internet Protocol version 4 (IPv4)
PPTX
Ch 19 Network-layer protocols Section 1
PPTX
Tcp header/IP Header/Authentication header
PDF
tcpheader-151221111244.pdf
PPT
Final Presentation
PPTX
TCP and UDP comparison and itsi application.pptx
PDF
I.p. protocol
PPT
Lecture 5 internet-protocol_assignments
DOC
Some important networking questions
PDF
Network Layer & Transport Layer
Computer Network - Network Layer
Internet Protocol
As the packet travels through the TCP.docx
10 coms 525 tcpip - internet protocol - ip
Introduction to IP
mohammad.ppt jahsjajajajajajwjjwjwjwjajajaja
Network Layer
TCP/IP 3RD SEM.2012 AUG.ASSIGNMENT
CN Unit 4.pptx related to ip network klk;k;hgkjkgkdk
The Internet Protocol version 4 (IPv4)
Ch 19 Network-layer protocols Section 1
Tcp header/IP Header/Authentication header
tcpheader-151221111244.pdf
Final Presentation
TCP and UDP comparison and itsi application.pptx
I.p. protocol
Lecture 5 internet-protocol_assignments
Some important networking questions
Network Layer & Transport Layer
Ad

Custom_IP_Network_Protocol_and_Router

  • 1. Custom IP Router Vishal Vasudev University of Southern California Los Angeles, CA vasudev@usc.edu Varunika Gupta University of Southern California Los Angeles, CA varunikg@usc.edu Rahul Mishra University of Southern California Los Angeles, CA rmishra@usc.edu ABSTRACT This paper demonstrates the steps involved in designing a custom protocol with custom network, which will have custom defined IP/TCP/UDP header and changes in the Ethernet structure. Application protocol like ftp will be developed to run on this custom network and throughput and performance will be measured. Keywords Custom Network, Modified stack, libpcap, raw sockets, ARP table, Routing Table 1. INTRODUCTION Traditional TCP header of size varying from 20 bytes to 60 bytes (20 bytes mandatory plus 40 bytes for options) carry lot of information such as Source port (16 bits) that identifies the sending port and Destination port (16 bits) that identifies the receiving port, Sequence number (32 bits) that has a 2 role: If the SYN flag is set as 1 then this is the initial sequence number. The sequence number of the actual first byte of data and the ack number in the corresponding ACK are then this sequence number plus 1. And If the SYN flag is 0, then this is the accumulated sequence number of the first byte of data of this segment for the current session. Acknowledgment number (32 bits), if the ACK flag is set then the value of this field is the next sequence number that the receiver is expecting. This acknowledges receipt of all prior bytes (if any). The first ACK sent by each end acknowledges the other end's initial sequence number itself, but no data. Data offset of 4 bits that specifies the size of the TCP header in 32-bit words. Thus giving the minimum size of 20 bytes and maximum of 60 bytes, allowing for up to 40 bytes of options in the header. While in case of UDP the size of header is 8 bytes and it consists of 4 fields source port number , destination port number, length (of header + data) and checksum. The IPv4 header at Network layer is of 20 bytes and contains fields such as Version, IP, Header Length, Type of Service (ToS),Size of datagram ,Identification ,Flags ,Fragmentation Offset, Time To Live ,Header Checksum ,Source Address, Destination Address and Options. Processing each of these fields while routing a packet adds lot of processing delay that’s why we made a custom network protocol as described below to make the packet transmission faster within our custom network. Our custom network will be subjected to some of the real life tests that make the network provide reliable connectivity to the end nodes. 2. OVERVIEW OF IMPLEMENTATION The custom router was implemented to imitate real world routers. This section gives details about how the functionalities of the router were implemented in our code. 2.1 Custom Network Design In order to capture packets and forward them within the network, all nodes and routers need to be aware of the layering mechanism being used. Hence we need to make all the nodes aware of the underlying modified IP layer being used. The topology for this lab consists of a three node topology with 2 host and a router. We have two networks one consisting of the sender node and the router and the other consisting of the receiver node and the router. We differentiate the networks based on their custom IP addresses which is explained in the next section. 2.2 Custom Header Design The custom header combines the essential features of the IP and the transport layer to provide the basic yet reliable features into one layer. The custom header consists of the following fields: Source and destination address: We have chosen a 16 bit address for the source and destination of the nodes on the interface. The first 2 bits are to represent the network address or subnet that the node belongs to and the other 14 bits are to represent the host ID. This allows scalability to extend the number of nodes on each network to 10,000 nodes since 2^14 is 16384 hosts. Also, the 2 bits for network can support 4 different networks since 2^2 is 4 networks. Sequence Number: This field is a 16 bit number which is used to keep track of the packets sent from the file sender node. This allows the receiver to keep track of the packets since packets can be sent and received out of sequence. This is useful to assemble the file at the receiver node and can be considered as source of reliability in our custom network protocol as the receiver can look into sequence number and later on at
  • 2. application layer the application can ask for missing packet with particular sequence number. Source and Destination Port Number: This field uses 8 bits each to represent destination and source port. This is useful since the sending and the receiving application will be able to determine the correct packet based on the port number. 2.3 Elimination of IP Header fields Some of the IP header fields have been eliminated in our design to cater for the essential fields and improve the performance of the network. Some of the fields removed are: Version: This has been eliminated since we are using a small network and only using one version of IP, we do not need this field. Type Of Service (TOS): There is no priority mechanism in place, hence this can be eliminated. IP Header length: We have a predefined header length which is known to all the nodes, hence this field is eliminated. Fragmentation Offset: This is a redundant field since we are already setting our maximum frame size to 1200 bytes at the application side. Hence this is also removed. Header checksum: The DETER nodes setup does not emulate any data corruption, hence we can be sure that there will be no corruption of the packets and hence this field is removed. Identification: Since the MTU size is fixed we can eliminate this field as well. Protocol: We are wrapping our payload in a custom header, we can also eliminate this field. 2.4 Implementation We have used the custom header to implement the network. Packets are sent over the network with the encapsulated payload with the custom header over the payload. Using libpcap library, packets are sniffed and injected. The router code has been modified to accommodate the custom header into the network. The file to be sent has been mapped to improve the efficiency. This is done using the mmap system call. The sender node will split the file into packets which is calculated based on the file size and the packet size that is decided by the node. The packet is then encapsulated inside the custom header. The router then received the packet and does a look up based on the first 2 bits. The packet is then injected to the appropriate interface. The receiver on receiving this packet then de-encapsulates it based on the offset and extracts the payload. 3. QUESTIONS AND ANSWERS Q1. Constraints that NIC have placed? A1. NIC acts as an interface between computer and network cable. Its role is to prepare data from the computer for network cable, send data to other computer and control the data flow between two nodes (computer), receive incoming data from cable and translate it into bytes form. Both sending and receiving NIC exchange or negotiate on following parameters – 1) Maximum size of chunk or group of data to be sent. 2) Time interval between sending data. 3) Speed of data transmission The default maximum transmission unit size is 1500 bytes at Network layer for Ethernet carrier. If the MTU of other network is less than the sent MTU size then it needs to be fragmented and thus the overhead processing time for managing the fragment offset and other functions for fragmentation increases the processing time and thus reduces throughput so generally NIC are constraints the MTU size to 1500 bytes at network layer and 1518 bytes at data link layer as the de facto MTU size for Ethernet carrier is 1518 bytes at data link layer. NIC also adds preamble and CRC bits. Q2. Constraints of Network data. Below shown is the traditional IPv4 header format. The mandatory length of IPv4 header is 20 byes with 40 bytes for option field. The various fields in IPV4 header are as shown below- Fig 1 : IPV4 header format In traditional OSI model kind of structure used currently by internet for each packet sent from the sending node we add a header to the data being sent right from the start i.e application layer . Then in the presentation layer , then in session layer . then in transport layer we add a header which
  • 3. contains field e.q in case of UDP it contains source port and destination port for process to process delivery and data length field and checksum. Similarly in the network layer we have IPv4 header as shown above. Many of the fields used in these headers are redundant and in some scenarios not at all useful. All of these things add a lot of overhead in processing of each data at the router before it transmit it to other interface. Thus this limits the throughput of router. 4. RESULTS AND ANALYSIS We limit the number of nodes to 3 where the center node is the router and the left node is the sender and the right node being the receiver. 4.1 TEST SETUP The configuration of our set up is like – nodeA connects to router rtr with a 1 Mbps link and 5 ms delay and node b is conncted to rtr with 1 Mbps link and 5 ms delay. Packet Size in bytes Throughput in Kilo bits per second 1400bytes 902 Kbps 1350 bytes 876 Kbps 1300 bytes 748 Kbps 1250 bytes 650 Kbps 1000 bytes 550 Kbps 700 bytes 412 Kbps 400 bytes 250 Kbps 400 500 600 700 800 900 1000 1100 1200 1300 1400 200 300 400 500 600 700 800 900 PacketS ize In Kbps ThroughputinKbps Fig 2: Above plot shows Throughput vs Packet size for sending a file of 10 MB from nodeA to nodeB. ANALYSIS Through the results we analyzed that throughput improves tremendously by using the custom network protocol this may be attributed to the fact that lot of processing delays to lot of fields present in traditional UDP/IP header is removed in custom protocol thus improvement came through less processing time. Also from Fig2 we see the throughput increases as we increase the packet size this is due to the fact that the bigger the packet size lesser the number of packets formed for sending same data and thus lesser processing overhead for the header fields in the packet. And when the packet size is less there is more number of packets for same data and more processing time as we have to process header of each packet sent. HOW TO RUN PROGRAM ReadMe instruction Compile the code files attached using below commands . 1) Sender node gcc -g sender_node.c -o sender -lpcap –lpthread 2) Router node gcc -g router.c -o router -lpcap –lpthread 3) Receiver node gcc -g receiver_node.c -o receiver -lpcap –lpthread Create test.txt file on sender node run sudo ./sender on sender node , sudo ./router on router node and sudo ./receiver test5.txt . File will get copied to receiver node . 5. CONCLUSION Thus through this experiment we can conclude that using our custom network protocol with limited number of necessary fields in header (only 8 bytes) we can improve the throughput performance of network. Also with variation in packet size we observed that higher the packet size higher is the throughput obtained. . 6. REFERENCES [1] Luis Martin Garcia, Programming with libpcap- sniffing the network from our own application [2] Tutorials on tcpdump.org [3] Kefei Cheng; Yanglei Cui, Design and implementation of network packets collection tools based on the android platform. 2012 9th International Conference on Fuzzy Systems and Knowledge Discovery (FSKD)