GENIEducation/SampleAssignments/TcpAssignment/ExerciseLayout/KernelMod: tcp_exp.c

File tcp_exp.c, 2.4 KB (added by sedwards@bbn.com, 6 years ago)
Line 
1#include <net/tcp.h>
2#include <linux/module.h>
3
4static void exp_slow_start(struct tcp_sock *tp)
5{
6    /* Handle cwnd manipulation for slow start here */
7}
8
9static void exp_cong_avoid(struct sock *sk, u32 adk, u32 in_flight)
10{
11    /* Handle cwnd manipulation for congestion avoidance here */
12}
13
14static u32 exp_ssthresh(struct sock *sk)
15{
16    /* Compute the appropriate value of ssthresh here */
17}
18
19
20//See  http://lwn.net/Articles/128681/ for more information
21/*
22 * The start() method initializes the algorithm when a new batch of data
23 * is being transmitted; this can happen for new sockets, or when one
24 * has been idle for a while.
25 *
26 * The ssthresh() method calculates the "slow start threshold"; when the
27 * congestion window is below that threshold, the connection is in slow
28 * start mode rather than full congestion avoidance mode. This method is
29 * called when congestion occurs.
30 *
31 * The actual initial window may be set by min_cwnd() to be less than
32 * the threshold value as a starting point for the slow start algorithm.
33 *
34 * When an acknowledgment arrives from the remote end, the cong_avoid()
35 * method is invoked; it may respond to successful packet delivery by
36 * enlarging the congestion window.
37 *
38 * rtt_sample() tells the algorithm about a measured round-trip time -
39 * the time taken between sending a packet and receiving the
40 * corresponding acknowledgment.
41 *
42 * set_state() indicates that the TCP state of the socket has changed.
43 *
44 * Various events of interest can be communicated to the algorithm via
45 * cwnd_event().
46 *
47 * Sometimes, transient situations can cause the congestion window to be
48 * reduced; the undo_cwnd() method can be called when such a situation
49 * is detected to restore a larger window.
50 *
51 * The get_info() method can be used to make congestion avoidance
52 * information available to user space.
53 */
54static struct tcp_congestion_ops tcp_exp __read_mostly = {
55    .init       = NULL,
56    .ssthresh   = exp_ssthresh,
57    .cong_avoid = exp_cong_avoid,
58    .min_cwnd   = tcp_reno_min_cwnd,
59   
60    .owner      = THIS_MODULE,
61    .name       = "exp"
62};
63
64static int __init exp_register(void)
65{
66        return tcp_register_congestion_control(&tcp_exp);
67}
68
69static void __exit exp_unregister(void)
70{
71        tcp_unregister_congestion_control(&tcp_exp);
72}
73
74module_init(exp_register);
75module_exit(exp_unregister);
76
77MODULE_AUTHOR("Your Name Here");
78MODULE_LICENSE("GPL");
79MODULE_DESCRIPTION("Experimental TCP");