Lab 9
Lab 9
Lab 9
Assumptions
IP version 4
Codes are from Kernel 2.6.9.EL
Ideas are similar
Interface to users
TCP/UDP/IP etc
Network card
receives
issues an
interrupt
a frame
Driver
handles
the interrupt
Frame RAM
Allocates sk_buff
(called skb)
Frame skb
sk_buff (cont.)
struct sk_buff
*next
struct sk_buff
*prev
struct sk_buff_head
struct sock
*list
*sk
Transport Header
Network Header
union {raw}
mac;
.
MAC Header
DATA
sk_buff (cont.)
Driver (cont.)
calls device independent
core/dev.c:netif_rx(skb)
puts skb into CPU queue
issues a soft interrupt
CPU
calls core/dev.c:net_rx_action()
removes skb from CPU queue
passes to network layer e.g. ip/arp
In this case: IPv4 ipv4/ip_input.c:ip_rcv()
ip_input.c:ip_rcv()
checks
Length >= IP Header (20 bytes)
Version == 4
Checksum
Check length again
calls
ip_rcv_finish()
calls
route.c:ip_route_input()
ipv4/route.c:ip_route_input()
Destination == me?
ip_input.c:ip_local_deliver()
YES
NO
Calls ip_route_input_slow()
ipv4/route.c:ip_route_input_slow()
Can forward?
Forwarding enabled?
Know route?
NO
Sends ICMP
Forwarding a Packet
Receiving device!
/proc/sys/net/ipv4/conf/<device>/forwarding
/proc/sys/net/ipv4/conf/default/forwarding
/proc/sys/net/ipv4/ip_forwarding
ipv4/ip_forward.c:ip_forward()
IP TTL > 1
YES
NO
Decreases TTL
Sends ICMP
pfifo_fast_enqueue()
Again, per-device basis
Queue Discipline (Qdisc: pkt_sched.c)
Not exactly a priority queue
Uses three queues (bands)
0 interactive
1 best effort
2 bulk
Priority is based on IP Type of Service (TOS)
http://linux-ip.net/articles/Traffic-Control-HOWTO/classless-qdisc.html
IP ToS: PPPDTRCX
PPP
Precedence
Linux = ignore
Cisco = Policy-Based Routing (PBR)
Minimizes Delay
T Maximizes Throughput
R Maximizes Reliability
C Minimizes Cost
X Reserved
Linux Priority
Band
0x0
0x2
0x4
0x6
0x8
0xA
0xC
0xE
0x10
0x12
0x14
0x16
0x18
0x1A
0x1C
0x1E
pfifo_fast_enqueue()
maps IP ToS to one of
three queues
IP ToS: PPPDTRCX
Mapping array: prior2band
Queue Selection
sch_generic.c
Mapping array
Change band
Kernel 2.6.9.EL
Qdisc
sk_buff_head band 0
sk_buff_head band 1
+prior2band[skb->priority&TC_PRIOR_MAX]
sk_buff_head band 2
pfifo_fast_dequeue()
Removes
Setup
Destination
Bottleneck link: 10Mbps
Linux Router
(Your HDD)
Virtual 1
Virtual 2
Lab 9 Part 2
Default: no IP forwarding
Enable IP forwarding /proc/
Only one router
Default route on destination
Lab 9 Part 2
Route???
Destination
ping reply
ping echo
Virtual 1
Linux Router
(Your Linux)
Virtual 2
Lab 9 Part 3
Scenario
Destination
TCP
10Mbps
UDP
Linux Router
(Your Linux)
Virtual 1
Virtual 2
Lab 9 Part 4
Lab 9 Part 5
IP ToS
Change it to TCP v.s. UDP (+others)
Options: UDP++ or TCP- Do NOT change IP ToS!