SlideShare a Scribd company logo
1 of 24
Project description:
In this Phase, we will develop two nodes for the network
simulator. The first node is a trasmitter and the second node is a
receiver.
Each node is defined by a unique node_ID. That is, there are no
two nodes in the network with the same ID.
Since we are using a single machine to perform PHY
transmissions, the node_ID values can be arbitrary IP address.
Each node has five layers namely: application_layer,
transport_layer, network_layer, link_layer and PHY_layer.
For this phase of the project, we develop protocols for three
layers: application_layer, transport_layer and PHY_layer
Each layer (depending on its location) has allocated buffers to
establish communication with the other layers above or below
it.
For instance, the transport_layer has four buffers:
to_network_layer, from_network_layer, from_application_layer,
to_application_layer
For the application_layer, we will develop file transfer protocol
(FTP). The FTP class has two sides, the transmitter and receiver
sides.
The transmitter sides reads a file (specified by user) and convert
that into application_layer_messages.
The receiver side gets application_layer_messages from the
transport_layer converts them into single file.
For the transport_layer, we will develop UDP protocol. This
protocol has two sides, the transmitter and receiver sides.
The transmitter side gets the application_layer_messages from
the application_layer and converts them into transport_layer
segments.
Note that the length of each segment should be maximum
segment size MSS (excluding UDP header).
The value of MSS usually depends on the PHY link that each
node is connected to.
Each segment should have the following fields:
# application_layer_messages_no: 4bytes: 32 bits
# segment_no: packet number : 4bytes: 32 bits
# source_port: this field identifies the sender's port : 2 bytes:
16 bits
# destination_port: This field identifies the receiver's port: 2
bytes : 16 bits
# Length: the length in bytes of the UDP header and UDP
data : 2 bytes : 16 bits
# Checksum: the checksum field is used for error-checking of
the header and data. 2 bytes : 16 bits
# Reference flag: indicates the beginning of a set of segments
for an individual application message
It is important to note that each application_layer_messages is
divided to a set of segments. The reference byte represent the
beginning of each set.
The receiver side of the transport_layer gets the set of segments
and concatenated them to makes a single
application_layer_messages.
For the PHY layer, we use python socket library to send and
receive messages over ports.
This is because, we will use a single machine for the network
simulator.
The PHY sender simply transfers packets over the specified
port.
The PHY receiver listens to that port and send the received
packets to the upper layer.
For this Phase, you need to develop the following files:
application_layer.py: contains FTP class
transport_layer.py: contains UDP class
PHY_layer.py: contains PHY class
node.py: contains node class that defines an individual node in
the network simulator
network_simulator.py: that defines the topology of the network
(for this phase there are only two nodes, sender and receiver)
The program should run by the following command:
./network_simulator.py --FTP_filename = filename.txt
The output of the program should contains the following
information:
1. generate filename_RX.txt (the received file name)
2. generate network_simulator.log (this is the log file for the
network_simulator operations)
This file should contains the follwoing information:
# node_num_log: <number of the nodes in the netwok>
# node_ID_log: <list of the nodes IP address in a form of
node_ID:IP_address>
# application_layer_messages_log: <the number of messages
generated by application_layer>
# transport_layer_segments_log: <the number of segments
generated by the transport_layer>
# segment_length_log: the length of each segment
*****************************************************
***********************************
# Physical layer file *********Completed***********
# we will define different classes for the phy layer
communicaiton
import socket
class PHY:
def __init__(self,app_port,pkt_size):
# define private variables
# buffer for processing link layer pkts
self.from_link_layer = dict()
# buffer to send to the link layer
self.to_link_layer = dict()
# Define TX and RX socket objects
self.TX_sock =
socket.socket(socket.AF_INET,socket.SOCK_DGRAM)
self.RX_sock =
socket.socket(socket.AF_INET,socket.SOCK_DGRAM)
# Define TX and RX IP and ports
self.IP = "127.0.0.1"
# app_port is configured by the application layer
self.TX_port = app_port
self.RX_port = app_port + 1
self.pkt_size = pkt_size
def transmitter(self,pkt):
# send a single packet over the port <loopback ip>
self.TX_sock.sendto(str(pkt), (self.IP, self.TX_port))
def transmitter_wrapper(self):
# give packets one by one to the PHY TX
for pktno in self.self.from_link_layer:
self.transmitter(self.self.from_link_layer[pktno])
def receiver(self):
# get each packet from the RX port
pkt, addr = self.RX_sock.recvfrom(self.pkt_size)
return eval(pkt)
def receiver_wrapper(self):
while True:
pkt = self.receiver()
pktno = pkt['pktno']
#app_payload = pkt['app_payload']
self.to_link_layer[pktno] = pkt
*****************************************************
**********************************
*****************************************************
**********************************
# run this with python3--transport laye---Partially completed
# This function defines necessary classes for the transport layer
# This class implements UDP protocol at the transport layer
import math
# we use md5 library for checksum
import md5
# use bitarray to convert sequence of bits to bytes
from bitstring import BitArray
# BitArray().tobytes() converts sequence of bits to bytes
# BitArray().bin converts bytes to sequence of bits
# UDP_payload: data content for the application layer
class UDP:
def __init__(self,MSS,source_port,destination_port):
# define private variables here
#define a buffer to store UDP segments to send to the
network layer
#################
##
## Your Code Here
##
##################
# define a buffer that stored datagrams provided by the
network layer
#################
##
## Your Code Here
##
##################
# define a buffer to store concatenated packets into data
payload to send to the application layer
#################
##
## Your Code Here
##
##################
# define a buffer to get data payload from application layer
to convert them into UDP segments
#################
##
## Your Code Here
##
##################
# define a maximum segment size MSS, source_port and
destination_port
#################
##
## Your Code Here
##
##################
# convert source_port and destination_port to byte format
#################
##
## Your Code Here
##
##################
# segment_no : keeps track of segments we generate
#################
##
## Your Code Here
##
##################
def
transmitter(self,application_message,application_message_no):
# define the transmitter function that get application data
payload and convert them into UDP segments
# function input parameters: application_message
# lenght of application_message is in bytes
# application_message in represented in bytes
# each segment have the following fields <here we assume
UDP packets>
###### packet header contains
# pktno: packet number : 4bytes: 32 bits
# source_port: this field identifies the sender's port : 2 bytes:
16 bits
# destination_port: This field identifies the receiver's port: 2
bytes : 16 bits
# Length: the length in bytes of the UDP header and UDP
data : 2 bytes : 16 bits
# Checksum: the checksum field is used for error-checking of
the header and data. 2 bytes : 16 bits
# Reference flag: indicates the beginning of a set of segments
for an individual application message
######
# generates appropriate number of segments for each
application payload
# length of each segment should be MSS (excluding UDP
header)
# define pktno 32 bits = 4 bytes
# calculate number of segments necessary to convert the
payload into segments
#################
##
## Your Code Here
##
##################
# Generate UDP segments: each segments should contain
MSS bytes of application payload + 12 bytes of UDP header
(pktno + source_port + destination_port + lenght + checksum)
#################
##
## Your Code Here
##
##################
# reference byte is one for the very first segment of each
set.
#################
##
## Your Code Here
##
##################
# add segment_no + checksum to each segment_no
#################
##
## Your Code Here
##
##################
# store the application_message number associated with this
segment
#################
##
## Your Code Here
##
##################
# store the generated segment into the self.to_network_layer
buffer
#################
##
## Your Code Here
##
##################
def transmitter_wrapper(self):
# the transmitter_wrapper function fetch one
application_message from self.from_application_layer buffer
# and pass it to transmitter function to generate UDP
segments for that message
#################
##
## Your Code Here
##
##################
def receiver(self,segment_set):
# this function concatenates a set of segments that represent a
single application message
# input: a set of segments
# output: a single data message
# define an empty data message
#################
##
## Your Code Here
##
##################
# go through each segment and extract the data payload and
concatinate it to the data_message
#################
##
## Your Code Here
##
##################
def receiver_wrapper(self):
# the receiver_wrapper function fetch transport layer
segments received from network layer and
# it look at the reference byte to finds the beginning of the
segment set that represent a single data message
#################
##
## Your Code Here
##
##################
*****************************************************
**********************************
# define applicaiton layer classess ---*********Partially
completed*************
# define ftp class
class FTP:
def __init__(self,node_IP,port_number):
# define necessary private variables for this class
# define buffer to send FTP data to transport layer
################
### your code
################
#define buffer to receive data from transport layer
################
### your code
################
# make a local variables for IP and port numbers
# IP and port numbers will be passed down to the
transport_layer
################
### your code
################
def transmitter(self,filename):
# define transmitter function
# this function read from a file <given by filename> line by
line
# and insert the data to buffer for transport layer
# open a file < we assume the file is ASCII
################
### your code
################
# read from a file line-by-line and store it in the buffer for
################
### your code
################
def receiver(self,filename):
# define a receiver function
# this function gets the segmented packets from the transport
layer buffer and
# create a file < we assume an ASCII file> specified by
filename
# open a file to write into
################
### your code
################
# read from the transport layer buffer and write the packet
application paylod into the file
################
### your code
################
*****************************************************
*********************************
Project descriptionIn this Phase, we will develop two nodes.docx

More Related Content

Similar to Project descriptionIn this Phase, we will develop two nodes.docx

Centralized monitoring station for it computing and network infrastructure1
Centralized monitoring station for it computing and network infrastructure1Centralized monitoring station for it computing and network infrastructure1
Centralized monitoring station for it computing and network infrastructure1
MOHD ARISH
 
Session 2 Tp 2
Session 2 Tp 2Session 2 Tp 2
Session 2 Tp 2
githe26200
 
CODE FOR echo_client.c A simple echo client using TCP #inc.pdf
CODE FOR echo_client.c A simple echo client using TCP  #inc.pdfCODE FOR echo_client.c A simple echo client using TCP  #inc.pdf
CODE FOR echo_client.c A simple echo client using TCP #inc.pdf
secunderbadtirumalgi
 
Emergency Service Provide by Mobile
Emergency Service Provide by MobileEmergency Service Provide by Mobile
Emergency Service Provide by Mobile
Samiul Hoque
 
Ip protocol
Ip protocolIp protocol
Ip protocol
H K
 

Similar to Project descriptionIn this Phase, we will develop two nodes.docx (20)

Np unit2
Np unit2Np unit2
Np unit2
 
Centralized monitoring station for it computing and network infrastructure1
Centralized monitoring station for it computing and network infrastructure1Centralized monitoring station for it computing and network infrastructure1
Centralized monitoring station for it computing and network infrastructure1
 
Simple chat room using python
Simple chat room using pythonSimple chat room using python
Simple chat room using python
 
Session 2 Tp 2
Session 2 Tp 2Session 2 Tp 2
Session 2 Tp 2
 
CODE FOR echo_client.c A simple echo client using TCP #inc.pdf
CODE FOR echo_client.c A simple echo client using TCP  #inc.pdfCODE FOR echo_client.c A simple echo client using TCP  #inc.pdf
CODE FOR echo_client.c A simple echo client using TCP #inc.pdf
 
TCP/IP 3RD SEM.2012 AUG.ASSIGNMENT
TCP/IP 3RD SEM.2012 AUG.ASSIGNMENTTCP/IP 3RD SEM.2012 AUG.ASSIGNMENT
TCP/IP 3RD SEM.2012 AUG.ASSIGNMENT
 
Emergency Service Provide by Mobile
Emergency Service Provide by MobileEmergency Service Provide by Mobile
Emergency Service Provide by Mobile
 
Design Package to Build and Evaluate Encryption Algorithms
Design Package to Build and Evaluate Encryption AlgorithmsDesign Package to Build and Evaluate Encryption Algorithms
Design Package to Build and Evaluate Encryption Algorithms
 
Ip protocol
Ip protocolIp protocol
Ip protocol
 
07 coms 525 tcpip - udp
07    coms 525 tcpip - udp07    coms 525 tcpip - udp
07 coms 525 tcpip - udp
 
Arduino Teaching Program
Arduino Teaching ProgramArduino Teaching Program
Arduino Teaching Program
 
Maxbox starter18
Maxbox starter18Maxbox starter18
Maxbox starter18
 
Tossim intro
Tossim introTossim intro
Tossim intro
 
CCNA 200-120 Exam Quick Notes
CCNA 200-120 Exam Quick NotesCCNA 200-120 Exam Quick Notes
CCNA 200-120 Exam Quick Notes
 
7 hands on
7 hands on7 hands on
7 hands on
 
Final srs
Final srsFinal srs
Final srs
 
project_531
project_531project_531
project_531
 
lecture-2-tcp-ip.ppt
lecture-2-tcp-ip.pptlecture-2-tcp-ip.ppt
lecture-2-tcp-ip.ppt
 
Alta disponibilidad en GNU/Linux
Alta disponibilidad en GNU/LinuxAlta disponibilidad en GNU/Linux
Alta disponibilidad en GNU/Linux
 
CCNA project-report
CCNA project-reportCCNA project-report
CCNA project-report
 

More from wkyra78

Melissa HinkhouseWeek 3-Original PostNURS 6050 Policy and A.docx
Melissa HinkhouseWeek 3-Original PostNURS 6050 Policy and A.docxMelissa HinkhouseWeek 3-Original PostNURS 6050 Policy and A.docx
Melissa HinkhouseWeek 3-Original PostNURS 6050 Policy and A.docx
wkyra78
 
Melissa HinkhouseAdvanced Pharmacology NURS-6521N-43Professo.docx
Melissa HinkhouseAdvanced Pharmacology NURS-6521N-43Professo.docxMelissa HinkhouseAdvanced Pharmacology NURS-6521N-43Professo.docx
Melissa HinkhouseAdvanced Pharmacology NURS-6521N-43Professo.docx
wkyra78
 
member is a security software architect in a cloud service provider .docx
member is a security software architect in a cloud service provider .docxmember is a security software architect in a cloud service provider .docx
member is a security software architect in a cloud service provider .docx
wkyra78
 
Melissa ShortridgeWeek 6COLLAPSEMy own attitude has ch.docx
Melissa ShortridgeWeek 6COLLAPSEMy own attitude has ch.docxMelissa ShortridgeWeek 6COLLAPSEMy own attitude has ch.docx
Melissa ShortridgeWeek 6COLLAPSEMy own attitude has ch.docx
wkyra78
 
Measurement  of  the  angle  θ          .docx
Measurement  of  the  angle  θ          .docxMeasurement  of  the  angle  θ          .docx
Measurement  of  the  angle  θ          .docx
wkyra78
 
Measurement of the angle θ For better understanding .docx
Measurement of the angle θ     For better understanding .docxMeasurement of the angle θ     For better understanding .docx
Measurement of the angle θ For better understanding .docx
wkyra78
 
Meaning-Making Forum 2 (Week 5)Meaning-Making Forums 1-4 are thi.docx
Meaning-Making Forum 2 (Week 5)Meaning-Making Forums 1-4 are thi.docxMeaning-Making Forum 2 (Week 5)Meaning-Making Forums 1-4 are thi.docx
Meaning-Making Forum 2 (Week 5)Meaning-Making Forums 1-4 are thi.docx
wkyra78
 
MBA6231 - 1.1 - project charter.docxProject Charter Pr.docx
MBA6231 - 1.1 - project charter.docxProject Charter Pr.docxMBA6231 - 1.1 - project charter.docxProject Charter Pr.docx
MBA6231 - 1.1 - project charter.docxProject Charter Pr.docx
wkyra78
 
MediationNameAMUDate.docx
MediationNameAMUDate.docxMediationNameAMUDate.docx
MediationNameAMUDate.docx
wkyra78
 
Media Content AnalysisPurpose Evaluate the quality and value of.docx
Media Content AnalysisPurpose Evaluate the quality and value of.docxMedia Content AnalysisPurpose Evaluate the quality and value of.docx
Media Content AnalysisPurpose Evaluate the quality and value of.docx
wkyra78
 
MBA 5110 – Business Organization and ManagementMidterm ExamAns.docx
MBA 5110 – Business Organization and ManagementMidterm ExamAns.docxMBA 5110 – Business Organization and ManagementMidterm ExamAns.docx
MBA 5110 – Business Organization and ManagementMidterm ExamAns.docx
wkyra78
 

More from wkyra78 (20)

Melissa HinkhouseWeek 3-Original PostNURS 6050 Policy and A.docx
Melissa HinkhouseWeek 3-Original PostNURS 6050 Policy and A.docxMelissa HinkhouseWeek 3-Original PostNURS 6050 Policy and A.docx
Melissa HinkhouseWeek 3-Original PostNURS 6050 Policy and A.docx
 
Melissa HinkhouseAdvanced Pharmacology NURS-6521N-43Professo.docx
Melissa HinkhouseAdvanced Pharmacology NURS-6521N-43Professo.docxMelissa HinkhouseAdvanced Pharmacology NURS-6521N-43Professo.docx
Melissa HinkhouseAdvanced Pharmacology NURS-6521N-43Professo.docx
 
Meiner, S. E., & Yeager, J. J. (2019). Chapter 17Chap.docx
Meiner, S. E., & Yeager, J. J. (2019).    Chapter 17Chap.docxMeiner, S. E., & Yeager, J. J. (2019).    Chapter 17Chap.docx
Meiner, S. E., & Yeager, J. J. (2019). Chapter 17Chap.docx
 
member is a security software architect in a cloud service provider .docx
member is a security software architect in a cloud service provider .docxmember is a security software architect in a cloud service provider .docx
member is a security software architect in a cloud service provider .docx
 
Melissa ShortridgeWeek 6COLLAPSEMy own attitude has ch.docx
Melissa ShortridgeWeek 6COLLAPSEMy own attitude has ch.docxMelissa ShortridgeWeek 6COLLAPSEMy own attitude has ch.docx
Melissa ShortridgeWeek 6COLLAPSEMy own attitude has ch.docx
 
Melissa is a 15-year-old high school student. Over the last week.docx
Melissa is a 15-year-old high school student. Over the last week.docxMelissa is a 15-year-old high school student. Over the last week.docx
Melissa is a 15-year-old high school student. Over the last week.docx
 
Measurement  of  the  angle  θ          .docx
Measurement  of  the  angle  θ          .docxMeasurement  of  the  angle  θ          .docx
Measurement  of  the  angle  θ          .docx
 
Measurement of the angle θ For better understanding .docx
Measurement of the angle θ     For better understanding .docxMeasurement of the angle θ     For better understanding .docx
Measurement of the angle θ For better understanding .docx
 
Meaning-Making Forum 2 (Week 5)Meaning-Making Forums 1-4 are thi.docx
Meaning-Making Forum 2 (Week 5)Meaning-Making Forums 1-4 are thi.docxMeaning-Making Forum 2 (Week 5)Meaning-Making Forums 1-4 are thi.docx
Meaning-Making Forum 2 (Week 5)Meaning-Making Forums 1-4 are thi.docx
 
MBA6231 - 1.1 - project charter.docxProject Charter Pr.docx
MBA6231 - 1.1 - project charter.docxProject Charter Pr.docxMBA6231 - 1.1 - project charter.docxProject Charter Pr.docx
MBA6231 - 1.1 - project charter.docxProject Charter Pr.docx
 
Medication Errors Led to Disastrous Outcomes1. Search th.docx
Medication Errors Led to Disastrous Outcomes1. Search th.docxMedication Errors Led to Disastrous Outcomes1. Search th.docx
Medication Errors Led to Disastrous Outcomes1. Search th.docx
 
Meet, call, Skype or Zoom with a retired athlete and interview himh.docx
Meet, call, Skype or Zoom with a retired athlete and interview himh.docxMeet, call, Skype or Zoom with a retired athlete and interview himh.docx
Meet, call, Skype or Zoom with a retired athlete and interview himh.docx
 
Medication Administration Make a list of the most common med.docx
Medication Administration Make a list of the most common med.docxMedication Administration Make a list of the most common med.docx
Medication Administration Make a list of the most common med.docx
 
media portfolio”about chapter 1 to 15 from the book  Ci.docx
media portfolio”about chapter 1 to 15 from the book  Ci.docxmedia portfolio”about chapter 1 to 15 from the book  Ci.docx
media portfolio”about chapter 1 to 15 from the book  Ci.docx
 
MediationNameAMUDate.docx
MediationNameAMUDate.docxMediationNameAMUDate.docx
MediationNameAMUDate.docx
 
Media coverage influences the publics perception of the crimina.docx
Media coverage influences the publics perception of the crimina.docxMedia coverage influences the publics perception of the crimina.docx
Media coverage influences the publics perception of the crimina.docx
 
Media Content AnalysisPurpose Evaluate the quality and value of.docx
Media Content AnalysisPurpose Evaluate the quality and value of.docxMedia Content AnalysisPurpose Evaluate the quality and value of.docx
Media Content AnalysisPurpose Evaluate the quality and value of.docx
 
Mayan gods and goddesses are very much a part of this text.  Their i.docx
Mayan gods and goddesses are very much a part of this text.  Their i.docxMayan gods and goddesses are very much a part of this text.  Their i.docx
Mayan gods and goddesses are very much a part of this text.  Their i.docx
 
Media and SocietyIn 1,100 words, complete the followingAn.docx
Media and SocietyIn 1,100 words, complete the followingAn.docxMedia and SocietyIn 1,100 words, complete the followingAn.docx
Media and SocietyIn 1,100 words, complete the followingAn.docx
 
MBA 5110 – Business Organization and ManagementMidterm ExamAns.docx
MBA 5110 – Business Organization and ManagementMidterm ExamAns.docxMBA 5110 – Business Organization and ManagementMidterm ExamAns.docx
MBA 5110 – Business Organization and ManagementMidterm ExamAns.docx
 

Recently uploaded

Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
ZurliaSoop
 
The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptx
heathfieldcps1
 

Recently uploaded (20)

Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
 
ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.
 
On National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsOn National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan Fellows
 
This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.
 
Google Gemini An AI Revolution in Education.pptx
Google Gemini An AI Revolution in Education.pptxGoogle Gemini An AI Revolution in Education.pptx
Google Gemini An AI Revolution in Education.pptx
 
Exploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptx
Exploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptxExploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptx
Exploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptx
 
Wellbeing inclusion and digital dystopias.pptx
Wellbeing inclusion and digital dystopias.pptxWellbeing inclusion and digital dystopias.pptx
Wellbeing inclusion and digital dystopias.pptx
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdf
 
Graduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - EnglishGraduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - English
 
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
 
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptxHMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
 
Understanding Accommodations and Modifications
Understanding  Accommodations and ModificationsUnderstanding  Accommodations and Modifications
Understanding Accommodations and Modifications
 
Food safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdfFood safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdf
 
The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptx
 
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdfUGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
 
Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)
 
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
 
How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17
 
FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024
 
On_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptx
On_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptxOn_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptx
On_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptx
 

Project descriptionIn this Phase, we will develop two nodes.docx

  • 1. Project description: In this Phase, we will develop two nodes for the network simulator. The first node is a trasmitter and the second node is a receiver. Each node is defined by a unique node_ID. That is, there are no two nodes in the network with the same ID. Since we are using a single machine to perform PHY transmissions, the node_ID values can be arbitrary IP address. Each node has five layers namely: application_layer, transport_layer, network_layer, link_layer and PHY_layer. For this phase of the project, we develop protocols for three layers: application_layer, transport_layer and PHY_layer Each layer (depending on its location) has allocated buffers to establish communication with the other layers above or below it. For instance, the transport_layer has four buffers: to_network_layer, from_network_layer, from_application_layer, to_application_layer
  • 2. For the application_layer, we will develop file transfer protocol (FTP). The FTP class has two sides, the transmitter and receiver sides. The transmitter sides reads a file (specified by user) and convert that into application_layer_messages. The receiver side gets application_layer_messages from the transport_layer converts them into single file. For the transport_layer, we will develop UDP protocol. This protocol has two sides, the transmitter and receiver sides. The transmitter side gets the application_layer_messages from the application_layer and converts them into transport_layer segments. Note that the length of each segment should be maximum segment size MSS (excluding UDP header). The value of MSS usually depends on the PHY link that each node is connected to. Each segment should have the following fields: # application_layer_messages_no: 4bytes: 32 bits # segment_no: packet number : 4bytes: 32 bits # source_port: this field identifies the sender's port : 2 bytes: 16 bits
  • 3. # destination_port: This field identifies the receiver's port: 2 bytes : 16 bits # Length: the length in bytes of the UDP header and UDP data : 2 bytes : 16 bits # Checksum: the checksum field is used for error-checking of the header and data. 2 bytes : 16 bits # Reference flag: indicates the beginning of a set of segments for an individual application message It is important to note that each application_layer_messages is divided to a set of segments. The reference byte represent the beginning of each set. The receiver side of the transport_layer gets the set of segments and concatenated them to makes a single application_layer_messages. For the PHY layer, we use python socket library to send and receive messages over ports. This is because, we will use a single machine for the network simulator. The PHY sender simply transfers packets over the specified port. The PHY receiver listens to that port and send the received
  • 4. packets to the upper layer. For this Phase, you need to develop the following files: application_layer.py: contains FTP class transport_layer.py: contains UDP class PHY_layer.py: contains PHY class node.py: contains node class that defines an individual node in the network simulator network_simulator.py: that defines the topology of the network (for this phase there are only two nodes, sender and receiver) The program should run by the following command: ./network_simulator.py --FTP_filename = filename.txt The output of the program should contains the following information: 1. generate filename_RX.txt (the received file name) 2. generate network_simulator.log (this is the log file for the network_simulator operations) This file should contains the follwoing information:
  • 5. # node_num_log: <number of the nodes in the netwok> # node_ID_log: <list of the nodes IP address in a form of node_ID:IP_address> # application_layer_messages_log: <the number of messages generated by application_layer> # transport_layer_segments_log: <the number of segments generated by the transport_layer> # segment_length_log: the length of each segment ***************************************************** *********************************** # Physical layer file *********Completed*********** # we will define different classes for the phy layer communicaiton import socket class PHY: def __init__(self,app_port,pkt_size):
  • 6. # define private variables # buffer for processing link layer pkts self.from_link_layer = dict() # buffer to send to the link layer self.to_link_layer = dict() # Define TX and RX socket objects self.TX_sock = socket.socket(socket.AF_INET,socket.SOCK_DGRAM) self.RX_sock = socket.socket(socket.AF_INET,socket.SOCK_DGRAM) # Define TX and RX IP and ports self.IP = "127.0.0.1" # app_port is configured by the application layer self.TX_port = app_port self.RX_port = app_port + 1
  • 7. self.pkt_size = pkt_size def transmitter(self,pkt): # send a single packet over the port <loopback ip> self.TX_sock.sendto(str(pkt), (self.IP, self.TX_port)) def transmitter_wrapper(self): # give packets one by one to the PHY TX for pktno in self.self.from_link_layer: self.transmitter(self.self.from_link_layer[pktno]) def receiver(self): # get each packet from the RX port pkt, addr = self.RX_sock.recvfrom(self.pkt_size) return eval(pkt) def receiver_wrapper(self): while True:
  • 8. pkt = self.receiver() pktno = pkt['pktno'] #app_payload = pkt['app_payload'] self.to_link_layer[pktno] = pkt ***************************************************** ********************************** ***************************************************** ********************************** # run this with python3--transport laye---Partially completed
  • 9. # This function defines necessary classes for the transport layer # This class implements UDP protocol at the transport layer import math # we use md5 library for checksum import md5 # use bitarray to convert sequence of bits to bytes from bitstring import BitArray # BitArray().tobytes() converts sequence of bits to bytes # BitArray().bin converts bytes to sequence of bits
  • 10. # UDP_payload: data content for the application layer class UDP: def __init__(self,MSS,source_port,destination_port): # define private variables here #define a buffer to store UDP segments to send to the network layer ################# ## ## Your Code Here ## ################## # define a buffer that stored datagrams provided by the network layer ################# ## ## Your Code Here
  • 11. ## ################## # define a buffer to store concatenated packets into data payload to send to the application layer ################# ## ## Your Code Here ## ################## # define a buffer to get data payload from application layer to convert them into UDP segments ################# ## ## Your Code Here ## ################## # define a maximum segment size MSS, source_port and destination_port
  • 12. ################# ## ## Your Code Here ## ################## # convert source_port and destination_port to byte format ################# ## ## Your Code Here ## ################## # segment_no : keeps track of segments we generate ################# ## ## Your Code Here ##
  • 13. ################## def transmitter(self,application_message,application_message_no): # define the transmitter function that get application data payload and convert them into UDP segments # function input parameters: application_message # lenght of application_message is in bytes # application_message in represented in bytes # each segment have the following fields <here we assume UDP packets> ###### packet header contains
  • 14. # pktno: packet number : 4bytes: 32 bits # source_port: this field identifies the sender's port : 2 bytes: 16 bits # destination_port: This field identifies the receiver's port: 2 bytes : 16 bits # Length: the length in bytes of the UDP header and UDP data : 2 bytes : 16 bits # Checksum: the checksum field is used for error-checking of the header and data. 2 bytes : 16 bits # Reference flag: indicates the beginning of a set of segments for an individual application message ###### # generates appropriate number of segments for each application payload # length of each segment should be MSS (excluding UDP header)
  • 15. # define pktno 32 bits = 4 bytes # calculate number of segments necessary to convert the payload into segments ################# ## ## Your Code Here ## ################## # Generate UDP segments: each segments should contain MSS bytes of application payload + 12 bytes of UDP header (pktno + source_port + destination_port + lenght + checksum) ################# ## ## Your Code Here ##
  • 16. ################## # reference byte is one for the very first segment of each set. ################# ## ## Your Code Here ## ################## # add segment_no + checksum to each segment_no ################# ## ## Your Code Here ## ################## # store the application_message number associated with this segment #################
  • 17. ## ## Your Code Here ## ################## # store the generated segment into the self.to_network_layer buffer ################# ## ## Your Code Here ## ################## def transmitter_wrapper(self): # the transmitter_wrapper function fetch one application_message from self.from_application_layer buffer # and pass it to transmitter function to generate UDP segments for that message #################
  • 18. ## ## Your Code Here ## ################## def receiver(self,segment_set): # this function concatenates a set of segments that represent a single application message # input: a set of segments # output: a single data message # define an empty data message ################# ## ## Your Code Here ## ##################
  • 19. # go through each segment and extract the data payload and concatinate it to the data_message ################# ## ## Your Code Here ## ################## def receiver_wrapper(self): # the receiver_wrapper function fetch transport layer segments received from network layer and # it look at the reference byte to finds the beginning of the segment set that represent a single data message ################# ## ## Your Code Here ## ##################
  • 20. ***************************************************** ********************************** # define applicaiton layer classess ---*********Partially completed************* # define ftp class class FTP: def __init__(self,node_IP,port_number): # define necessary private variables for this class # define buffer to send FTP data to transport layer ################ ### your code ################ #define buffer to receive data from transport layer
  • 21. ################ ### your code ################ # make a local variables for IP and port numbers # IP and port numbers will be passed down to the transport_layer ################ ### your code ################ def transmitter(self,filename): # define transmitter function # this function read from a file <given by filename> line by line # and insert the data to buffer for transport layer
  • 22. # open a file < we assume the file is ASCII ################ ### your code ################ # read from a file line-by-line and store it in the buffer for ################ ### your code ################ def receiver(self,filename): # define a receiver function # this function gets the segmented packets from the transport layer buffer and # create a file < we assume an ASCII file> specified by filename
  • 23. # open a file to write into ################ ### your code ################ # read from the transport layer buffer and write the packet application paylod into the file ################ ### your code ################ ***************************************************** *********************************