Graduation Project
Graduation Project
SCHOOL OF ELECTRICAL-ELECTRONICS
MSSV: 20182930
Name of Instructors:....................................................................................................
Name od student: .....................................................MSSV: 20182930 .....................
Name of project:..........................................................................................................
.....................................................................................................................................
Select the appropriate score for students to present according to criteria below:
Very poor (1); Poor (2); Pass (3); Good (4); Very good(5)
There is a combination of theory and practice (20)
State the urgency and importance of the topic, issues and hypotheses
1 (including purpose and relevance) as well as the scope of application 1 2 3 4 5
of the project.
2 Update the most recent research results (domestic/international) 1 2 3 4 5
3 Specify and detail the research/problem solving method 1 2 3 4 5
Have simulation/experimental results and clearly present the obtained
4 1 2 3 4 5
results
Ability to analyze and evaluate results (15)
A clear work plan including objectives and implementation methods
5 1 2 3 4 5
based on the results of theoretical research in a systematic way
The results are presented in a logical and easy to understand manner,
6 1 2 3 4 5
all results are analyzed and evaluated satisfactorily.
In the conclusion, the author points out the differences (if any)
7 between the achieved results and the initial goals set out and provides 1 2 3 4 5
arguments to suggest possible solutions in the future.
Project Report ‘s technical writing skills (10)
The project presents in accordance with the prescribed form with a
logical and beautiful structure of chapters (tables, clear images, with
8 1 2 3 4 5
titles)has a chapter introduction and chapter conclusion, a list of
referencescitations.
Excellent writing skills (standard sentence structure, scientific style,
9 logical and well-founded reasoning, appropriate vocabulary usage, 1 2 3 4 5
etc.)
Scientific research achievements (5) (choose 1 out of 3 cases)
Having a scientific article published or accepted for
1
publication/winner of 3rd prize at Institute level or higher/scientific
0 5
awards (international/domestic) from 3rd prize or higher/ Having
a
registered a patent
Reported at the Institute council in the conference of scientific
1
research students but did not win the 3rd prize or higher / Won the
0 2
consolation prize in other national and international competitions on
b
the subject such as TI contest.
1
0 No achivements of scientific research 0
c
Total points /50
Total points based on base 10
1
Other comments (about students' attitudes and working spirit)
.....................................................................................................................................
.....................................................................................................................................
.....................................................................................................................................
.....................................................................................................................................
.....................................................................................................................................
.....................................................................................................................................
Date: … / … / 20…
Instructor
2
PREFACE
Before presenting the content of my project report, I would like to express my
sincere thanks to Dr. Dang Quang Hieu, who has directly guide and provide
documents for me during the project implementation.
Due to time constraints and limited knowledge, the report is not avoid making some
minor errors. Therefore, I look forward to receiving comments from teachers and
friends to improve the topic.
Hanoi, August 2022
Students present
Le Bao Ngoc
3
GUARANTEE
My name is Le Bao Ngoc, student number 2012930, student of Elitech Program’s
Electronic Class 01, course 63. The instructor is Dr. Dang Quang Hieu. I hereby
declare that all the content presented in the project "Deploying a multi-layer network
system using dynamic routing of RIP, OSPF, BGP" is the result of my research .
The data stated in the project is completely honest, reflecting the simulation results
achieved. All information cited is subject to intellectual property regulations; The
references are clearly listed. I take full responsibility for the content written in this
project.
Hanoi, August 2022
The guarantor
Le Bao Ngoc
4
TABLE OF CONTENTS
5
4. LAB MODELS OF RIP, OSPF, BGP ............................................................... 30
4.1 RIP’s lab model ............................................................................................... 30
4.1.1 Process of RIP .......................................................................................... 30
4.1.2 Compare RIPv1 and RIPv2 ...................................................................... 31
4.2 OSPF’s lab model ........................................................................................... 32
4.2.1 Introduce................................................................................................... 32
4.2.2 How OSPF works ..................................................................................... 33
4.2.3 OSPF packet types ................................................................................... 34
4.3 BGP’s lab model ............................................................................................. 35
4.3.1 Introduction to eBGP and iBGP ............................................................... 35
4.3.2 Data sheets of BGP .................................................................................. 37
5. Emulate a Cisco router on GNS3 ...................................................................... 43
5.1 About GN3 ...................................................................................................... 43
5.2 NS3’s Configuration ....................................................................................... 43
5.3 Load IOS for router ......................................................................................... 44
5.4 Learn the basic router configurations (how to assign IPs to interfaces, check IP
parameters). .............................................................................................................. 44
6. INSTALLATION INSTALLATION ................................................................ 50
6 . FIrst Network model ............................................................................................ 50
6.2 General settings (using the Linux OS commandline) ........................................ 52
6.3 Deploying the top-of-the-line network model .................................................... 53
6.3.1 IP Configuration .......................................................................................... 53
6.3.2 Config of OSPF routers ............................................................................ 56
6.3.3 Operating the OSPF model on the top layer ................................................ 58
6.4 Deploy the middle and lower layer network model ........................................ 59
6.4.1 IP Configuration .......................................................................................... 59
6.4.2 Configuration RIP router.......................................................................... 62
6.4.3 RIP operation on middle and lower layer network model ....................... 64
6.5 Deploy top layer network model..................................................................... 66
6.5.1 IP Configuration .......................................................................................... 66
6.5.2 Config for OSPF routers .......................................................................... 68
6.5.3 Operating OSPF on top layer’s network model ....................................... 71
6.6 Configure BGP for routers .............................................................................. 73
6
6.6.1 IP Configuration .......................................................................................... 73
6.6.2 Operate BGP across the network model ...................................................... 74
7 SYSTEM OPERATION .................................................................................... 77
7.1 Check connection by ping and tracepath ........................................................... 77
7.2 OSPF responsiveness test with AS 1 ................................................................ 79
7.3 Check the responsiveness of RIP with AS 2 .................................................... 80
7.4 Steps to test the system by installing and connecting to DNS servers ........... 81
8. SIMULATION ON C ............................................................................................. 82
8.1 Simulation RIP .................................................................................................. 82
8.2 Simulate OSPF _ ............................................................................................... 88
8.3 Simulation BGP _ .............................................................................................. 99
9. EXPANDED : AODV AND OSPF COMPARISON ......................................... 117
9.1 About AODV .................................................................................................. 117
9.2 Evaluation of AODV and OSPF when operating in WiMAX ....................... 118
CONCLUSION ......................................................................................................... 120
REFERENCES ......................................................................................................... 121
7
LIST OF FIGURE
8
LIST OF SIGNS AND ABBREVIATIONS
Letter write Turn off Cluster are from write full enough
OSPF Open Shortest Path First
SR Static Route
DR Dynamic Route
AS Autonomous System
9
PROJECT SUMMARY
In this project, first of all, I thoroughly understand the theory of routing, then
learn the network model, learn its operating structure, then I deploy multilayer
network using RIP dynamic routing , OSPF, BGP on GNS3 to study the
accuracy and feasibility of deploying the system to operate network models
thanks to the above implementation on Linux OS and Windows. After
successfully deploying on GNS3, I tried to optimize the model, routes, IP
configuration for each route and the accuracy when doing work when doing
simulation operations on the network model.
After successful training on GNS3, that multilayer network, I also performed
simulation on C with technical requirements for multilayer network. From the
technical requirement, I build a test plan and follow it to verify the design. The
design has passed the specification when 100% functional coverage has been
achieved. In addition, I also build MANET network model, a single network
model with not too complicated configuration and can directly code separate
functions for each leg of the network and from there compare it with the multi-
layer network system that I have. I designed in this project and the feasibility of
using this system in practice.
10
1. INTRODUCTION
In the development of today's life, the Internet has become a tool for us to interact,
transact, look up information as well as store data. Therefore, understanding the
implementation as well as understanding the algorithms on routers that support routing
is extremely important for future engineers. Therefore, in the framework of this
exercise, I would like to show you how to set up and operate a 3-tier network:
- The top layer is the area for the routers of the network operator (ISP), in this
area, the routing algorithm used is BGP.
- The middle layer is the area of routers in the local area network, routed using
OSPF or RIP algorithms.
- The bottom layer is the personal computers, directly connected to the Routers.
Overview Of Routing
Hình 1: Overview Of Routing
Routing is a process that routers Hi
perform to move a packet (Packet) from a source
̀ nh 2:Tổng quan về Routing
address to a destination address in the network. In this process, the router must rely
on the routing information to make decisions to forward the packet to the
predetermined destination address.
Hình 3:Tổng
11quan về Routing
The routing table contains a route to every destination network that a router knows
how to access. When you configure interfaces, they are listed as directly connected
interfaces in the routing table. You can manually advertise routes to this table to
specify the destination network. However, as the network becomes larger and more
complex, manually configuring every route on each router becomes infeasible. Even
if you use default routes and central routers to minimize the number of routes that
individual routers must know, configuring routes manually for network expansion
can be time consuming. time. Entering static routes is also error prone: it's easy to
press the wrong key and enter incorrect routes. Instead of configuring static routes,
you can use dynamic routing protocols, which allow routers to exchange routing
information with other routers in the network. Each router can then use this
information to build its routing table.
There are two basic types of routing, Static Route and Dynamic Route.
Network administrators when choosing a dynamic routing protocol need to consider
factors such as the size of the network system, the bandwidth of the transmission
lines, and the router's capabilities. Router type and router version, the protocols
running in the network.
2.2 Static routing protocol overview
For static routing, the route information must be entered by the network
administrator for the router. When the network structure has any changes, the
network administrator must delete or add routing information for the router. Such
paths are called fixed paths. For a large network, the maintenance of the router
network as above takes a lot of time. As for the small network operator system, there
is little change, this job is less laborious. Because static routing requires the network
administrator to configure all routing information for the router, there is no
flexibility like dynamic routing. In large networks, static routing is often combined
with dynamic routing protocols for some special purpose.
RTZ(config)#ip route 172.24.4.0 255.255.255.0 172.16.1.2
3. THEORY
EGP
3.1 Autonomous System ( AS ) and BGP between ASs
̀Hinh 10: EGP và BGP giữa các
A collection of interconnectionsASof several managed IP networks routed by an
administrative entity. Each entity consists of many subunits. Each of these units
manages and operates the physical network system independently. These networks are
13
then interconnected and routed according to a common design defined by the entity. As
such, this entire internal system can be thought of as an AS autonomous system.
In this system, the network connection configuration and diagram can be clearly
defined. On the other hand, obviously, one AS will not be able to grasp the connection
diagram of another AS. This resulted in separate routing protocols defined for
implementation in and out of the AS, including:
- Internal Gateway Protocols (IGPs): are protocols that allow routers to route
within the AS. In this article, we will use 2 IGP protocols, including Routing
Information Protocol (RIP) and Open Shortest Path First (OSPF).
- Exterior Gateway Protocols (EGPs): are protocols that route connections
between ASs. In the article, we use EGP protocol is Border Gateway Protocol (BGP).
14
3.2 RIP
3.2.1 Concept
RIP is an IGP routing protocol used for small ASs, not for large and complex
networks. The routing information protocol is a type of distance-vector routing
protocol, which uses a value to measure that is the number of hops (hop count) in the
path from the source to the destination. Each hop in the path from source to destination
is considered to have a value of 1 hop count. When a router receives a routing update
for a packet, it adds 1 to the measurement and updates the routing table.
3.2.2 How it works
RIP uses the Distance Vector Algorithms (DVA) routing algorithm. This is an
interoperable routing algorithm that computes the shortest path between pairs of nodes
in the network, based on a centralized method known as the Bellman-Ford algorithm.
Network nodes exchange information on the basis of destination address, next node,
and shortest path to the destination.
3.2.3 Limit
RIP right judge physical one number magic error _ prize muscle department cause
out. Head first , in transparent time " holddown " time later when the yes specified
information _ line bag replace change , if the router receives Okay updated information
_ Japan are from a smooth router Neighbors other but this information _ give know yes
Street arrive network X with pine number determined line good than the road that router
first there then it will ignore , no access Japan this information . _
Next follow to be error count enter term . Dinh line repeat yes can happen out when
the board determined line above routers yet ? Okay access Japanese do so submit
festival capacitor slow .
3.3 OSPF
3.3.1 Concept
OSPF is a typical IGP link-state routing protocol. This is a protocol widely used
in large enterprise networks. The OSPF protocol is standardized for routers to exchange
information and build link state databases. OSPF operates in only one AS region, so it
is classed as RIP.
3.3.2 How it works
Each router running the protocol sends its link states to all routers in the area.
After a period of exchange, the routers will identify the link state database table (Link
State Database - LSDB) with each other, each router will have a network map of the
whole area. From there, each router will run Dijkstra's algorithm to calculate a shortest
path tree (Shortest Path Tree) and based on this tree to build a routing table.
15
When a router runs OSPF, there must be a unique value that identifies the router
in the community of OSPF routers. This value is called Router-id. Router - The id on
the router running OSPF in the format of an IP address.
By default, the OSPF process on each router will automatically elect the router
value - id is the highest IP address in the active interfaces, giving priority to the loopback
port. To change the router - id of the process, you have to restart the router or remove
the OSPF process and reconfigure, then the router - id election process will be done
again with the existing interfaces on the router .
Another way to reset the router-id value is to use the “router-id” command to
manually set this value on the router.
Router (config) # router ospf 1
Router (config-router) # router-id ABCD
or set via config file with line
ospf router id ABCD
3.4 BGP
3.4.1 Concept
BGP is an important component of the Internet in routing routers between
different ASs. It works based on updating a table containing network addresses (prefix)
indicating the linkage between autonomous systems (autonomous systems), a collection
of network systems under the control of an administrator. network, usually an Internet
service provider, ISP. In addition to using BGP between ASs, BGP can also be used in
large-scale private networks because OSPF is not available. Another reason is to use
BGP to support multihome.
Most Internet users do not use BGP directly. Only Internet service providers use
BGP to exchange routes. BGP is one of the most important protocols for ensuring the
connectivity of the Internet.
3.4.2 How it works
Routers using BGP connect pairwise with each other by establishing a TCP
session over port 179. This connection is maintained by sending keep- alive 19 bytes
every 60 seconds (default).
There are four types of BGP messages: open (opening session), update (notifying
or withdrawing a path), notification (notifying error), keep-alive (maintaining the
connection).
17
Verizon Enterprise Solutions America 701 22 805,000 won
Zayo Group America 6461 ten 196,339
OSPF -Exact routes taking into - Complex configuration. -More extensive LAN
account link speed and -Costs can be high. and WAN networks.
cost. -OSPF cannot be used as -Not to be used over
- Convergence happens an EGP without dial-up connections.
quickly. redistribution.
-As low as RIP if the
network is well designed.
19
Typically, a routing table can only include one best route per destination. Even if a
router learns many equally good routes to the same destination, it must choose one.
Other routes cannot be used unless the selected route fails for some reason.
However, when configuring routers, implementing lab models of protocols, building
network models can also perform load sharing, allowing it to add multiple routes to
the same destination to its routing table. it. This option allows the router to use
redundant connections for the same remote site.
When you enable load sharing, a router can set up to six routes to the same
destination in its active routing table. It can learn these routes from any source,
meaning you can enter them manually or the router can learn them using a dynamic
routing protocol. However, keep in mind that load sharing allows the router to
choose the best multiple routes. Routes must have the same metric and
administrative distance; otherwise, only the route with the lowest value will be
selected. Because different routing protocols have different administrative distances,
multiple routes will generally be discovered using the same dynamic protocol.
another route. In this case, the traffic may not be properly balanced across multiple
connections, but the more sessions the router supports, the more balanced the traffic
will be. routing each time it routes a new packet to the destination network.
However, configuring the router for shared load in this way can cause packets to
arrive at their destination out of order and generally unappreciated.
3.9 Configuration of RIP, OSPF, BGP
3.9.1 Configuration of RIP
Before sending a RIP route, the Security Router checks the route's source or next
hop address. If the router is sending an update to a source for a particular route, it
will send an abnormal reverse instead of the normal route. Poison Reverse is a route
with a metric of 16 (which is infinite for RIP). Poison Reverse distinguishes a
legitimate backup route from one that the local router has received from a neighbor.
Basically, Poison Reverse notifies the neighbor that it cannot access the network in
question through the local router. This mechanism is called " Speeding
Convergence: Split Horizon, Poison Reverse, and Triggered Update" . Neighbors is
listed as the next address that will change the metric for the route. The router then
changes the metric for the route in its own table. to a new metric plus a new metric
Another neighbor advertises a route with a lower metric The router changes the route
to list this neighbor as the next step address and enters the metric new Router does
not receive route information for the entire length of the invalidation period Router
marks the route for deletion It sends unique updates to the route in two update cycles
update before removing the route completely from its routing table RIP update, v1
and v2RIP update packets contain different information, depending on whether the
RIP version is 1 or 2. A RIP v1 packet includes: one command field - indicates
whether the package is a request or a reply version field (set at 1), an address family
20
field - set at 2, for bi Note that addresses in IPv4 format have a maximum of 25
entries, each of which includes:
• Destination IP address
• A metric, which is the number of hops to the destination address from the router
sending the packet
When a router discovers a new or better route from a RIP v1 update, it assumes that
the neighbor from which it received the update is the next hop for the route. The
router adds one to the index for its own routing table entry. RIP v2 fixes some
shortcomings of RIP v1. RIP v2 provides route summary partitioning for class
networks and supports EGP. A RIP v2 packet includes: a command field —
indicating whether the packet is a request or a routing domain response version
fielda — identifying the routing daemon that generates the message, allowing a
device to run certain processes RIP at an address with the same address fielda family
routing tag (including AS number for use with EGP) up to 25 entries, each of which
includes:
• Destination IP address
• Subnet mask-provides support for variable length subnets
• Next step IP address
• A metric-number of hops to the destination address from the next hop address
When a router discovers a new or better route to the destination from a RIP v2
packet, it enters the route with the next hop IP address specified in the packet. If the
IP address field of the next hop is all zeros, the router will assume that the source of
the packet is the IP address of the next hop. (This assumption provides some
backward compatibility with RIP v1). RIP v1 interfaces broadcast their routing
updates to the entire subnet. RIP v2 routers join the pool for the RIP v2 multicast
address (224.0.0.9) and multilayer updates to this address. Therefore, the RIP v1 and
v2 interfaces may not receive each other's updates.
*Speeding Convergence: Split Horizon, Poison Reverse, and Triggered Update
One shortcoming of RIP is the relatively slow convergence in some network
environments. The router sends updates every 30 seconds. In a large network, a
router may not receive accurate and up-to-date information about a route for several
minutes. Another problem with slow convergence is that it can trigger an infinity of
network congestion when the connection fails. For example, examine the network
in the diagram below and consider the updates each router receives for Network 1
when the routers run simple RIP without Split Horizon or Poison Reverse.
21
Network Don’t Use Split Horizon hoặc Poison Reverse
Hình 12: Network Don’t Use Split Horizon hoặc Poison Reverse
Router B is directly connected to Network 1, so it advertises a route to it with index
1. Router A and C receive this route from Router B. Both host it route to Network 1
Hình 13: Network mà không sử dụng Split Horizon hoặc Poison
with B being theReverse
next hop address and metric 2. Routers A and C then start
advertising this route. Router C receives the route from Router A. It does not change
its routing table to indicate that Router A is the next hop , because metric (2) is
higher than theNetwork
metric Don’t
advertised by Router
Use Split HorizonA.hoặc
router B. Router
Poison ReverseB also receives the
route from Router A. There is nothing in the update that Router B received from
Hình 14: Network mà không sử dụng Split Horizon hoặc Poison
Router A indicating that this route eventually passed through Router B itself. Router
Reverse
B simply rejected the route for the same reason. the reason that Router C did: the
metric was higher than the route it took. Exempt to be network still is fine
determined , too submit
Network Don’t
thisUse
nextSplit
custom smooth
Horizon hoặc share
Poison. Reverse
Although of course , the
question topic bouncing
Hình 15: born if mà
Network structure
không sửbamboo
dụng Split contact conclude
Horizon hoặc Poison replace change .
Reverse
See review thing what will happen out when the contact conclude Between The set
determined line B and Network 1 no Fort public . Router B catches head advertising
fox one line arrive Network
Network Don’t1Use
withSplit
a metric of 16
Horizon to Poison
hoặc only out that it are not can access
Reverse
access okay .
Hình 16: Network mà không sử dụng Split Horizon hoặc Poison
Reverse
Routers A and C receive Okay copy access Japan this from router B and replace
change the metric, but are not before when the they already to send private routers
_ of the me give Network 1 with metric is 2. Router A receives determined line from
router C and router C receive same route from router A.
By Because the line Street this have metric short than _ _ line router line B, router
A and C save store the line Street this in board determined line of the them ( extra
22
one enter metric ) . Because conclude connect of the main it with Network 1 no Fort
public , router B accepts take line road .
Count to infinity
̀
Hinh 17: Count to
Routers A and C now both have routes infinityto Network 1 with a metric of 3, pointing to
each other. During the next update cycle, router A receives the route from router C.
It updates the route routing in its table with a metric of 4. Router C, receiving the
update from router A, does the same.
Count to The next time the routers advertise the route,
infinity
it has a metric of 4. Eventually, Hi this metric will reach 16 and the routers will
̀ nh 18: Count to
determine that they cannot reach Network
infinity 1 through each other. This process is
called “Count to infinity”, and it can slow down convergence considerably.
Split Horizon is one solution to the convergence problem Split Horizon specifies
Count to infinity
that an interface must not send updates about a route to the interface it received the
route from. In other words, routers assume that the router from which they received
a route to an original destination is more directly connected and update on that
Count to infinity
destination. Split Horizon also minimizes the number of packets sent during normal
Hình 19: Count to
operations. infinity
23
Interval Router Default
Update 30 seconds
Timeout 180 seconds
Poision 60 seconds
Flush 240 seconds
25
OSPF Areas
̀
Hinh 20: OSPF
Stub Areas and Stub Routers: The stub Areas network is the network in which the
traffic terminates. The network receives traffic destined for its servers, but it does
not forward any traffic to another network. A stub area is an extension of the idea
of a stub network. OSPF Areas
Backbone(Area 0): Network's backbone, orOSPF
Hình 21: area 0, linking all stub areas. As
Areas
discussed above, it includes ABRs. Through exchanges with other ABRs in the
backbone, all ABRs keep a topological database for the entire network. They
generate route summaries for each non-backbone area. They then send these
OSPF Areas
route summaries to each other and to the internal routers they serve. Obviously,
the ABR has to handle more routes than the primitive router and correspondingly
requires more power. OSPF Areas
NSSA: NSSA is an area that resembles Hìnah stub area in many ways. It connects to
22: OSPF
Areas
the network backbone and usually does not redirect traffic to other areas.
However, a router in NSSA also connects to a remote site or an ISP through the
ASBR. Normally, OSPF will not allow external routes to be delivered into the
stub. However, internal routers within an NSSA may receive LSAs specifically
defined for external routes.
Route Computation
Routers use the information they receive from the LSA to assemble the AS's
topology (or, if configured, region) database. This database includes:
- Routers belong to separate AS or area
- Networks belonging to a separate AS or area
- Connections belong to a separate AS or area
- Cost for links belonging to a separate AS or area
26
OSPF Configuration Concerns
-Role of each router:
• Internal Router
• ABR
• ASBR
-ID of each router
-OSPF zone for each directly connected network
A common topology for WANs is with Headquarters (HQ) , defined as area 0, which
connects to stub areas at one or more remote locations. In this topology, headquarters
routers that connect to remote sites are ABRs. Routers at remote points are internal
routers. If a router connects to another public or external network, such as an ISP,
it's ASBR.
27
OSPF Network with Headquarters (HQ)- area 0
Hình 26: OSPF Network với Headquarters (HQ) là area 0
-BGP can filter both the routes it receives and those it sends by bit length, thus
minimizing the number of routes exchanged.
-BGP uses policies to determine the best routes instead of the number of hops per
hop, as RIP does, or link states, as OSPF does. Autonomous systems can set their
own policies.
-The router only communicates with manually configured neighbors.
-Configure different policies to exchange routes with different neighbors
BGP runs under External BGP (eBGP), which is the protocol used to communicate
between two autonomous systems, and Internal BGP (iBGP), which is the protocol
that the AS uses to synchronize its own routing tables.
Enable BGP
To enable BGP, you must set the local AS number, then enter the context of BGP
configuration
Local Network Promotion
Specify the local networks that remote sites can access. Users should only advertise
networks originating from their AS.
Set up the router's ID
The BGP interface identifies itself with its neighbors by its router ID. Usually this
ID is the IP address of the logical interface connecting to each neighbor. It can also
be the address of the repeater interface used as the update source.
Configuration for BGP Neighborhood
BGP differs from many routing protocols because it does not allow a router to
automatically search for peers from which to obtain routes. You must configure a
separate BGP neighbor for each router with which the local router can communicate.
For each neighbor, you can configure a policy to specify the routes that the BGP
interface sends to and accepts from the neighbor.
Set up ID for BGP Neighbor
BGP identifies a peer router by its IP address. You set the neighbor's ID when
creating the policy for it.
Distinguish Local and Remote AS
The router includes the local AS number in the BGP routes it receives from your
router and advertises it to another peer. Typically, ISPs forbid their routers to
advertise routes using your AS on the path to outside neighbors. The local AS should
be the same number, assigned to you by your ISP, that you configured when BGP
was enabled.
28
Load Balancing
Multi-tier BGP routers connect to more than one ISP or more than one ISP router.
Such a router can legitimately forward external traffic through more than one
connection. Load balancing ensures that one connection is not used to the exclusion
of another. There are many ways to balance loads, some of which are quite complex
and beyond the scope of this configuration guide. This section will only give you
some general tips on ways you can try to distribute external traffic via:
-Multiple connections to the same neighbor on the same router
-Connect with multiple neighbors on the same router
-Connect to multiple neighbors on multiple routers
Load Balancing on the connections of different neighbors
- Balancing outgoing traffic: In this situation, the BGP route selection algorithm
automatically balances outbound traffic.
- Inbound Traffic Balancing: Manually balance incoming traffic by letting the router
advertise certain networks to one neighbor and others to the other neighbor.
Prefix configuration example
Router A in AS 1 connects to the Internet. It uses a default route for regular Internet
traffic, but needs routes to private networks at a remote VPN site. Each site in the
VPN uses addresses in the 10.1.0.0/16 range. To minimize the number of routes
routers have to learn, the organization decided that each site should advertise the
range. your subnet as a 20-bit network. For example, the local site uses subnets in
the 10.1.0.0/20 range, Site 2 uses the subnets in the 10.1.16.0/20 range, etc.
Configure route maps
The route map applied to outgoing data determines how the router advertises routes
to its neighbors. You can configure this route map to perform tasks like:
Define routes the router can advertise to:
• network address or prefix length
• AS that traffic must go through
• community properties
• metric
Create route map entries
You can apply a route map for each neighbor for outgoing data and a map for
incoming data. You can configure multiple policies in a single route map by creating
entries with the same name but different sequence numbers.
29
Configuration for community list
To create a community list, switch to the global configuration mode context. From
this mode context, you can select one or more clearly defined community
relationships. You can also enter a value for a privately defined community.
Configuration for AS path list
You can use the AS path list to select routes for a policy according to the values in
the route's AS field.
Define routes that routers can advertise
You can control whether the BGP interface advertises the route to the neighbor by
route:
-Network address
-Prefix length
-AS path
-Community
-Metric
Filter incoming routes
We can control the routes that the local router advertises to a neighbor, we can also
control the routes the router accepts from a neighbor. You can filter incoming routes
by:
-Destination network address and prefix length
-Community
-AS path
30
Support for VLSM(Varibale Length Subnet Masking) masks of different
lengths).
- RIP avoids infinite count loop routing by limiting the maximum number of hops
allowed from the sender to the receiver, the maximum number of hops per path
is 15. For the paths the router receives from the throughput. update of the
neighboring router, the router will increase the hop count by 1 because the router
considers itself a hop in the path. If, after increasing the hop index to 1, this index
is greater than 15, the router will consider the destination network not
corresponding to this path, so it cannot be reached. In addition, RIP has similar
characteristics to other routing protocols : RIP also has a horizon and holddown
to avoid updating incorrect routing information.
31
Send broadcasts at 255.255.255.255 Sending multicast to address 224.0.0.9
should be more efficient
RIPv2 Model
Hình 29: RIPv2
Model
4.2 OSPF’s lab model
4.2.1 Introduce
RIPv2 Model
OSPF is a link-state routing protocol implemented based on open standards. OSPF
is described in many standards of IETF (Internet Engineering Task Force), Open
standard here means OSPF is completely open to the public, no read rights.
RIPv2 Model
- Compared with RIPv1 and v2, OSPF is a better IGP internal routing protocol
because of its scalability. RIP is limited to 15 hops, converges slowly, and
RIPv2 Model
sometimes chooses a slow path because when deciding to choose, it does not
consider other important factors such as bandwidth. OSPF overcomes the
disadvantages of RIP and it is a powerful, scalable routing protocol that is suitable
for modern networks. OSPF can be configured as a single-zone to use small
networks.
32
Large OSPF networks are decentralized and divided into many areas
Hình 30: Large OSPF networks are decentralized and divided into many areas
- Large OSPF networks need to use a hierarchical design and divide into multiple zones.
These regions are all connected to the same partition 0, also known as the backbone
Large OSPF networks are decentralized and divided into many areas
area. This design allows for control over routing updates. Such partitioning reduces the
load of routing operations, speeds up convergence, limits the variability of the network
to each region, and increases operational efficiency.
Large OSPF networks are decentralized and divided into many areas
The following are the features of OSPF:
It isLarge
a link-state routing protocol.
OSPF networks are decentralized and divided into many areas
Used in RFC 2328.
Use the SPF algorithm to calculate the best path.
Update only when the network structure changes
4.2.2 How OSPF works
OSPF collects link state information from neighboring routers. Each OSPF router
advertises the status of its links and forwards the information it receives to all other
neighbors.
The router processes the information received to build a database of link state in an
area. All routers in the same OSPF zone will have this same database. Therefore, all
routers will have the same information about the state of the links and the neighbors
of the other routers. Each router applies the SPF algorithm and its database to
calculate the best path for the destination network. The SPF algorithm calculates the
cost of the link bandwidth. The path with the lowest cost is selected for inclusion in
the routing table .
33
- Each router keeps a list of intimate neighbors, this list is called the intimate
neighbor database. Neighbors that are called intimate are neighbors with which the
router has established a bidirectional relationship. A router can have many
neighbors, but not all neighbors have an intimate relationship. For each router the
intimate neighbor list will be different.
To reduce the amount of routing information exchanged with many neighboring
routers in the same network, OSPF routers elect a representative router called
Designate router (DR) and a redundant proxy router called Designated backup.
BDR) as the central point for routing information.
4.2.3 OSPF packet types
OSPF has 5 types of packets: Hello, Database Description, Link State Request, Link
State Update, and Link State Acknowledge.
Version Type Packet Length
Router ID
Area ID
Checksum Authentication Type
Authentication Data
OSPF’s Packet
- Hello: Hello packet is used to detect and exchange information about neighboring
OSPF’s Packet
routers.
- Database Description: This packet is used to select which router will be authorized
OSPF’s Packet
to exchange information first (master/slave).
Link State Request: This packet is used to specify the type of LSA to use during the
exchange of DBD packets.
OSPF’s Packet
- Link State Update: This packet is used to send LSA packets to the adjacent router
requesting this packet when it receives the Request message.
- Link State Acknowledge: This packet is used to signal that the Update packet has
been received
34
One-zone OSPF model
Hình 31: One-zone OSPF model
35
Receiving a connection must open port 179 for TCP. We say that BGP runs on TCP,
using port 179. Administrators need to understand to properly configure data control
devices (eg Firewall), control devices need to let through flows. TCP with port 179.
Another point worth noting when BGP uses TCP for transmission is that TCP does
not support sending data in groups, so the establishment of neighbor relationship
between two routers completely uses unicast method. That is, the administrator It
is mandatory to explicitly declare the IP address of each neighbor that the router is
considering to establish peering. Neighbors in BGP must in principle be declared
manually. BGP does not support automatic multicast neighbor setup as with internal
routing protocols.
A BGP neighbor relationship (or BGP peering) can be established between routers
belonging to the same AS or between routers located on two different ASs:
The first case is called iBGP peering (internal BGP).
The latter case is called eBGP peering (external BGP).
Because BGP runs on top of TCP, two peer-to-peer BGP routers do not necessarily
connect directly to each other like internal routing protocols do. 2 routers that want to
eBGP
peering together just need to make Peering ’s Model
sure their 2 IP addresses can go to each other to be
able to establish a TCP connection
Hình 37: from
Mô hìnhbuilding TCP peering. However, this only
eBGP peering
applies to iBGP peering; With eBGP peering, the two routers still use direct IP
connections to establish peering with each other. We can configure the routers to
change, allowing two routerseBGPto Peering
build eBGP’s Model
peering with IP addresses that are not
directly connected to each other.
4.3.2 Data sheets of BGP
eBGP Peering ’s Model
Neighbor table: ThisHìnhtable
38: Môincludes
hình eBGP all routers that have established BGP
peering
peering with the router under consideration. The information will list the IP
address of the neighbor router, the status of the peering relationship with this
neighbor, and many other related issues.
BGP table: Neighbor routers that have successfully established peering with
the router in question will send all IP prefixes along with the best set of
parameters they can calculate to this router. The router under consideration
will put all received information into a repository called "BGP table". As a
mostly distance-vector-based protocol, a BGP router only advertises to its
neighbors the best "routes" it has. Thus, a router's BGP table is the repository
of the best routes provided by its neighbors.
Routing table: The BGP router will use a process called BGP path selection
process (BGP path selection process) to scan the entire BGP table mentioned
above. This process selects the best routes out of the routes stored in the BGP
37
table to enter the routing table to use as the official route to the destination
networks, and the BGP router will continue to advertise the best routers.
select to the next neighbors. As mentioned, the BGP table already contains
the best routes advertised by neighbors for the router in question, so the BGP
routing table is where the "best of the best" routes are stored by the routing
process of the router. BGP.
Router R hasHisuccessfully
̀ nh 39: BGP routing information
peered withreception and filtering
neighbors R1,R2,R3. Routers R1, R2,
R3 will send out BGP routing updates to advertise the best BGP routers they
have previously selected.
Router R, whenBGP receiving
routing information receptionfrom
routing updates and filtering
neighbors, will aggregate
them all into a route "repository" called the BGP table. Thus, a router's BGP
table is the collection of all routing information it receives from its neighbors
BGP routing information reception and filtering
38
BGP routing information reception and filtering
Next, router R will perform a "selection" from the "route store" in BGP to
find the best routes for each destination network. This selection follows a set
of rules that compare the path attributes of the routes to choose the optimal
route called the BGP Path Selection Process.
The best routes selected above will be updated by router R into the routing
table for official use for data routing, and also advertised to the next neighbor
router. 1 router Path-vector or distance vector only advertises advertise the
neighbor to the best routes it has.
Some common path attributes:
AS-path: A character string that lists the ASNs of the ASs that an IP
prefix has propagated through to reach the router in question.
Example Of AS-path
Hình 40: Example Of AS-
From the figure above, we consider the process
path of prefix 192.168.1.0 propagating
from AS64520, through AS65500 and then to router B located on AS 65000. When
Hình 41: Ví dụ về AS-
router B displays information about 192.168.1.0
path that it received from BGP, 1 An
accompanying string of characters will appear indicating which AS this prefix has
passed before reaching router B. This string represents the ASN in order from closest
to furthest to router B: “65500 64250”.
Next-hop: Similar to distance-vector
Example Of AS-path protocols, the next-hop is the
address of the neighbor router
Hình that
42: Víhas broadcast
dụ về AS- routing information
path
to the router in question , the next router to pass in its route to a certain
destination network. However, in handling routing information
advertised back and forth between ASs, since BGP is an external
routing protocol, the next-hop is treated as the inbound IP address of
the next AS en route toExample
the destination.
Of AS-path
Hình 43: Ví dụ về AS-
path
Example
39 Of AS-path
Hình 44: Ví dụ về AS-
path
Example Of Next-hop
̀
Hinh 45: Example Of
From the figure above, router A (AS 64520) advertises prefix 172.16.0.0 to router B via
Next-hop
an eBGP session with the next-hop in routing set to "10.10.10.3". In turn, router B
continues to advertise this prefix to router C. If like normal IGP protocols, B will
advertise the next-hop address for C as "172.20.10.1" - its own IP but since this is a
BGP-an external routing protocol, router B will still leave the next-hop "10.10.10.3" for
network 172.16.0.0 but broadcast Example
to router OfC. AsLocal
a result, C will receive routing updates
Preference
The route for prefix 172.16.0.0 has a next-hop of 10.10.10.3, and if C was not previously
routed to reach 10.10.10.3, C will
Hiǹ hnot 46:beVí
abledụtovềuse this routing update, henceforth
Unable to route data to networkLocal
172.16.0.0.
PreferenceExample
Origin: There are many ways for a router to initially advertise IP
Of Next-hop
prefixes to the BGP network. The method used is to use the "network"
command to look up and advertise the IP prefix that is previously
present in the router's routing table to BGP.
There are three origin codesExample
that can appear in the Origin property:
Of Local
“i”-“IGP”: This codePreference
indicates that the prefix in question is advertised by the
original router into BGP Hìnwith
h 47: Vía dụcommand.
về Local “network” or by the address
Preference
summary operation.
“e”-“EGP”: This code indicates that the prefix under consideration is
advertised by the original router into BGP by redistributed routes of another
external routing protocol, EGP. EGP is an old external routing protocol, BGP
is almost the only external
Example routing
Of protocol
Local used, so unless the administrator
of the original routerPreference
intentionally sets the origin code to "e", we rarely see
origin codes. this in the BGP table.
“?”-“Incomplete”: This̀ code indicates that the IP prefix was entered into
Hinh 48: Ví dụ về
Local
BGP by the original router by an unknown method.
PreferenceExample
Of Next-hop
40
Local preference : A BGP base is established towards an IP prefix.
The principle that a BGP router chooses a path on the Local
Preference attribute comparison is: in many directions to the same
destination, the path with the highest value attached to Local
preference is considered the best and will be chosen as the best route.
official direction to the destination under consideration.
41
Example Of MED
Router A of AS 65000 performs network
Hình 55:advertisement
Example Of 172.16.0.0 to routers B and
MED
C of AS 65000. AS 65000 policy (router A side) wants that AS neighbor 65500
when sending data to network 172.16.0.0
Hình 56: needs
Ví dụ vềto go. to AS 65000 via the link
MED
between A and B, while the link between A and C is only for redundancy. If the
administrator of AS 65000 sets the MED attribute for network 172.16.0.0 to 150
when broadcasting to router B and 200 to router C. The internal routers of AS 65500
when considering two directions to network 172.16.0.0 through 2 gateways B and
Example
C will see that the direction through B OfhasMED
MED smaller than the MED of the
direction through C(150<200), so will
Hìnhchoose thevề direction through B to drive the
57: Ví dụ
data to 172.16.0.0. MED
Example Of MED
Hình 59: Ví dụ về
MED
Example Of Weight
Hình 60: Example Of
Weight
In the above example, router A receives routing updates to reach network 172.20.0.0
of AS 65520 from two directions, Hìnhvia
61: router
Ví dụ vềB and router C. In this case, the
MED
administrator wants router A to always choose the direction through B to go to
network 172.20.0.0, direction through C just for redundancy regardless of the
attributes on these two paths. By default, a BGP router will assign the value
42
Example Of Weight
Hình 62: Ví dụ về
MED
Weight=0 to all prefixes received from other routers and assign Weight=32768 to
prefixes that enter BGP itself (often called local routes). For the example under
consideration, router A will assign the value Weight=200 to prefix 172.20.0.0 when
receiving this prefix from router B and assign Weight = 150 to the same prefix when
receiving it from router C, from then on, router A will always choose direction B to
go to 172.20.0.0 and direction C just for backup.
43
5.3 Load IOS for router
1. Go to Edit IOS images and hypervisor/IOS images.
2. Next, click on Router C3725, hold and drag and drop it into the box next to it.
Now we will see the Topology Summary tab, the router will be red, which means
the router is in turn off mode.
3. Turn up by right-clicking on the router, select start, you will see R1 green.
4. When you start, go to Task Manager and you will see that the CPU is 100%.
5. Using the Idle PC feature
6. Select the item marked with an asterisk
7. CPU has decreased significantly, now we proceed to configure the router
5.4 Learn the basic router configurations (how to assign IPs to interfaces,
check IP parameters).
5.4.1 Router config modes
Cisco routers have many modes (modes) when configuring, each mode has its own
characteristics, providing a number of features to configure the router.
- User mode or User EXEC Mode :
This is the first mode when starting a session with the router (via Console or
Telnet). In this mode we can only perform some common router commands
. These commands have the same effect as the show command or the clear
command for some counters of the router or interface. These commands will
not be written to the router's config file and therefore will not affect the
router's subsequent reboots.
- Privileged EXEC Mode:
To enter Privileged EXEC Mode, from User EXEC mode type enable and
password (if necessary), Privileged EXEC Mode provides important
commands to monitor router activity, access config files, IOS, set password..
Prvileged EXEC Mode is the key to enter Configuration Mode, which allows
you to configure all router functions.
- Configuration Mode:
As mentioned above, configuration mode allows configuring all Cisco router
functions including interfaces, routing protocols, console lines, vty(telnet),
tty (async connection). Commands in configuration mode will directly affect
the current configuration of the router contained in RAM (running-
configuration). If this configuration is written back to NVRAM, these
commands will take effect on subsequent reboots of the router.
+ Configuration Mode has many modes with many small modes, the first is
global configuration mode, then interface configuration mode, line configuration
mode,, routing configuration mode.
44
+ ROM Mode: ROM Mode is used for specialized tasks, directly interfering
with the router's hardware such as Recovery password, maintainance>
Usually in addition to the command lines that force the router into ROM
mode, the router will automatically Switch to ROM mode if the IOS file is
not found or the IOS file is damaged during the boot process.
45
Router Config’s Mode
Hình 65: Router Config’s
Mode
- ̀ nh Enter
Immediately after pressingHithe 67: Một
key số to
mode
execute the command, the prompt
config của router
changes from the default name to the newly set Router name.
- Router
Change the password for Config’s Mode
the console:
46
Router Config’s Mode
- We also need to set a password for 1 or more vty to control users to remotely
access the router and telnet. Normally cisco router will have 5 vty lines with
the order from 0 to 4. We usually use 1 password for all vty lines, but
sometimes we should put a separate password for every line to backup both
The other 4 lines are all in use. Following are the commands that need to be
used to set the password for the vty lines:
- The enable and enable secret passwords are used to restrict access to
privileged EXEC mode. The eneable password is only used when we set the
enable secret password because this password is encrypted and the enable
password is not. The following are the commands used to set the enable secret
password:
47
- Have Many show commands are used to check the contents of files on the
router and to find problems. In both privileged EXEC and user EXEC modes,
typing <<show?>> will show a list of show commands. Of course, there are
more show commands available in privileged EXEC mode than in user
EXEC mode.
- Show interface - displays the status of all communication ports on the router.
To see the status of a certain port, we add the name and ordinal number of
that port after the show interface command. Eg:
+ Displays the global status and status of the communication ports that have
been configured with the Layer 3 protocol:
48
Static route’s lab model
Hình 70: Static route’s lab model
Overview Of Network
Model Static route’s lab
model
Hình 72: Mô hình lab static route
- Configure the static route to be able to forward a packet from a source address
Overview Of Network
to a destination address inModel
the network.
- Checking the routing table of router NgocR1 we see that the router has
learned the network route 192.169.1.0/24
Top layer‘s network
model
Overview Of Network
Model Static route’s lab
model
Hình 75: Mô hình lab static route
49
- Configure the static route to be able to forward a packet from a source address
to a destination address in the network.
6. INSTALLATION INSTALLATION
6 . FIrst Network model
50
Top layer‘s network model
Hình 77: Mô hình mạng tầng trên
cùngOverview Of Network Model
Top layer‘s network model
Hình 81: Top layer‘s network model
ngocle.vn
ngocle.vn
NgocLe.vn
NgocLe.vn
52
Throughput vs. speed of nodes
Hình 97: Tốc độ của các nút so với thông lượng với hai định
tuyến AODV và OSPFThe middle and lower layer
6.3 Deploying the top-of-the-line network model
6.3.1 IP Configuration
- Configure router R3:
+ enp0s3 (128.123.1.2/16):
+ enp0s8 (192.168.2.1/24):
+ enp0s9 (192.168.1.1/24):
53
- Configure router R4 :
+ enp0s3 (192.168.2.2/24):
+ enp0s8 (192.168.3.1/24):
+ enp0s9 (192.168.4.1/24):
- Configure router R5 :
+ enp0s3 (192.168.1.2/24):
+ enp0s8 (192.168.3.2/24):
54
+ enp0s9 (192.168.5.1/24):
55
- Config router R9
+ enp0s3
+ enp0s8
- Config router R10
+ enp0s3
+ enp0s8
+ Config ospfd.conf :
56
+ Config ospfd.conf :
+ Config ospfd.conf :
57
+ Config ospfd.conf :
Check on routers, see that the addresses have been updated in the routing table
+R3:
58
+R4:
+R5:
59
+ enp0s3 (119.118.1.2/16):
+ enp0s8 (192.169.2.1/24):
+ enp0s9 (192.169.1.1/24):
+ enp0s8 (192.169.3.1/24):
60
+ enp0s9 (192.169.4.1/24):
+ enp0s8 (192.169.3.2/24):
+ enp0s9 (192.169.5.1/24):
61
- Config PC4 (192.169.5.10/24):
+ Config ripd.conf :
62
“default- information originate” information helps other routers in AS set default
gateway through R6 .
- Configure router R7 :
+ Config zebra.conf :
+ Config ripd.conf :
63
- Configure router R8 :
+ Config zebra.conf :
+ Config ripd.conf :
64
Start rip on router R7:
Checking on routers, the addresses have been updated to the routing table:
+R6:
+R7:
65
+R8:
+ eth6 (10.1.2.1/8):
66
- Configure router R0:
+ enp0s3 (12.2.1.1/8):
+ enp0s8 (11.1.1.1/8):
+ enp0s9 (128.123.1.1/16):
+ enp0s8 (11.2.1.1/8):
67
+ enp0s9 (129.118.18.1/16):
+ Config ospfd.conf :
68
- Configure router R1:
+ Configure zebra.conf :
+ Config ospfd.conf :
69
- Configure router R2:
+ Configure zebra.conf :
+ Config ospfd.conf :
70
6.5.3 Operating OSPF on top layer’s network model
Note : All routers have iptables turned off
Start OSPF dynamics on router R0:
71
Checking on routers, the addresses have been updated to the routing table:
+ Router R0:
+ Router R1:
+ Router R2:
72
6.6 Configure BGP for routers
6.6.1 IP Configuration
In the model, BGP routers need to be configured including routers: R1, R2, R3, R6
- Config R1:
- Config R2:
- Config R3:
73
- Config R6:
- Config R9:
- Config R2:
- Config R3:
- Config R6:
74
- Check the routing table on BGP routers:
+ R1:
+ R2:
75
+ R3:
+ R6:
76
+ R9:
7 SYSTEM OPERATION
7.1 Check connection by ping and tracepath
- Ping from PC1 to PC2:
77
- Ping from PC1 to PC3:
78
- Ping from PC3 to PC4:
Thus, the system can respond well to changes in the network (e.g. enp0s8 is
disconnected when the wire breaks).
• Performing a test ping from R3 to PC1 (192.168.4.10/24) is still successful:
79
Performing a test ping from PC1 to PC3 (192.169.4.10/24) is still successful:
80
We proceed to disconnect enp0s3 of router R7 to check the ability to change RIP.
Checking the routing table again, we see that the route has changed.
.
Try pinging PC3 to PC4 (192.169.5.10) and PC3 to PC1 (192.168.4.10) is still
successful:
7.4 Steps to test the system by installing and connecting to DNS servers
- Install DNS mydomain.vn and configure file name.domain.vn
- Install DNS NgocLe.vn on PC1
Configure file named.conf
Configure file named.NgocLe.vn
- Install DNS ngocle.vn on PC0
Configure file named.conf
Configure file named.ngocle.vn
- Check the connection to the DNS server with the dig and nslookup
commands
- Send mail from DNS servers
81
Send email from NgocLe.vn to mydomain.vn
Config file named.NgocLe.vn on PC1
Send email from NgocLe.vn to mydomain.vn
Received on mydomain.vn from NgocLe.vn
Send mail from ngocle.vn to mydomain.vn
Config named.ngocle.vn on PC0
Send email from ngocle.vn to mydomain.vn
Received email on mydomain.vn from ngocle.vn
8. SIMULATION ON C
8.1 Simulation RIP
- struct definition for ripd:
static struct option longopts[] =
{
{ "daemon", no_argument, NULL, 'd'},
{ "config_file", required_argument, NULL, 'f'},
{ "pid_file", required_argument, NULL, 'i'},
{ "help", no_argument, NULL, 'h'},
{ "dryrun", no_argument, NULL, 'C'},
{ "vty_addr", required_argument, NULL, 'A'},
{ "vty_port", required_argument, NULL, 'P'},
{ "retain", no_argument, NULL, 'r'},
{ "user", required_argument, NULL, 'u'},
{ "group", required_argument, NULL, 'g'},
{ "version", no_argument, NULL, 'v'},
{0}
};
- ripd's priviledges:
zebra_capabilities_t _caps_p [] =
{
ZCAP_NET_RAW,
ZCAP_BIND
};
- The name of the program that runs the ripd simulation, first declare the rein
mode of the route:
int retain_mode = 0;
- Show information:
static void
usage (char *progname, int status)
{
if (status != 0)
fprintf (stderr, "Try `%s --help' for more information.\n", progname);
else
{
printf("Usage : %s [OPTION...]\n\
Daemon which manages RIP versions 1 and 2.\n\n\
-d, --daemon Runs in daemon mode\n\
83
-f, --config_file Set configuration file name\n\
-i, --pid_file Set process identifier file name\n\
-A, --vty_addr Set vty's bind address\n\
-P, --vty_port Set vty's port number\n\
-C, --dryrun Check configuration for validity and exit\n\
-r, --retain When program terminates, retain added route by ripd.\n\
-u, --user User to run as\n\
-g, --group Group to run as\n\
-v, --version Print program version\n\
-h, --help Display this help and exit\n\
\n\
Report bugs to %s\n", progname, ZEBRA_BUG_ADDRESS);
}
exit (status);
}
- SIGNUP handlers:
static void
sighup (void)
{
zlog_info ("SIGHUP received");
rip_clean();
rip_reset();
zlog_info ("ripd restarting!");
- SIGINT handler:
static void
sign (void)
{
zlog_notice ("Terminate on signal");
if (! retain_mode)
rip_clean();
exit (0);
84
}
- SIGUSR1 handler:
static void
sigusr1 (void)
{
zlog_rotate(NULL);
}
85
progname = ((p = strrchr (argv[0], '/')) ? ++p : argv[0]);
if (opt == EOF)
break;
switch (opt)
{
case 0:
break;
case 'd':
daemon_mode = 1;
break;
case 'f':
config_file = optarg;
break;
case 'A':
vty_addr = optarg;
break;
case 'i':
pid_file = optarg;
break;
case 'P':
/* Deal with atoi() returning 0 on failure, and ripd not
listening on rip port... */
if (strcmp(optarg, "0") == 0)
{
vty_port = 0;
break;
}
vty_port = atoi(optarg);
if (vty_port <= 0 || vty_port > 0xffff)
86
vty_port = RIP_VTY_PORT;
break;
case 'r':
retain_mode = 1;
break;
case 'C':
dryrun = 1;
break;
case 'u':
ripd_privs.user = optarg;
break;
case 'g':
ripd_privs.group = optarg;
break;
case 'v':
print_version(progname);
exit (0);
break;
case 'h':
usage(progname, 0);
break;
default:
usage(progname, 1);
break;
}
}
87
/* Sort all connection statements */
sort_node();
/* Print banners. */
zlog_notice ("RIPd %s starting: vty@%d", QUAGGA_VERSION,
vty_port);
/* Execute thread. */
while (thread_fetch (master, &thread))
thread_call (&thread);
/* Inaccessible. */
return (0);
}
88
ZCAP_NET_RAW,
ZCAP_BIND,
ZCAP_NET_ADMIN,
};
- Select ospfd:
struct option longopts [ ] =
{
{ " daemon", no_argument , NULL, 'd'},
{ " config_file ", required_argument , NULL, 'f'},
{ " pid_file ", required_argument , NULL, ' i '},
{ " dryrun ", no_argument , NULL, 'C'},
89
{ " help", no_argument , NULL, 'h'},
{ " vty_addr ", required_argument , NULL, 'A'},
{ " vty_port ", required_argument , NULL, 'P'},
{ " user", required_argument , NULL, 'u'},
{ " group", required_argument , NULL, 'g'},
{ " apiserver ", no_argument , NULL, 'a'},
{ " version", no_argument , NULL, 'v'},
{0}
};
- Name of program running osfd simulation, declare master thread:
struct thread_master *master;
# ifdef SUPPORT_OSPF_API
extern int ospf_apiserver_enable ;
#endif /* SUPPORT_OSPF_API */
- Show information:
static void __attribute__ (( noreturn ))
usage (char * progname , int status)
{
if ( status ! = 0)
fprintf (stderr, "Try `%s --help' for more information.\n", progname );
else
{
printf (" Usage : %s [OPTION...]\n\
Daemon which manages OSPF.\n\n\
90
-d, --daemon Runs in daemon mode\n\
-f, -- config_ file Set configuration file name\n\
- i , -- pid_file Set process identifier file name\n\
-A, -- vty_addr Set vty's bind address\n\
-P, -- vty_port Set vty's port number\n\
-u, --user User to run as\n\
-g, --group Group to run as\n\
-a. -- apiserver Enable OSPF apiserver \n\
-v, --version Print program version\n\
-C, -- dryrun Check configuration for validity and exit\n\
-h, --help Display this help and exit\n\
\n\
Report bugs to %s\n", progname , ZEBRA_BUG_ADDRESS);
}
exit (status);
}
91
- SIGHUP handler :
static void sighup (void)
{
zlog (NULL, LOG_INFO, "SIGHUP received");
}
- SIGUSR1 handler :
static void sigusr1 (void)
{
zlog_rotate (NULL);
}
92
},
{
.signal = SIGINT,
.handler = & sigint ,
},
{
.signal = SIGTERM,
.handler = & sigint ,
},
};
93
- ripd :
int main (int argc , char ** argv )
{
char *p;
char * vty_addr = NULL;
int vty_port = OSPF_VTY_PORT;
int daemon_mode = 0;
char * config_file = NULL;
char * progname ;
struct thread thread ;
int dryrun = 0;
94
/* OSPF master init. */
ospf_master_init ();
# ifdef SUPPORT_OSPF_API
/* OSPF apiserver is disabled by default. */
ospf_apiserver_enable = 0;
#endif /* SUPPORT_OSPF_API */
while (1)
{
int opt;
opt = getopt_long ( argc , argv , " df:i :hA:P:u:g:avC ", longopts , 0);
if (opt == EOF)
break;
switch (opt)
{
case 0:
break;
case 'd':
daemon_mode = 1;
break;
case 'f':
config_file = optarg ;
break;
case 'A':
vty_addr = optarg ;
95
break;
case ' i ':
pid_file = optarg ;
break;
case 'P':
/* Deal with atoi ( ) returning 0 on failure, and ospfd not
listening on ospfd port... */
if ( strcmp ( optarg , "0") == 0)
{
vty_port = 0;
break;
}
vty_port = atoi ( optarg );
if ( vty_port <= 0 || vty_port > 0xffff)
vty_port = OSPF_VTY_PORT;
break;
case 'u':
ospfd_privs.user = optarg ;
break;
case 'g':
ospfd_ privs.group = optarg ;
break;
# ifdef SUPPORT_OSPF_API
case 'a':
ospf_apiserver_enable = 1;
break;
#endif /* SUPPORT_OSPF_API */
case 'v':
print_version ( progname );
96
exit (0);
break;
case 'C':
dryrun = 1;
break;
case 'h':
usage ( progname , 0);
break;
default:
usage ( progname , 1);
break;
}
}
/ * Initialize . */
master = om->master;
/* Initialize library . */
zprivs_init (& ospfd_privs );
signal_init (master, Q_ SIGC( ospf_signals ), ospf_signals );
cmd_init (1);
debug_init ();
vty_init (master);
memory_init ();
access_list_init ();
prefix_list_init ();
/* OSPFd inits . */
97
ospf_if_init ();
ospf_zebra_init ();
ospf_route_map_init ();
# ifdef HAVE_SNMP
ospf_snmp_init ();
#endif /* HAVE_SNMP */
# ifdef HAVE_OPAQUE_LSA
ospf_opaque_init ();
#endif /* HAVE_OPAQUE_LSA */
sort_node ();
98
}
/* Print banners. */
zlog_notice (" OSPFd %s starting: vty @%d", QUAGGA_VERSION, vty_port );
/* Not reached. */
return (0);
}
99
{ " bgp_port ", required_argument , NULL, 'p'},
{0}
};
- Signal definition :
100
{
.signal = SIGHUP,
},
.signal = SIGUSR1,
.handler = &sigusr1,
},
.signal = SIGINT,
},
.signal = SIGTERM,
},
};
101
/* Master of threads. */
- Authorization :
ZCAP_BIND,
ZCAP_NET_RAW,
ZCAP_NET_ADMIN,
};
.user = QUAGGA_USER,
102
.group = QUAGGA_GROUP,
# endif
# ifdef VTY_GROUP
# endif
. caps _p = _ caps_p ,
. cap_num_i = 0,
};
- Show information:
if ( status ! = 0)
else
103
-l, -- listenon Listen on specified address (implies - n)\n\
-r, --retain When program terminates, retain added route by bgpd .\n\
\n\
exit (status);
104
- SIGHUP handler
void
sighup (void)
bgp_terminate ();
bgp_reset ();
- SIGINT handler :
void
sign (void)
105
zlog_notice ("Terminate on signal");
if (! retain_mode )
bgp_terminate ();
bgp_exit (0);
- SIGUSR1 handler :
void
sigusr1 (void)
zlog_rotate (NULL);
/*
Zebra route removal and protocol teardown are not meant to be done here.
*/
106
{
int *socket;
/* clan exit */
assert(status == 0);
/* reverse bgp_master_init */
bgp_delete ( bgp );
/* reverse bgp_master_init */
107
/* reverse bgp_zebra_init / if_init */
if ( retain_mode )
bgp_connected_delete (c);
if_delete ( ifp );
list_free ( iflist );
/* reverse bgp_attr_init */
bgp_attr_finish ();
/* reverse bgp_dump_init */
bgp_dump_finish ();
/* reverse bgp_route_init */
bgp_route_finish ();
108
/* reverse bgp_route_map_init / route_map_init */
route_map_finish ();
/* reverse bgp_scan_init */
bgp_scan_finish ();
/* reverse access_list_init */
access_list_add_hook (NULL);
access_list_delete_hook (NULL);
access_list_reset ();
/* reverse bgp_filter_init */
as_list_add_hook (NULL);
as_list_delete_hook (NULL);
bgp_filter_reset ();
/* reverse prefix_list_init */
prefix_list_add_hook (NULL);
prefix_list_delete_hook (NULL);
prefix_list_reset ();
/* reverse community_list_init */
community_list_terminate ( bgp_clist );
109
cmd_terminate ();
vty_terminate ();
if ( zclient )
zclient_free ( zclient );
if ( zlookup )
zclient_free ( zlookup );
if ( bgp_nexthop_buf )
stream_free ( bgp_nexthop_buf );
/* reverse bgp_master_init */
if (master)
thread_master_free (master);
if ( zlog_default )
closezlog ( zlog_default );
exit (status);
110
- bgpd :
int
char *p;
int opt;
int daemon_mode = 0;
int dryrun = 0;
char * progname ;
int tmp_port ;
umask (0027);
LOG_CONS|LOG_NDELAY|LOG_PID, LOG_DAEMON);
bgp_master_init ();
111
/* Command line argument treatment. */
while (1)
opt = getopt_long ( argc , argv , " df:i :hp:l:A:P:rnu:g:vCI ", longopts , 0);
if (opt == EOF)
break;
switch (opt)
case 0:
break;
case 'd':
daemon_mode = 1;
break;
case 'f':
config_file = optarg ;
break;
pid_file = optarg ;
break;
case 'p':
112
bm->port = BGP_PORT_DEFAULT;
else
bm->port = tmp_port ;
break;
case 'A':
vty_addr = optarg ;
break;
case 'P':
vty_port = 0;
break;
vty_port = BGP_VTY_PORT;
break;
case 'r':
retain_mode = 1;
break;
case 'l':
bm->address = optarg ;
113
/* listenon implies -n */
case 'n':
bgp_option_set (BGP_OPT_NO_FIB);
break;
case 'u':
bgpd_privs.user = optarg ;
break;
case 'g':
break;
case 'v':
print_version ( progname );
exit (0);
break;
case 'C':
dryrun = 1;
break;
case 'I':
bgp_option_set (BGP_OPT_IMPORT_CHECK);
break;
case 'h':
break;
default:
114
usage ( progname , 1);
break;
master = bm->master;
/* Initializations. */
srand (time(NULL));
cmd_init (1);
vty_init (master);
memory_init ();
bgp_init ();
sort_node ();
115
/* Start execution only if not in dry-run mode */
if( dryrun )
return( 0);
zlog_ err ( " BGPd daemon failed: %s", strerror ( errno ));
return (1);
pid_output ( pid_file );
/* Print banners. */
zlog_notice (" BGPd %s starting: vty @%d, bgp @% s:% d", QUAGGA_VERSION,
vty_port ,
bm->port);
116
/* Start finite state machine, here we go! */
thread_call (&thread);
/* Not reached. */
return (0);
117
+Node 3 has 3-5-8-9-10 .
+Node 4 has 4-6-8-9-10 .
+ Node 4 reponds .
119
CONCLUSION
In this report, I presented the most basic problems of multilayer network along with
OSLR, BGP, RIP routing. From deploying multilayer network on GN3, the results
have been successfully deployed and the test operation is also high. This design is
applicable to real-world networks, but has not yet created great commercial value
because the model is not optimal and small, although it was a period of time that I
learned. much about multi-layer networking as well as working and operating
systems on Linux as well as Windows Server. It was also a time for me to improve
my skills in using C language and my ability to work on Linux.
Despite achieving the set goal, but due to time constraints, the project has not yet
fully developed the features of a multi-layer network, specifically, just deployed
basic information such as sending mail. , user information, images are simple, but
perfecting and optimizing the system takes time. In the future, if I have the
opportunity, I will continue to research and develop various types of network
systems and study more deeply about network routing and computer network
structure.
120
REFERENCES
121